CbmRoot
Loading...
Searching...
No Matches
CaToolsMCPoint.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: Sergei Zharko [committer] */
4
9
10#ifndef CaToolsMCPoint_h
11#define CaToolsMCPoint_h 1
12
13#include "CaToolsDef.h"
14#include "CaToolsLinkKey.h"
15#include "CaVector.h"
16
17#include <string>
18
19using namespace cbm::algo::ca; //TODO: remove
20
21namespace cbm::algo::ca
22{
23 enum class EDetectorID;
24}
25
26namespace cbm::ca::tools
27{
30
33 class MCPoint {
34 public:
36 MCPoint() = default;
37
39 ~MCPoint() = default;
40
42 MCPoint(const MCPoint&) = default;
43
45 MCPoint(MCPoint&&) = default;
46
48 MCPoint& operator=(const MCPoint&) = default;
49
51 MCPoint& operator=(MCPoint&&) = default;
52
53
57
58
59 // *********************
60 // ** Getters **
61 // *********************
62
64 double GetCharge() const { return fCharge; }
65
68
70 int GetEventId() const { return fLinkKey.fEvent; }
71
75 int GetExternalId() const { return fLinkKey.fIndex; }
76
78 int GetFileId() const { return fLinkKey.fFile; }
79
81 int GetId() const { return fId; }
82
84 int GetInvSpeed() const { return std::sqrt(1. + GetMass() * GetMass() / GetP() / GetP()) * phys::SpeedOfLightInv; }
85
87 int GetInvSpeedIn() const
88 {
89 return std::sqrt(1. + GetMass() * GetMass() / GetPIn() / GetPIn()) * phys::SpeedOfLightInv;
90 }
91
93 int GetInvSpeedOut() const
94 {
95 return std::sqrt(1. + GetMass() * GetMass() / GetPOut() / GetPOut()) * phys::SpeedOfLightInv;
96 }
97
99 const auto& GetHitIndexes() const { return fvHitIndexes; }
100
102 LinkKey GetLinkKey() const { return fLinkKey; }
103
105 double GetMass() const { return fMass; }
106
108 int GetMotherId() const { return fMotherId; }
109
111 double GetP() const { return std::sqrt(fMom[0] * fMom[0] + fMom[1] * fMom[1] + fMom[2] * fMom[2]); }
112
114 int GetPdgCode() const { return fPdgCode; }
115
117 double GetPhi() const { return std::atan2(-fMom[1], fMom[0]); }
118
120 double GetPhiIn() const { return std::atan2(-fMomIn[1], fMomIn[0]); }
121
123 double GetPhiOut() const { return std::atan2(-fMomOut[1], fMomOut[0]); }
124
126 double GetPIn() const { return std::sqrt(fMomIn[0] * fMomIn[0] + fMomIn[1] * fMomIn[1] + fMomIn[2] * fMomIn[2]); }
127
129 double GetPOut() const
130 {
131 return std::sqrt(fMomOut[0] * fMomOut[0] + fMomOut[1] * fMomOut[1] + fMomOut[2] * fMomOut[2]);
132 }
133
135 double GetPt() const { return sqrt(fMom[0] * fMom[0] + fMom[1] * fMom[1]); }
136
138 double GetPtIn() const
139 {
140 return sqrt(fMomIn[0] * fMomIn[0] + fMomIn[1] * fMomIn[1]);
141 ;
142 }
143
145 double GetPtOut() const
146 {
147 return sqrt(fMomOut[0] * fMomOut[0] + fMomOut[1] * fMomOut[1]);
148 ;
149 }
150
151
153 double GetPx() const { return fMom[0]; }
154
156 double GetPxIn() const { return fMomIn[0]; }
157
159 double GetPxOut() const { return fMomOut[0]; }
160
162 double GetPy() const { return fMom[1]; }
163
165 double GetPyIn() const { return fMomIn[1]; }
166
168 double GetPyOut() const { return fMomOut[1]; }
169
171 double GetPz() const { return fMom[2]; }
172
174 double GetPzIn() const { return fMomIn[2]; }
175
177 double GetPzOut() const { return fMomOut[2]; }
178
180 double GetQp() const { return fCharge / GetP(); }
181
183 double GetQpIn() const { return fCharge / GetPIn(); }
184
186 double GetQpOut() const { return fCharge / GetPOut(); }
187
189 int GetStationId() const { return fStationId; }
190
192 double GetTheta() const { return std::acos(GetPz() / GetP()); }
193
195 double GetThetaIn() const { return std::acos(GetPzIn() / GetPIn()); }
196
198 double GetThetaOut() const { return std::acos(GetPzOut() / GetPOut()); }
199
201 double GetTime() const { return fTime; }
202
204 int GetTrackId() const { return fTrackId; }
205
207 double GetTx() const { return fMom[0] / fMom[2]; }
208
210 double GetTxIn() const { return fMomIn[0] / fMomIn[2]; }
211
213 double GetTxOut() const { return fMomOut[0] / fMomOut[2]; }
214
216 double GetTy() const { return fMom[1] / fMom[2]; }
217
219 double GetTyIn() const { return fMomIn[1] / fMomIn[2]; }
220
222 double GetTyOut() const { return fMomOut[1] / fMomOut[2]; }
223
225 double GetX() const { return fPos[0]; }
226
228 double GetXIn() const { return fPosIn[0]; }
229
231 double GetXOut() const { return fPosOut[0]; }
232
234 double GetY() const { return fPos[1]; }
235
237 double GetYIn() const { return fPosIn[1]; }
238
240 double GetYOut() const { return fPosOut[1]; }
241
243 double GetZ() const { return fPos[2]; }
244
246 double GetZIn() const { return fPosIn[2]; }
247
249 double GetZOut() const { return fPosOut[2]; }
250
251 // *********************
252 // ** Setters **
253 // *********************
254
256 void SetCharge(double charge) { fCharge = charge; }
257
260
262 void SetEventId(int eventId) { fLinkKey.fEvent = eventId; }
263
265 void SetExternalId(int id) { fLinkKey.fIndex = id; }
266
268 void SetFileId(int fileId) { fLinkKey.fFile = fileId; }
269
271 void SetId(int id) { fId = id; }
272
274 void SetMass(double mass) { fMass = mass; }
275
277 void SetMotherId(int motherId) { fMotherId = motherId; }
278
280 void SetPdgCode(int pdg) { fPdgCode = pdg; }
281
283 void SetPx(double px) { fMom[0] = px; }
284
286 void SetPxIn(double px) { fMomIn[0] = px; }
287
289 void SetPxOut(double px) { fMomOut[0] = px; }
290
292 void SetPy(double py) { fMom[1] = py; }
293
295 void SetPyIn(double py) { fMomIn[1] = py; }
296
298 void SetPyOut(double py) { fMomOut[1] = py; }
299
301 void SetPz(double pz) { fMom[2] = pz; }
302
304 void SetPzIn(double pz) { fMomIn[2] = pz; }
305
307 void SetPzOut(double pz) { fMomOut[2] = pz; }
308
309
311 void SetStationId(int stationId) { fStationId = stationId; }
312
314 void SetTime(double time) { fTime = time; }
315
317 void SetTrackId(int trackId) { fTrackId = trackId; }
318
320 void SetX(double x) { fPos[0] = x; }
321
323 void SetXIn(double x) { fPosIn[0] = x; }
324
326 void SetXOut(double x) { fPosOut[0] = x; }
327
329 void SetY(double y) { fPos[1] = y; }
330
332 void SetYIn(double y) { fPosIn[1] = y; }
333
335 void SetYOut(double y) { fPosOut[1] = y; }
336
338 void SetZ(double z) { fPos[2] = z; }
339
341 void SetZIn(double z) { fPosIn[2] = z; }
342
344 void SetZOut(double z) { fPosOut[2] = z; }
345
352 std::string ToString(int verbose, bool printHeader = false) const;
353
354 // ****************************
355 // ** Data variables **
356 // ****************************
357
358 private:
371
375
377
384
386
387 // TODO: SZh 17.05.2023: Check, if there are more then one index can be added
388 ca::Vector<int> fvHitIndexes{"ca::tools::MCPoint::fvHitIndexes"};
389 };
390} // namespace cbm::ca::tools
391
392
393#endif // CaToolsMCPoint_h
Definitions for ca::tools namespace.
Data structure to represent a MC link in CA tracking MC module.
friend fvec sqrt(const fvec &a)
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 GetTyOut() const
Gets slope along x-axis at exit of station.
int GetExternalId() const
Gets MC external ID.
std::array< double, 3 > fMomOut
Momentum at exit of station [cm].
void SetPzOut(double pz)
Sets track momentum z component at exit of station [GeV/c].
void AddHitID(int iH)
Adds index of hits from the container of hits of event/TS.
void SetPz(double pz)
Sets track momentum z component at reference z of station [GeV/c].
void SetTrackId(int trackId)
Sets track ID in the CA internal track container (within event/TS)
void SetPdgCode(int pdg)
Sets PDG code.
void SetPxOut(double px)
Sets track momentum x component at exit of station [GeV/c].
double GetPz() const
Gets track momentum z component at reference z of station [GeV/c].
double GetTime() const
Gets time [ns].
std::array< double, 3 > fMom
Momentum at reference z of station [GeV/c].
double GetMass() const
Gets mass of the particle [GeV/c2].
int fStationId
Global index of active tracking station.
double GetPxOut() const
Gets track momentum x component at exit of station [GeV/c].
double GetPtIn() const
Gets track transverse momentum at entrance to station [GeV/c].
double GetPhi() const
Gets track azimuthal angle at reference z of station [rad].
double GetTxIn() const
Gets slope along x-axis at entrance to station.
void SetPxIn(double px)
Sets track momentum x component at entrance to station [GeV/c].
int GetEventId() const
Gets MC event ID.
void SetZIn(double z)
Sets z coordinate at entrance to station [cm].
std::array< double, 3 > fPosOut
Position at exit of station [cm].
double GetTx() const
Gets slope along x-axis at reference z of station.
void SetMotherId(int motherId)
Sets index of mother track in the internal CA data structures.
int GetInvSpeedIn() const
Gets inverse speed at entrance to station [ns/cm].
void SetX(double x)
Sets x coordinate at reference z of station [cm].
~MCPoint()=default
Destructor.
void SetZ(double z)
Sets z coordinate at reference z of station [cm].
int fPdgCode
Particle PDG code.
int GetStationId() const
Gets global ID of the active tracking station.
double GetTheta() const
Gets polar angle at reference z of station [rad].
double GetYOut() const
Gets y coordinate at exit of station [cm].
MCPoint(MCPoint &&)=default
Move constructor.
double fMass
Particle mass [GeV/c2].
double GetZIn() const
Gets z coordinate at entrance to station [cm].
MCPoint & operator=(const MCPoint &)=default
Copy assignment operator.
void SetXIn(double x)
Sets x coordinate at entrance to station [cm].
double GetQpIn() const
Gets track momentum absolute value at entrance to station [ec/GeV].
ca::EDetectorID fDetectorId
Detector ID of MC point.
double GetZ() const
Gets z coordinate at reference z of station [cm].
int GetFileId() const
Gets MC file ID.
void SetY(double y)
Sets y coordinate at reference z of station [cm].
void SetZOut(double z)
Sets z coordinate at exit of station [cm].
double fCharge
Particle charge [e].
double GetPy() const
Gets track momentum y component at reference z of station [GeV/c].
double GetY() const
Gets y coordinate at reference z of station [cm].
std::array< double, 3 > fPos
Position at reference z of station [cm].
double GetThetaIn() const
Gets polar angle at entrance to station [rad].
double GetPtOut() const
Gets track transverse momentum at exit of station [GeV/c].
double GetPxIn() const
Gets track momentum x component at entrance to station [GeV/c].
double GetYIn() const
Gets y coordinate at entrance to station [cm].
void SetPx(double px)
Sets track momentum x component at reference z of station [GeV/c].
int GetInvSpeedOut() const
Gets inverse speed at exit of station [ns/cm].
double GetX() const
Gets x coordinate at reference z of station [cm].
double GetTyIn() const
Gets slope along x-axis at entrance to station.
void SetYIn(double y)
Sets y coordinate at entrance to station [cm].
double GetThetaOut() const
Gets polar angle at exit of station [rad].
double GetPx() const
Gets track momentum x component at reference z of station [GeV/c].
double GetPzOut() const
Gets track momentum z component at exit of station [GeV/c].
void SetId(int id)
Sets index of this point in the CA internal structure.
int GetPdgCode() const
Gets PDG code of the particle.
void SetYOut(double y)
Sets x coordinate at exit of station [cm].
LinkKey fLinkKey
Link key of point.
int GetId() const
Gets index of this point in internal CA container.
double GetTy() const
Gets slope along x-axis at reference z of station.
double GetPzIn() const
Gets track momentum z component at entrance to station [GeV/c].
void SetPyIn(double py)
Sets track momentum y component at entrance to station [GeV/c].
LinkKey GetLinkKey() const
Gets link key.
int GetMotherId() const
Gets mother ID of the track.
void SetPyOut(double py)
Sets track momentum y component at exit of station [GeV/c].
double GetPyOut() const
Gets track momentum y component at exit of station [GeV/c].
std::string ToString(int verbose, bool printHeader=false) const
Prints content for a given verbosity level.
int GetInvSpeed() const
Gets inverse speed at reference z of station [ns/cm].
double GetPyIn() const
Gets track momentum y component at entrance to station [GeV/c].
void SetFileId(int fileId)
Sets index of MC file containing this point.
MCPoint(const MCPoint &)=default
Copy constructor.
double fTime
Point time [ns].
ca::EDetectorID GetDetectorId() const
Gets detector ID.
double GetZOut() const
Gets z coordinate at exit of station [cm].
double GetQp() const
Gets track charge over momentum at reference z of station [ec/GeV].
void SetCharge(double charge)
Sets particle charge [e].
void SetXOut(double x)
Sets x coordinate at exit of station [cm].
std::array< double, 3 > fMomIn
Momentum at entrance to station [GeV/c].
void SetDetectorId(ca::EDetectorID detId)
Sets detector ID.
double GetQpOut() const
Gets track momentum absolute value at exit of station [ec/GeV].
double GetXOut() const
Gets x coordinate at exit of station [cm].
MCPoint()=default
Default constructor.
const auto & GetHitIndexes() const
Gets container of matched hit indexes.
double GetPIn() const
Gets track momentum absolute value at entrance to station [GeV/c].
void SetStationId(int stationId)
Sets global index of active station.
int GetTrackId() const
Gets ID of track from the internal CA MC track container (within event/TS)
void SetTime(double time)
Sets time [ns].
int fId
Index of MC point in the external MC point container.
double GetPhiOut() const
Gets track azimuthal angle at exit of station [rad].
double GetPt() const
Gets track transverse momentum at reference z of station [GeV/c].
double GetTxOut() const
Gets slope along x-axis at exit of station.
void SetExternalId(int id)
Sets index of this point in external data structures.
double GetPhiIn() const
Gets track azimuthal angle at entrance to station [rad].
double GetPOut() const
Gets track momentum absolute value at exit of station [GeV/c].
void SetMass(double mass)
Sets particle mass [GeV/c2].
void SetEventId(int eventId)
Sets index of MC event containing this point.
int fTrackId
Index of associated MC track in CA internal track container within TS/event.
double GetP() const
Gets track momentum absolute value at reference z of station [GeV/c].
double GetXIn() const
Gets x coordinate at entrance to station [cm].
double GetCharge() const
Gets charge of the particle [e].
int fMotherId
Index of mother track in CA internal data structures (within event/TS)
MCPoint & operator=(MCPoint &&)=default
Move assignment operator.
std::array< double, 3 > fPosIn
Position at entrance to station [cm].
ca::Vector< int > fvHitIndexes
Indexes of hits, assigned to this point.
void SetPzIn(double pz)
Sets track momentum z component at entrance to station [GeV/c].
void SetPy(double py)
Sets track momentum y component at reference z of station [GeV/c].
Physics constants.
Definition CaDefs.h:72
constexpr fscal SpeedOfLightInv
Inverse speed of light [ns/cm].
Definition CaDefs.h:89
constexpr int Undef< int >
Definition CaDefs.h:113
constexpr double Undef< double >
Definition CaDefs.h:122
TODO: SZh 8.11.2022: add selection of parameterisation.
Definition CaBranch.h:14
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
Definition CbmDefs.h:176
int fEvent
Index of MC event.
int fFile
Index of MC file.
int fIndex
Index of MC point/track in external data structures.