CbmRoot
Loading...
Searching...
No Matches
CaToolsMCTrack.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 CaToolsMCTrack_h
11#define CaToolsMCTrack_h 1
12
13#include "CaToolsDef.h"
14#include "CaToolsLinkKey.h"
15#include "CaVector.h"
16#include "CbmL1Hit.h"
17#include "TMath.h"
18
19#include <functional>
20
22
23namespace cbm::ca::tools
24{
25 class MCPoint;
26
28
29 class MCTrack {
30 public:
32 MCTrack() = default;
33
35 ~MCTrack() = default;
36
38 MCTrack(const MCTrack&) = default;
39
41 MCTrack(MCTrack&&) = default;
42
44 MCTrack& operator=(const MCTrack&) = default;
45
47 MCTrack& operator=(MCTrack&&) = default;
48
52
56
60
65
67 void Clear();
68
71
73 void ClearHitIndexes() { fvHitIndexes.clear(); }
74
77
81
82 // *********************
83 // ** Getters **
84 // *********************
85
87 int GetChainId() const { return fChainId; }
88
90 double GetCharge() const { return fCharge; }
91
93 double GetE() const { return std::sqrt(GetP() * GetP() + fMass * fMass); }
94
96 double GetEkin() const { return GetE() - fMass; }
97
99 double GetEta() const { return -std::log(std::tan(GetTheta() * 0.5)); }
100
102 int GetEventId() const { return fLinkKey.fEvent; }
103
105 int GetExternalId() const { return fLinkKey.fIndex; }
106
108 int GetFileId() const { return fLinkKey.fFile; }
109
111 const auto& GetHitIndexes() const { return fvHitIndexes; }
112
114 int GetId() const { return fId; }
115
117 LinkKey GetLinkKey() const { return fLinkKey; }
118
120 double GetMass() const { return fMass; }
121
124
127
129 int GetMotherId() const { return fMotherId; }
130
132 int GetNofClones() const { return (fvRecoTrackIndexes.size() > 0 ? fvRecoTrackIndexes.size() - 1 : 0); }
133
136
139
141 int GetNofHits() const { return fvHitIndexes.size(); }
142
144 int GetNofPoints() const { return fvPointIndexes.size(); }
145
147 int GetNofRecoTracks() const { return fvRecoTrackIndexes.size(); }
148
150 int GetNofTouchTracks() const { return fvTouchTrackIndexes.size(); }
151
153 double GetP() const { return std::sqrt(fMom[0] * fMom[0] + fMom[1] * fMom[1] + fMom[2] * fMom[2]); }
154
156 int GetPdgCode() const { return fPdgCode; }
157
159 double GetPhi() const { return std::atan2(fMom[1], fMom[0]); }
160
162 const auto& GetPointIndexes() const { return fvPointIndexes; }
163
165 unsigned GetProcessId() const { return fProcId; }
166
168 double GetPt() const { return std::sqrt(fMom[0] * fMom[0] + fMom[1] * fMom[1]); }
169
171 double GetPx() const { return fMom[0]; }
172
174 double GetPy() const { return fMom[1]; }
175
177 double GetPz() const { return fMom[2]; }
178
180 double GetRapidity() const { return 0.5 * std::log((GetE() + fMom[2]) / (GetE() - fMom[2])); }
181
183 const auto& GetRecoTrackIndexes() const { return fvRecoTrackIndexes; }
184
186 double GetSpeed() const { return GetP() / GetE(); }
187
189 double GetStartT() const { return fTime; }
190
192 double GetStartX() const { return fPos[0]; }
193
195 double GetStartY() const { return fPos[1]; }
196
198 double GetStartZ() const { return fPos[2]; }
199
201 double GetTheta() const { return std::acos(fMom[2] / GetP()); }
202
205
208
210 double GetTx() const { return fMom[0] / fMom[2]; }
211
213 double GetTy() const { return fMom[1] / fMom[2]; }
214
216 MCPoint GetVertexPoint() const;
217
220 const auto& GetTouchTrackIndexes() const { return fvTouchTrackIndexes; }
221
229
237 void InitPointsInfo(const ca::Vector<MCPoint>& vPoints);
238
239
240 // *******************
241 // ** Flags **
242 // *******************
243
245 bool IsAdditional() const { return fIsAdditional; }
246
248 bool IsDisturbed() const { return fvTouchTrackIndexes.size(); }
249
251 bool IsPrimary() const { return fProcId == 0; }
252
255 bool IsReconstructable() const { return fIsReconstructable; }
256
257 bool IsReconstructed() const { return fvRecoTrackIndexes.size(); }
258
260 bool IsSignal() const { return fIsSignal; }
261
262
263 // *********************
264 // ** Setters **
265 // *********************
266
268 void SetChainId(int chainId) { fChainId = chainId; }
269
271 void SetCharge(double q) { fCharge = q; }
272
274 void SetEventId(int iEvent) { fLinkKey.fEvent = iEvent; }
275
278 void SetExternalId(int id) { fLinkKey.fIndex = id; }
279
281 void SetFileId(int iFile) { fLinkKey.fFile = iFile; }
282
284 void SetId(int id) { fId = id; }
285
288 void SetMotherId(int motherId) { fMotherId = motherId; }
289
291 void SetMass(double mass) { fMass = mass; }
292
294 void SetPdgCode(int pdg) { fPdgCode = pdg; }
295
297 void SetProcessId(unsigned procId) { fProcId = procId; }
298
300 void SetPx(double px) { fMom[0] = px; }
301
303 void SetPy(double py) { fMom[1] = py; }
304
306 void SetPz(double pz) { fMom[2] = pz; }
307
309 void SetFlagAdditional(bool isAdditional) { fIsAdditional = isAdditional; }
310
312 void SetFlagReconstructable(bool isReconstructable) { fIsReconstructable = isReconstructable; }
313
315 void SetFlagSignal(bool isSignal) { fIsSignal = isSignal; }
316
318 void SetStartT(double t) { fTime = t; }
319
321 void SetStartX(double x) { fPos[0] = x; }
322
324 void SetStartY(double y) { fPos[1] = y; }
325
327 void SetStartZ(double z) { fPos[2] = z; }
328
331 void SortPointIndexes(const std::function<bool(const int& lhs, const int& rhs)>& cmpFn);
332
337 std::string ToString(int verbose = 1, bool header = false) const;
338
339 private:
340 // ****************************
341 // ** Data variables **
342 // ****************************
343
347
352
355
356 // Track address
360
363
364 bool fIsSignal = false;
365 bool fIsReconstructable = false;
366 bool fIsAdditional = false;
367
368 // Arrangement of hits and points within the stations
376
377 ca::Vector<int> fvPointIndexes = {"ca::tools::fvPointIndexes"};
378 ca::Vector<int> fvHitIndexes = {"ca::tools::fvHitIndexes"};
379 ca::Vector<int> fvRecoTrackIndexes = {"ca::tools::fvRecoTrackIndexes"};
380 ca::Vector<int> fvTouchTrackIndexes = {"ca::tools::fvTouchTrackIndexes"};
382 };
383
384} // namespace cbm::ca::tools
385
386#endif // CaToolsMCTrack_h
Definitions for ca::tools namespace.
Data structure to represent a MC link in CA tracking MC module.
void push_back_no_warning(Tinput value)
Pushes back a value to the vector without testing for the memory re-alocation.
Definition CaVector.h:188
Class describes a unified MC-point, used in CA tracking QA analysis.
double GetPt() const
Gets transverse momentum [GeV/c].
double GetStartX() const
Gets x component of the track vertex [cm].
double GetTy() const
Gets track slope along y-axis.
MCTrack & operator=(MCTrack &&)=default
Move assignment operator.
const auto & GetTouchTrackIndexes() const
int GetNofPoints() const
Gets number of points.
bool fIsReconstructable
If track is reconstructable.
void ClearHitIndexes()
Clears container of hit indexes.
MCTrack(MCTrack &&)=default
Move constructor.
void SetProcessId(unsigned procId)
Sets process ID.
const auto & GetHitIndexes() const
Gets a reference to associated hit indexes.
void SetStartT(double t)
Sets time of the track vertex [ns].
int GetTotNofStationsWithPoint() const
Gets total number of stations with MC points.
double GetPy() const
Gets x component of momentum [GeV/c].
double GetStartZ() const
Gets z component of the track vertex [cm].
int GetNofConsStationsWithHit() const
Gets number of consecutive stations with hits.
void SetStartZ(double z)
Sets z component of the track vertex [cm].
int GetMaxNofHitsOnStation() const
Gets max number of hits within a station.
int fMotherId
Index of mother MC track in the external tracks container.
int GetNofRecoTracks() const
Gets number of assigned reconstructed tracks.
double fCharge
Particle charge [e].
ca::Vector< int > fvHitIndexes
Indexes of hits in int.container.
bool IsAdditional() const
Returns .... TODO.
void SetMass(double mass)
Sets particle mass [GeV/c2].
void SetFlagAdditional(bool isAdditional)
Sets flag, if the track is additional (not reconstructable but still interesting)
void SetId(int id)
Sets index of track in the CA internal data structure (within event/TS)
double GetMass() const
Gets particle mass [GeV/c2].
void SetPy(double py)
Sets x component of momentum [GeV/c].
void SortPointIndexes(const std::function< bool(const int &lhs, const int &rhs)> &cmpFn)
ca::Vector< int > fvPointIndexes
Indexes of MC points in ext.container.
double GetEta() const
Gets pseudo-rapidity.
int GetMotherId() const
Gets index of mother track in CA internal data structures.
int fTotNofStationsWithHit
Total number of stations with hits.
void SetStartX(double x)
Sets x component of the track vertex [cm].
int fMaxNofHitsOnStation
Max number of hits on a station.
const auto & GetRecoTrackIndexes() const
Gets a reference to vector associated reconstructed track indexes.
double fTime
Time of track [cm].
double GetRapidity() const
Gets rapidity.
int GetNofHits() const
Gets number of hits.
double GetPx() const
Gets x component of momentum [GeV/c].
void AddTouchTrackIndex(int iTre)
void SetChainId(int chainId)
Sets index of the first particle in the decay chain.
double GetStartT() const
Gets time of the track vertex [ns].
int GetFileId() const
Gets index of MC file containing this track in external data structures.
void SetFlagSignal(bool isSignal)
Sets flag, if the track comes from signal.
bool fIsAdditional
If track is not reconstructable, but still interesting.
void SetEventId(int iEvent)
Sets index of MC event containing this track in external data structures.
std::array< double, 3 > fPos
Track vertex components [cm].
~MCTrack()=default
Destructor.
int fNofConsStationsWithPoint
Number of consecutive stations with points.
unsigned GetProcessId() const
Gets process ID.
int GetNofTouchTracks() const
Gets number of reconstructed tracks, which contain hits from this MC track.
double GetPhi() const
Gets azimuthal angle [rad].
void SetPz(double pz)
Sets x component of momentum [GeV/c].
MCTrack & operator=(const MCTrack &)=default
Copy assignment operator.
void InitPointsInfo(const ca::Vector< MCPoint > &vPoints)
Initializes information about MC track points arrangement within stations Defines: #1) Number of stat...
double GetCharge() const
Gets charge [e].
int GetChainId() const
Gets index of the first particle in the decay chain.
void ClearRecoTrackIndexes()
Clears container of reconstructed track indexes.
double GetTx() const
Gets track slope along x-axis.
void SetCharge(double q)
Sets charge [e].
int fMaxNofPointsOnStation
Max number of MC points on a station.
void SetStartY(double y)
Sets y component of the track vertex [cm].
int GetEventId() const
Gets index of MC event containing this track in external data structures.
int fTotNofStationsWithPoint
Total number of stations with MC points.
int fPdgCode
PDG encoding.
std::string ToString(int verbose=1, bool header=false) const
Provides string representation of a track.
void SetFlagReconstructable(bool isReconstructable)
Sets flag, if the track is reconstructable.
double GetP() const
Gets absolute momentum [GeV/c].
std::array< double, 3 > fMom
Momentum components [GeV/c].
int GetMaxNofPointsOnStation() const
Gets max number of points within a station.
bool IsSignal() const
Returns flag, if the track comes from a real particle (true), or from generated noise (false)
double GetEkin() const
Gets kinetic energy [GeV].
int GetTotNofStationsWithHit() const
Gets total number of stations with hits.
int GetId() const
Gets index of track.
const auto & GetPointIndexes() const
Gets a reference to associated point indexes.
int GetPdgCode() const
Gets PDG encoding.
void SetPx(double px)
Sets x component of momentum [GeV/c].
MCPoint GetVertexPoint() const
Creates an MC point from the track vertex.
MCTrack()=default
Default constructor.
ca::Vector< int > fvTouchTrackIndexes
double GetStartY() const
Gets y component of the track vertex [cm].
void SetMotherId(int motherId)
void SetPdgCode(int pdg)
Sets PDG encoding.
void AddRecoTrackIndex(int iTre)
double GetSpeed() const
Gets particle speed [c].
ca::Vector< int > fvRecoTrackIndexes
Indexes of associated reco tracks.
double GetTheta() const
Gets track polar angle.
double GetPz() const
Gets x component of momentum [GeV/c].
bool IsPrimary() const
Returns flag, if the track is primary (process ID is 0 either mother ID is -1)
bool fIsSignal
If the track comes from signal.
int GetExternalId() const
Gets index of the track in the external data structures.
void SetFileId(int iFile)
Sets index of MC file containing this track in external data structures.
int GetNofConsStationsWithPoint() const
Gets number of consecutive stations with MC points.
int GetNofClones() const
Gets number of clones.
void Clear()
Clears contents.
double GetE() const
Gets total energy [GeV].
void InitHitsInfo(const ca::Vector< CbmL1HitDebugInfo > &vHits)
Initializes information about MC track hits arrangement within stations Defines: #1) Number of statio...
LinkKey fLinkKey
A link key of this track in the external data structures.
int fId
Index of MC track in internal container for TS/event.
double fMass
Particle mass [GeV/c2].
LinkKey GetLinkKey() const
Gets link key.
MCTrack(const MCTrack &)=default
Copy constructor.
int fNofConsStationsWithHit
Number of consecutive stations with hits.
bool IsDisturbed() const
Returns true, if this MC track.
unsigned fProcId
Process ID (from ROOT::TProcessID)
int fChainId
Index of the first particle in the decay chain.
int fMaxNofPointsOnSensor
Max number of MC points with same Z (means on same sensor)
void ClearPointIndexes()
Clears container of point indexes.
constexpr int Undef< int >
Definition CaDefs.h:113
constexpr unsigned Undef< unsigned >
Definition CaDefs.h:116
constexpr double Undef< double >
Definition CaDefs.h:122
int fEvent
Index of MC event.
int fFile
Index of MC file.
int fIndex
Index of MC point/track in external data structures.