-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invoke CreateGeometry() from StBFChain #477
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
#include "StEnumerations.h" | ||
#include "TTree.h" | ||
#include "TEnv.h" | ||
#include "StarVMC/StarGeometry/CreateGeometry.h" | ||
#define STAR_LOGGER 1 | ||
// PLease, preserve the comment after = { . It is used for documentation formatting | ||
// | ||
|
@@ -1023,21 +1024,7 @@ Int_t StBFChain::Init() { | |
if (GetOption("VmcGeo")) { | ||
path = "./StarDb/VmcGeo:$STAR/StarDb/VmcGeo"; | ||
} | ||
TString geom("Geometry."); | ||
geom += DbAlias[i].geometry; | ||
geom += ".C"; | ||
Char_t *file = gSystem->Which(path.Data(),geom,kReadPermission); | ||
if (file) { | ||
LOG_INFO << "StBFChain::Init force load of " << file << endm; | ||
TString command = ".L "; command += file; | ||
gInterpreter->ProcessLine(command); | ||
gInterpreter->Calc("CreateTable()"); | ||
command.ReplaceAll(".L ",".U "); | ||
gInterpreter->ProcessLine(command); | ||
delete [] file; | ||
} else { | ||
LOG_INFO << "StBFChain::Init file for geometry tag " << geom << " has not been found in path" << path << endm; | ||
} | ||
CreateGeometry(DbAlias[i].geometry); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CreateGeometry will not be found if the agml libraries are not loaded, e.g. if the AgML chain option is not specified. We switched to using AgML for the geometry description ~ 2012. Prior to that the geometry was supported from macros translated directly from the AgSTAR geometries (StarDb/AgiGeometry/). Thpse macros also depend on "CreateGeometry"... albeit a much simpler macro. |
||
break; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include <TGeoManager.h> | ||
|
||
#include "StBFChain/StBFChain.h" | ||
#include "StarVMC/StarAgmlLib/AgModule.h" | ||
#include "StarVMC/StarAgmlLib/StarTGeoStacker.h" | ||
#include "StarVMC/StarGeometry/StarGeo.h" | ||
|
||
extern StBFChain* chain; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Looks like we've never landed the 205f44a. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yes! I think that is the reason why half of the tests crashed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now ROOT5 seems to not handle the |
||
|
||
/** | ||
* Adapted from StarDb/VmcGeometry/CreateGeometry.h | ||
*/ | ||
TDataSet *CreateGeometry(const Char_t *name="y2011") { | ||
TObjectSet *geom = 0; | ||
if ( gGeoManager ) { | ||
cout << "AgML geometry: Existing TGeoManager " << gGeoManager->GetName() | ||
<< " detected, ignoring request for " | ||
<< name << endl; | ||
return geom; | ||
} | ||
|
||
// Cache geometry to a TFile. Geometry will be restored from TFile on subsequent calls. | ||
TString filename = ""; | ||
if (chain) { filename = chain->GetFileOut(); if ( filename=="" ) filename = chain->GetFileIn(); } | ||
else { filename = name; } | ||
|
||
// Strip out @ symbol | ||
filename = filename.ReplaceAll("@",""); | ||
// Strip off the last extention in the filename | ||
filename = filename( 0, filename.Last('.') ); | ||
// Append geom.root to the extentionless filename | ||
filename+=".geom.root"; | ||
|
||
// Detect second call to the system | ||
if ( AgModule::Find("HALL") ) { | ||
if ( chain->GetOption("Sti") || | ||
chain->GetOption("StiCA") || | ||
chain->GetOption("StiVMC") ){ | ||
cout << "AgML geometry: HALL exists. Restore from cache file " | ||
<< filename.Data() << endl; | ||
gGeoManager = 0; | ||
assert(0); | ||
TGeoManager::Import( filename ); | ||
veprbl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert(gGeoManager); | ||
} | ||
return geom; | ||
} | ||
|
||
cout << "AgML: Building geometry " << name << " " << endl; | ||
|
||
// Create the geometry using TGeo | ||
AgBlock::SetStacker( new StarTGeoStacker() ); | ||
|
||
Geometry *build = new Geometry(); | ||
|
||
// Suppress copious ROOT warnings | ||
Long_t save = gErrorIgnoreLevel; gErrorIgnoreLevel = 9999; | ||
build->ConstructGeometry(name); | ||
gErrorIgnoreLevel = save; | ||
|
||
if ( gGeoManager ) | ||
{ | ||
gGeoManager->CloseGeometry(); | ||
geom = new TObjectSet("Geometry",gGeoManager, false ); | ||
geom -> SetTitle( Form("AgML Geometry: %s",name) ); | ||
|
||
TFile *file = new TFile( filename, "recreate" ); | ||
file->cd(); | ||
gGeoManager->Write(); | ||
file->Close(); | ||
delete file; | ||
} | ||
|
||
return (TDataSet *)geom; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class TDataSet; | ||
|
||
TDataSet *CreateGeometry(const char *name="y2011"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose, we might want to remove the macro files, if they are not used anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The StarDb/AgMLGeometry macros are still required. Any maker in the chain can request the geometry through GetDatabase("VmcGeometry") at any point in the lifetime of the application (during or after StChain::Init()). When that call is made, the DB looks for macros under StarDb/AgMLGeometry (or AgiGeometry depending on alias settings...).
The initialization of the geometry in StBFChain is only performed when certain makers are in the chain (see line 1015).