Skip to content

Commit 033996f

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 033996f

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

fairroot/base/sim/FairModule.cxx

Lines changed: 4 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,10 @@ 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()
284+
<< " failed, beacuse it was already defined";
285285
return;
286286
}
287287
++fNbOfVolumes;

fairroot/base/sim/FairVolumeList.cxx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
#include "FairVolumeList.h"
1414

15+
#include "FairDetector.h"
16+
#include "FairVolume.h"
17+
1518
FairVolume* FairVolumeList::getVolume(const TString& name)
1619
{
1720
auto obj = findObject(name);
@@ -35,8 +38,13 @@ FairVolume* FairVolumeList::addVolume(std::unique_ptr<FairVolume> vol)
3538
auto vol_found = findObject(vol->GetName());
3639

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

0 commit comments

Comments
 (0)