Skip to content

Commit

Permalink
fix(Base): Only search vList once
Browse files Browse the repository at this point in the history
Fix #1495
  • Loading branch information
dennisklein committed May 24, 2024
1 parent b890b98 commit 54fab0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions fairroot/base/sim/FairModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,19 @@ void FairModule::ProcessNodes(TList* aList)

void FairModule::AddSensitiveVolume(TGeoVolume* v)
{
LOG(debug2) << "AddSensitiveVolume " << v->GetName();
auto vol_name = v->GetName();
LOG(debug2) << "AddSensitiveVolume " << vol_name;

auto volume = std::make_unique<FairVolume>(vol_name, fNbOfVolumes);

// Only register volumes which are not already registered
// Otherwise the stepping will be slowed down
if (!vList->findObject(v->GetName())) {
auto volume = std::make_unique<FairVolume>(v->GetName(), fNbOfVolumes++);
auto volume_ptr = volume.get();
vList->addVolume(std::move(volume));
volume_ptr->setModId(fModId);
volume_ptr->SetModule(this);
fAllSensitiveVolumes.push_back(volume_ptr);
fNbOfSensitiveVol++;
if (auto vol_added = vList->addVolume(std::move(volume)); vol_added) {
++fNbOfVolumes;
vol_added->setModId(fModId);
vol_added->SetModule(this);
fAllSensitiveVolumes.push_back(vol_added);
++fNbOfSensitiveVol;
}
}

Expand Down
1 change: 1 addition & 0 deletions fairroot/base/sim/FairModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class FairModule : public TNamed
* \deprecated Not used anywhere, will be removed in a future release
*/
[[deprecated]] FairVolume* getFairVolume(FairGeoNode* fNode);
/** Takes ownership of passed volume **/
void AddSensitiveVolume(TGeoVolume* v);

private:
Expand Down

0 comments on commit 54fab0a

Please sign in to comment.