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