2121#include < CommonConstants/MathConstants.h>
2222
2323#include < array>
24+ #include < bitset>
2425#include < cmath>
2526#include < cstdint>
2627#include < span>
2728
2829namespace o2 ::upgrade
2930{
30- static constexpr uint8_t ProducedByDecayer = 0xFF ;
31+
32+ enum class DecayerBits { ProducedByDecayer = 0 ,
33+ IsPrimary,
34+ IsAlive };
3135
3236class OTFParticle
3337{
@@ -48,20 +52,29 @@ class OTFParticle
4852 mVy = particle.vy ();
4953 mVz = particle.vz ();
5054 mVt = particle.vt ();
55+ mFlag = particle.flags ();
56+ mStatusCode = particle.statusCode ();
5157 mIsFromMcParticles = true ;
5258 if (particle.has_mothers ()) {
5359 mIndicesMother = {particle.mothersIds ().front (), particle.mothersIds ().back ()};
5460 }
61+ if constexpr ( requires { particle.decayerBits (); } ) {
62+ mBits = particle.decayerBits ();
63+ } else {
64+ // If we are here, we created particle in the standard workflow -- without secondaries
65+ // Then we should set all particles as physical primaries accordingly
66+ setBitOn (DecayerBits::IsPrimary);
67+ }
5568 }
5669
5770 // Setters
58- void setIsAlive (const bool isAlive) { mIsAlive = isAlive; }
5971 void setIsPrimary (const bool isPrimary) { mIsPrimary = isPrimary; }
6072 void setCollisionId (const int collisionId) { mCollisionId = collisionId; }
6173 void setPDG (const int pdg) { mPdgCode = pdg; }
6274 void setIndicesMother (const int start, const int stop) { mIndicesMother = {start, stop}; }
6375 void setIndicesDaughter (const int start, const int stop) { mIndicesDaughter = {start, stop}; }
6476 void setProductionTime (const float vt) { mVt = vt; }
77+ void setFlags (uint8_t flag) { mFlag = flag; }
6578 void setVxVyVz (const float vx, const float vy, const float vz)
6679 {
6780 mVx = vx;
@@ -88,16 +101,8 @@ class OTFParticle
88101 static constexpr float Weight = 1 .f ;
89102 return Weight;
90103 }
91- uint8_t flags () const
92- {
93- static constexpr uint8_t Flags = 1 ;
94- return Flags; // todo
95- }
96- int statusCode () const
97- {
98- static constexpr int StatusCode = 1 ;
99- return StatusCode; // todo
100- }
104+ uint8_t flags () const { return mFlag ; }
105+ int statusCode () const { return mStatusCode ; }
101106 float vx () const { return mVx ; }
102107 float vy () const { return mVy ; }
103108 float vz () const { return mVz ; }
@@ -113,7 +118,8 @@ class OTFParticle
113118 float phi () const { return o2::constants::math::PI + std::atan2 (-1 .0f * py (), -1 .0f * px ()); }
114119 float eta () const
115120 {
116- // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1943
121+ // Conditionally defined to avoid FPEs
122+ // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1959
117123 static constexpr float Tolerance = 1e-7f ;
118124 if ((p () - mPz ) < Tolerance) {
119125 return (mPz < 0 .0f ) ? -100 .0f : 100 .0f ;
@@ -123,7 +129,8 @@ class OTFParticle
123129 }
124130 float y () const
125131 {
126- // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1922
132+ // Conditionally defined to avoid FPEs
133+ // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1980
127134 static constexpr float Tolerance = 1e-7f ;
128135 if ((e () - mPz ) < Tolerance) {
129136 return (mPz < 0 .0f ) ? -100 .0f : 100 .0f ;
@@ -152,13 +159,27 @@ class OTFParticle
152159 return (mGlobalIndex != -1 );
153160 }
154161
162+ // Bits
163+ bool checkBit (DecayerBits bit) const { return mBits .test (static_cast <size_t >(bit)); }
164+ void setBit (DecayerBits bit, bool value = true ) { mBits .set (static_cast <size_t >(bit), value); }
165+ void setBitOn (DecayerBits bit) { mBits .set (static_cast <size_t >(bit), true ); }
166+ void setBitOff (DecayerBits bit) { mBits .set (static_cast <size_t >(bit), false ); }
167+
168+ std::bitset<8 > getBits () const { return mBits ; }
169+ uint8_t getBitsValue () const { return static_cast <uint8_t >(mBits .to_ulong ()); }
170+ void setBits (std::bitset<8 > bits) { mBits = bits; }
171+
155172 private:
156173 int mPdgCode {}, mGlobalIndex {-1 };
157174 int mCollisionId {};
158175 float mVx {}, mVy {}, mVz {}, mVt {};
159176 float mPx {}, mPy {}, mPz {}, mE {};
160177 bool mIsAlive {}, mIsFromMcParticles {false };
161178 bool mIsPrimary {};
179+
180+ int mStatusCode {};
181+ uint8_t mFlag {};
182+ std::bitset<8 > mBits {};
162183 std::array<int , 2 > mIndicesMother {-1 , -1 }, mIndicesDaughter {-1 , -1 };
163184};
164185
0 commit comments