Jpp  18.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JEvtWeightMiscellaneous.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JEVTWEIGHTMISCELLANEOUS__
2 #define __JAANET__JEVTWEIGHTMISCELLANEOUS__
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"
17 
18 
19 /**
20  * \author bjjung
21  */
22 
23 namespace JAANET {}
24 namespace JPP { using namespace JAANET; }
25 
26 namespace JAANET {
27 
28  using JLANG::JClonable;
29 
30 
31  /**
32  * Implementation of event weighing for miscellaneous data\n
33  * such as a merged offline file containing neutrinos and atmospheric muons.\n
34  * A uniform weight of 1.0 is applied to all events.
35  */
37  public JClonable<JEvtWeight, JEvtWeightMiscellaneous>,
38  public JEvtWeightFactorHelper<JEvtWeightFactor>
39  {
41 
42 
43  /**
44  * Default constructor.
45  */
48  {}
49 
50 
51  /**
52  * Constructor.
53  *
54  * \param header header
55  */
56  JEvtWeightMiscellaneous(const JHead& header) :
58  {
59  configure(header);
60  }
61 
62 
63  /**
64  * Constructor.
65  *
66  * \param header header
67  * \param factor factor
68  */
70  const JEvtWeightFactor& factor) :
72  {
73  configure(header);
75  }
76 
77 
78  /**
79  * Copy constructor.
80  *
81  * \param object original object
82  */
84  {
85  this->norm = object.norm;
86 
87  if (static_cast<const JEvtWeightFactorHelper_t&>(object)) {
88  JEvtWeightFactorHelper::configure(*(object.get()));
89  }
90  }
91 
92 
93  /**
94  * Configuration.
95  *
96  * \param header header
97  */
98  void configure(const JHead& header) override
99  {
100  using namespace JPP;
101 
102  if (check(header)) {
103 
104  norm = 1.0;
105 
106  } else {
107 
108  THROW(JValueOutOfRange, "JEvtWeightMiscellaneous::configure(): Provided header is inconsistent with a miscellaneous, merged offline file.");
109  }
110  }
111 
112 
113  /**
114  * Check whether header is consistent with this event weighter.
115  *
116  * \param header header
117  * \return true if consistent; else false
118  */
119  bool check(const JHead& header) const override
120  {
121  return header.simul.empty() && !is_daq(header);
122  }
123 
124 
125  /**
126  * Get weight of given event.
127  *
128  * \param evt event
129  * \return weight [1/s]
130  */
131  double getWeight(const Evt& evt) const override
132  {
133  if (static_cast<const JEvtWeightFactorHelper_t&>(*this)) {
134 
135  return getFactor(evt) * getNormalisation(evt);
136 
137  } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
138 
139  return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
140 
141  } else {
142 
143  return getNormalisation(evt);
144  }
145  }
146  };
147 }
148 
149 #endif
Exceptions.
static const int WEIGHTLIST_RESCALED_EVENT_RATE
Rescaled event rate [s-1].
Definition: weightlist.hh:17
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
bool check(const JHead &header) const override
Check whether header is consistent with this event weighter.
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
Implementation of event weighing for miscellaneous data such as a merged offline file containing neut...
JEvtWeightFactorHelper< JEvtWeightFactor > JEvtWeightFactorHelper_t
void configure(const JHead &header) override
Configuration.
double getWeight(const Evt &evt) const override
Get weight of given event.
JEvtWeightMiscellaneous(const JHead &header, const JEvtWeightFactor &factor)
Constructor.
double getFactor(const Evt &evt) const
Get weight-factor of given event.
Monte Carlo run header.
Definition: JHead.hh:1234
JEvtWeightMiscellaneous()
Default constructor.
bool is_daq(const JHead &header)
Check for real data.
Template class for object cloning.
Definition: JClonable.hh:20
Helper class for event-weight factor.
void configure(const JEvtWeightFactor_t &factor)
Configure event-weight factor.
std::vector< JAANET::simul > simul
Definition: JHead.hh:1588
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:178
JEvtWeightMiscellaneous(const JHead &header)
Constructor.
Low-level interface for retrieving a specifiable multiplication factor corresponding to a given event...
JEvtWeightMiscellaneous(const JEvtWeightMiscellaneous &object)
Copy constructor.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20