Jpp  17.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Evt.hh
Go to the documentation of this file.
1 #ifndef EVT_HH_INCLUDED
2 #define EVT_HH_INCLUDED
3 
9 
10 #include "TTimeStamp.h"
11 
12 #include <uuid/uuid.h>
13 #include <vector>
14 
15 /**
16  * The Evt class respresent a Monte Carlo (MC) event as well as an offline event.\n
17  * Some data from the online (DAQ) event are copied.
18  */
19 
20 struct Evt: public AAObject
21 {
22  int id; ///< offline event identifier
23  int det_id; ///< detector identifier from DAQ
24  int mc_id; ///< identifier of the MC event (as found in ascii or antcc file).
25 
26  int run_id; ///< DAQ run identifier
27  int mc_run_id; ///< MC run identifier
28 
29  int frame_index; ///< from the raw data
30  ULong64_t trigger_mask; ///< trigger mask from raw data (i.e. the trigger bits)
31  ULong64_t trigger_counter; ///< trigger counter
32  unsigned int overlays; ///< number of overlaying triggered events
33  TTimeStamp t; ///< UTC time of the timeslice, or the event_time for MC. (default: 01 Jan 1970 00:00:00)
34 
35  uuid_t header_uuid; ///< UUID of header containing the event-weight information
36 
37  //hits and tracks
38  std::vector<Hit> hits; ///< list of hits
39  std::vector<Trk> trks; ///< list of reconstructed tracks (can be several because of prefits,showers, etc).
40 
41  //Monte carlo
42  std::vector<double> w; ///< MC: Weights w[0]=w1, w[1]=w2, w[2]=w3 (see e.g. <a href="https://simulation.pages.km3net.de/taglist/taglist.pdf">Tag list</a> or km3net-dataformat/definitions)
43  std::vector<double> w2list; ///< MC: factors that make up w[1]=w2 (see e.g. <a href="https://simulation.pages.km3net.de/taglist/taglist.pdf">Tag list</a> or km3net-dataformat/definitions)
44  std::vector<double> w3list; ///< MC: atmospheric flux information
45 
46  TTimeStamp mc_event_time; ///< MC: true generation time (UTC) of the event, (default: 01 Jan 1970 00:00:00)
47  double mc_t; ///< MC: time where the mc-event was put in the timeslice, since start of run (offset+frameidx*timeslice_duration)
48  std::vector<Hit> mc_hits; ///< MC: list of MC truth hits
49  std::vector<Trk> mc_trks; ///< MC: list of MC truth tracks
50 
51  // --- place to store user info ---
52  TString comment; ///< user can use this as he/she likes
53  int index; ///< user can use this as he/she likes
54  int flags; ///< user can use this as he/she likes
55 
56 
57  /**
58  * Default constructor.
59  */
60  Evt() :
61  id(0), det_id(0), mc_id(0), run_id(0), mc_run_id(0), frame_index(0),
63  overlays(0), t(0), mc_event_time(0), mc_t(0), index(0), flags(0)
64  {
65  uuid_clear(this->header_uuid);
66  }
67 
68 
69  /**
70  * Print event.
71  *
72  * \param out output stream
73  */
74  void print(std::ostream& out = std::cout) const
75  {
76  out << "Evt: id=" << id <<
77  " run_id=" << run_id <<
78  " #hits=" << hits.size() <<
79  " #mc_hits=" << mc_hits.size() <<
80  " #trks=" << trks.size() <<
81  " #mc_trks=" << mc_trks.size() << std::endl;
82  }
83 
84 
85  /**
86  * Reset event.
87  */
88  void clear()
89  {
90  *this = Evt();
91  }
92 
93 
94  /**
95  * Clear the hit vectors and all the references to hits in the tracks
96  */
97  void clear_hits()
98  {
99  hits.clear();
100  mc_hits.clear();
101  for (auto& t : trks ) t.hit_ids.clear();
102  for (auto& t : mc_trks ) t.hit_ids.clear();
103  }
104 
105 
106  /**
107  * Return a vector with const pointers to the tracks that are 'primary'.\n
108  * Here, primary means the tracks have no parents.
109  *
110  * This method only works if MC parent-child relations are availabe.
111  *
112  * \return list of pointers to primary tracks
113  */
115  {
117  for (auto& t : mc_trks )
118  {
119  if ( t.is_primary() ) r.push_back(&t);
120  }
121  return r;
122  }
123 
124 
125  /**
126  * Return a vector of pointers to tracks that are 'primary'.\n
127  * Here, primary means the tracks have no parents.
128  *
129  * \return list of pointers to primary tracks
130  */
132  {
134  for (auto& t : mc_trks )
135  {
136  if ( t.is_primary() ) r.push_back(&t);
137  }
138  return r;
139  }
140 
141 
142  /**
143  * Get a const pointer to the (first) neutrino from the MC track list.
144  *
145  * \return pointer to neutrino (nullptr if no neutrino is in the list)
146  */
147  const Trk* neutrino() const
148  {
149  for (auto& t : mc_trks )
150  {
151  if ( t.is_neutrino() ) return &t;
152  }
153  return nullptr;
154  }
155 
156  /**
157  * Get a pointer to the (first) neutrino from the MC track list.
158  *
159  * \return const pointer to neutrino (nullptr if no neutrino is in the list)
160  */
161 
163  {
164  // see Effective C++, Scott Meyers, ISBN-13: 9780321334879.
165  return const_cast<Trk *>(static_cast<const Evt &>(*this).neutrino() );
166  }
167 
168 
169  /**
170  * Get a const pointer to primary neutrino from the MC track list.
171  *
172  * Only works if MC parent-child relations are availabe.
173  *
174  * \return const pointer to primary neutrino (may be nullptr)
175  */
176  const Trk* primary_neutrino() const
177  {
178  for ( auto& t : mc_trks )
179  {
180  if ( t.is_neutrino() and t.is_primary() ) return &t;
181  }
182  return nullptr;
183  }
184 
185  /**
186  * Get a pointer to primary neutrino from the MC track list.
187  *
188  * Only works if MC parent-child relations are availabe.
189  *
190  * \return pointer to primary neutrino
191  */
193  {
194  return const_cast<Trk *>(static_cast<const Evt &>(*this).primary_neutrino() );
195  }
196 
197 
198  /**
199  * Get a const pointer to the first leading lepton from the MC track list.
200  * Here, leading means the lepton that has a neutrino as mother.
201  *
202  * Only works if MC parent-child relations are availabe.
203  *
204  * \return pointer to leadig lepton (may be nullptr in case not found)
205  */
206  const Trk* leading_lepton() const
207  {
208  const Trk* nu = primary_neutrino();
209  if (!nu) return nullptr;
210 
211  for (auto& t : mc_trks )
212  {
213  if ( t.is_lepton() &&
214  t.mother_id == nu->id &&
215  !t.is_orphan() ) return &t;
216  }
217  return nullptr;
218  }
219 
220  /**
221  * Get a pointer to leading lepton from the MC track list.
222  * Here, leading means the lepton that has a neutrino as mother.
223  *
224  * Only works if MC parent-child relations are availabe.
225  *
226  * \return pointer to leadig lepton (may be nullptr in case not found)
227  */
229  {
230  return const_cast<Trk *>(static_cast<const Evt &>(*this).leading_lepton() );
231  }
232 
233  /**
234  * Get a const pointer to the (first) parent of the track 'child'.\n
235  * This method return nullptr if no parent is found.
236  *
237  * \param child child particle
238  * \return pointer to parent
239  */
240  const Trk * get_parent_of( const Trk & child ) const
241  {
242  for (auto& t : mc_trks )
243  {
244  if (child.mother_id == t.id ) return &t;
245  }
246  return nullptr;
247  }
248 
249 
250  /**
251  * Get a pointer ot the (first) parent of the track 'child'.\n
252  * This method return nullptr if no parent is found.
253  *
254  * \param child child particle
255  * \return pointer to parent
256  */
257 
258  Trk* get_parent_of( const Trk & child )
259  {
260  return const_cast<Trk *>(static_cast<const Evt &>(*this).get_parent_of(child) );
261  }
262 
263 
264  ClassDef(Evt, 16)
265 };
266 
267 #endif
void clear_hits()
Clear the hit vectors and all the references to hits in the tracks.
Definition: Evt.hh:97
const Trk * get_parent_of(const Trk &child) const
Get a const pointer to the (first) parent of the track &#39;child&#39;.
Definition: Evt.hh:240
const Trk * neutrino() const
Get a const pointer to the (first) neutrino from the MC track list.
Definition: Evt.hh:147
Trk * get_parent_of(const Trk &child)
Get a pointer ot the (first) parent of the track &#39;child&#39;.
Definition: Evt.hh:258
ULong64_t trigger_counter
trigger counter
Definition: Evt.hh:31
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]=w3 (see e.g. Tag list or km3net-dataformat/definitions) ...
Definition: Evt.hh:42
data_type r[M+1]
Definition: JPolint.hh:779
int mother_id
MC id of the parent particle.
Definition: Trk.hh:29
Trk * primary_neutrino()
Get a pointer to primary neutrino from the MC track list.
Definition: Evt.hh:192
int frame_index
from the raw data
Definition: Evt.hh:29
unsigned int overlays
number of overlaying triggered events
Definition: Evt.hh:32
Trk * leading_lepton()
Get a pointer to leading lepton from the MC track list.
Definition: Evt.hh:228
int mc_run_id
MC run identifier.
Definition: Evt.hh:27
uuid_t header_uuid
UUID of header containing the event-weight information.
Definition: Evt.hh:35
TString comment
user can use this as he/she likes
Definition: Evt.hh:52
Trk * neutrino()
Get a pointer to the (first) neutrino from the MC track list.
Definition: Evt.hh:162
int mc_id
identifier of the MC event (as found in ascii or antcc file).
Definition: Evt.hh:24
TTimeStamp mc_event_time
MC: true generation time (UTC) of the event, (default: 01 Jan 1970 00:00:00)
Definition: Evt.hh:46
int run_id
DAQ run identifier.
Definition: Evt.hh:26
std::vector< Trk * > primary_trks()
Return a vector of pointers to tracks that are &#39;primary&#39;.
Definition: Evt.hh:131
double mc_t
MC: time where the mc-event was put in the timeslice, since start of run (offset+frameidx*timeslice_d...
Definition: Evt.hh:47
int det_id
detector identifier from DAQ
Definition: Evt.hh:23
int id
track identifier
Definition: Trk.hh:16
#define ClassDef(name, version)
Definition: JRoot.hh:32
AAObject is a base class for I/O-classes that adds the possibility to add &#39;user&#39; information which wi...
Definition: AAObject.hh:18
TTimeStamp t
UTC time of the timeslice, or the event_time for MC. (default: 01 Jan 1970 00:00:00) ...
Definition: Evt.hh:33
Evt()
Default constructor.
Definition: Evt.hh:60
void print(std::ostream &out=std::cout) const
Print event.
Definition: Evt.hh:74
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Definition: Evt.hh:39
std::vector< Hit > mc_hits
MC: list of MC truth hits.
Definition: Evt.hh:48
int flags
user can use this as he/she likes
Definition: Evt.hh:54
int index
user can use this as he/she likes
Definition: Evt.hh:53
int id
offline event identifier
Definition: Evt.hh:22
void clear()
Reset event.
Definition: Evt.hh:88
std::vector< Hit > hits
list of hits
Definition: Evt.hh:38
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
const Trk * leading_lepton() const
Get a const pointer to the first leading lepton from the MC track list.
Definition: Evt.hh:206
std::vector< double > w2list
MC: factors that make up w[1]=w2 (see e.g. Tag list or km3net-dataformat/definitions) ...
Definition: Evt.hh:43
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition: Evt.hh:49
ULong64_t trigger_mask
trigger mask from raw data (i.e. the trigger bits)
Definition: Evt.hh:30
std::vector< double > w3list
MC: atmospheric flux information.
Definition: Evt.hh:44
std::vector< const Trk * > primary_trks() const
Return a vector with const pointers to the tracks that are &#39;primary&#39;.
Definition: Evt.hh:114
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
const Trk * primary_neutrino() const
Get a const pointer to primary neutrino from the MC track list.
Definition: Evt.hh:176