Skip to content

Commit 8e9398b

Browse files
committed
Fix the construction of cloned sensitive volumes
FairRoot allows for construction of clones volumes using the volume_name#{clone_number} scheme. Changing FairMCApplication::ConstructSensitiveDetectors() to support this.
1 parent 33dc8aa commit 8e9398b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

base/sim/FairMCApplication.cxx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,9 +1336,22 @@ void FairMCApplication::UndoGeometryModifications()
13361336

13371337
void FairMCApplication::ConstructSensitiveDetectors()
13381338
{
1339+
std::map<std::string, FairModule*> cloneVolumeMap;
1340+
13391341
for (auto const& x : fMapSensitiveDetectors) {
1340-
LOG(debug) << "FairMCApplication::ConstructSensitiveDetectors " << x.first << " " << x.second;
1341-
TVirtualMC::GetMC()->SetSensitiveDetector(x.first, x.second);
1342+
std::string volName = x.first; //.substr(0, x.first.find("#", 0));
1343+
if (volName.find('#') != std::string::npos) {
1344+
volName = volName.substr(0, volName.find("#", 0));
1345+
std::map<std::string, FairModule*>::iterator it;
1346+
it = cloneVolumeMap.find(volName);
1347+
LOG(debug) << "FairMCApplication::ConstructSensitiveDetectors got clone " << x.first << " " << x.second;
1348+
if (it != cloneVolumeMap.end())
1349+
continue;
1350+
cloneVolumeMap[volName] = x.second;
1351+
LOG(debug) << "FairMCApplication::ConstructSensitiveDetectors really do " << volName;
1352+
}
1353+
LOG(debug) << "FairMCApplication::ConstructSensitiveDetectors really do " << volName;
1354+
TVirtualMC::GetMC()->SetSensitiveDetector(volName, x.second);
13421355
}
13431356
}
13441357

0 commit comments

Comments
 (0)