Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JHeadToolkit.hh
Go to the documentation of this file.
1 #ifndef __JAANET_JHEADTOOLKIT__
2 #define __JAANET_JHEADTOOLKIT__
3 
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 (header.is_valid(&JHead::can))
304  return Vec(0.0, 0.0, -header.can.zmin);
305  else if (header.is_valid(&JHead::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
bool is_mupage(const JHead &header)
Check for generator.
Data structure for vector in two dimensions.
Definition: JVector2D.hh:31
getGenieHeader()
Default constructor.
Definition: JHeadToolkit.hh:67
static const std::string GSEAGEN
Definition: JHead.hh:844
getSireneHeader()
Default constructor.
static const std::string KM3
Definition: JHead.hh:847
Livetime of DAQ data.
Definition: JHead.hh:716
getDAQHeader()
Default constructor.
double z
Definition: Vec.hh:14
Data structure for circle in two dimensions.
Definition: JCircle2D.hh:29
Generator for simulation.
Definition: JHead.hh:318
getGSeaGenHeader()
Default constructor.
Definition: JHeadToolkit.hh:86
std::string program
program name
Definition: JHead.hh:296
static const std::string KM3SIM
Definition: JHead.hh:848
getCorsikaHeader(const int A, const int Z)
Constructor.
std::vector< JAANET::physics > physics
Definition: JHead.hh:1089
std::vector< JAANET::simul > simul
Definition: JHead.hh:1090
double livetime_s
Live time [s].
Definition: JHead.hh:750
double y
Definition: Vec.hh:14
getMUPAGEHeader()
Default constructor.
Definition: JHeadToolkit.hh:30
Generator for neutrino interaction.
Definition: JHead.hh:308
Match header for genie.
Definition: JHeadToolkit.hh:61
Match header for Corsika.
Match header for genhen.
Definition: JHeadToolkit.hh:42
Match header for km3.
double x
Definition: Vec.hh:14
JAANET::can can
Definition: JHead.hh:1096
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition: Vec.hh:12
void push(T JHead::*pd)
Push given data member to Head.
Definition: JHead.hh:956
int type
Particle type.
Definition: JHead.hh:806
Cylinder object.
Definition: JCylinder3D.hh:37
Match header for DAQ.
JAANET::livetime livetime
Definition: JHead.hh:1102
do set_variable OUTPUT_DIRECTORY $WORKDIR T
static const std::string GENIE
Definition: JHead.hh:843
Match header for JSirene.cc.
Definition: JHeadToolkit.hh:99
bool is_daq(const JHead &header)
Check for real data.
static const std::string JSIRENE
Definition: JHead.hh:846
JAANET::primary primary
Definition: JHead.hh:1106
Monte Carlo run header.
Definition: JHead.hh:836
getKM3Header()
Default constructor.
bool is_genhen(const JHead &header)
Check for generator.
Normalisation of MUPAGE events.
Definition: JHead.hh:604
bool is_sirene(const JHead &header)
Check for detector simulation.
Match header for MUPAGE.
Definition: JHeadToolkit.hh:24
getKM3SimHeader()
Default constructor.
Primary particle.
Definition: JHead.hh:776
bool is_km3sim(const JHead &header)
Check for detector simulation.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
static const std::string GENHEN
Generators.
Definition: JHead.hh:842
JAANET::DAQ DAQ
Definition: JHead.hh:1104
getGenhenHeader()
Default constructor.
Definition: JHeadToolkit.hh:48
bool match(const JHead &header, const bool option=true) const
Test match of headers.
Definition: JHead.hh:991
double numberOfSeconds
Live time [s].
Definition: JHead.hh:654
Vec coord_origin() const
Get coordinate origin.
Definition: Head.hh:319
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
Match header for km3.
bool is_genie(const JHead &header)
Check for generator.
bool is_km3(const JHead &header)
Check for detector simulation.
Match header for gseagen.
Definition: JHeadToolkit.hh:80