@@ -52,6 +52,12 @@ namespace bdm {
5252 using Momentum_t = geo::Vector_t; // /< Type to represent momenta.
5353 using PDGID_t = int ; // /< Type of the particle ID.
5454
55+ using Flags_t = unsigned int ; // /< Type of flags mask.
56+
57+ // / Flag: is the particle valid at all?
58+ static constexpr Flags_t flValid = 1 << 0 ;
59+
60+
5561 // / 4-momentum
5662 using FourMomentum_t
5763 = ROOT::Math::LorentzVector<ROOT::Math::Cartesian3D<double >>;
@@ -71,13 +77,15 @@ namespace bdm {
7177 * @param time time of appearance
7278 * @param startPosition initial position [cm]
7379 * @param endPosition final position [cm]
80+ * @param flags flags (see `flags()`)
7481 *
7582 * The particle is initialized with the specified values.
7683 */
7784 SmearedMCParticle (
7885 PDGID_t id,
7986 Momentum_t momentum, double energy,
80- double time, Position_t startPosition, Position_t endPosition
87+ double time, Position_t startPosition, Position_t endPosition,
88+ Flags_t flags = defaultFlags()
8189 );
8290
8391
@@ -135,6 +143,32 @@ namespace bdm {
135143 // --- END access to data --------------------------------------------------
136144
137145
146+ // / @{
147+
148+
149+ // --- BEGIN access to flags -----------------------------------------------
150+ // / @name Access to flags
151+ // / @{
152+
153+ // / Returns the full set of flags.
154+ Flags_t flags () const { return fFlags ; }
155+
156+ // / Returns whether this particle is valid at all.
157+ bool isValid () const { return flags () & flValid; }
158+
159+ // / Returns whether this particle is not valid.
160+ bool isInvalid () const { return !isValid (); }
161+
162+ // / Returns the default set of flags for a reconstructed particle.
163+ static constexpr Flags_t defaultFlags () { return flValid; }
164+
165+ // / Returns a flag set for an invalid particle.
166+ static constexpr Flags_t invalidParticleFlags () { return 0U ; }
167+
168+ // / @}
169+ // --- END access to flags -------------------------------------------------
170+
171+
138172 // --- BEGIN printing data -------------------------------------------------
139173 // / @{
140174 // / @name Printing data
@@ -186,12 +220,15 @@ namespace bdm {
186220
187221 double fEnergy = 0.0 ; // /< Reconstructed energy of the particle [GeV].
188222 Momentum_t fMomentum ; // /< Reconstructed momentum of the particle [GeV/c].
189- double fTime = 0.0 ; // /< Reconstructed creation time [ns].
223+ double fTime = 0.0 ; // /< Reconstructed creation time [ns].
190224 Position_t fStartingVertex ; // /< Reconstructed starting position [cm].
191225 Position_t fEndVertex ; // /< Reconstructed ending position [cm].
192226
193227 PDGID_t fPDGID = InvalidParticleID; // /< Particle ID in PDG standard.
194228
229+ // / Flags associated to this particle.
230+ Flags_t fFlags = invalidParticleFlags();
231+
195232 }; // class SmearedMCParticle
196233
197234
@@ -223,11 +260,22 @@ void bdm::SmearedMCParticle::dump(
223260 if (verbosity >= 1 ) {
224261 out << firstIndent
225262 << " particle: " ;
263+ if (isInvalid ()) {
264+ out << " invalid" ;
265+ return ;
266+ }
226267 auto const * pPDGinfo = particleInfo ();
227268 if (pPDGinfo) out << pPDGinfo->GetName () << " (ID=" << particleId () << " )" ;
228269 else out << " ID " << particleId ();
229270 }
230- else out << firstIndent << " ID=" << particleId (); // <== verbosity: 0
271+ else {
272+ out << firstIndent;
273+ if (isInvalid ()) {
274+ out << " invalid" ;
275+ return ;
276+ }
277+ out << " ID=" << particleId (); // <== verbosity: 0
278+ }
231279
232280 if (verbosity >= 1 ) out << " starting" ;
233281 if (verbosity >= 3 ) out << " on " << time () << " ns" ;
@@ -237,7 +285,9 @@ void bdm::SmearedMCParticle::dump(
237285 // verbosity: 0
238286 out << " ; E=" << energy () << " GeV, cp=" << momentum () << " GeV/c" ;
239287
240- } // lar::example::CheatTrack::dump()
288+ // would print flags here, but there is none yet besides the "valid" one
289+
290+ } // bdm::SmearedMCParticle::dump()
241291
242292// ------------------------------------------------------------------------------
243293
0 commit comments