Jpp  18.6.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  {
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  setNormalisation(object.getNormalisation());
86 
87  if (static_cast<const JEvtWeightFactorHelper_t&>(object)) {
88  JEvtWeightFactorHelper::configure(*(object.get()));
89  }
90  }
91 
92 
93  /**
94  * Get name.
95  *
96  * \return name
97  */
98  virtual const char* const getName() const override
99  {
100  return "Miscellaneous";
101  }
102 
103 
104  /**
105  * Configuration.
106  *
107  * \param header header
108  */
109  void configure(const JHead& header) override
110  {
111  using namespace JPP;
112 
113  if (check(header)) {
114 
115  setNormalisation(1.0);
116 
117  } else {
118 
119  THROW(JValueOutOfRange, "JEvtWeightMiscellaneous::configure(): Provided header is inconsistent with a miscellaneous, merged offline file.");
120  }
121  }
122 
123 
124  /**
125  * Check whether header is consistent with this event weighter.
126  *
127  * \param header header
128  * \return true if consistent; else false
129  */
130  bool check(const JHead& header) const override
131  {
132  return header.simul.empty() && !is_daq(header);
133  }
134 
135 
136  /**
137  * Get weight of given event.
138  *
139  * \param evt event
140  * \return weight [1/s]
141  */
142  double getWeight(const Evt& evt) const override
143  {
144  if (static_cast<const JEvtWeightFactorHelper_t&>(*this)) {
145 
146  return getFactor(evt) * getNormalisation(evt);
147 
148  } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
149 
150  return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
151 
152  } else {
153 
154  return getNormalisation(evt);
155  }
156  }
157  };
158 }
159 
160 #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.
virtual const char *const getName() const override
Get name.
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:1590
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