2222
2323#include < TLorentzVector.h>
2424
25+ #include < array>
26+ #include < span>
2527#include < vector>
2628
2729namespace o2 ::upgrade
2830{
2931
30-
31-
3232class OTFParticle
3333{
3434 public:
@@ -48,6 +48,9 @@ class OTFParticle
4848 mVy = particle.vy ();
4949 mVz = particle.vz ();
5050 mIsFromMcParticles = true ;
51+ if (particle.hasMothers ()) {
52+ mIndicesMother = {particle.mothersIds ().front (), particle.mothersIds ().back ()};
53+ }
5154 }
5255
5356 // Setters
@@ -78,21 +81,25 @@ class OTFParticle
7881 bool isAlive () const { return mIsAlive ; }
7982 bool isPrimary () const { return mIsPrimary ; }
8083 bool isFromMcParticles () const { return mIsFromMcParticles ; }
81- float weight () const {
84+ float weight () const
85+ {
8286 static constexpr float Weight = 1 .f ;
83- return Weight;
87+ return Weight;
8488 }
85- uint8_t flags () const {
89+ uint8_t flags () const
90+ {
8691 static constexpr uint8_t Flags = 1 ;
87- return Flags;
92+ return Flags;
8893 }
89- float vt ()const {
94+ float vt () const
95+ {
9096 static constexpr float Vt = 1 .f ;
91- return Vt;
97+ return Vt;
9298 }
93- int statusCode ()const {
94- static constexpr int StatusCode = 1 ;
95- return StatusCode;
99+ int statusCode () const
100+ {
101+ static constexpr int StatusCode = 1 ;
102+ return StatusCode;
96103 }
97104 float vx () const { return mVx ; }
98105 float vy () const { return mVy ; }
@@ -113,7 +120,7 @@ class OTFParticle
113120 if ((p () - mPz ) < Tolerance) {
114121 return (mPz < 0 .0f ) ? -100 .0f : 100 .0f ;
115122 } else {
116- return 0 .5f * std::log ((p () + mPz ) / (p () - mPz ));
123+ return 0 .5f * std::log ((p () + mPz ) / (p () - mPz ));
117124 }
118125 }
119126
@@ -129,13 +136,14 @@ class OTFParticle
129136 }
130137
131138 bool hasDaughters () const { return (mIndicesDaughter [0 ] > 0 ); }
139+ bool hasMothers () const { return (mIndicesMother [0 ] > 0 ); }
132140 int getMotherIndexStart () const { return mIndicesMother [0 ]; }
133141 int getMotherIndexStop () const { return mIndicesMother [1 ]; }
134142 int getDaughterIndexStart () const { return mIndicesDaughter [0 ]; }
135143 int getDaughterIndexStop () const { return mIndicesDaughter [1 ]; }
136144 std::array<int , 2 > getMothers () const { return mIndicesMother ; }
137- std::span<const int > getMotherSpan () const { return std::span<const int >(mIndicesMother .data (), 2 ); }
138145 std::array<int , 2 > getDaughters () const { return mIndicesDaughter ; }
146+ std::span<const int > getMotherSpan () const { return hasMothers () ? std::span<const int >(mIndicesMother .data (), 2 ) : std::span<const int >(); }
139147
140148 bool hasNaN () const
141149 {
@@ -148,7 +156,6 @@ class OTFParticle
148156 return (mGlobalIndex != -1 );
149157 }
150158
151-
152159 private:
153160 int mPdgCode {}, mGlobalIndex {-1 };
154161 int mCollisionId {};
@@ -158,10 +165,9 @@ class OTFParticle
158165 bool mIsAlive {}, mIsFromMcParticles {false };
159166 bool mIsPrimary {};
160167
161- std::array<int , 2 > mIndicesMother {}, mIndicesDaughter {-1 , -1 };
168+ std::array<int , 2 > mIndicesMother {- 1 , - 1 }, mIndicesDaughter {-1 , -1 };
162169};
163170
164-
165171// / Function to convert a TLorentzVector into a perfect Track
166172// / \param charge particle charge (integer)
167173// / \param particle the particle to convert (TLorentzVector)
0 commit comments