Skip to content

Commit 2259768

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 82b4dd3 commit 2259768

File tree

5 files changed

+22
-75
lines changed

5 files changed

+22
-75
lines changed

base/sim/FairDetector.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "FairGeoNode.h" // for FairGeoNode
1616
#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
17-
#include "FairMCApplication.h" // TEMPORARY until the depracated Bool_t ProcessHits() in use
1817
#include "FairModule.h" // for FairModule::svList, etc
1918
#include "FairRootManager.h"
2019
#include "FairVolume.h" // for FairVolume
@@ -135,7 +134,7 @@ void FairDetector::ProcessHits()
135134
LOG(warning) << " Replace with void FairDetector::ProcessHits(). ";
136135
return true;
137136
}();
138-
ProcessHits(FairMCApplication::Instance()->GetFairVolume());
137+
ProcessHits(NULL);
139138
return;
140139
}
141140

base/sim/FairMCApplication.cxx

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,6 @@ void FairMCApplication::InitGeometry()
900900
if (detector) {
901901
// check whether detector is active
902902
if (detector->IsActive()) {
903-
detector->Initialize();
904903
detector->Register();
905904
}
906905
}
@@ -1359,51 +1358,4 @@ void FairMCApplication::AddSensitiveModule(std::string volName, FairModule* modu
13591358
{
13601359
fMapSensitiveDetectors[volName] = module;
13611360
}
1362-
1363-
FairVolume* FairMCApplication::GetFairVolume()
1364-
{
1365-
// Check if the volume with id is in the volume multimap.
1366-
// If it is not in the map the volume is not a sensitive volume
1367-
// and we do not call nay of our ProcessHits functions.
1368-
1369-
// If the volume is in the multimap, check in second step if the current
1370-
// copy is alredy inside the multimap.
1371-
// If the volume is not in the multimap add the copy of the volume to the
1372-
// multimap.
1373-
// In any case call the ProcessHits function for this specific detector.
1374-
Int_t copyNo;
1375-
Int_t id = fMC->CurrentVolID(copyNo);
1376-
fDisVol = 0;
1377-
Int_t fCopyNo = 0;
1378-
fVolIter = fVolMap.find(id);
1379-
1380-
if (fVolIter != fVolMap.end()) {
1381-
1382-
// Call Process hits for FairVolume with this id, copyNo
1383-
do {
1384-
fDisVol = fVolIter->second;
1385-
fCopyNo = fDisVol->getCopyNo();
1386-
if (copyNo == fCopyNo) {
1387-
return fDisVol;
1388-
}
1389-
++fVolIter;
1390-
} while (fVolIter != fVolMap.upper_bound(id));
1391-
1392-
// Create new FairVolume with this id, copyNo.
1393-
// Use the FairVolume with the same id found in the map to get
1394-
// the link to the detector.
1395-
// Seems that this never happens (?)
1396-
// cout << "Volume not in map; fDisVol ? " << fDisVol << endl
1397-
FairVolume* fNewV = new FairVolume(fMC->CurrentVolName(), id);
1398-
fNewV->setMCid(id);
1399-
fNewV->setModId(fDisVol->getModId());
1400-
fNewV->SetModule(fDisVol->GetModule());
1401-
fNewV->setCopyNo(copyNo);
1402-
fVolMap.insert(pair<Int_t, FairVolume*>(id, fNewV));
1403-
1404-
return fNewV;
1405-
}
1406-
return 0;
1407-
}
1408-
14091361
ClassImp(FairMCApplication)

base/sim/FairMCApplication.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,12 @@ class FairMCApplication : public TVirtualMCApplication
221221
* Add module to the list of sensitive detectors.
222222
*/
223223
void AddSensitiveModule(std::string volName, FairModule* module);
224-
224+
225225
/**
226226
* Return non-owning pointer to FairRadGridManager
227227
*/
228228
auto GetRadGridMan() { return fRadGridMan.get(); }
229229

230-
/**
231-
* Method introduced temporarily. It should go awway with DEPRACATED Bool_t FairDetector::ProcessHits()
232-
*/
233-
FairVolume* GetFairVolume();
234-
235230
private:
236231
// methods
237232
Int_t GetIonPdg(Int_t z, Int_t a) const;

examples/advanced/propagator/src/FairTutPropDet.cxx

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

6565
void FairTutPropDet::Initialize() { FairDetector::Initialize(); }
6666

67-
Bool_t FairTutPropDet::ProcessHits(FairVolume* vol)
67+
void FairTutPropDet::ProcessHits()
6868
{
6969

7070
/** This method is called from the MC stepping */
@@ -84,10 +84,11 @@ Bool_t FairTutPropDet::ProcessHits(FairVolume* vol)
8484
if (TVirtualMC::GetMC()->IsTrackExiting() || TVirtualMC::GetMC()->IsTrackStop()
8585
|| TVirtualMC::GetMC()->IsTrackDisappeared()) {
8686
fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
87-
fVolumeID = vol->getMCid();
87+
Int_t copyNo;
88+
fVolumeID = fMC->CurrentVolID(copyNo);
8889

8990
if (fELoss == 0.) {
90-
return kFALSE;
91+
return;
9192
}
9293

9394
// Taking stationNr from string is almost effortless.
@@ -112,7 +113,7 @@ Bool_t FairTutPropDet::ProcessHits(FairVolume* vol)
112113
stack->AddPoint(kTutProp);
113114
}
114115

115-
return kTRUE;
116+
return;
116117
}
117118

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

examples/advanced/propagator/src/FairTutPropDet.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,24 @@ class FairTutPropDet : public FairDetector
3333
virtual ~FairTutPropDet();
3434

3535
/** Initialization of the detector is done here */
36-
virtual void Initialize();
36+
void Initialize() override;
3737

3838
/** this method is called for each step during simulation
3939
* (see FairMCApplication::Stepping())
4040
*/
41-
virtual Bool_t ProcessHits(FairVolume* v = 0);
41+
void ProcessHits() override;
4242

4343
/** Registers the produced collections in FAIRRootManager. */
44-
virtual void Register();
44+
void Register() override;
4545

4646
/** Gets the produced collections */
47-
virtual TClonesArray* GetCollection(Int_t iColl) const;
47+
TClonesArray* GetCollection(Int_t iColl) const override;
4848

4949
/** has to be called after each event to reset the containers */
50-
virtual void Reset();
50+
void Reset() override;
5151

5252
/** Create the detector geometry */
53-
void ConstructGeometry();
53+
void ConstructGeometry() override;
5454

5555
/** This method is an example of how to add your own point
5656
* of type FairTutPropDetPoint to the clones array
@@ -64,14 +64,14 @@ class FairTutPropDet : public FairDetector
6464

6565
// virtual void CopyClones( TClonesArray* cl1, TClonesArray* cl2 ,
6666
// Int_t offset) {;}
67-
virtual void SetSpecialPhysicsCuts() { ; }
68-
virtual void EndOfEvent();
69-
virtual void FinishPrimary() { ; }
70-
virtual void FinishRun() { ; }
71-
virtual void BeginPrimary() { ; }
72-
virtual void PostTrack() { ; }
73-
virtual void PreTrack() { ; }
74-
virtual void BeginEvent() { ; }
67+
void SetSpecialPhysicsCuts() override { ; }
68+
void EndOfEvent() override;
69+
void FinishPrimary() override { ; }
70+
void FinishRun() override { ; }
71+
void BeginPrimary() override { ; }
72+
void PostTrack() override { ; }
73+
void PreTrack() override { ; }
74+
void BeginEvent() override { ; }
7575

7676
void SetPointsArrayName(const std::string& tempName) { fPointsArrayName = tempName; };
7777

@@ -96,7 +96,7 @@ class FairTutPropDet : public FairDetector
9696
FairTutPropDet(const FairTutPropDet&);
9797
FairTutPropDet& operator=(const FairTutPropDet&);
9898

99-
ClassDef(FairTutPropDet, 1);
99+
ClassDefOverride(FairTutPropDet, 1);
100100
};
101101

102102
#endif // FAIRTUTPROPDET_H

0 commit comments

Comments
 (0)