Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JEvtWeightKM3BUU.hh
Go to the documentation of this file.
1#ifndef __JAANET__JEVTWEIGHTKM3BUU__
2#define __JAANET__JEVTWEIGHTKM3BUU__
3
5
8
9#include "JLang/JException.hh"
10#include "JLang/JClonable.hh"
11
12#include "JAAnet/JHead.hh"
14#include "JAAnet/JEvtWeight.hh"
16#include "JAAnet/JFlux.hh"
17#include "JAAnet/JFluxHelper.hh"
18
19
20/**
21 * \author bjung
22 */
23
24namespace JAANET {}
25namespace JPP { using namespace JAANET; }
26
27namespace JAANET {
28
29 using JLANG::JClonable;
30
31
32 /**
33 * Implementation of event weighting for KM3BUU data.
34 */
35 struct JEvtWeightKM3BUU final :
36 public JFluxHelper,
37 public JClonable<JEvtWeight, JEvtWeightKM3BUU>
38 {
39 /**
40 * Default constructor.
41 */
45
46
47 /**
48 * Constructor.
49 *
50 * \param header header
51 */
52 JEvtWeightKM3BUU(const JHead& header) :
54 {
55 configure(header);
56 }
57
58
59 /**
60 * Constructor.
61 *
62 * \param header header
63 * \param flux flux
64 */
65 JEvtWeightKM3BUU(const JHead& header,
66 const JFlux& flux) :
68 {
69 configure(header);
71 }
72
73
74 /**
75 * Get name.
76 *
77 * \return name
78 */
79 const char* const getName() const override final
80 {
81 return "KM3BUU";
82 }
83
84
85 /**
86 * Weight configuration.
87 *
88 * \param header header
89 */
90 void configure(const JHead& header) override final
91 {
92 using namespace JPP;
93
94 if (check(header)) {
95
96 const double Nevents = header.genvol.numberOfEvents;
97 const double dt = (header.tgen.numberOfSeconds > 0.0 ?
98 header.tgen.numberOfSeconds : 1.0);
99
100 setNormalisation(1.0 / Nevents / dt);
101
102 } else {
103
104 THROW(JValueOutOfRange, "JEvtWeightKM3BUU::configure(): Provided header is inconsistent with KM3BUU.");
105 }
106 }
107
108
109 /**
110 * Check whether header is consistent with this event weighter.
111 *
112 * \param header header
113 * \return true if consistent; else false
114 */
115 bool check(const JHead& header) const override final
116 {
117 return is_km3buu(header);
118 }
119
120
121 /**
122 * Get weight of given event.
123 *
124 * \param evt event
125 * \return weight [Hz]
126 */
127 double getWeight(const Evt& evt) const override final
128 {
129 using namespace JPP;
130
131 if (static_cast<const JFluxHelper&>(*this) &&
132 evt.w.size() > WEIGHTLIST_DIFFERENTIAL_EVENT_RATE) {
133
134 return evt.w[WEIGHTLIST_DIFFERENTIAL_EVENT_RATE] * getFactor(evt) * getNormalisation(evt);
135
136 } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
137
138 return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
139
140 } else if (evt.w.size() > WEIGHTLIST_EVENT_RATE) {
141
142 return evt.w[WEIGHTLIST_EVENT_RATE] * getNormalisation(evt);
143
144 } else {
145
146 if (!static_cast<const JFluxHelper&>(*this)) {
147 THROW(JNullPointerException, "JEvtWeightKM3BUU::getWeight(): Unspecified flux function.");
148 } else {
149 THROW(JIndexOutOfRange, "JEvtWeightKM3BUU::getWeight(): Empty " << (evt.w.size() < 3 ? "w2-" : "w3-") << "weight.");
150 }
151 }
152 }
153 };
154}
155
156#endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Monte Carlo run header.
Definition JHead.hh:1236
Exception for accessing an index in a collection that is outside of its range.
Exception for null pointer operation.
Exception for accessing a value in a collection that is outside of its range.
Extensions to Evt data format.
bool is_km3buu(const JHead &header)
Check for generator.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
void configure(const pointer_type &p)
Configure event-weight factor.
JEvtWeightFactor & getFactor() const
Get reference to event-weight factor.
Implementation of event weighting for KM3BUU data.
JEvtWeightKM3BUU()
Default constructor.
bool check(const JHead &header) const override final
Check whether header is consistent with this event weighter.
JEvtWeightKM3BUU(const JHead &header)
Constructor.
double getWeight(const Evt &evt) const override final
Get weight of given event.
const char *const getName() const override final
Get name.
void configure(const JHead &header) override final
Weight configuration.
JEvtWeightKM3BUU(const JHead &header, const JFlux &flux)
Constructor.
Helper class for flux function.
Low-level interface for retrieving the flux corresponding to a given event.
Definition JFlux.hh:23
Neutrino flux.
Definition JHead.hh:906
Template class for object cloning.
Definition JClonable.hh:59
static const int WEIGHTLIST_DIFFERENTIAL_EVENT_RATE
Event rate per unit of flux (c.f. taglist document) [GeV m2 sr].
Definition weightlist.hh:14
static const int WEIGHTLIST_RESCALED_EVENT_RATE
Rescaled event rate [s-1].
Definition weightlist.hh:17
static const int WEIGHTLIST_EVENT_RATE
Event rate [s-1].
Definition weightlist.hh:15