@@ -40,21 +40,20 @@ class OTFParticle
4040 OTFParticle () = default ;
4141
4242 template <typename TParticle>
43- explicit OTFParticle (const TParticle& particle)
43+ explicit OTFParticle (const TParticle& particle) : mPdgCode(particle.pdgCode()),
44+ mGlobalIndex(particle.globalIndex()),
45+ mCollisionId(particle.mcCollisionId()),
46+ mVx(particle.vx()),
47+ mVy(particle.vy()),
48+ mVz(particle.vz()),
49+ mVt(particle.vt()),
50+ mPx(particle.px()),
51+ mPy(particle.py()),
52+ mPz(particle.pz()),
53+ mE(particle.e()),
54+ mStatusCode(particle.statusCode()),
55+ mFlag(particle.flags())
4456 {
45- mPdgCode = particle.pdgCode ();
46- mGlobalIndex = particle.globalIndex ();
47- mCollisionId = particle.mcCollisionId ();
48- mPx = particle.px ();
49- mPy = particle.py ();
50- mPz = particle.pz ();
51- mE = particle.e ();
52- mVx = particle.vx ();
53- mVy = particle.vy ();
54- mVz = particle.vz ();
55- mVt = particle.vt ();
56- mFlag = particle.flags ();
57- mStatusCode = particle.statusCode ();
5857 setBitOff (DecayerBits::ProducedByDecayer);
5958 if (particle.has_mothers ()) {
6059 mIndicesMother = {particle.mothersIds ().front (), particle.mothersIds ().back ()};
@@ -102,84 +101,82 @@ class OTFParticle
102101 }
103102
104103 // Getters
105- int pdgCode () const { return mPdgCode ; }
106- int globalIndex () const { return mGlobalIndex ; }
107- int collisionId () const { return mCollisionId ; }
108- bool isAlive () const { return checkBit (DecayerBits::IsAlive); }
109- bool isPrimary () const { return checkBit (DecayerBits::IsPrimary); }
110- bool isFromMcParticles () const { return !checkBit (DecayerBits::ProducedByDecayer); }
111- float weight () const
104+ [[nodiscard]] int pdgCode () const { return mPdgCode ; }
105+ [[nodiscard]] int globalIndex () const { return mGlobalIndex ; }
106+ [[nodiscard]] int collisionId () const { return mCollisionId ; }
107+ [[nodiscard]] bool isAlive () const { return checkBit (DecayerBits::IsAlive); }
108+ [[nodiscard]] bool isPrimary () const { return checkBit (DecayerBits::IsPrimary); }
109+ [[nodiscard]] bool isFromMcParticles () const { return !checkBit (DecayerBits::ProducedByDecayer); }
110+ [[nodiscard]] float weight () const
112111 {
113112 static constexpr float Weight = 1 .f ;
114113 return Weight;
115114 }
116- uint8_t flags () const { return mFlag ; }
117- int statusCode () const { return mStatusCode ; }
118- float vx () const { return mVx ; }
119- float vy () const { return mVy ; }
120- float vz () const { return mVz ; }
121- float vt () const { return mVt ; }
122- float px () const { return mPx ; }
123- float py () const { return mPy ; }
124- float pz () const { return mPz ; }
125- float e () const { return mE ; }
126- float radius () const { return std::hypot (mVx , mVy ); }
127- float decayRadius () const { return mDecayRadius ; }
128- float r () const { return radius (); }
129- float pt () const { return std::hypot (mPx , mPy ); }
130- float p () const { return std::hypot (mPx , mPy , mPz ); }
131- float phi () const { return o2::constants::math::PI + std::atan2 (-1 .0f * py (), -1 .0f * px ()); }
132- float eta () const
115+ [[nodiscard]] uint8_t flags () const { return mFlag ; }
116+ [[nodiscard]] int statusCode () const { return mStatusCode ; }
117+ [[nodiscard]] float vx () const { return mVx ; }
118+ [[nodiscard]] float vy () const { return mVy ; }
119+ [[nodiscard]] float vz () const { return mVz ; }
120+ [[nodiscard]] float vt () const { return mVt ; }
121+ [[nodiscard]] float px () const { return mPx ; }
122+ [[nodiscard]] float py () const { return mPy ; }
123+ [[nodiscard]] float pz () const { return mPz ; }
124+ [[nodiscard]] float e () const { return mE ; }
125+ [[nodiscard]] float radius () const { return std::hypot (mVx , mVy ); }
126+ [[nodiscard]] float decayRadius () const { return mDecayRadius ; }
127+ [[nodiscard]] float r () const { return radius (); }
128+ [[nodiscard]] float pt () const { return std::hypot (mPx , mPy ); }
129+ [[nodiscard]] float p () const { return std::hypot (mPx , mPy , mPz ); }
130+ [[nodiscard]] float phi () const { return o2::constants::math::PI + std::atan2 (-1 .0f * py (), -1 .0f * px ()); }
131+ [[nodiscard]] float eta () const
133132 {
134133 // Conditionally defined to avoid FPEs
135134 // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1959
136135 static constexpr float Tolerance = 1e-7f ;
137136 if ((p () - mPz ) < Tolerance) {
138137 return (mPz < 0 .0f ) ? -100 .0f : 100 .0f ;
139- } else {
140- return 0 .5f * std::log ((p () + mPz ) / (p () - mPz ));
141138 }
139+ return 0 .5f * std::log ((p () + mPz ) / (p () - mPz ));
142140 }
143- float y () const
141+ [[nodiscard]] float y () const
144142 {
145143 // Conditionally defined to avoid FPEs
146144 // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1980
147145 static constexpr float Tolerance = 1e-7f ;
148146 if ((e () - mPz ) < Tolerance) {
149147 return (mPz < 0 .0f ) ? -100 .0f : 100 .0f ;
150- } else {
151- return 0 .5f * std::log ((mE + mPz ) / (mE - mPz ));
152148 }
149+ return 0 .5f * std::log ((mE + mPz ) / (mE - mPz ));
153150 }
154- int getMotherIndexStart () const { return mIndicesMother [0 ]; }
155- int getMotherIndexStop () const { return mIndicesMother [1 ]; }
156- int getDaughterIndexStart () const { return mIndicesDaughter [0 ]; }
157- int getDaughterIndexStop () const { return mIndicesDaughter [1 ]; }
158- const std::array<int , 2 >& getMothers () const { return mIndicesMother ; }
159- const std::array<int , 2 >& getDaughters () const { return mIndicesDaughter ; }
160- std::span<const int > getMotherSpan () const { return hasMothers () ? std::span<const int >(mIndicesMother .data (), 2 ) : std::span<const int >(); }
151+ [[nodiscard]] int getMotherIndexStart () const { return mIndicesMother [0 ]; }
152+ [[nodiscard]] int getMotherIndexStop () const { return mIndicesMother [1 ]; }
153+ [[nodiscard]] int getDaughterIndexStart () const { return mIndicesDaughter [0 ]; }
154+ [[nodiscard]] int getDaughterIndexStop () const { return mIndicesDaughter [1 ]; }
155+ [[nodiscard]] const std::array<int , 2 >& getMothers () const { return mIndicesMother ; }
156+ [[nodiscard]] const std::array<int , 2 >& getDaughters () const { return mIndicesDaughter ; }
157+ [[nodiscard]] std::span<const int > getMotherSpan () const { return hasMothers () ? std::span<const int >(mIndicesMother .data (), 2 ) : std::span<const int >(); }
161158
162159 // Checks
163- bool hasDaughters () const { return (mIndicesDaughter [0 ] >= 0 ); }
164- bool hasMothers () const { return (mIndicesMother [0 ] >= 0 ); }
165- bool hasNaN () const
160+ [[nodiscard]] bool hasDaughters () const { return (mIndicesDaughter [0 ] >= 0 ); }
161+ [[nodiscard]] bool hasMothers () const { return (mIndicesMother [0 ] >= 0 ); }
162+ [[nodiscard]] bool hasNaN () const
166163 {
167164 return std::isnan (mPx ) || std::isnan (mPy ) || std::isnan (mPz ) || std::isnan (mE ) ||
168165 std::isnan (mVx ) || std::isnan (mVy ) || std::isnan (mVz );
169166 }
170- bool hasIndex () const
167+ [[nodiscard]] bool hasIndex () const
171168 {
172169 return (mGlobalIndex != -1 );
173170 }
174171
175172 // Bits
176- bool checkBit (DecayerBits bit) const { return mBits .test (static_cast <size_t >(bit)); }
173+ [[nodiscard]] bool checkBit (DecayerBits bit) const { return mBits .test (static_cast <size_t >(bit)); }
177174 void setBit (DecayerBits bit, bool value = true ) { mBits .set (static_cast <size_t >(bit), value); }
178175 void setBitOn (DecayerBits bit) { mBits .set (static_cast <size_t >(bit), true ); }
179176 void setBitOff (DecayerBits bit) { mBits .set (static_cast <size_t >(bit), false ); }
180177
181- const std::bitset<8 >& getBits () const { return mBits ; }
182- uint8_t getBitsValue () const { return static_cast <uint8_t >(mBits .to_ulong ()); }
178+ [[nodiscard]] const std::bitset<8 >& getBits () const { return mBits ; }
179+ [[nodiscard]] uint8_t getBitsValue () const { return static_cast <uint8_t >(mBits .to_ulong ()); }
183180 void setBits (std::bitset<8 > bits) { mBits = bits; }
184181
185182 private:
@@ -191,7 +188,7 @@ class OTFParticle
191188
192189 int mStatusCode {};
193190 uint8_t mFlag {};
194- std::bitset<8 > mBits {} ;
191+ std::bitset<8 > mBits ;
195192 std::array<int , 2 > mIndicesMother {-1 , -1 }, mIndicesDaughter {-1 , -1 };
196193};
197194
0 commit comments