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{
3031
32+ enum class DecayerBits { ProducedByDecayer = 0 ,
33+ IsPrimary,
34+ IsAlive };
35+
3136class OTFParticle
3237{
3338 public:
@@ -47,20 +52,29 @@ class OTFParticle
4752 mVy = particle.vy ();
4853 mVz = particle.vz ();
4954 mVt = particle.vt ();
55+ mFlag = particle.flags ();
56+ mStatusCode = particle.statusCode ();
5057 mIsFromMcParticles = true ;
5158 if (particle.has_mothers ()) {
5259 mIndicesMother = {particle.mothersIds ().front (), particle.mothersIds ().back ()};
5360 }
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+ }
5468 }
5569
5670 // Setters
57- void setIsAlive (const bool isAlive) { mIsAlive = isAlive; }
5871 void setIsPrimary (const bool isPrimary) { mIsPrimary = isPrimary; }
5972 void setCollisionId (const int collisionId) { mCollisionId = collisionId; }
6073 void setPDG (const int pdg) { mPdgCode = pdg; }
6174 void setIndicesMother (const int start, const int stop) { mIndicesMother = {start, stop}; }
6275 void setIndicesDaughter (const int start, const int stop) { mIndicesDaughter = {start, stop}; }
6376 void setProductionTime (const float vt) { mVt = vt; }
77+ void setFlags (uint8_t flag) { mFlag = flag; }
6478 void setVxVyVz (const float vx, const float vy, const float vz)
6579 {
6680 mVx = vx;
@@ -87,16 +101,8 @@ class OTFParticle
87101 static constexpr float Weight = 1 .f ;
88102 return Weight;
89103 }
90- uint8_t flags () const
91- {
92- static constexpr uint8_t Flags = 1 ;
93- return Flags; // todo
94- }
95- int statusCode () const
96- {
97- static constexpr int StatusCode = 1 ;
98- return StatusCode; // todo
99- }
104+ uint8_t flags () const { return mFlag ; }
105+ int statusCode () const { return mStatusCode ; }
100106 float vx () const { return mVx ; }
101107 float vy () const { return mVy ; }
102108 float vz () const { return mVz ; }
@@ -112,7 +118,8 @@ class OTFParticle
112118 float phi () const { return o2::constants::math::PI + std::atan2 (-1 .0f * py (), -1 .0f * px ()); }
113119 float eta () const
114120 {
115- // 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
116123 static constexpr float Tolerance = 1e-7f ;
117124 if ((p () - mPz ) < Tolerance) {
118125 return (mPz < 0 .0f ) ? -100 .0f : 100 .0f ;
@@ -122,7 +129,8 @@ class OTFParticle
122129 }
123130 float y () const
124131 {
125- // 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
126134 static constexpr float Tolerance = 1e-7f ;
127135 if ((e () - mPz ) < Tolerance) {
128136 return (mPz < 0 .0f ) ? -100 .0f : 100 .0f ;
@@ -151,13 +159,27 @@ class OTFParticle
151159 return (mGlobalIndex != -1 );
152160 }
153161
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+
154172 private:
155173 int mPdgCode {}, mGlobalIndex {-1 };
156174 int mCollisionId {};
157175 float mVx {}, mVy {}, mVz {}, mVt {};
158176 float mPx {}, mPy {}, mPz {}, mE {};
159177 bool mIsAlive {}, mIsFromMcParticles {false };
160178 bool mIsPrimary {};
179+
180+ int mStatusCode {};
181+ uint8_t mFlag {};
182+ std::bitset<8 > mBits {};
161183 std::array<int , 2 > mIndicesMother {-1 , -1 }, mIndicesDaughter {-1 , -1 };
162184};
163185
0 commit comments