Skip to content

Commit

Permalink
TVirtualMCSensitiveDetector: Cleanup of functions
Browse files Browse the repository at this point in the history
Removed FairDetector::DefineSensitiveVolumes() function,
the functionality moved to FairMCApplication private special copy constructor.

Removed detector initialization from FairMCApplication::RegisterOutput(),
the detectors are initialized in the VMC.
  • Loading branch information
karabowi committed Jan 30, 2023
1 parent 1566441 commit 83bbbc6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
29 changes: 5 additions & 24 deletions base/sim/FairDetector.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
Expand Down Expand Up @@ -45,7 +45,10 @@ FairDetector::FairDetector(const FairDetector& rhs)
, fLogger(rhs.fLogger)
{}

FairDetector::~FairDetector() { delete flGeoPar; }
FairDetector::~FairDetector()
{
delete flGeoPar;
}

FairDetector& FairDetector::operator=(const FairDetector& rhs)
{
Expand All @@ -70,34 +73,12 @@ FairDetector::FairDetector()

// -------------------------------------------------------------------------

void FairDetector::DefineSensitiveVolumes()
{
LOG(info) << "FairDetector::DefineSensitiveVolumes";
TObjArray* volumes = gGeoManager->GetListOfVolumes();
TIter next(volumes);
TGeoVolume* volume;
while ((volume = static_cast<TGeoVolume*>(next()))) {
if (IsSensitive(volume->GetName())) {
LOG(debug) << "Sensitive Volume " << volume->GetName();
AddSensitiveVolume(volume);
}
}
}

// -------------------------------------------------------------------------

void FairDetector::Initialize()
{
// Registers hits collection in Root manager;
// sets sensitive volumes.
// ---

// Define sensitive volumes if in MT
if (gMC->IsMT()) {
std::cout << "Define sensitive volume " << std::endl;
DefineSensitiveVolumes();
}

Int_t NoOfEntries = svList->GetEntries();
Int_t fMCid;
FairGeoNode* fN;
Expand Down
4 changes: 1 addition & 3 deletions base/sim/FairDetector.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
Expand Down Expand Up @@ -109,8 +109,6 @@ class FairDetector : public FairModule
/** Assignment operator */
FairDetector& operator=(const FairDetector&);

void DefineSensitiveVolumes();

Int_t fDetId; // Detector Id has to be set from ctr.
FairLogger* fLogger; //! /// FairLogger

Expand Down
6 changes: 5 additions & 1 deletion base/sim/FairMCApplication.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ FairMCApplication::FairMCApplication(const FairMCApplication& rhs, std::unique_p
auto& clone = fOwnedModules.emplace_back(module->CloneModule());
fListModules.emplace_back(clone.get());
fModules->Add(clone.get());
for (auto sens : rhs.fMapSensitiveDetectors) {
if (sens.second == module) {
fMapSensitiveDetectors[sens.first] = clone.get();
}
}
}

// Create and fill a list of active detectors
Expand Down Expand Up @@ -932,7 +937,6 @@ void FairMCApplication::RegisterOutput()
if (detector) {
// check whether detector is active
if (detector->IsActive()) {
detector->Initialize();
detector->Register();
}
}
Expand Down

0 comments on commit 83bbbc6

Please sign in to comment.