Skip to content

Commit 121cb79

Browse files
committed
Extending track references
1 parent ff93406 commit 121cb79

13 files changed

Lines changed: 171 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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void Detector::Reset()
106106
if (!o2::utils::ShmManager::Instance().isOperational()) {
107107
mHits->clear();
108108
}
109+
mTrackRefLastTrackID = -1;
109110
}
110111

111112
void Detector::Register() { FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE); }
@@ -123,6 +124,13 @@ Bool_t Detector::ProcessHits(FairVolume* v)
123124
// ported from AliRoot 2019
124125
// ------------------------------------------------------------------------
125126

127+
if (fMC->IsTrackEntering() && !fMC->IsNewTrack() && fMC->TrackCharge() != 0) { // one reference per charged particle, first entry from outside
128+
auto o2stack = static_cast<o2::data::Stack*>(fMC->GetStack());
129+
if (o2stack->GetCurrentTrackNumber() != mTrackRefLastTrackID) {
130+
mTrackRefLastTrackID = o2stack->GetCurrentTrackNumber();
131+
o2stack->addTrackReference(o2::TrackReference(*fMC, GetDetId()));
132+
}
133+
}
126134
// analyze only charged
127135
if (fMC->TrackCharge() == 0) {
128136
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: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ void Detector::InitializeO2Detector()
103103
Bool_t Detector::ProcessHits(FairVolume* vol)
104104
{
105105
// This is step manager
106+
if (fMC->IsTrackEntering() && !fMC->IsNewTrack() && fMC->TrackCharge() != 0) { // one reference per charged particle, first entry from outside
107+
auto o2stack = static_cast<o2::data::Stack*>(fMC->GetStack());
108+
if (o2stack->GetCurrentTrackNumber() != mTrackRefLastTrackID) {
109+
mTrackRefLastTrackID = o2stack->GetCurrentTrackNumber();
110+
o2stack->addTrackReference(o2::TrackReference(*fMC, GetDetId()));
111+
}
112+
}
106113
// do not track neutral particles
107114
if (!(fMC->TrackCharge())) {
108115
return kFALSE;
@@ -138,7 +145,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
138145
// FDA 3 = 12-15
139146

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

143150
Float_t destep_ad = fMC->Edep();
144151
Int_t nPhotonsInStep_ad = Int_t(fFDDLightYield * destep_ad);
@@ -164,7 +171,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
164171
if (fMC->IsTrackExiting() || fMC->IsTrackStop() || fMC->IsTrackDisappeared()) {
165172
Int_t trackID = fMC->GetStack()->GetCurrentTrackNumber();
166173

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

169176
addHit(trackID, ADsector, vPos, time, eloss_ad, nPhotons_ad);
170177
return kTRUE;
@@ -176,7 +183,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
176183
//_____________________________________________________________________________
177184
Hit* Detector::addHit(int trackID, unsigned short detID, const TVector3& Pos, double Time, double eLoss, int nPhot)
178185
{
179-
//LOG(info) << "FDD hit "<<trackID<<" "<<detID<<" "<<Time<<" "<<eLoss<<" "<<nPhot;
186+
// LOG(info) << "FDD hit "<<trackID<<" "<<detID<<" "<<Time<<" "<<eLoss<<" "<<nPhot;
180187
mHits->emplace_back(trackID, detID, Pos, Time, eLoss, nPhot);
181188
auto stack = (o2::data::Stack*)fMC->GetStack();
182189
stack->addHit(GetDetId());
@@ -373,4 +380,5 @@ void Detector::Reset()
373380
if (!o2::utils::ShmManager::Instance().isOperational()) {
374381
mHits->clear();
375382
}
383+
mTrackRefLastTrackID = -1;
376384
}

‎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)