Jpp  18.2.0-rc.1
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  {
40  /**
41  * Default constructor.
42  */
45  {}
46 
47 
48  /**
49  * Constructor.
50  *
51  * \param header header
52  */
53  JEvtWeightMiscellaneous(const JHead& header) :
55  {
56  configure(header);
57  }
58 
59 
60  /**
61  * Constructor.
62  *
63  * \param header header
64  * \param factor factor
65  */
67  const JEvtWeightFactor& factor) :
69  {
70  configure(header);
72  }
73 
74 
75  /**
76  * Copy constructor.
77  *
78  * \param object original object
79  */
81  {
82  this->norm = object.norm;
83 
84  if (object.is_valid()) {
85  JEvtWeightFactorHelper::configure(*(object.get()));
86  }
87  }
88 
89 
90  /**
91  * Configuration.
92  *
93  * \param header header
94  */
95  void configure(const JHead& header) override
96  {
97  using namespace JPP;
98 
99  if (check(header)) {
100 
101  norm = 1.0;
102 
103  } else {
104 
105  THROW(JValueOutOfRange, "JEvtWeightMiscellaneous::configure(): Provided header is inconsistent with a miscellaneous, merged offline file.");
106  }
107  }
108 
109 
110  /**
111  * Check whether header is consistent with this event weighter.
112  *
113  * \param header header
114  * \return true if consistent; else false
115  */
116  bool check(const JHead& header) const override
117  {
118  return header.simul.empty() && !is_daq(header);
119  }
120 
121 
122  /**
123  * Get weight of given event.
124  *
125  * \param evt event
126  * \return weight [1/s]
127  */
128  double getWeight(const Evt& evt) const override
129  {
130  if (is_valid()) {
131 
132  return getFactor(evt) * getNormalisation(evt);
133 
134  } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
135 
136  return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
137 
138  } else {
139 
140  return getNormalisation(evt);
141  }
142  }
143  };
144 }
145 
146 #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...
bool is_valid() const
Check validity of pointer.
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