Jpp  18.4.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 /**
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:
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  * Configuration.
55  *
56  * \param header header
57  */
58  void configure(const JHead& header) override
59  {
60  using namespace JPP;
61 
62  if (check(header)) {
63 
64  norm = 1.0 / header.DAQ.livetime_s;
65 
66  } else {
67 
68  THROW(JValueOutOfRange, "JEvtWeightDAQ::configure(): Provided header is inconsistent with a DAQ-header.");
69  }
70  }
71 
72 
73  /**
74  * Check whether header is consistent with this event weighter.
75  *
76  * \param header header
77  * \return true if consistent; else false
78  */
79  bool check(const JHead& header) const override
80  {
81  return is_daq(header);
82  }
83 
84 
85  /**
86  * Get weight of given event.
87  *
88  * \param evt event
89  * \return weight [1/s]
90  */
91  double getWeight(const Evt& evt) const override
92  {
93  if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
95  } else {
96  return getNormalisation(evt);
97  }
98  }
99  };
100 }
101 
102 #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:712
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:1053
void configure(const JHead &header) override
Configuration.
Monte Carlo run header.
Definition: JHead.hh:1234
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
JEvtWeightDAQ(const JHead &header)
Constructor.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:178
JAANET::DAQ DAQ
Definition: JHead.hh:1604
JEvtWeightDAQ()
Default constructor.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20