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,
the program prints appropriate `LOG(fatal)`.

Fixes the issue #1595.
  • Loading branch information
karabowi committed Jan 23, 2025
1 parent 23a39ba commit 033996f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions fairroot/base/sim/FairModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ void FairModule::SetGeometryFileName(TString fname, TString)

void FairModule::RegisterSensitiveVolume(FairVolume& vol)
{
vol.setModId(fModId);
vol.SetModule(this);
fAllSensitiveVolumes.push_back(&vol);
++fNbOfSensitiveVol;
}
Expand Down Expand Up @@ -249,7 +247,7 @@ void FairModule::ProcessNodes(TList* nodes)
std::ignore = node->calcLabTransform();

auto nodeTruncName = node->getTruncName();
auto volume = std::make_unique<FairVolume>(nodeTruncName, fNbOfVolumes);
auto volume = std::make_unique<FairVolume>(nodeTruncName, fNbOfVolumes, fModId, this);
volume->setRealName(node->GetName());

auto addedVol = vList->addVolume(std::move(volume));
Expand Down Expand Up @@ -280,8 +278,10 @@ 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, fModId, 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
12 changes: 10 additions & 2 deletions fairroot/base/sim/FairVolumeList.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

#include "FairVolumeList.h"

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

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

if (vol_found) {
LOG(error) << "FairVolumeList element: " << vol->GetName() << " VolId : " << vol->getVolumeId()
<< " already defined " << vol_found->getVolumeId();
// FATAL: The same volume name for different detectors
if (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();
}
return nullptr;
}

Expand Down

0 comments on commit 033996f

Please sign in to comment.