Skip to content

Commit 9b9d611

Browse files
committed
Fix the double initialization of FairDetector
Since VMC is initializing TVirtualMCSensitiveDetector, removed detector->Initialize() from FairMCApplication. Removed the GetFairVolume function used by FairDetector::ProcessHits(). It now calls the deprecated function with NULL argument. Changed the propagator example to use the new ProcessHits().
1 parent 3938cbd commit 9b9d611

File tree

7 files changed

+21
-65
lines changed

7 files changed

+21
-65
lines changed

base/sim/FairDetector.cxx

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

1313
#include "FairDetector.h"
1414

15-
#include "FairGeoNode.h" // for FairGeoNode
16-
#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
17-
#include "FairMCApplication.h" // TEMPORARY until the depracated Bool_t ProcessHits() in use
18-
#include "FairModule.h" // for FairModule::svList, etc
15+
#include "FairGeoNode.h" // for FairGeoNode
16+
#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
17+
#include "FairModule.h" // for FairModule::svList, etc
1918
#include "FairRootManager.h"
2019
#include "FairVolume.h" // for FairVolume
2120

@@ -135,7 +134,8 @@ void FairDetector::ProcessHits()
135134
LOG(warning) << " Replace with void FairDetector::ProcessHits(). ";
136135
return true;
137136
}();
138-
ProcessHits(FairMCApplication::Instance()->GetFairVolume());
137+
(void)printOnce;
138+
ProcessHits(NULL);
139139
return;
140140
}
141141

base/sim/FairMCApplication.cxx

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,6 @@ void FairMCApplication::Stepping()
526526
TrackId = fMC->GetStack()->GetCurrentTrackNumber();
527527
}
528528

529-
Int_t copyNo;
530-
Int_t id = fMC->CurrentVolID(copyNo);
531-
532529
// If information about the tracks should be stored the information as to be
533530
// stored for any step.
534531
// Information about each single step has also to be stored for the other
@@ -546,6 +543,8 @@ void FairMCApplication::Stepping()
546543
}
547544
}
548545
if (fRadLenMan || fRadMapMan) {
546+
Int_t copyNo;
547+
Int_t id = fMC->CurrentVolID(copyNo);
549548
id = fMC->CurrentVolID(copyNo);
550549
auto modvoliter = (fParent ? fParent : this)->fModVolMap.find(id);
551550
if (fRadLenMan) {
@@ -1313,51 +1312,4 @@ void FairMCApplication::AddSensitiveModule(std::string volName, FairModule* modu
13131312
{
13141313
fMapSensitiveDetectors[volName] = module;
13151314
}
1316-
1317-
FairVolume* FairMCApplication::GetFairVolume()
1318-
{
1319-
// Check if the volume with id is in the volume multimap.
1320-
// If it is not in the map the volume is not a sensitive volume
1321-
// and we do not call nay of our ProcessHits functions.
1322-
1323-
// If the volume is in the multimap, check in second step if the current
1324-
// copy is alredy inside the multimap.
1325-
// If the volume is not in the multimap add the copy of the volume to the
1326-
// multimap.
1327-
// In any case call the ProcessHits function for this specific detector.
1328-
Int_t copyNo;
1329-
Int_t id = fMC->CurrentVolID(copyNo);
1330-
fDisVol = 0;
1331-
Int_t fCopyNo = 0;
1332-
fVolIter = fVolMap.find(id);
1333-
1334-
if (fVolIter != fVolMap.end()) {
1335-
1336-
// Call Process hits for FairVolume with this id, copyNo
1337-
do {
1338-
fDisVol = fVolIter->second;
1339-
fCopyNo = fDisVol->getCopyNo();
1340-
if (copyNo == fCopyNo) {
1341-
return fDisVol;
1342-
}
1343-
++fVolIter;
1344-
} while (fVolIter != fVolMap.upper_bound(id));
1345-
1346-
// Create new FairVolume with this id, copyNo.
1347-
// Use the FairVolume with the same id found in the map to get
1348-
// the link to the detector.
1349-
// Seems that this never happens (?)
1350-
// cout << "Volume not in map; fDisVol ? " << fDisVol << endl
1351-
FairVolume* fNewV = new FairVolume(fMC->CurrentVolName(), id);
1352-
fNewV->setMCid(id);
1353-
fNewV->setModId(fDisVol->getModId());
1354-
fNewV->SetModule(fDisVol->GetModule());
1355-
fNewV->setCopyNo(copyNo);
1356-
fVolMap.insert(pair<Int_t, FairVolume*>(id, fNewV));
1357-
1358-
return fNewV;
1359-
}
1360-
return 0;
1361-
}
1362-
13631315
ClassImp(FairMCApplication)

base/sim/FairMCApplication.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class FairMCApplication : public TVirtualMCApplication
233233
* Add module to the list of sensitive detectors.
234234
*/
235235
void AddSensitiveModule(std::string volName, FairModule* module);
236-
236+
237237
/**
238238
* Return non-owning pointer to FairRadGridManager
239239
*/

base/sim/FairModule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ class FairModule : public TVirtualMCSensitiveDetector
149149
FairVolume* getFairVolume(FairGeoNode* fNode);
150150
void AddSensitiveVolume(TGeoVolume* v);
151151

152-
virtual void EndOfEvent() {}
152+
void EndOfEvent() override {}
153153

154-
virtual void Initialize() {}
154+
void Initialize() override {}
155155

156-
virtual void ProcessHits() {}
156+
void ProcessHits() override {}
157157

158158
private:
159159
/** Re-implimented from ROOT: TGeoMatrix::SetDefaultName() */

base/sim/fastsim/FairFastSimDetector.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ void FairFastSimDetector::ConstructGeometry()
5959
}
6060
}
6161

62-
void FairFastSimDetector::ProcessHits() { FastSimProcessParticle(); }
62+
void FairFastSimDetector::ProcessHits()
63+
{
64+
FastSimProcessParticle();
65+
}
6366

6467
ClassImp(FairFastSimDetector);

examples/advanced/propagator/src/FairTutPropDet.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ FairTutPropDet::~FairTutPropDet()
6262
}
6363
}
6464

65-
Bool_t FairTutPropDet::ProcessHits(FairVolume* vol)
65+
void FairTutPropDet::ProcessHits()
6666
{
6767

6868
/** This method is called from the MC stepping */
@@ -82,10 +82,11 @@ Bool_t FairTutPropDet::ProcessHits(FairVolume* vol)
8282
if (TVirtualMC::GetMC()->IsTrackExiting() || TVirtualMC::GetMC()->IsTrackStop()
8383
|| TVirtualMC::GetMC()->IsTrackDisappeared()) {
8484
fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
85-
fVolumeID = vol->getMCid();
85+
Int_t copyNo;
86+
fVolumeID = fMC->CurrentVolID(copyNo);
8687

8788
if (fELoss == 0.) {
88-
return kFALSE;
89+
return;
8990
}
9091

9192
// Taking stationNr from string is almost effortless.
@@ -110,7 +111,7 @@ Bool_t FairTutPropDet::ProcessHits(FairVolume* vol)
110111
stack->AddPoint(kTutProp);
111112
}
112113

113-
return kTRUE;
114+
return;
114115
}
115116

116117
void FairTutPropDet::EndOfEvent() { fFairTutPropPointCollection->Clear(); }

examples/advanced/propagator/src/FairTutPropDet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class FairTutPropDet : public FairDetector
3535
/** this method is called for each step during simulation
3636
* (see FairMCApplication::Stepping())
3737
*/
38-
Bool_t ProcessHits(FairVolume* v = nullptr) override;
38+
void ProcessHits() override;
3939

4040
/** Registers the produced collections in FAIRRootManager. */
4141
void Register() override;

0 commit comments

Comments
 (0)