Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions StRoot/StBFChain/StBFChain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -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;
}
Copy link
Member

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?

Copy link
Contributor

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).

CreateGeometry(DbAlias[i].geometry);
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
}
}
Expand Down
75 changes: 75 additions & 0 deletions StarVMC/StarGeometry/CreateGeometry.cxx
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dlopen error: /star-sw/.sl79_gcc485/LIB/libStarGeometry.so: undefined symbol: chain

Looks like we've never landed the 205f44a.

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now ROOT5 seems to not handle the extern *chain in bfc.C.


/**
* 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;
}
3 changes: 3 additions & 0 deletions StarVMC/StarGeometry/CreateGeometry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class TDataSet;

TDataSet *CreateGeometry(const char *name="y2011");
Loading