Skip to content

Commit 2f12803

Browse files
committed
Extending track references
1 parent 3590904 commit 2f12803

13 files changed

Lines changed: 177 additions & 116 deletions

File tree

‎Detectors/CPV/simulation/include/CPVSimulation/Detector.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class Detector : public o2::base::DetImpl<Detector>
157157

158158
// Simulation
159159
std::vector<Hit>* mHits = nullptr; //! Collection of CPV hits
160+
int mTrackRefLastTrackID = -1; //! last track that received a TrackReference in the current event
160161

161162
template <typename Det>
162163
friend class o2::base::DetImpl;

‎Detectors/CPV/simulation/src/Detector.cxx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "DetectorsBase/GeometryManager.h"
3232
#include "DetectorsBase/Stack.h"
33+
#include "SimulationDataFormat/MonopoleParticles.h"
3334

3435
#include <boost/algorithm/string/predicate.hpp>
3536
#include <boost/range/irange.hpp>
@@ -106,6 +107,7 @@ void Detector::Reset()
106107
if (!o2::utils::ShmManager::Instance().isOperational()) {
107108
mHits->clear();
108109
}
110+
mTrackRefLastTrackID = -1;
109111
}
110112

111113
void Detector::Register() { FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE); }
@@ -123,6 +125,13 @@ Bool_t Detector::ProcessHits(FairVolume* v)
123125
// ported from AliRoot 2019
124126
// ------------------------------------------------------------------------
125127

128+
if (fMC->IsTrackEntering() && !fMC->IsNewTrack() && (fMC->TrackCharge() != 0 || o2::sim::isMonopole(fMC->TrackPid()))) { // one reference per charged particle (or monopole), first entry from outside
129+
auto o2stack = static_cast<o2::data::Stack*>(fMC->GetStack());
130+
if (o2stack->GetCurrentTrackNumber() != mTrackRefLastTrackID) {
131+
mTrackRefLastTrackID = o2stack->GetCurrentTrackNumber();
132+
o2stack->addTrackReference(o2::TrackReference(*fMC, GetDetId()));
133+
}
134+
}
126135
// analyze only charged
127136
if (fMC->TrackCharge() == 0) {
128137
fMC->SetMaxStep(1.e10);

‎Detectors/FIT/FDD/simulation/include/FDDSimulation/Detector.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Detector : public o2::base::DetImpl<Detector>
7171

7272
/// Container for data points
7373
std::vector<o2::fdd::Hit>* mHits = nullptr;
74+
int mTrackRefLastTrackID = -1; //! last track that received a TrackReference in the current event
7475

7576
Detector& operator=(const Detector&);
7677

‎Detectors/FIT/FDD/simulation/src/Detector.cxx‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "FDDSimulation/Detector.h"
2222

2323
#include "DetectorsBase/Stack.h"
24+
#include "SimulationDataFormat/MonopoleParticles.h"
2425
#include "Field/MagneticField.h"
2526

2627
#include "TVirtualMC.h"
@@ -103,6 +104,13 @@ void Detector::InitializeO2Detector()
103104
Bool_t Detector::ProcessHits(FairVolume* vol)
104105
{
105106
// This is step manager
107+
if (fMC->IsTrackEntering() && !fMC->IsNewTrack() && (fMC->TrackCharge() != 0 || o2::sim::isMonopole(fMC->TrackPid()))) { // one reference per charged particle (or monopole), first entry from outside
108+
auto o2stack = static_cast<o2::data::Stack*>(fMC->GetStack());
109+
if (o2stack->GetCurrentTrackNumber() != mTrackRefLastTrackID) {
110+
mTrackRefLastTrackID = o2stack->GetCurrentTrackNumber();
111+
o2stack->addTrackReference(o2::TrackReference(*fMC, GetDetId()));
112+
}
113+
}
106114
// do not track neutral particles
107115
if (!(fMC->TrackCharge())) {
108116
return kFALSE;
@@ -138,7 +146,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
138146
// FDA 3 = 12-15
139147

140148
Float_t fFDDLightYield(12.8e6);
141-
//BC420 yield is 0.64 of antracene which is 20k photons/MeV = 12800/MeV = 12.8e6/GeV
149+
// BC420 yield is 0.64 of antracene which is 20k photons/MeV = 12800/MeV = 12.8e6/GeV
142150

143151
Float_t destep_ad = fMC->Edep();
144152
Int_t nPhotonsInStep_ad = Int_t(fFDDLightYield * destep_ad);
@@ -164,7 +172,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
164172
if (fMC->IsTrackExiting() || fMC->IsTrackStop() || fMC->IsTrackDisappeared()) {
165173
Int_t trackID = fMC->GetStack()->GetCurrentTrackNumber();
166174

167-
Float_t time = fMC->TrackTime() * 1.0e9; //time from seconds to ns
175+
Float_t time = fMC->TrackTime() * 1.0e9; // time from seconds to ns
168176

169177
addHit(trackID, ADsector, vPos, time, eloss_ad, nPhotons_ad);
170178
return kTRUE;
@@ -176,7 +184,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
176184
//_____________________________________________________________________________
177185
Hit* Detector::addHit(int trackID, unsigned short detID, const TVector3& Pos, double Time, double eLoss, int nPhot)
178186
{
179-
//LOG(info) << "FDD hit "<<trackID<<" "<<detID<<" "<<Time<<" "<<eLoss<<" "<<nPhot;
187+
// LOG(info) << "FDD hit "<<trackID<<" "<<detID<<" "<<Time<<" "<<eLoss<<" "<<nPhot;
180188
mHits->emplace_back(trackID, detID, Pos, Time, eLoss, nPhot);
181189
auto stack = (o2::data::Stack*)fMC->GetStack();
182190
stack->addHit(GetDetId());
@@ -373,4 +381,5 @@ void Detector::Reset()
373381
if (!o2::utils::ShmManager::Instance().isOperational()) {
374382
mHits->clear();
375383
}
384+
mTrackRefLastTrackID = -1;
376385
}

‎Detectors/FIT/FT0/simulation/include/FT0Simulation/Detector.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ class Detector : public o2::base::DetImpl<Detector>
149149
std::vector<Double_t> mRindexFrontWindow;
150150

151151
// Define the aluminium frame for the detector
152-
TGeoVolume* constructFrameAGeometry(); //A-side
153-
TGeoVolume* constructFrameCGeometry(); //C-side
152+
TGeoVolume* constructFrameAGeometry(); // A-side
153+
TGeoVolume* constructFrameCGeometry(); // C-side
154154
std::string cPlateShapeString();
155155

156156
// BEGIN: Support structure constants
@@ -179,6 +179,7 @@ class Detector : public o2::base::DetImpl<Detector>
179179

180180
/// Container for data points
181181
std::vector<o2::ft0::HitType>* mHits = nullptr;
182+
int mTrackRefLastTrackID = -1; //! last track that received a TrackReference in the current event
182183

183184
// Define volume IDs
184185
int mREGVolID = -1;

0 commit comments

Comments
 (0)