All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeneratedParticleInfo.h
Go to the documentation of this file.
1 /**
2  * @file lardataobj/Simulation/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 LARDATAOBJ_SIMULATION_GENERATEDPARTICLEINFO_H
10 #define LARDATAOBJ_SIMULATION_GENERATEDPARTICLEINFO_H
11 
12 // LArSoft libraries
13 #include "nusimdata/SimulationBase/simb.h" // sim::GeneratedParticleIndex_t, ...
14 
15 
16 namespace sim {
17 
18  /**
19  * @brief Contains information about a generated particle.
20  *
21  * This information is designed to be added as metadata to an association
22  * between a `simb::MCParticle` produced by the simulation of particle
23  * propagation through the detector (e.g. `LArG4`) with the generator truth
24  * record that particle derives from:
25  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
26  * art::Assns<simb::MCParticle, simb::MCTruth, sim::GeneratedParticleInfo>
27  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28  *
29  * The associated `simb::MCParticle` is expected to be the generated particle
30  * of the generator truth record, as processed by the simulation.
31  * The provided information is currently:
32  * * index of the generated particle within the generator record; the particle
33  * itself can be obtained as:
34  * @code{.cpp}
35  * mctruthPtr->GetParticle(genParticleInfo.generatedParticleIndex());
36  * @endcode
37  *
38  */
40 
41  public:
42 
43  //--- BEGIN Generated particle index ---------------------------------------
44  /// @{
45  /// @name Generated particle index
46 
47  /// Type of particle index in the generator truth record (`simb::MCTruth`).
48  using GeneratedParticleIndex_t = simb::GeneratedParticleIndex_t;
49 
50  /// Constant representing the absence of generator truth information.
52  = simb::NoGeneratedParticleIndex;
53 
54  /**
55  * @brief Returns the generated particle index.
56  * @return generated particle index (`NoGeneratedParticleIndex` if none)
57  */
59  { return fGeneratedParticleIndex; }
60 
61  /// Returns whether the specified one is an acceptable generator index.
63  { return simb::isGeneratedParticleIndex(fGeneratedParticleIndex); }
64 
65  /// @}
66  //--- END Generated particle index -----------------------------------------
67 
68 
69  //--- BEGIN Constructors ---------------------------------------------------
70  /// Default constructor (for ROOT I/O only).
71  GeneratedParticleInfo() = default;
72 
73  /**
74  * @brief Constructor: assigns all the values.
75  * @param index generated particle index (`NoGeneratedParticleIndex` if none)
76  */
79  {}
80  //--- END Constructors ---------------------------------------------------
81 
82 
83  private:
84 
85  /// Index of the generated particle in its `simb::MCTruth` record.
87 
88  }; // class GeneratedParticleInfo
89 
90 
91 
92 } // namespace sim
93 
94 #endif // LARDATAOBJ_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).
static constexpr GeneratedParticleIndex_t NoGeneratedParticleIndex
Constant representing the absence of generator truth information.
bool hasGeneratedParticleIndex() const
Returns whether the specified one is an acceptable generator index.
GeneratedParticleInfo(GeneratedParticleIndex_t index)
Constructor: assigns all the values.
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.