Skip to content

Commit 3fcd915

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, it crashes the program with appropriate `LOG(fatal)`. Fixes the issue #1595.
1 parent 23a39ba commit 3fcd915

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

fairroot/base/sim/FairModule.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,9 @@ void FairModule::AddSensitiveVolume(TGeoVolume* vol)
280280
auto volName = vol->GetName();
281281
LOG(debug2) << "AddSensitiveVolume " << volName;
282282

283-
auto addedVol = vList->addVolume(std::make_unique<FairVolume>(volName, fNbOfVolumes));
283+
auto addedVol = vList->addVolume(std::make_unique<FairVolume>(volName, fNbOfVolumes, 0, this));
284284
if (!addedVol) {
285+
LOG(debug) << "FairModule: Trying to register element " << vol->GetName() << " for detector " << GetName() << " failed, beacuse it was already defined";
285286
return;
286287
}
287288
++fNbOfVolumes;

fairroot/base/sim/FairVolumeList.cxx

Lines changed: 12 additions & 3 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
{
@@ -34,13 +36,20 @@ FairVolume* FairVolumeList::addVolume(std::unique_ptr<FairVolume> vol)
3436
{
3537
auto vol_found = findObject(vol->GetName());
3638

39+
auto vol_added = static_cast<FairVolume*>(vol.get());
40+
41+
// FATAL: The same volume name for different detectors
42+
if (vol_found && vol->GetDetector() != vol_found->GetDetector() ) {
43+
LOG(fatal) << "FairVolumeList Trying to register element: " << vol->GetName() << " (VolId=" << vol->getVolumeId()
44+
<< ") for detector " << vol->GetDetector()->GetName() << ", but it was already defined (VolId="
45+
<< vol_found->getVolumeId() << ") for detector " << vol_found->GetDetector()->GetName();
46+
std::terminate();
47+
return nullptr;
48+
}
3749
if (vol_found) {
38-
LOG(error) << "FairVolumeList element: " << vol->GetName() << " VolId : " << vol->getVolumeId()
39-
<< " already defined " << vol_found->getVolumeId();
4050
return nullptr;
4151
}
4252

43-
auto vol_added = vol.get();
4453
fData.Add(vol.release());
4554
return vol_added;
4655
}

0 commit comments

Comments
 (0)