All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventInfo_t.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/details/EventInfo_t.h
3  * @brief Class hosting selected information about the event.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date May 15, 2020
6  * @see icaruscode/PMT/Trigger/Algorithms/details/EventInfo_t.cxx
7  */
8 
9 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHM_DETAILS_EVENTINFO_T_H
10 #define ICARUSCODE_PMT_TRIGGER_ALGORITHM_DETAILS_EVENTINFO_T_H
11 
12 
13 // LArSoft libraries
14 #include "lardataalg/DetectorInfo/DetectorTimingTypes.h" // simulation_time
15 #include "lardataalg/Utilities/quantities/energy.h" // gigaelectronvolt
16 #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Point_t
17 
18 // C/C++ standard libraries
19 #include <vector>
20 #include <ostream>
21 #include <cstddef> // std::size_t
22 
23 
24 //------------------------------------------------------------------------------
25 namespace icarus::trigger::details {
26 
27  struct EventInfo_t;
28 
29  std::ostream& operator<< (std::ostream& out, EventInfo_t const& info);
30 
31 } // namespace icarus::trigger::details
32 
33 
34 //------------------------------------------------------------------------------
35 /**
36  * @brief Selected information about the event.
37  *
38  * This is intended as a record for transferring relevant event information
39  * between object.
40  *
41  * The exact definition of the quantities is deferred to the user
42  * (e.g. when and how long the beam and pre-spill windows are, the definition
43  * of active volume, etc.).
44  */
46 
47  /// @name Local type aliases
48  /// @{
51  /// @}
52 
53  /// Constructor. As if nobody noticed.
54  EventInfo_t() { fInteractions.fill(0U); }
55 
56  // --- BEGIN Generation information ----------------------------------------
57  /**
58  * @name Generation information
59  *
60  * The information is available only if `hasGenerated()` returns `true`.
61  * Otherwise, the return value of all the members in this group is undefined.
62  */
63  /// @{
64 
65  /// Returns whether generator information is available.
66  bool hasGenerated() const { return fHasGenerated; }
67 
68  /// Returns the number of weak charged current interactions in the event.
69  unsigned int nWeakChargedCurrentInteractions() const
70  { return fInteractions[itWCC]; }
71 
72  /// Returns the number of weak neutral current interactions in the event.
73  unsigned int nWeakNeutralCurrentInteractions() const
74  { return fInteractions[itWNC]; }
75 
76  /// Returns the number of weak current interactions in the event.
77  unsigned int nWeakCurrentInteractions() const
78  {
79  return
81  }
82 
83  /// Returns whether the event is generated as a neutrino CC interaction.
84  bool isWeakChargedCurrent() const
85  { return nWeakChargedCurrentInteractions() > 0U; }
86 
87  /// Returns whether the event is generated as a neutrino NC interaction.
88  bool isWeakNeutralCurrent() const
89  { return nWeakNeutralCurrentInteractions() > 0U; }
90 
91  /// Returns whether the event is generated as a neutrino interaction.
92  bool isNeutrino() const
94 
95  /// Returns which neutrino flavor is present in an event
96  bool isNu_mu() const { return nu_mu; }
97  bool isNu_e() const { return nu_e; }
98 
99  /// Returns the neutrino PDG code
100  int NeutrinoPDG() const { return fNeutrinoPDG; }
101 
102  /// Returns the neutrino energy [GeV]
103  GeV NeutrinoEnergy() const { return fNeutrinoEnergy; }
104 
105  /// Returns the lepton energy [GeV]
106  GeV LeptonEnergy() const { return fLeptonEnergy; }
107 
108  /// Returns the interaction type
109  int InteractionType() const { return fInteractionType; }
110 
111  /// Returns the time of the first interaction, in simulation time scale [ns]
113 
114  /// Returns whether this type of event has a known vertex.
115  bool hasVertex() const { return !fVertices.empty(); }
116 
117  /// Returns the number of known interaction vertices.
118  unsigned int nVertices() const { return fVertices.size(); }
119 
120  /// Returns the list of a known interaction vertex.
121  std::vector<geo::Point_t> const& Vertices() const { return fVertices; }
122 
123  /// Returns whether there is an interaction within the active volume.
124  bool isInActiveVolume() const { return fInActiveVolume; }
125 
126  /// @}
127  // --- END Generation information ------------------------------------------
128 
129 
130  // --- BEGIN Deposited energy information ----------------------------------
131  /**
132  * @name Deposited energy information
133  *
134  * The information is available only if `hasDepEnergy()` returns `true`.
135  * Otherwise, the return value of all the members in this group is undefined.
136  */
137  /// @{
138 
139  /// Returns whether generator information is available.
140  bool hasDepEnergy() const { return fHasDepEnergy; }
141 
142  /// Returns the total energy deposited in the detector during the event [GeV]
143  GeV DepositedEnergy() const { return fEnergyDepTotal; }
144 
145  /// Returns the total energy deposited in the detector during beam [GeV]
147 
148  /// Returns the total energy deposited in the detector in the pre-spill window
149  /// [GeV]
151 
152  /// Returns the energy deposited in the active volume during the event [GeV]
154 
155  /// Returns the energy deposited in the active volume during the beam [GeV]
157  { return fEnergyDepSpillActive; }
158 
159  /// Returns the energy deposited in the active volume during the pre-spill
160  /// window [GeV]
162  { return fEnergyDepPreSpillActive; }
163 
164  /// @}
165  // --- END Deposited energy information ------------------------------------
166 
167 
168  // --- BEGIN Set interface -------------------------------------------------
169  /// @name Set interface
170  /// @{
171 
172  /// Marks this event as including _n_ more weak charged current interactions.
173  void AddWeakChargedCurrentInteractions(unsigned int n = 1U)
174  { setGen(); fInteractions[itWCC] += n; }
175 
176  /// Marks this event as including _n_ more weak neutral current interactions.
177  void AddWeakNeutralCurrentInteractions(unsigned int n = 1U)
178  { setGen(); fInteractions[itWNC] += n; }
179 
180  /// Marks the flavor of the neutrino in the first interaction.
181  void SetNu_mu(bool numu) { setGen(); nu_mu = numu; }
182  void SetNu_e(bool nue) { setGen(); nu_e = nue; }
183 
184  /// Marks the neutrino type of the first interaction in the event.
185  void SetNeutrinoPDG(int NU) { setGen(); fNeutrinoPDG = NU; }
186 
187  /// Sets the neutrino energy.
188  void SetNeutrinoEnergy(GeV eNu) { setGen(); fNeutrinoEnergy = eNu; }
189 
190  /// Sets the lepton energy.
191  void SetLeptonEnergy(GeV eL) { setGen(); fLeptonEnergy = eL; }
192 
193  /// Sets the interaction type
195 
196  /// Sets the time of the first interaction.
198  { setGen(); fInteractionTime = time; }
199 
200  /// Set whether the event has relevant activity in the active volume.
201  void SetInActiveVolume(bool active = true)
202  { setGen(); fInActiveVolume = active; }
203 
204  /// Adds a point to the list of interaction vertices in the event.
206  { setGen(); fVertices.push_back(vertex); }
207 
208  /// Inserts a point in the specified position of the list of interaction
209  /// vertices in the event.
210  void InsertVertex(geo::Point_t const& vertex, std::size_t beforeIndex)
211  { setGen(); fVertices.insert(next(begin(fVertices), beforeIndex), vertex); }
212 
213  /// Sets the total deposited energy of the event [GeV]
215 
216  /// Sets the energy of the event deposited during beam gate [GeV]
218 
219  /// Sets the energy of the event deposited during pre-spill window [GeV]
221 
222  /// Sets the total deposited energy of the event in active volume [GeV]
224  { setDep(); fEnergyDepActive = e; }
225 
226  /// Sets the energy of the event deposited during beam gate in active volume
227  /// [GeV]
229  { setDep(); fEnergyDepSpillActive = e; }
230 
231  /// Sets the energy of the event deposited during pre-spill window in active
232  /// volume [GeV]
235 
236  /// @}
237  // --- END Set interface ---------------------------------------------------
238 
239  /// Prints the content of the object into a stream.
240  void dump(std::ostream& out) const;
241 
242  private:
243 
244  // --- BEGIN interaction type constants ------------------------------------
245 
246  static constexpr std::size_t itWCC { 0U }; ///< Charged weak current.
247  static constexpr std::size_t itWNC { 1U }; ///< Neutral weak current.
248  static constexpr std::size_t NInteractionTypes { 2U };
249 
250  // --- END interaction type constants --------------------------------------
251 
252 
253  // --- BEGIN generator information -----------------------------------------
254  bool fHasGenerated = false; ///< Whether generation information is available.
255 
256  std::array<unsigned int, NInteractionTypes> fInteractions;
257 
258  int fNeutrinoPDG { 0 };
259  int fInteractionType { 0 };
260 
261  simulation_time fInteractionTime; ///< Time of the first interaction [ns]
262 
265  //GeV fNucleonEnergy { 0.0 };
266 
267  bool nu_mu { false };
268  bool nu_e { false };
269 
270  /// Whether the event has activity inside the active volume.
271  bool fInActiveVolume { false };
272 
273  std::vector<geo::Point_t> fVertices; ///< Position of all vertices.
274 
275  // --- END generator information -------------------------------------------
276 
277 
278  // --- BEGIN deposited energy information ----------------------------------
279  bool fHasDepEnergy = false; ///< Whether deposited energy info is available.
280 
281  GeV fEnergyDepTotal { 0.0 }; ///< Total deposited energy.
282  GeV fEnergyDepSpill { 0.0 }; ///< Energy deposited in spill.
283  GeV fEnergyDepPreSpill { 0.0 }; ///< Energy deposited in pre-spill.
284  GeV fEnergyDepActive { 0.0 }; ///< Energy deposited in active volume.
285  /// Energy deposited in active volume in spill.
287  /// Energy deposited in active volume in pre-spill window.
289 
290  // --- END deposited energy information ------------------------------------
291 
292 
293  /// Declares that this object has generator information.
294  void setGen() { fHasGenerated = true; }
295 
296  /// Declares that this object has deposited energy information.
297  void setDep() { fHasDepEnergy = true; }
298 
299 }; // struct icarus::trigger::details::EventInfo_t
300 
301 inline std::ostream& icarus::trigger::details::operator<<
302  (std::ostream& out, EventInfo_t const& info)
303  { info.dump(out); return out; }
304 
305 
306 //------------------------------------------------------------------------------
307 
308 
309 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHM_DETAILS_EVENTINFO_T_H
process_name vertex
Definition: cheaterreco.fcl:51
bool isInActiveVolume() const
Returns whether there is an interaction within the active volume.
Definition: EventInfo_t.h:124
bool fHasDepEnergy
Whether deposited energy info is available.
Definition: EventInfo_t.h:279
void SetNu_mu(bool numu)
Marks the flavor of the neutrino in the first interaction.
Definition: EventInfo_t.h:181
std::vector< geo::Point_t > fVertices
Position of all vertices.
Definition: EventInfo_t.h:273
GeV fEnergyDepPreSpillActive
Energy deposited in active volume in pre-spill window.
Definition: EventInfo_t.h:288
GeV NeutrinoEnergy() const
Returns the neutrino energy [GeV].
Definition: EventInfo_t.h:103
GeV fEnergyDepSpillActive
Energy deposited in active volume in spill.
Definition: EventInfo_t.h:286
void InsertVertex(geo::Point_t const &vertex, std::size_t beforeIndex)
Definition: EventInfo_t.h:210
std::array< unsigned int, NInteractionTypes > fInteractions
Definition: EventInfo_t.h:256
void SetDepositedEnergyInSpill(GeV e)
Sets the energy of the event deposited during beam gate [GeV].
Definition: EventInfo_t.h:217
void setDep()
Declares that this object has deposited energy information.
Definition: EventInfo_t.h:297
void setGen()
Declares that this object has generator information.
Definition: EventInfo_t.h:294
GeV LeptonEnergy() const
Returns the lepton energy [GeV].
Definition: EventInfo_t.h:106
bool hasDepEnergy() const
Returns whether generator information is available.
Definition: EventInfo_t.h:140
bool fInActiveVolume
Whether the event has activity inside the active volume.
Definition: EventInfo_t.h:271
bool hasVertex() const
Returns whether this type of event has a known vertex.
Definition: EventInfo_t.h:115
void SetInteractionTime(simulation_time time)
Sets the time of the first interaction.
Definition: EventInfo_t.h:197
EventInfo_t()
Constructor. As if nobody noticed.
Definition: EventInfo_t.h:54
void SetDepositedEnergyInPreSpillInActiveVolume(GeV e)
Definition: EventInfo_t.h:233
void SetDepositedEnergyInPreSpill(GeV e)
Sets the energy of the event deposited during pre-spill window [GeV].
Definition: EventInfo_t.h:220
Information about the event.
void AddVertex(geo::Point_t const &vertex)
Adds a point to the list of interaction vertices in the event.
Definition: EventInfo_t.h:205
bool isWeakChargedCurrent() const
Returns whether the event is generated as a neutrino CC interaction.
Definition: EventInfo_t.h:84
void AddWeakNeutralCurrentInteractions(unsigned int n=1U)
Marks this event as including n more weak neutral current interactions.
Definition: EventInfo_t.h:177
GeV fEnergyDepTotal
Total deposited energy.
Definition: EventInfo_t.h:281
void SetLeptonEnergy(GeV eL)
Sets the lepton energy.
Definition: EventInfo_t.h:191
Definitions of geometry vector data types.
timescale_traits< SimulationTimeCategory >::time_point_t simulation_time
A point in time on the simulation time scale.
A value measured in the specified unit.
Definition: quantities.h:566
unsigned int nWeakChargedCurrentInteractions() const
Returns the number of weak charged current interactions in the event.
Definition: EventInfo_t.h:69
static constexpr std::size_t itWNC
Neutral weak current.
Definition: EventInfo_t.h:247
simulation_time fInteractionTime
Time of the first interaction [ns].
Definition: EventInfo_t.h:261
void SetInActiveVolume(bool active=true)
Set whether the event has relevant activity in the active volume.
Definition: EventInfo_t.h:201
void dump(std::ostream &out) const
Prints the content of the object into a stream.
Definition: EventInfo_t.cxx:21
void SetNeutrinoEnergy(GeV eNu)
Sets the neutrino energy.
Definition: EventInfo_t.h:188
bool isNu_mu() const
Returns which neutrino flavor is present in an event.
Definition: EventInfo_t.h:96
GeV DepositedEnergyInSpill() const
Returns the total energy deposited in the detector during beam [GeV].
Definition: EventInfo_t.h:146
gigaelectronvolt_as<> gigaelectronvolt
Type of energy stored in gigaelectronvolt, in double precision.
Definition: energy.h:129
simulation_time InteractionTime() const
Returns the time of the first interaction, in simulation time scale [ns].
Definition: EventInfo_t.h:112
static constexpr std::size_t NInteractionTypes
Definition: EventInfo_t.h:248
detinfo::timescales::simulation_time simulation_time
Definition: EventInfo_t.h:50
GeV DepositedEnergyInSpillInActiveVolume() const
Returns the energy deposited in the active volume during the beam [GeV].
Definition: EventInfo_t.h:156
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
bool hasGenerated() const
Returns whether generator information is available.
Definition: EventInfo_t.h:66
GeV DepositedEnergyInPreSpillInActiveVolume() const
Definition: EventInfo_t.h:161
bool isWeakNeutralCurrent() const
Returns whether the event is generated as a neutrino NC interaction.
Definition: EventInfo_t.h:88
void SetNeutrinoPDG(int NU)
Marks the neutrino type of the first interaction in the event.
Definition: EventInfo_t.h:185
Dimensioned variables representing energy.
bool isNeutrino() const
Returns whether the event is generated as a neutrino interaction.
Definition: EventInfo_t.h:92
unsigned int nVertices() const
Returns the number of known interaction vertices.
Definition: EventInfo_t.h:118
std::ostream & operator<<(std::ostream &out, EventInfo_t const &info)
Definition: EventInfo_t.h:302
void SetDepositedEnergy(GeV e)
Sets the total deposited energy of the event [GeV].
Definition: EventInfo_t.h:214
Data types for detinfo::DetectorTimings.
GeV DepositedEnergy() const
Returns the total energy deposited in the detector during the event [GeV].
Definition: EventInfo_t.h:143
do i e
GeV DepositedEnergyInActiveVolume() const
Returns the energy deposited in the active volume during the event [GeV].
Definition: EventInfo_t.h:153
static constexpr std::size_t itWCC
Charged weak current.
Definition: EventInfo_t.h:246
GeV fEnergyDepSpill
Energy deposited in spill.
Definition: EventInfo_t.h:282
Selected information about the event.
Definition: EventInfo_t.h:45
unsigned int nWeakNeutralCurrentInteractions() const
Returns the number of weak neutral current interactions in the event.
Definition: EventInfo_t.h:73
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
void SetInteractionType(int type)
Sets the interaction type.
Definition: EventInfo_t.h:194
void AddWeakChargedCurrentInteractions(unsigned int n=1U)
Marks this event as including n more weak charged current interactions.
Definition: EventInfo_t.h:173
void SetDepositedEnergyInActiveVolume(GeV e)
Sets the total deposited energy of the event in active volume [GeV].
Definition: EventInfo_t.h:223
int NeutrinoPDG() const
Returns the neutrino PDG code.
Definition: EventInfo_t.h:100
bool fHasGenerated
Whether generation information is available.
Definition: EventInfo_t.h:254
std::vector< geo::Point_t > const & Vertices() const
Returns the list of a known interaction vertex.
Definition: EventInfo_t.h:121
GeV fEnergyDepPreSpill
Energy deposited in pre-spill.
Definition: EventInfo_t.h:283
unsigned int nWeakCurrentInteractions() const
Returns the number of weak current interactions in the event.
Definition: EventInfo_t.h:77
int InteractionType() const
Returns the interaction type.
Definition: EventInfo_t.h:109