2222
2323#include < TLorentzVector.h>
2424
25- #include < cmath>
2625#include < vector>
2726
2827namespace o2 ::upgrade
2928{
3029
31- // / Struct to store mc info for the otf decayer
32- struct OTFParticle {
30+
31+
32+ class OTFParticle
33+ {
34+ public:
3335 OTFParticle () = default ;
3436
3537 template <typename TParticle>
3638 explicit OTFParticle (const TParticle& particle)
3739 {
3840 mPdgCode = particle.pdgCode ();
41+ mGlobalIndex = particle.globalIndex ();
42+ mCollisionId = particle.mcCollisionId ();
3943 mPx = particle.px ();
4044 mPy = particle.py ();
4145 mPz = particle.pz ();
4246 mE = particle.e ();
4347 mVx = particle.vx ();
4448 mVy = particle.vy ();
4549 mVz = particle.vz ();
50+ mIsFromMcParticles = true ;
4651 }
4752
4853 // Setters
49- void setIsAlive (bool isAlive) { mIsAlive = isAlive; }
50- void setPDG (int pdg) { mPdgCode = pdg; }
51- void setVxVyVz (float vx, float vy, float vz)
54+ void setIsAlive (const bool isAlive) { mIsAlive = isAlive; }
55+ void setIsPrimary (const bool isPrimary) { mIsPrimary = isPrimary; }
56+ void setCollisionId (const int collisionId) { mCollisionId = collisionId; }
57+ void setPDG (const int pdg) { mPdgCode = pdg; }
58+ void setIndicesMother (const int start, const int stop) { mIndicesMother = {start, stop}; }
59+ void setIndicesDaughter (const int start, const int stop) { mIndicesDaughter = {start, stop}; }
60+ void setVxVyVz (const float vx, const float vy, const float vz)
5261 {
5362 mVx = vx;
5463 mVy = vy;
5564 mVz = vz;
5665 }
57- void setPxPyPzE (float px, float py, float pz, float e)
66+ void setPxPyPzE (const float px, const float py, const float pz, const float e)
5867 {
5968 mPx = px;
6069 mPy = py;
@@ -64,27 +73,95 @@ struct OTFParticle {
6473
6574 // Getters
6675 int pdgCode () const { return mPdgCode ; }
76+ int globalIndex () const { return mGlobalIndex ; }
77+ int collisionId () const { return mCollisionId ; }
6778 bool isAlive () const { return mIsAlive ; }
79+ bool isPrimary () const { return mIsPrimary ; }
80+ bool isFromMcParticles () const { return mIsFromMcParticles ; }
81+ float weight () const {
82+ static constexpr float Weight = 1 .f ;
83+ return Weight;
84+ }
85+ uint8_t flags () const {
86+ static constexpr uint8_t Flags = 1 ;
87+ return Flags;
88+ }
89+ float vt ()const {
90+ static constexpr float Vt = 1 .f ;
91+ return Vt;
92+ }
93+ int statusCode ()const {
94+ static constexpr int StatusCode = 1 ;
95+ return StatusCode;
96+ }
6897 float vx () const { return mVx ; }
6998 float vy () const { return mVy ; }
7099 float vz () const { return mVz ; }
71100 float px () const { return mPx ; }
72101 float py () const { return mPy ; }
73102 float pz () const { return mPz ; }
74103 float e () const { return mE ; }
75- float r () const { return std::hypot (mVx , mVy ); }
76- float radius () const { return radius (); }
104+ float radius () const { return std::hypot (mVx , mVy ); }
105+ float r () const { return radius (); }
77106 float pt () const { return std::hypot (mPx , mPy ); }
78107 float p () const { return std::hypot (mPx , mPy , mPz ); }
108+ float phi () const { return o2::constants::math::PI + std::atan2 (-1 .0f * py (), -1 .0f * px ()); }
109+ float eta () const
110+ {
111+ // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1943
112+ static constexpr float Tolerance = 1e-7f ;
113+ if ((p () - mPz ) < Tolerance) {
114+ return (mPz < 0 .0f ) ? -100 .0f : 100 .0f ;
115+ } else {
116+ return 0 .5f * std::log ((p () + mPz ) / (p () - mPz ));
117+ }
118+ }
119+
120+ float y () const
121+ {
122+ // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1922
123+ static constexpr float Tolerance = 1e-7f ;
124+ if ((e () - mPz ) < Tolerance) {
125+ return (mPz < 0 .0f ) ? -100 .0f : 100 .0f ;
126+ } else {
127+ return 0 .5f * std::log ((mE + mPz ) / (mE - mPz ));
128+ }
129+ }
130+
131+ bool hasDaughters () const { return (mIndicesDaughter [0 ] > 0 ); }
132+ int getMotherIndexStart () const { return mIndicesMother [0 ]; }
133+ int getMotherIndexStop () const { return mIndicesMother [1 ]; }
134+ int getDaughterIndexStart () const { return mIndicesDaughter [0 ]; }
135+ int getDaughterIndexStop () const { return mIndicesDaughter [1 ]; }
136+ std::array<int , 2 > getMothers () const { return mIndicesMother ; }
137+ std::span<const int > getMotherSpan () const { return std::span<const int >(mIndicesMother .data (), 2 ); }
138+ std::array<int , 2 > getDaughters () const { return mIndicesDaughter ; }
139+
140+ bool hasNaN () const
141+ {
142+ return std::isnan (mPx ) || std::isnan (mPy ) || std::isnan (mPz ) || std::isnan (mE ) ||
143+ std::isnan (mVx ) || std::isnan (mVy ) || std::isnan (mVz );
144+ }
145+
146+ bool hasIndex () const
147+ {
148+ return (mGlobalIndex != -1 );
149+ }
150+
79151
80152 private:
81- int mPdgCode {};
153+ int mPdgCode {}, mGlobalIndex {-1 };
154+ int mCollisionId {};
82155 float mE {};
83156 float mVx {}, mVy {}, mVz {};
84157 float mPx {}, mPy {}, mPz {};
85- bool mIsAlive {};
158+ bool mIsAlive {}, mIsFromMcParticles {false };
159+ bool mIsPrimary {};
160+
161+ std::array<int , 2 > mIndicesMother {}, mIndicesDaughter {-1 , -1 };
86162};
87163
164+
88165// / Function to convert a TLorentzVector into a perfect Track
89166// / \param charge particle charge (integer)
90167// / \param particle the particle to convert (TLorentzVector)
0 commit comments