Skip to content

Commit

Permalink
fix(sim): Clarify behaviour for same-name sensitive volumes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
karabowi committed Dec 18, 2024
1 parent 23a39ba commit 3fcd915
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion fairroot/base/sim/FairModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ void FairModule::AddSensitiveVolume(TGeoVolume* vol)
auto volName = vol->GetName();
LOG(debug2) << "AddSensitiveVolume " << volName;

auto addedVol = vList->addVolume(std::make_unique<FairVolume>(volName, fNbOfVolumes));
auto addedVol = vList->addVolume(std::make_unique<FairVolume>(volName, fNbOfVolumes, 0, this));
if (!addedVol) {
LOG(debug) << "FairModule: Trying to register element " << vol->GetName() << " for detector " << GetName() << " failed, beacuse it was already defined";
return;
}
++fNbOfVolumes;
Expand Down
15 changes: 12 additions & 3 deletions fairroot/base/sim/FairVolumeList.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// -------------------------------------------------------------------------

#include "FairVolumeList.h"
#include "FairVolume.h"
#include "FairDetector.h"

FairVolume* FairVolumeList::getVolume(const TString& name)
{
Expand All @@ -34,13 +36,20 @@ FairVolume* FairVolumeList::addVolume(std::unique_ptr<FairVolume> vol)
{
auto vol_found = findObject(vol->GetName());

auto vol_added = static_cast<FairVolume*>(vol.get());

// FATAL: The same volume name for different detectors
if (vol_found && vol->GetDetector() != vol_found->GetDetector() ) {
LOG(fatal) << "FairVolumeList Trying to register element: " << vol->GetName() << " (VolId=" << vol->getVolumeId()
<< ") for detector " << vol->GetDetector()->GetName() << ", but it was already defined (VolId="
<< vol_found->getVolumeId() << ") for detector " << vol_found->GetDetector()->GetName();
std::terminate();
return nullptr;
}
if (vol_found) {
LOG(error) << "FairVolumeList element: " << vol->GetName() << " VolId : " << vol->getVolumeId()
<< " already defined " << vol_found->getVolumeId();
return nullptr;
}

auto vol_added = vol.get();
fData.Add(vol.release());
return vol_added;
}

0 comments on commit 3fcd915

Please sign in to comment.