Skip to content

Commit 718e712

Browse files
committed
fix(sim): Clarify behaviour for same-name sensitive volumes
The transport engines allow registering of multiple nodes with the same volume/same volume name (copy mechanism). In `FairRoot` this mechanism works provided unique volume name over the whole geometry setup of different detectors. The commit clarifies the situtation: 1. for same volume names in one detector, it quenches the log message by moving `LOG` and changing it severity from `LOG(error)` in `FairVolumeList::addVolume()` to `LOG(debug)` in `FairModule::AddSensitiveVolume()`. 2. for same volume names accross different detectors, the program prints appropriate `LOG(fatal)`. Fixes the issue #1595.
1 parent 23a39ba commit 718e712

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

fairroot/base/sim/FairModule.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ void FairModule::SetGeometryFileName(TString fname, TString)
216216

217217
void FairModule::RegisterSensitiveVolume(FairVolume& vol)
218218
{
219-
vol.setModId(fModId);
220-
vol.SetModule(this);
221219
fAllSensitiveVolumes.push_back(&vol);
222220
++fNbOfSensitiveVol;
223221
}
@@ -249,7 +247,7 @@ void FairModule::ProcessNodes(TList* nodes)
249247
std::ignore = node->calcLabTransform();
250248

251249
auto nodeTruncName = node->getTruncName();
252-
auto volume = std::make_unique<FairVolume>(nodeTruncName, fNbOfVolumes);
250+
auto volume = std::make_unique<FairVolume>(nodeTruncName, fNbOfVolumes, fModId, this);
253251
volume->setRealName(node->GetName());
254252

255253
auto addedVol = vList->addVolume(std::move(volume));
@@ -280,8 +278,9 @@ void FairModule::AddSensitiveVolume(TGeoVolume* vol)
280278
auto volName = vol->GetName();
281279
LOG(debug2) << "AddSensitiveVolume " << volName;
282280

283-
auto addedVol = vList->addVolume(std::make_unique<FairVolume>(volName, fNbOfVolumes));
281+
auto addedVol = vList->addVolume(std::make_unique<FairVolume>(volName, fNbOfVolumes, fModId, this));
284282
if (!addedVol) {
283+
LOG(debug) << "FairModule: Trying to register element " << vol->GetName() << " for detector " << GetName() << " failed, beacuse it was already defined";
285284
return;
286285
}
287286
++fNbOfVolumes;

fairroot/base/sim/FairVolumeList.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// -------------------------------------------------------------------------
1212

1313
#include "FairVolumeList.h"
14+
#include "FairVolume.h"
15+
#include "FairDetector.h"
1416

1517
FairVolume* FairVolumeList::getVolume(const TString& name)
1618
{
@@ -35,8 +37,12 @@ FairVolume* FairVolumeList::addVolume(std::unique_ptr<FairVolume> vol)
3537
auto vol_found = findObject(vol->GetName());
3638

3739
if (vol_found) {
38-
LOG(error) << "FairVolumeList element: " << vol->GetName() << " VolId : " << vol->getVolumeId()
39-
<< " already defined " << vol_found->getVolumeId();
40+
// FATAL: The same volume name for different detectors
41+
if (vol->GetDetector() != vol_found->GetDetector()) {
42+
LOG(fatal) << "FairVolumeList Trying to register element: " << vol->GetName() << " (VolId=" << vol->getVolumeId()
43+
<< ") for detector " << vol->GetDetector()->GetName() << ", but it was already defined (VolId="
44+
<< vol_found->getVolumeId() << ") for detector " << vol_found->GetDetector()->GetName();
45+
}
4046
return nullptr;
4147
}
4248

0 commit comments

Comments
 (0)