Jpp  16.0.2
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  */
33  JEvtWeightDAQ() : W(0.0)
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  * \return true if okay; else false
53  */
54  void configure(const JHead& header) override
55  {
56  if (check(header) && header.DAQ.livetime_s > 0.0) {
57 
58  W = 1.0 / header.DAQ.livetime_s;
59 
60  } else {
61 
62  THROW(JValueOutOfRange, "JEvtWeightDAQ::configure(): Provided header is inconsistent with a DAQ-header.");
63  }
64  }
65 
66 
67  /**
68  * Check whether header is consistent with this event weighter.
69  *
70  * \param header header
71  * \return true if consistent; else false
72  */
73  bool check(const JHead& header) const override
74  {
75  return is_daq(header);
76  }
77 
78 
79  /**
80  * Get weight of given event.
81  *
82  * \param evt event
83  * \return weight [1/s]
84  */
85  double getWeight(const Evt& evt) const override
86  {
87  return W;
88  }
89 
90  private:
91  double W;
92  };
93 }
94 
95 #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:1037
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:1164
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:1476
JEvtWeightDAQ()
Default constructor.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19