Jpp  master_rocky
the software that should make you happy
JEvtWeightDAQ.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JEVTWEIGHTDAQ__
2 #define __JAANET__JEVTWEIGHTDAQ__
3 
5 
8 
9 #include "JLang/JException.hh"
10 #include "JLang/JClonable.hh"
11 
12 #include "JAAnet/JHead.hh"
13 #include "JAAnet/JHeadToolkit.hh"
14 #include "JAAnet/JEvtWeight.hh"
15 
16 
17 /**
18  * \author mdejong
19  */
20 
21 namespace JAANET {}
22 namespace JPP { using namespace JAANET; }
23 
24 namespace JAANET {
25 
26  using JLANG::JClonable;
27 
28 
29  /**
30  * Implementation of event weighing for DAQ data.
31  */
32  struct JEvtWeightDAQ final :
33  public JClonable<JEvtWeight, JEvtWeightDAQ>
34  {
35  /**
36  * Default constructor.
37  */
39  {}
40 
41 
42  /**
43  * Constructor.
44  *
45  * \param header header
46  */
47  JEvtWeightDAQ(const JHead& header)
48  {
49  configure(header);
50  }
51 
52 
53  /**
54  * Get name.
55  *
56  * \return name
57  */
58  const char* const getName() const override final
59  {
60  return "DAQ";
61  }
62 
63 
64  /**
65  * Configuration.
66  *
67  * \param header header
68  */
69  void configure(const JHead& header) override final
70  {
71  using namespace JPP;
72 
73  if (check(header)) {
74 
75  setNormalisation(1.0 / header.DAQ.livetime_s);
76 
77  } else {
78 
79  THROW(JValueOutOfRange, "JEvtWeightDAQ::configure(): Provided header is inconsistent with a DAQ-header.");
80  }
81  }
82 
83 
84  /**
85  * Check whether header is consistent with this event weighter.
86  *
87  * \param header header
88  * \return true if consistent; else false
89  */
90  bool check(const JHead& header) const override final
91  {
92  return is_daq(header);
93  }
94 
95 
96  /**
97  * Get weight of given event.
98  *
99  * \param evt event
100  * \return weight [1/s]
101  */
102  double getWeight(const Evt& evt) const override final
103  {
104  if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
105  return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
106  } else {
107  return getNormalisation(evt);
108  }
109  }
110  };
111 }
112 
113 #endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Monte Carlo run header.
Definition: JHead.hh:1236
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180
Extensions to Evt data format.
bool is_daq(const JHead &header)
Check for real data.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:21
Implementation of event weighing for DAQ data.
double getWeight(const Evt &evt) const override final
Get weight of given event.
bool check(const JHead &header) const override final
Check whether header is consistent with this event weighter.
JEvtWeightDAQ(const JHead &header)
Constructor.
JEvtWeightDAQ()
Default constructor.
const char *const getName() const override final
Get name.
void configure(const JHead &header) override final
Configuration.
Template class for object cloning.
Definition: JClonable.hh:59
static const int WEIGHTLIST_RESCALED_EVENT_RATE
Rescaled event rate [s-1].
Definition: weightlist.hh:17