Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JWeightMupage.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JWEIGHTMUPAGE__
2 #define __JAANET__JWEIGHTMUPAGE__
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/JWeightEvent.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 MUPAGE data.
26  */
27  struct JWeightMupage :
28  public JClonable<JWeightEvent, JWeightMupage>
29  {
30  /**
31  * Default Constructor.
32  */
33  JWeightMupage() : W(0.0)
34  {}
35 
36  /**
37  * Constructor.
38  *
39  * \param header header
40  */
41  JWeightMupage(const JHead& header)
42  {
43  configure(header);
44  }
45 
46 
47  /**
48  * Configuration.
49  *
50  * \param header header
51  */
52  void configure(const JHead& header) override
53  {
54  if (check(header) && header.livetime.numberOfSeconds > 0.0) {
55 
56  W = 1.0 / header.livetime.numberOfSeconds;
57 
58  } else {
59 
60  THROW(JValueOutOfRange, "JWeightMupage::configure(): Provided header is inconsistent with MUPAGE.");
61  }
62  }
63 
64 
65  /**
66  * Check whether header is consistent with this event weighter.
67  *
68  * \param header header
69  * \return true if consistent; else false
70  */
71  bool check(const JHead& header) const override
72  {
73  return is_mupage(header);
74  }
75 
76 
77  /**
78  * Get weight of given event.
79  *
80  * \param evt event
81  * \return weight [1/s]
82  */
83  double getWeight(const Evt& evt) const override
84  {
85  return W;
86  }
87 
88  private:
89  double W;
90  };
91 }
92 
93 #endif
bool is_mupage(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:78
Exceptions.
Implementation of event weighing for MUPAGE data.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
JWeightMupage()
Default Constructor.
double getWeight(const Evt &evt) const override
Get weight of given event.
bool check(const JHead &header) const override
Check whether header is consistent with this event weighter.
JAANET::livetime livetime
Definition: JHead.hh:1412
Template class for object cloning.
Definition: JClonable.hh:20
JWeightMupage(const JHead &header)
Constructor.
Monte Carlo run header.
Definition: JHead.hh:1113
void configure(const JHead &header) override
Configuration.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
double numberOfSeconds
Live time [s].
Definition: JHead.hh:829
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19