GeneratedParticleInfo.h
Go to the documentation of this file.
1 /**
2  * @file garsoft/Utilities/GeneratedParticleInfo.h
3  * @brief Contains data associated to particles from detector simulation.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date January 10, 2018
6  *
7  */
8 
9 #ifndef GARSOFT_SIMULATION_GENERATEDPARTICLEINFO_H
10 #define GARSOFT_SIMULATION_GENERATEDPARTICLEINFO_H
11 
12 #include "nusimdata/SimulationBase/simb.h" // sim::GeneratedParticleIndex_t, ...
13 
14 
15 namespace sim {
16 
17  /**
18  * @brief Contains information about a generated particle.
19  *
20  * This information is designed to be added as metadata to an association
21  * between a `simb::MCParticle` produced by the simulation of particle
22  * propagation through the detector (e.g. `GArG4`) with the generator truth
23  * record that particle derives from:
24  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
25  * art::Assns<simb::MCParticle, simb::MCTruth, sim::GeneratedParticleInfo>
26  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27  *
28  * The associated `simb::MCParticle` is expected to be the generated particle
29  * of the generator truth record, as processed by the simulation.
30  * The provided information is currently:
31  * * index of the generated particle within the generator record; the particle
32  * itself can be obtained as:
33  * @code{.cpp}
34  * mctruthPtr->GetParticle(genParticleInfo.generatedParticleIndex());
35  * @endcode
36  *
37  */
39 
40  public:
41 
42  //--- BEGIN Generated particle index ---------------------------------------
43  /// @{
44  /// @name Generated particle index
45 
46  /// Type of particle index in the generator truth record (`simb::MCTruth`).
48 
49  /// Constant representing the absence of generator truth information.
52 
53  /**
54  * @brief Returns the generated particle index.
55  * @return generated particle index (`NoGeneratedParticleIndex` if none)
56  */
58  { return fGeneratedParticleIndex; }
59 
60  /// Returns whether the specified one is an acceptable generator index.
63 
64  /// @}
65  //--- END Generated particle index -----------------------------------------
66 
67 
68  //--- BEGIN Constructors ---------------------------------------------------
69  /// Default constructor (for ROOT I/O only).
70  GeneratedParticleInfo() = default;
71 
72  /**
73  * @brief Constructor: assigns all the values.
74  * @param index generated particle index (`NoGeneratedParticleIndex` if none)
75  */
78  {}
79  //--- END Constructors ---------------------------------------------------
80 
81 
82  private:
83 
84  /// Index of the generated particle in its `simb::MCTruth` record.
86 
87  }; // class GeneratedParticleInfo
88 
89 
90 
91 } // namespace sim
92 
93 #endif // GARSOFT_SIMULATION_GENERATEDPARTICLEINFO_H
GeneratedParticleInfo()=default
Default constructor (for ROOT I/O only).
simb::GeneratedParticleIndex_t GeneratedParticleIndex_t
Type of particle index in the generator truth record (simb::MCTruth).
bool hasGeneratedParticleIndex() const
Returns whether the specified one is an acceptable generator index.
GeneratedParticleInfo(GeneratedParticleIndex_t index)
Constructor: assigns all the values.
constexpr GeneratedParticleIndex_t NoGeneratedParticleIndex
Constant representing the absence of generator truth information.
Definition: simb.h:34
static constexpr GeneratedParticleIndex_t NoGeneratedParticleIndex
Constant representing the absence of generator truth information.
bool isGeneratedParticleIndex(GeneratedParticleIndex_t index)
Returns whether the specified one is an acceptable generator index.
Definition: simb.h:37
Code to link reconstructed objects back to the MC truth information.
Contains information about a generated particle.
GeneratedParticleIndex_t generatedParticleIndex() const
Returns the generated particle index.
GeneratedParticleIndex_t fGeneratedParticleIndex
Index of the generated particle in its simb::MCTruth record.
Common type definitions for data products (and a bit beyond).
std::size_t GeneratedParticleIndex_t
Type of particle index in the generator truth record (simb::MCTruth).
Definition: simb.h:30