Jpp  16.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JEvtWeightKM3BUU.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JEVTWEIGHTKM3BUU__
2 #define __JAANET__JEVTWEIGHTKM3BUU__
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/JFlux.hh"
13 #include "JAAnet/JEvtWeight.hh"
14 
15 /**
16  * \author bjung
17  */
18 
19 namespace JAANET {
20 
21  using JLANG::JClonable;
24 
25 
26  /**
27  * Implementation of event weighting for KM3BUU data.
28  */
30  public JClonable<JEvtWeight, JEvtWeightKM3BUU>,
31  public JFluxHelper
32  {
33  /**
34  * Default constructor.
35  */
37  JFluxHelper(),
38  W(0.0)
39  {}
40 
41 
42  /**
43  * Constructor.
44  *
45  * \param header header
46  */
47  JEvtWeightKM3BUU(const JHead& header) :
48  JFluxHelper()
49  {
50  configure(header);
51  }
52 
53 
54  /**
55  * Constructor.
56  *
57  * \param header header
58  * \param flux flux
59  */
60  JEvtWeightKM3BUU(const JHead& header,
61  const JFlux& flux)
62  {
63  configure(header);
65  }
66 
67 
68  /**
69  * Copy constructor.
70  *
71  * \param object original object
72  */
74  {
75  this->W = object.W;
76  JFluxHelper::configure(*(object.get()));
77  }
78 
79 
80  /**
81  * Weight configuration.
82  *
83  * \param header header
84  */
85  void configure(const JHead& header) override
86  {
87  const double N = header.genvol.numberOfEvents;
88  const double dt = (header.tgen.numberOfSeconds > 0.0 ?
89  header.tgen.numberOfSeconds : 1.0);
90 
91  if (check(header) && N > 0.0 && dt > 0.0) {
92 
93  W = 1.0 / N / dt;
94 
95  } else {
96 
97  THROW(JValueOutOfRange, "JEvtWeightKM3BUU::configure(): Provided header is inconsistent with KM3BUU.");
98  }
99  }
100 
101 
102  /**
103  * Check whether header is consistent with this event weighter.
104  *
105  * \param header header
106  * \return true if consistent; else false
107  */
108  bool check(const JHead& header) const override
109  {
110  return is_km3buu(header);
111  }
112 
113 
114  /**
115  * Get weight of given event.
116  *
117  * \param evt event
118  * \return weight [Hz]
119  */
120  double getWeight(const Evt& evt) const override
121  {
122  if (is_valid() && evt.w.size() > 1) {
123 
124  return W * evt.w[1] * getFlux(evt);
125 
126  } else if (evt.w.size() > 2) {
127 
128  return W * evt.w[2];
129 
130  } else {
131 
132  if (!is_valid()) {
133  THROW(JNullPointerException, "JEvtWeightKM3BUU::getWeight(): Unspecified flux function.");
134  } else {
135  THROW(JIndexOutOfRange, "JEvtWeightKM3BUU::getWeight(): Empty " << (evt.w.size() < 3 ? "w2-" : "w3-") << "weight.");
136  }
137  }
138  }
139 
140 
141  private:
142 
143  double W;
144  };
145 }
146 
147 #endif
JAANET::genvol genvol
Definition: JHead.hh:1469
Exceptions.
bool is_km3buu(const JHead &header)
Check for generator.
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.
double numberOfEvents
Number of events.
Definition: JHead.hh:705
JEvtWeightKM3BUU(const JEvtWeightKM3BUU &object)
Copy constructor.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]]=w3 (see e.g. Tag list)
Definition: Evt.hh:39
JEvtWeightKM3BUU(const JHead &header)
Constructor.
bool is_valid() const
Check validity of pointer.
JEvtWeightKM3BUU()
Default constructor.
Exception for null pointer operation.
Definition: JException.hh:216
Neutrino flux.
Definition: JHead.hh:890
Template class for object cloning.
Definition: JClonable.hh:20
void configure(const JEvtWeightFactor &factor)
Configure event-weight factor.
Helper class for event-weight factor.
Monte Carlo run header.
Definition: JHead.hh:1164
double getFlux(const Evt &evt) const
Get flux of given event.
Implementation of event weighting for KM3BUU data.
JAANET::tgen tgen
Definition: JHead.hh:1477
void configure(const JHead &header) override
Weight configuration.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
Exception for accessing an index in a collection that is outside of its range.
Definition: JException.hh:90
double numberOfSeconds
Time in seconds.
Definition: JHead.hh:1065
Low-level interface for retrieving a specifiable multiplication factor corresponding to a given event...
JEvtWeightKM3BUU(const JHead &header, const JFlux &flux)
Constructor.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19