CbmRoot
Loading...
Searching...
No Matches
CaMcTrack.h
Go to the documentation of this file.
1/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov, Sergei Zharko [committer] */
4
9
10#ifndef CaMcTrack_h
11#define CaMcTrack_h 1
12
13#include "CaDefs.h"
14#include "CaMcLinkKey.h"
15#include "CaVector.h"
16
17#include <functional>
18
19namespace cbm::algo::ca
20{
21 class McPoint;
22 class McHitInfo;
23
24 class McTrack {
25 public:
27 McTrack() = default;
28
30 ~McTrack() = default;
31
33 McTrack(const McTrack&) = default;
34
36 McTrack(McTrack&&) = default;
37
39 McTrack& operator=(const McTrack&) = default;
40
42 McTrack& operator=(McTrack&&) = default;
43
46 void AddPointIndex(int iP) { fvPointIndexes.push_back_no_warning(iP); }
47
50 void AddHitIndex(int iH) { fvHitIndexes.push_back_no_warning(iH); }
51
54 void AddRecoTrackIndex(int iTre) { fvRecoTrackIndexes.push_back_no_warning(iTre); }
55
59 void AddTouchTrackIndex(int iTre) { fvTouchTrackIndexes.push_back_no_warning(iTre); }
60
62 void Clear();
63
66
68 void ClearHitIndexes() { fvHitIndexes.clear(); }
69
72
76
77 // *********************
78 // ** Getters **
79 // *********************
80
82 int GetChainId() const { return fChainId; }
83
85 double GetCharge() const { return fCharge; }
86
88 double GetE() const { return std::sqrt(GetP() * GetP() + fMass * fMass); }
89
91 double GetEkin() const { return GetE() - fMass; }
92
94 double GetEta() const { return -std::log(std::tan(GetTheta() * 0.5)); }
95
97 int GetEventId() const { return fLinkKey.fEvent; }
98
100 int GetExternalId() const { return fLinkKey.fIndex; }
101
103 int GetFileId() const { return fLinkKey.fFile; }
104
106 const auto& GetHitIndexes() const { return fvHitIndexes; }
107
109 int GetId() const { return fId; }
110
113
115 double GetMass() const { return fMass; }
116
119
122
124 int GetMotherId() const { return fMotherId; }
125
127 int GetNofClones() const { return (fvRecoTrackIndexes.size() > 0 ? fvRecoTrackIndexes.size() - 1 : 0); }
128
131
134
136 int GetNofHits() const { return fvHitIndexes.size(); }
137
139 int GetNofPoints() const { return fvPointIndexes.size(); }
140
142 int GetNofRecoTracks() const { return fvRecoTrackIndexes.size(); }
143
145 int GetNofTouchTracks() const { return fvTouchTrackIndexes.size(); }
146
148 double GetP() const { return std::sqrt(fMom[0] * fMom[0] + fMom[1] * fMom[1] + fMom[2] * fMom[2]); }
149
151 int GetPdgCode() const { return fPdgCode; }
152
154 double GetPhi() const { return std::atan2(fMom[1], fMom[0]); }
155
157 const auto& GetPointIndexes() const { return fvPointIndexes; }
158
160 unsigned GetProcessId() const { return fProcId; }
161
163 double GetPt() const { return std::sqrt(fMom[0] * fMom[0] + fMom[1] * fMom[1]); }
164
166 double GetPx() const { return fMom[0]; }
167
169 double GetPy() const { return fMom[1]; }
170
172 double GetPz() const { return fMom[2]; }
173
175 double GetRapidity() const { return 0.5 * std::log((GetE() + fMom[2]) / (GetE() - fMom[2])); }
176
178 const auto& GetRecoTrackIndexes() const { return fvRecoTrackIndexes; }
179
181 double GetSpeed() const { return GetP() / GetE(); }
182
184 double GetStartT() const { return fTime; }
185
187 double GetStartX() const { return fPos[0]; }
188
190 double GetStartY() const { return fPos[1]; }
191
193 double GetStartZ() const { return fPos[2]; }
194
196 double GetTheta() const { return std::acos(fMom[2] / GetP()); }
197
200
203
205 double GetTx() const { return fMom[0] / fMom[2]; }
206
208 double GetTy() const { return fMom[1] / fMom[2]; }
209
211 McPoint GetVertexPoint() const;
212
215 const auto& GetTouchTrackIndexes() const { return fvTouchTrackIndexes; }
216
224
232 void InitPointsInfo(const ca::Vector<McPoint>& vPoints);
233
234
235 // *******************
236 // ** Flags **
237 // *******************
238
240 bool IsAdditional() const { return fIsAdditional; }
241
243 bool IsDisturbed() const { return fvTouchTrackIndexes.size(); }
244
246 bool IsPrimary() const { return fProcId == 0; }
247
250 bool IsReconstructable() const { return fIsReconstructable; }
251
252 bool IsReconstructed() const { return fvRecoTrackIndexes.size(); }
253
255 bool IsSignal() const { return fIsSignal; }
256
257
258 // *********************
259 // ** Setters **
260 // *********************
261
263 void SetChainId(int chainId) { fChainId = chainId; }
264
266 void SetCharge(double q) { fCharge = q; }
267
269 void SetEventId(int iEvent) { fLinkKey.fEvent = iEvent; }
270
273 void SetExternalId(int id) { fLinkKey.fIndex = id; }
274
276 void SetFileId(int iFile) { fLinkKey.fFile = iFile; }
277
279 void SetId(int id) { fId = id; }
280
283 void SetMotherId(int motherId) { fMotherId = motherId; }
284
286 void SetMass(double mass) { fMass = mass; }
287
289 void SetPdgCode(int pdg) { fPdgCode = pdg; }
290
292 void SetProcessId(unsigned procId) { fProcId = procId; }
293
295 void SetPx(double px) { fMom[0] = px; }
296
298 void SetPy(double py) { fMom[1] = py; }
299
301 void SetPz(double pz) { fMom[2] = pz; }
302
304 void SetFlagAdditional(bool isAdditional) { fIsAdditional = isAdditional; }
305
307 void SetFlagReconstructable(bool isReconstructable) { fIsReconstructable = isReconstructable; }
308
310 void SetFlagSignal(bool isSignal) { fIsSignal = isSignal; }
311
313 void SetStartT(double t) { fTime = t; }
314
316 void SetStartX(double x) { fPos[0] = x; }
317
319 void SetStartY(double y) { fPos[1] = y; }
320
322 void SetStartZ(double z) { fPos[2] = z; }
323
326 void SortPointIndexes(const std::function<bool(const int& lhs, const int& rhs)>& cmpFn);
327
332 std::string ToString(int verbose = 1, bool header = false) const;
333
334 private:
335 // ****************************
336 // ** Data variables **
337 // ****************************
338
342
347
350
351 // Track address
355
358
359 bool fIsSignal = false;
360 bool fIsReconstructable = false;
361 bool fIsAdditional = false;
362
363 // Arrangement of hits and points within the stations
371
372 ca::Vector<int> fvPointIndexes = {"ca::tools::fvPointIndexes"};
373 ca::Vector<int> fvHitIndexes = {"ca::tools::fvHitIndexes"};
374 ca::Vector<int> fvRecoTrackIndexes = {"ca::tools::fvRecoTrackIndexes"};
375 ca::Vector<int> fvTouchTrackIndexes = {"ca::tools::fvTouchTrackIndexes"};
377 };
378
379} // namespace cbm::algo::ca
380
381#endif // CaMcTrack_h
Compile-time constants definition for the CA tracking algorithm.
Data structure to represent a MC link in CA tracking MC module.
Class describes a unified MC-point, used in CA tracking QA analysis.
Definition CaMcPoint.h:33
int fMaxNofPointsOnSensor
Max number of MC points with same Z (means on same sensor)
Definition CaMcTrack.h:369
void ClearRecoTrackIndexes()
Clears container of reconstructed track indexes.
Definition CaMcTrack.h:71
int GetMaxNofHitsOnStation() const
Gets max number of hits within a station.
Definition CaMcTrack.h:118
double GetEta() const
Gets pseudo-rapidity.
Definition CaMcTrack.h:94
int fPdgCode
PDG encoding.
Definition CaMcTrack.h:348
double GetPx() const
Gets x component of momentum [GeV/c].
Definition CaMcTrack.h:166
double GetEkin() const
Gets kinetic energy [GeV].
Definition CaMcTrack.h:91
int fId
Index of MC track in internal container for TS/event.
Definition CaMcTrack.h:352
bool IsReconstructed() const
Definition CaMcTrack.h:252
bool IsSignal() const
Returns flag, if the track comes from a real particle (true), or from generated noise (false)
Definition CaMcTrack.h:255
void AddTouchTrackIndex(int iTre)
Definition CaMcTrack.h:59
void SetStartZ(double z)
Sets z component of the track vertex [cm].
Definition CaMcTrack.h:322
McTrack & operator=(McTrack &&)=default
Move assignment operator.
void AddRecoTrackIndex(int iTre)
Definition CaMcTrack.h:54
void SetPx(double px)
Sets x component of momentum [GeV/c].
Definition CaMcTrack.h:295
McPoint GetVertexPoint() const
Creates an MC point from the track vertex.
Definition CaMcTrack.cxx:34
bool IsReconstructable() const
Definition CaMcTrack.h:250
void SetFlagAdditional(bool isAdditional)
Sets flag, if the track is additional (not reconstructable but still interesting)
Definition CaMcTrack.h:304
bool fIsAdditional
If track is not reconstructable, but still interesting.
Definition CaMcTrack.h:361
int GetNofClones() const
Gets number of clones.
Definition CaMcTrack.h:127
ca::Vector< int > fvTouchTrackIndexes
Definition CaMcTrack.h:375
void SetCharge(double q)
Sets charge [e].
Definition CaMcTrack.h:266
void ClearHitIndexes()
Clears container of hit indexes.
Definition CaMcTrack.h:68
double GetPhi() const
Gets azimuthal angle [rad].
Definition CaMcTrack.h:154
bool IsPrimary() const
Returns flag, if the track is primary (process ID is 0 either mother ID is -1)
Definition CaMcTrack.h:246
double GetStartX() const
Gets x component of the track vertex [cm].
Definition CaMcTrack.h:187
void SetPdgCode(int pdg)
Sets PDG encoding.
Definition CaMcTrack.h:289
double GetStartZ() const
Gets z component of the track vertex [cm].
Definition CaMcTrack.h:193
ca::Vector< int > fvRecoTrackIndexes
Indexes of associated reco tracks.
Definition CaMcTrack.h:374
int GetNofHits() const
Gets number of hits.
Definition CaMcTrack.h:136
std::string ToString(int verbose=1, bool header=false) const
Provides string representation of a track.
McTrack(const McTrack &)=default
Copy constructor.
int GetNofTouchTracks() const
Gets number of reconstructed tracks, which contain hits from this MC track.
Definition CaMcTrack.h:145
unsigned fProcId
Process ID (from ROOT::TProcessID)
Definition CaMcTrack.h:349
int GetTotNofStationsWithPoint() const
Gets total number of stations with MC points.
Definition CaMcTrack.h:202
int fMotherId
Index of mother MC track in the external tracks container.
Definition CaMcTrack.h:353
McTrack(McTrack &&)=default
Move constructor.
void SetStartX(double x)
Sets x component of the track vertex [cm].
Definition CaMcTrack.h:316
void SetProcessId(unsigned procId)
Sets process ID.
Definition CaMcTrack.h:292
void SetChainId(int chainId)
Sets index of the first particle in the decay chain.
Definition CaMcTrack.h:263
int GetNofRecoTracks() const
Gets number of assigned reconstructed tracks.
Definition CaMcTrack.h:142
void InitHitsInfo(const ca::Vector< cbm::algo::ca::McHitInfo > &vHits)
Initializes information about MC track hits arrangement within stations Defines: #1) Number of statio...
Definition CaMcTrack.cxx:69
double fCharge
Particle charge [e].
Definition CaMcTrack.h:340
void AddPointIndex(int iP)
Definition CaMcTrack.h:46
ca::Vector< int > fvHitIndexes
Indexes of hits in int.container.
Definition CaMcTrack.h:373
void SortPointIndexes(const std::function< bool(const int &lhs, const int &rhs)> &cmpFn)
double fTime
Time of track [cm].
Definition CaMcTrack.h:341
bool IsAdditional() const
Returns .... TODO.
Definition CaMcTrack.h:240
const auto & GetTouchTrackIndexes() const
Definition CaMcTrack.h:215
int fNofConsStationsWithPoint
Number of consecutive stations with points.
Definition CaMcTrack.h:365
bool IsDisturbed() const
Returns true, if this MC track.
Definition CaMcTrack.h:243
void SetStartY(double y)
Sets y component of the track vertex [cm].
Definition CaMcTrack.h:319
void Clear()
Clears contents.
Definition CaMcTrack.cxx:23
int GetId() const
Gets index of track.
Definition CaMcTrack.h:109
int GetTotNofStationsWithHit() const
Gets total number of stations with hits.
Definition CaMcTrack.h:199
int fMaxNofPointsOnStation
Max number of MC points on a station.
Definition CaMcTrack.h:368
void SetMass(double mass)
Sets particle mass [GeV/c2].
Definition CaMcTrack.h:286
void ClearPointIndexes()
Clears container of point indexes.
Definition CaMcTrack.h:65
std::array< double, 3 > fPos
Track vertex components [cm].
Definition CaMcTrack.h:343
void SetPz(double pz)
Sets x component of momentum [GeV/c].
Definition CaMcTrack.h:301
void SetPy(double py)
Sets x component of momentum [GeV/c].
Definition CaMcTrack.h:298
int GetMotherId() const
Gets index of mother track in CA internal data structures.
Definition CaMcTrack.h:124
const auto & GetPointIndexes() const
Gets a reference to associated point indexes.
Definition CaMcTrack.h:157
int GetExternalId() const
Gets index of the track in the external data structures.
Definition CaMcTrack.h:100
double GetTx() const
Gets track slope along x-axis.
Definition CaMcTrack.h:205
double GetMass() const
Gets particle mass [GeV/c2].
Definition CaMcTrack.h:115
void SetEventId(int iEvent)
Sets index of MC event containing this track in external data structures.
Definition CaMcTrack.h:269
int GetNofPoints() const
Gets number of points.
Definition CaMcTrack.h:139
unsigned GetProcessId() const
Gets process ID.
Definition CaMcTrack.h:160
double GetCharge() const
Gets charge [e].
Definition CaMcTrack.h:85
double GetRapidity() const
Gets rapidity.
Definition CaMcTrack.h:175
int fTotNofStationsWithPoint
Total number of stations with MC points.
Definition CaMcTrack.h:367
double GetSpeed() const
Gets particle speed [c].
Definition CaMcTrack.h:181
double GetTheta() const
Gets track polar angle.
Definition CaMcTrack.h:196
std::array< double, 3 > fMom
Momentum components [GeV/c].
Definition CaMcTrack.h:345
void SetId(int id)
Sets index of track in the CA internal data structure (within event/TS)
Definition CaMcTrack.h:279
int fNofConsStationsWithHit
Number of consecutive stations with hits.
Definition CaMcTrack.h:364
ca::McLinkKey fLinkKey
A link key of this track in the external data structures.
Definition CaMcTrack.h:356
int GetFileId() const
Gets index of MC file containing this track in external data structures.
Definition CaMcTrack.h:103
McTrack & operator=(const McTrack &)=default
Copy assignment operator.
void AddHitIndex(int iH)
Definition CaMcTrack.h:50
int GetEventId() const
Gets index of MC event containing this track in external data structures.
Definition CaMcTrack.h:97
void SetFileId(int iFile)
Sets index of MC file containing this track in external data structures.
Definition CaMcTrack.h:276
~McTrack()=default
Destructor.
void SetMotherId(int motherId)
Definition CaMcTrack.h:283
int GetNofConsStationsWithHit() const
Gets number of consecutive stations with hits.
Definition CaMcTrack.h:130
double GetP() const
Gets absolute momentum [GeV/c].
Definition CaMcTrack.h:148
int GetMaxNofPointsOnStation() const
Gets max number of points within a station.
Definition CaMcTrack.h:121
ca::McLinkKey GetLinkKey() const
Gets link key.
Definition CaMcTrack.h:112
double GetE() const
Gets total energy [GeV].
Definition CaMcTrack.h:88
double GetTy() const
Gets track slope along y-axis.
Definition CaMcTrack.h:208
void SetExternalId(int id)
Definition CaMcTrack.h:273
void SetStartT(double t)
Sets time of the track vertex [ns].
Definition CaMcTrack.h:313
void ClearTouchTrackIndexes()
Definition CaMcTrack.h:75
int fTotNofStationsWithHit
Total number of stations with hits.
Definition CaMcTrack.h:366
double GetStartT() const
Gets time of the track vertex [ns].
Definition CaMcTrack.h:184
const auto & GetRecoTrackIndexes() const
Gets a reference to vector associated reconstructed track indexes.
Definition CaMcTrack.h:178
bool fIsReconstructable
If track is reconstructable.
Definition CaMcTrack.h:360
void InitPointsInfo(const ca::Vector< McPoint > &vPoints)
Initializes information about MC track points arrangement within stations Defines: #1) Number of stat...
bool fIsSignal
If the track comes from signal.
Definition CaMcTrack.h:359
int fChainId
Index of the first particle in the decay chain.
Definition CaMcTrack.h:354
void SetFlagReconstructable(bool isReconstructable)
Sets flag, if the track is reconstructable.
Definition CaMcTrack.h:307
double fMass
Particle mass [GeV/c2].
Definition CaMcTrack.h:339
void SetFlagSignal(bool isSignal)
Sets flag, if the track comes from signal.
Definition CaMcTrack.h:310
ca::Vector< int > fvPointIndexes
Indexes of MC points in ext.container.
Definition CaMcTrack.h:372
const auto & GetHitIndexes() const
Gets a reference to associated hit indexes.
Definition CaMcTrack.h:106
int fMaxNofHitsOnStation
Max number of hits on a station.
Definition CaMcTrack.h:370
double GetPz() const
Gets x component of momentum [GeV/c].
Definition CaMcTrack.h:172
int GetChainId() const
Gets index of the first particle in the decay chain.
Definition CaMcTrack.h:82
double GetPy() const
Gets x component of momentum [GeV/c].
Definition CaMcTrack.h:169
McTrack()=default
Default constructor.
int GetNofConsStationsWithPoint() const
Gets number of consecutive stations with MC points.
Definition CaMcTrack.h:133
int GetPdgCode() const
Gets PDG encoding.
Definition CaMcTrack.h:151
double GetPt() const
Gets transverse momentum [GeV/c].
Definition CaMcTrack.h:163
double GetStartY() const
Gets y component of the track vertex [cm].
Definition CaMcTrack.h:190
constexpr T2 Undef
Undefined values.
Definition CaDefs.h:117
TODO: SZh 8.11.2022: add selection of parameterisation.
Definition CaBranch.h:14