Jpp  18.0.0
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 
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  * \author mdejong
18  */
19 
20 namespace JAANET {
21 
22  using JLANG::JClonable;
24 
25 
26  /**
27  * Implementation of event weighing for DAQ data.
28  */
29  struct JEvtWeightDAQ:
30  public JClonable<JEvtWeight, JEvtWeightDAQ>
31  {
32  /**
33  * Default constructor.
34  */
36  {}
37 
38 
39  /**
40  * Constructor.
41  *
42  * \param header header
43  */
44  JEvtWeightDAQ(const JHead& header)
45  {
46  configure(header);
47  }
48 
49 
50  /**
51  * Configuration.
52  *
53  * \param header header
54  */
55  void configure(const JHead& header) override
56  {
57  if (check(header) && header.DAQ.livetime_s > 0.0) {
58 
59  norm = 1.0 / header.DAQ.livetime_s;
60 
61  } else {
62 
63  THROW(JValueOutOfRange, "JEvtWeightDAQ::configure(): Provided header is inconsistent with a DAQ-header.");
64  }
65  }
66 
67 
68  /**
69  * Check whether header is consistent with this event weighter.
70  *
71  * \param header header
72  * \return true if consistent; else false
73  */
74  bool check(const JHead& header) const override
75  {
76  return is_daq(header);
77  }
78 
79 
80  /**
81  * Get weight of given event.
82  *
83  * \param evt event
84  * \return weight [1/s]
85  */
86  double getWeight(const Evt& evt) const override
87  {
88  if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
90  } else {
91  return getNormalisation(evt);
92  }
93  }
94  };
95 }
96 
97 #endif
Exceptions.
Implementation of event weighing for DAQ data.
static const int WEIGHTLIST_RESCALED_EVENT_RATE
Rescaled event rate [s-1].
Definition: weightlist.hh:17
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
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]=w3 (see e.g. Tag list or km3net-dataformat/definitions) ...
Definition: Evt.hh:42
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