Skip to content

Commit b461f4a

Browse files
Benedikt Volkelbenedikt-voelkel
authored andcommitted
Update TGeo keyname handling
Don't assume any keyname (-->"") when loading geometry in MCReplayGenericApplication. TGeo will take first key in file where it can find a valid geometry
1 parent 99c3e92 commit b461f4a

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

MCReplay/src/MCReplayEngine.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ int MCReplayEngine::getMediumId(int volId) const
728728
mCurrentLookups->volidtomedium[volId]->size() != 0) {
729729
// extract medium name, from that the TGeoMedium and from that finally the ID
730730
auto mediumName{*(mCurrentLookups->volidtomedium[volId])};
731-
auto medium{gGeoManager->GetMedium(mediumName.c_str())};
731+
auto medium{mGeoManager->GetMedium(mediumName.c_str())};
732732
if (medium) {
733733
return medium->GetId();
734734
}

MCReplay/src/MCReplayGenericApplication.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ MCReplayGenericApplication::MCReplayGenericApplication(const std::string& geoFil
2727
mStack{nullptr},
2828
mPrimGen{nullptr}
2929
{
30-
if (mGeoFilename.empty() || mGeoKeyname.empty()) {
31-
// Otherwise assume that the geometry was constructed already by the user
30+
if (mGeoFilename.empty()) {
31+
// we only require the file name to be non-empty. In that case the geo manager would take the first key
32+
// under which a geometry can be found
3233
::Fatal("MCReplayGenericApplication::ctor", "Need file and key name where to find TGeo geometry");
3334
}
35+
3436
mGeoManager = TGeoManager::Import(mGeoFilename.c_str(), mGeoKeyname.c_str());
37+
38+
if (!mGeoManager) {
39+
::Fatal("MCReplayGenericApplication::ctor", "Could not load geometry from path %s under key %s", mGeoFilename.c_str(), mGeoKeyname.c_str());
40+
}
3541
}
3642

3743
void MCReplayGenericApplication::ConstructGeometry()

MCReplay/src/replay.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main(int argc, char* argv[])
2424
{
2525
// prepare reading cmd options and store them
2626
bpo::options_description desc("Replaying a previously recorded particle transport step-by-step. Mainly meant for checking and performance measurements/optimisation of the transport");
27-
desc.add_options()("help", "show this help message and exit")("stepfilename", bpo::value<std::string>()->default_value("MCStepLoggerOutput.root"), "MCStepLogger filename")("steptreename", bpo::value<std::string>()->default_value("StepLoggerTree"), "treename inside file where to find step tree")("geofilename", bpo::value<std::string>()->default_value("o2sim_geometry.root"), "ROOT geometry filename")("geokeyname", bpo::value<std::string>()->default_value("FAIRGeom"), "key name inside geo file where to find geometry tree")("nevents,n", bpo::value<int>()->default_value(-1), "number of events to replay")("energycut,e", bpo::value<float>()->default_value(-1.), "energy cut to be applied [GeV]");
27+
desc.add_options()("help", "show this help message and exit")("stepfilename", bpo::value<std::string>()->default_value("MCStepLoggerOutput.root"), "MCStepLogger filename")("steptreename", bpo::value<std::string>()->default_value("StepLoggerTree"), "treename inside file where to find step tree")("geofilename", bpo::value<std::string>()->default_value("o2sim_geometry.root"), "ROOT geometry filename")("geokeyname", bpo::value<std::string>()->default_value(""), "key name inside geo file where to find geometry tree")("nevents,n", bpo::value<int>()->default_value(-1), "number of events to replay")("energycut,e", bpo::value<float>()->default_value(-1.), "energy cut to be applied [GeV]");
2828

2929
bpo::variables_map vm;
3030
bpo::store(bpo::parse_command_line(argc, argv, desc), vm);

0 commit comments

Comments
 (0)