Jpp
JHeadToolkit.hh
Go to the documentation of this file.
1 #ifndef __JAANET_JHEADTOOLKIT__
2 #define __JAANET_JHEADTOOLKIT__
3 
4 #include "evt/Vec.hh"
5 #include "evt/Head.hh"
6 
9 #include "JAAnet/JHead.hh"
10 
11 
12 /**
13  * \author mdejong
14  */
15 namespace JAANET {
16 
19 
20 
21  /**
22  * Match header for MUPAGE.
23  */
24  struct getMUPAGEHeader :
25  public JHead
26  {
27  /**
28  * Default constructor.
29  */
31  {
32  this->livetime.numberOfSeconds = 1.0;
33 
34  this->push(&JHead::livetime);
35  }
36  };
37 
38 
39  /**
40  * Match header for genhen.
41  */
42  struct getGenhenHeader :
43  public JHead
44  {
45  /**
46  * Default constructor.
47  */
49  {
50  this->physics.resize(1);
51  this->physics[0].program = JHead::GENHEN;
52 
53  this->push(&JHead::physics);
54  }
55  };
56 
57 
58  /**
59  * Match header for genie.
60  */
61  struct getGenieHeader :
62  public JHead
63  {
64  /**
65  * Default constructor.
66  */
68  {
69  this->physics.resize(1);
70  this->physics[0].program = JHead::GENIE;
71 
72  this->push(&JHead::physics);
73  }
74  };
75 
76 
77  /**
78  * Match header for gseagen.
79  */
81  public JHead
82  {
83  /**
84  * Default constructor.
85  */
87  {
88  this->physics.resize(1);
89  this->physics[0].program = JHead::GSEAGEN;
90 
91  this->push(&JHead::physics);
92  }
93  };
94 
95 
96  /**
97  * Match header for JSirene.cc.
98  */
99  struct getSireneHeader :
100  public JHead
101  {
102  /**
103  * Default constructor.
104  */
106  {
107  this->simul.resize(1);
108  this->simul[0].program = JHead::JSIRENE;
109 
110  this->push(&JHead::simul);
111  }
112  };
113 
114 
115  /**
116  * Match header for km3.
117  */
118  struct getKM3Header :
119  public JHead
120  {
121  /**
122  * Default constructor.
123  */
125  {
126  this->simul.resize(1);
127  this->simul[0].program = JHead::KM3;
128 
129  this->push(&JHead::simul);
130  }
131  };
132 
133 
134  /**
135  * Match header for km3.
136  */
138  public JHead
139  {
140  /**
141  * Default constructor.
142  */
144  {
145  this->simul.resize(1);
146  this->simul[0].program = JHead::KM3SIM;
147 
148  this->push(&JHead::simul);
149  }
150  };
151 
152 
153  /**
154  * Match header for Corsika.
155  */
157  public JHead
158  {
159  /**
160  * Constructor.
161  *
162  * \param A atomic number
163  * \param Z proton number
164  */
165  getCorsikaHeader(const int A,
166  const int Z)
167  {
168  primary.type = A*100 + Z;
169 
170  this->push(&JHead::primary);
171  }
172  };
173 
174 
175  /**
176  * Match header for DAQ.
177  */
178  struct getDAQHeader :
179  public JHead
180  {
181  /**
182  * Default constructor.
183  */
185  {
186  this->DAQ.livetime_s = 1.0;
187 
188  this->push(&JHead::DAQ);
189  }
190  };
191 
192 
193  /**
194  * Check for generator.
195  *
196  * \param header header
197  * \return true if this Monte Carlo is produced by mupage; else false
198  */
199  inline bool is_mupage(const JHead& header)
200  {
201  return header.match(getMUPAGEHeader(), false);
202  }
203 
204 
205  /**
206  * Check for generator.
207  *
208  * \param header header
209  * \return true if this Monte Carlo is produced by genhen; else false
210  */
211  inline bool is_genhen(const JHead& header)
212  {
213  return header.match(getGenhenHeader(), false);
214  }
215 
216 
217  /**
218  * Check for generator.
219  *
220  * \param header header
221  * \return true if this Monte Carlo is produced by genie; else false
222  */
223  inline bool is_genie(const JHead& header)
224  {
225  return (header.match(getGenieHeader(), false) ||
226  header.match(getGSeaGenHeader(), false));
227  }
228 
229 
230  /**
231  * Check for detector simulation.
232  *
233  * \param header header
234  * \return true if this Monte Carlo is processed with JSirene; else false
235  */
236  inline bool is_sirene(const JHead& header)
237  {
238  return header.match(getSireneHeader(), false);
239  }
240 
241 
242  /**
243  * Check for detector simulation.
244  *
245  * \param header header
246  * \return true if this Monte Carlo is processed with km3; else false
247  */
248  inline bool is_km3(const JHead& header)
249  {
250  return header.match(getKM3Header(), false);
251  }
252 
253 
254  /**
255  * Check for detector simulation.
256  *
257  * \param header header
258  * \return true if this Monte Carlo is processed with KM3Sim; else false
259  */
260  inline bool is_km3sim(const JHead& header)
261  {
262  return header.match(getKM3SimHeader(), false);
263  }
264 
265 
266  /**
267  * Check for real data.
268  *
269  * \param header header
270  * \return true if this header corresponds to real data; else false
271  */
272  inline bool is_daq(const JHead& header)
273  {
274  return header.match(getDAQHeader(), false);
275  }
276 
277 
278  /**
279  * Get object from header.
280  *
281  * \param header header
282  * \return object
283  */
284  template<class T>
285  inline T get(const JHead& header);
286 
287 
288  /**
289  * Get position offset of detector due to generator.
290  *
291  * \param header header
292  * \return position
293  */
294  template<>
295  inline Vec get(const JHead& header)
296  {
297  if (is_sirene(header) || is_km3(header)) {
298 
299  return header.coord_origin;
300 
301  } else {
302 
303  if (is_valid(header.can))
304  return Vec(0.0, 0.0, -header.can.zmin);
305  else if (is_valid(header.coord_origin))
306  return header.coord_origin;
307  else
308  return Vec(0.0, 0.0, 0.0);
309  }
310  }
311 
312 
313  /**
314  * Get position offset of detector due to generator.
315  *
316  * \param header header
317  * \return position
318  */
319  template<>
320  inline JPosition3D get(const JHead& header)
321  {
322  const Vec pos = get<Vec>(header);
323 
324  return JPosition3D(pos.x, pos.y, pos.z);
325  }
326 
327 
328  /**
329  * Get cylinder corresponding to can.
330  *
331  * \param header header
332  * \return cylinder
333  */
334  template<>
335  inline JCylinder3D get(const JHead& header)
336  {
337  using namespace JGEOMETRY2D;
338 
339  return JCylinder3D(JCircle2D(JVector2D(), header.can.r),
340  header.can.zmin,
341  header.can.zmax);
342  }
343 }
344 
345 #endif
JAANET::JHead::physics
std::vector< JAANET::physics > physics
Definition: JHead.hh:1076
JAANET::JHead::simul
std::vector< JAANET::simul > simul
Definition: JHead.hh:1077
JAANET::JHead::match
bool match(const JHead &header, const bool option=true) const
Test match of headers.
Definition: JHead.hh:979
JAANET::can::r
double r
Radius [m].
Definition: JHead.hh:371
JAANET::getDAQHeader::getDAQHeader
getDAQHeader()
Default constructor.
Definition: JHeadToolkit.hh:184
JAANET::is_daq
bool is_daq(const JHead &header)
Check for real data.
Definition: JHeadToolkit.hh:272
JAANET::JHead::GENHEN
static const std::string GENHEN
Generators.
Definition: JHead.hh:845
JHead.hh
JAANET::JHead::livetime
JAANET::livetime livetime
Definition: JHead.hh:1089
JAANET::DAQ
Livetime of DAQ data.
Definition: JHead.hh:706
JAANET::JHead::GENIE
static const std::string GENIE
Definition: JHead.hh:846
JPosition3D.hh
JAANET::JHead::coord_origin
JAANET::coord_origin coord_origin
Definition: JHead.hh:1086
JAANET::getGenieHeader::getGenieHeader
getGenieHeader()
Default constructor.
Definition: JHeadToolkit.hh:67
JAANET::JHead::DAQ
JAANET::DAQ DAQ
Definition: JHead.hh:1091
JAANET::getGenhenHeader::getGenhenHeader
getGenhenHeader()
Default constructor.
Definition: JHeadToolkit.hh:48
JAANET::is_valid
bool is_valid(const T &value)
Check validity of given value.
Definition: JHead.hh:823
JGEOMETRY2D::JCircle2D
Data structure for circle in two dimensions.
Definition: JCircle2D.hh:29
JAANET::JHead::JSIRENE
static const std::string JSIRENE
Definition: JHead.hh:849
JAANET::getCorsikaHeader::getCorsikaHeader
getCorsikaHeader(const int A, const int Z)
Constructor.
Definition: JHeadToolkit.hh:165
JAANET::getMUPAGEHeader::getMUPAGEHeader
getMUPAGEHeader()
Default constructor.
Definition: JHeadToolkit.hh:30
JAANET::generator::program
std::string program
program name
Definition: JHead.hh:286
JAANET::is_sirene
bool is_sirene(const JHead &header)
Check for detector simulation.
Definition: JHeadToolkit.hh:236
JAANET::JHead::GSEAGEN
static const std::string GSEAGEN
Definition: JHead.hh:847
JAANET::getSireneHeader::getSireneHeader
getSireneHeader()
Default constructor.
Definition: JHeadToolkit.hh:105
JAANET::getKM3Header
Match header for km3.
Definition: JHeadToolkit.hh:118
JGEOMETRY2D
Auxiliary classes and methods for 2D geometrical objects and operations.
Definition: JAngle2D.hh:18
JAANET::DAQ::livetime_s
double livetime_s
Live time [s].
Definition: JHead.hh:740
JAANET::is_mupage
bool is_mupage(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:199
JAANET::is_km3sim
bool is_km3sim(const JHead &header)
Check for detector simulation.
Definition: JHeadToolkit.hh:260
JAANET::JHead
Monte Carlo run header.
Definition: JHead.hh:839
JAANET::getGenhenHeader
Match header for genhen.
Definition: JHeadToolkit.hh:42
JAANET::can::zmin
double zmin
Bottom [m].
Definition: JHead.hh:369
JGEOMETRY3D::JCylinder3D
Cylinder object.
Definition: JCylinder3D.hh:37
JAANET::getGenieHeader
Match header for genie.
Definition: JHeadToolkit.hh:61
JAANET::is_km3
bool is_km3(const JHead &header)
Check for detector simulation.
Definition: JHeadToolkit.hh:248
JAANET::is_genhen
bool is_genhen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:211
JAANET::JHead::KM3SIM
static const std::string KM3SIM
Definition: JHead.hh:851
JGEOMETRY3D::JPosition3D
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
JAANET::getCorsikaHeader
Match header for Corsika.
Definition: JHeadToolkit.hh:156
JAANET::getKM3Header::getKM3Header
getKM3Header()
Default constructor.
Definition: JHeadToolkit.hh:124
JAANET::getSireneHeader
Match header for JSirene.cc.
Definition: JHeadToolkit.hh:99
JAANET::livetime::numberOfSeconds
double numberOfSeconds
Live time [s].
Definition: JHead.hh:644
JAANET::can::zmax
double zmax
Top [m].
Definition: JHead.hh:370
JAANET
Extensions to AAnet data format.
Definition: JAAnetToolkit.hh:36
JAANET::JHead::can
JAANET::can can
Definition: JHead.hh:1083
JAANET::JHead::push
void push(T JHead::*pd)
Push given data member to Head.
Definition: JHead.hh:944
JAANET::physics
Generator for neutrino interaction.
Definition: JHead.hh:298
JAANET::JHead::KM3
static const std::string KM3
Definition: JHead.hh:850
JAANET::getMUPAGEHeader
Match header for MUPAGE.
Definition: JHeadToolkit.hh:24
JAANET::getKM3SimHeader
Match header for km3.
Definition: JHeadToolkit.hh:137
JCylinder3D.hh
JAANET::is_genie
bool is_genie(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:223
JAANET::livetime
Normalisation of MUPAGE events.
Definition: JHead.hh:594
JAANET::primary::type
int type
Particle type.
Definition: JHead.hh:796
JAANET::primary
Primary particle.
Definition: JHead.hh:766
JAANET::get
T get(const JHead &header)
Get object from header.
Definition: JHeadToolkit.hh:295
JAANET::getDAQHeader
Match header for DAQ.
Definition: JHeadToolkit.hh:178
JAANET::getGSeaGenHeader::getGSeaGenHeader
getGSeaGenHeader()
Default constructor.
Definition: JHeadToolkit.hh:86
JAANET::getKM3SimHeader::getKM3SimHeader
getKM3SimHeader()
Default constructor.
Definition: JHeadToolkit.hh:143
JAANET::getGSeaGenHeader
Match header for gseagen.
Definition: JHeadToolkit.hh:80
JAANET::JHead::primary
JAANET::primary primary
Definition: JHead.hh:1093
JAANET::simul
Generator for simulation.
Definition: JHead.hh:308
JGEOMETRY2D::JVector2D
Data structure for vector in two dimensions.
Definition: JVector2D.hh:31