Skip to content

Commit feecef2

Browse files
authored
Extending track references to other detectors (#15997)
Extending "entering" track references to few other detectors as discussed in the WP12 meeting of https://indico.cern.ch/event/1743928/ related to https://its.cern.ch/jira/browse/O2-7253
1 parent 612f9ef commit feecef2

13 files changed

Lines changed: 57 additions & 2 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: 8 additions & 0 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;
@@ -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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,13 @@ Bool_t Detector::ProcessHits(FairVolume* v)
11231123

11241124
Int_t copy;
11251125
Int_t volID = fMC->CurrentVolID(copy);
1126+
if (fMC->IsTrackEntering() && !fMC->IsNewTrack() && fMC->TrackCharge() != 0 && volID == mTOPVolID) { // one reference per charged particle, first entry from outside
1127+
auto o2stack = static_cast<o2::data::Stack*>(fMC->GetStack());
1128+
if (o2stack->GetCurrentTrackNumber() != mTrackRefLastTrackID) {
1129+
mTrackRefLastTrackID = o2stack->GetCurrentTrackNumber();
1130+
o2stack->addTrackReference(o2::TrackReference(*fMC, GetDetId()));
1131+
}
1132+
}
11261133

11271134
TVirtualMCStack* stack = fMC->GetStack();
11281135
Int_t quadrant, mcp;
@@ -1206,6 +1213,7 @@ void Detector::Reset()
12061213
if (!o2::utils::ShmManager::Instance().isOperational()) {
12071214
mHits->clear();
12081215
}
1216+
mTrackRefLastTrackID = -1;
12091217
}
12101218

12111219
void Detector::CreateMaterials()

‎Detectors/FIT/FV0/simulation/include/FV0Simulation/Detector.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class Detector : public o2::base::DetImpl<Detector>
107107
private:
108108
/// Container for hits
109109
std::vector<o2::fv0::Hit>* mHits = nullptr;
110+
int mTrackRefLastTrackID = -1; //! last track that received a TrackReference in the current event
110111

111112
/// Geometry pointer
112113
Geometry* mGeometry = nullptr; //!

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ Bool_t Detector::ProcessHits(FairVolume* v)
8080
{
8181
// This method is called from the MC stepping
8282

83+
if (fMC->IsTrackEntering() && !fMC->IsNewTrack() && fMC->TrackCharge() != 0) { // one reference per charged particle, first entry from outside
84+
auto o2stack = static_cast<o2::data::Stack*>(fMC->GetStack());
85+
if (o2stack->GetCurrentTrackNumber() != mTrackRefLastTrackID) {
86+
mTrackRefLastTrackID = o2stack->GetCurrentTrackNumber();
87+
o2stack->addTrackReference(o2::TrackReference(*fMC, GetDetId()));
88+
}
89+
}
8390
// Track only charged particles and photons
8491
bool isPhotonTrack = false;
8592
Int_t particlePdg = fMC->TrackPid();
@@ -150,6 +157,7 @@ void Detector::Reset()
150157
if (!o2::utils::ShmManager::Instance().isOperational()) {
151158
mHits->clear();
152159
}
160+
mTrackRefLastTrackID = -1;
153161
}
154162

155163
void Detector::EndOfEvent()

‎Detectors/ITSMFT/MFT/simulation/include/MFTSimulation/Detector.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class Detector : public o2::base::DetImpl<Detector>
148148
private:
149149
/// Container for hit data
150150
std::vector<o2::itsmft::Hit>* mHits;
151+
int mTrackRefLastTrackID = -1; //! last track that received a TrackReference in the current event
151152

152153
Detector(const Detector&);
153154
Detector& operator=(const Detector&);

‎Detectors/ITSMFT/MFT/simulation/src/Detector.cxx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
9696
{
9797
// This method is called from the MC stepping
9898

99+
if (fMC->IsTrackEntering() && !fMC->IsNewTrack() && fMC->TrackCharge() != 0) { // one reference per charged particle, first entry from outside
100+
auto o2stack = static_cast<o2::data::Stack*>(fMC->GetStack());
101+
if (o2stack->GetCurrentTrackNumber() != mTrackRefLastTrackID) {
102+
mTrackRefLastTrackID = o2stack->GetCurrentTrackNumber();
103+
o2stack->addTrackReference(o2::TrackReference(*fMC, GetDetId()));
104+
}
105+
}
99106
// do not track neutral particles
100107
if (!(fMC->TrackCharge())) {
101108
return kFALSE;
@@ -744,4 +751,5 @@ void Detector::Reset()
744751
if (!o2::utils::ShmManager::Instance().isOperational()) {
745752
mHits->clear();
746753
}
754+
mTrackRefLastTrackID = -1;
747755
}

0 commit comments

Comments
 (0)