Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JEvtWeightCorsika.hh
Go to the documentation of this file.
1#ifndef __JAANET__JEVTWEIGHTCORSIKA__
2#define __JAANET__JEVTWEIGHTCORSIKA__
3
6
9
10#include "JLang/JException.hh"
11#include "JLang/JClonable.hh"
12
13#include "JAAnet/JHead.hh"
15#include "JAAnet/JEvtWeight.hh"
17#include "JAAnet/JFlux.hh"
18#include "JAAnet/JFluxHelper.hh"
19
20
21/**
22 * \author bjung
23 */
24
25namespace JAANET {}
26namespace JPP { using namespace JAANET; }
27
28namespace JAANET {
29
30 using JLANG::JClonable;
31
32
33 /**
34 * Implementation of event weighting for Corsika data.
35 */
36 struct JEvtWeightCorsika final :
37 public JFluxHelper,
38 public JClonable<JEvtWeight, JEvtWeightCorsika>
39 {
40 /**
41 * Default Constructor.
42 */
46
47
48 /**
49 * Constructor.
50 *
51 * \param header header
52 */
53 JEvtWeightCorsika(const JHead& header) :
55 {
56 configure(header);
57 }
58
59
60 /**
61 * Constructor.
62 *
63 * \param header header
64 * \param flux flux
65 */
66 JEvtWeightCorsika(const JHead& header,
67 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 "Corsika";
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 setNormalisation(1.0 / header.genvol.numberOfEvents);
97
98 } else {
99
100 THROW(JValueOutOfRange, "JEvtWeightCorsika::configure(): Provided header is inconsistent with Corsika.");
101 }
102 }
103
104
105 /**
106 * Check whether header is consistent with this event weighter.
107 *
108 * \param header header
109 * \return true if consistent; else false
110 */
111 bool check(const JHead& header) const override final
112 {
113 return is_corsika(header);
114 }
115
116
117 /**
118 * Get weight of given event.
119 *
120 * \param evt event
121 * \return weight [Hz]
122 */
123 double getWeight(const Evt& evt) const override final
124 {
125 using namespace JPP;
126
127 const double Nretries = evt.w2list[W2LIST_GSEAGEN_N_RETRIES];
128
129 if (static_cast<const JFluxHelper&>(*this) &&
130 evt.w.size() > WEIGHTLIST_DIFFERENTIAL_EVENT_RATE) {
131
132 return evt.w[WEIGHTLIST_DIFFERENTIAL_EVENT_RATE] * getFactor(evt) * getNormalisation(evt) / (1 + Nretries);
133
134 } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
135
136 return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
137
138 } else if (evt.w.size() > WEIGHTLIST_EVENT_RATE) {
139
140 return evt.w[WEIGHTLIST_EVENT_RATE] * getNormalisation(evt) / (1 + Nretries);
141
142 } else {
143
144 if (!static_cast<const JFluxHelper&>(*this)) {
145 THROW(JNullPointerException, "JEvtWeightCorsika::getWeight(): Unspecified flux function.");
146 } else {
147 THROW(JIndexOutOfRange, "JEvtWeightCorsika::getWeight(): Empty " << (evt.w.size() < 3 ? "w2-" : "w3-") << "weight.");
148 }
149 }
150 }
151 };
152}
153
154#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_corsika(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
Implementation of event weighting for Corsika data.
JEvtWeightCorsika(const JHead &header)
Constructor.
JEvtWeightCorsika()
Default Constructor.
double getWeight(const Evt &evt) const override final
Get weight of given event.
JEvtWeightCorsika(const JHead &header, const JFlux &flux)
Constructor.
const char *const getName() const override final
Get name.
bool check(const JHead &header) const override final
Check whether header is consistent with this event weighter.
void configure(const JHead &header) override final
Weight configuration.
void configure(const pointer_type &p)
Configure event-weight factor.
JEvtWeightFactor & getFactor() const
Get reference to event-weight factor.
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 W2LIST_GSEAGEN_N_RETRIES
Number of extra chances given to each CORSIKA shower to hit the can.
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