Jpp  18.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JEvtWeightDAQ.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JEVTWEIGHTDAQ__
2 #define __JAANET__JEVTWEIGHTDAQ__
3 
6 
7 #include "JLang/JException.hh"
8 #include "JLang/JClonable.hh"
9 
10 #include "JAAnet/JHead.hh"
11 #include "JAAnet/JHeadToolkit.hh"
12 #include "JAAnet/JEvtWeight.hh"
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JAANET {
19 
20  using JLANG::JClonable;
22 
23 
24  /**
25  * Implementation of event weighing for DAQ data.
26  */
27  struct JEvtWeightDAQ:
28  public JClonable<JEvtWeight, JEvtWeightDAQ>
29  {
30  /**
31  * Default constructor.
32  */
34  {}
35 
36 
37  /**
38  * Constructor.
39  *
40  * \param header header
41  */
42  JEvtWeightDAQ(const JHead& header)
43  {
44  configure(header);
45  }
46 
47 
48  /**
49  * Configuration.
50  *
51  * \param header header
52  */
53  void configure(const JHead& header) override
54  {
55  if (check(header) && header.DAQ.livetime_s > 0.0) {
56 
57  norm = 1.0 / header.DAQ.livetime_s;
58 
59  } else {
60 
61  THROW(JValueOutOfRange, "JEvtWeightDAQ::configure(): Provided header is inconsistent with a DAQ-header.");
62  }
63  }
64 
65 
66  /**
67  * Check whether header is consistent with this event weighter.
68  *
69  * \param header header
70  * \return true if consistent; else false
71  */
72  bool check(const JHead& header) const override
73  {
74  return is_daq(header);
75  }
76 
77 
78  /**
79  * Get weight of given event.
80  *
81  * \param evt event
82  * \return weight [1/s]
83  */
84  double getWeight(const Evt& evt) const override
85  {
86  return norm;
87  }
88  };
89 }
90 
91 #endif
Exceptions.
Implementation of event weighing for DAQ data.
bool check(const JHead &header) const override
Check whether header is consistent with this event weighter.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
double livetime_s
Live time [s].
Definition: JHead.hh:1040
void configure(const JHead &header) override
Configuration.
double getWeight(const Evt &evt) const override
Get weight of given event.
bool is_daq(const JHead &header)
Check for real data.
Template class for object cloning.
Definition: JClonable.hh:20
Monte Carlo run header.
Definition: JHead.hh:1221
JEvtWeightDAQ(const JHead &header)
Constructor.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
JAANET::DAQ DAQ
Definition: JHead.hh:1589
JEvtWeightDAQ()
Default constructor.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20