Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JOscFlux.hh
Go to the documentation of this file.
1#ifndef __JAANET__JOSCFLUX__
2#define __JAANET__JOSCFLUX__
3
5
8
9#include "JLang/JClonable.hh"
10
11#include "JAAnet/JGENIETypes.hh"
14
18
19#include "JAAnet/JFlux.hh"
22
23
24/**
25 * \author bjung
26 */
27
28namespace JAANET {}
29namespace JPP { using namespace JAANET; }
30
31namespace JAANET {
32
33 using JLANG::JClonable;
34
37
38
39 /**
40 * Implementation of oscillated neutrino flux.
41 */
42 struct JOscFlux :
43 public JClonable<JFlux, JOscFlux>
44 {
45 /**
46 * Constructor.
47 *
48 * \param diffuseFlux diffuse flux function object
49 * \param oscProb oscillation probability function object
50 */
51 JOscFlux(const JDiffuseFluxHelper& diffuseFlux,
52 const JOscProbHelper& oscProb) :
53 P(oscProb),
54 F(diffuseFlux)
55 {
56 check_validity();
57 }
58
59
60 /**
61 * Get oscillation probability calculator.
62 *
63 * \return oscillation probability calculator
64 */
66 {
67 return P;
68 }
69
70
71 /**
72 * Set oscillation probability calculator.
73 *
74 * \param oscProb oscillation probability calculator.
75 */
76 void setOscProb(const JOscProbHelper oscProb)
77 {
78 using namespace JPP;
79
80 if (oscProb) {
81 this->P = oscProb;
82 } else {
83 THROW(JNullPointerException, "JOscFlux::setOscProb(): Given oscillation probability calculator is invalid.");
84 }
85 }
86
87
88 /**
89 * Get diffuse flux function.
90 *
91 * \return diffuse flux function
92 */
94 {
95 return F;
96 }
97
98
99 /**
100 * Set diffuse flux function.
101 *
102 * \param flux diffuse flux function
103 */
105 {
106 using namespace std;
107 using namespace JPP;
108
109 if (flux && flux->is_valid()) {
110 this->F = flux;
111 } else if (flux) {
112 THROW(JValueOutOfRange, "JOscFlux::setFlux(): Given flux function is invalid: " << endl << *flux);
113 } else {
114 THROW(JNullPointerException, "JOscFlux::setFlux(): Given flux function is invalid.");
115 }
116 }
117
118
119 /**
120 * Check whether this oscillated neutrino flux object is valid.
121 *
122 * \return true if valid; else false
123 */
124 bool is_valid() const override final
125 {
126 return (P && F && F->is_valid());
127 }
128
129
130 /**
131 * Get flux for given event.
132 *
133 * Note that in this evaluation the zenith-angle is defined\n
134 * with respect to the line of sight (i.e. a neutrino pointing straight at you\n
135 * from the center of the Earth has \f$ cos(\theta) = -1.0 \f$).
136 *
137 * \param evt event
138 * \return flux \f$ \left[\mathrm{GeV}^{-1} \, \mathrm{m}^{-2} \, \mathrm{sr}^{-1} \, \mathrm{s}^{-1}\right] \f$
139 */
140 double getFactor(const Evt& evt) const override final
141 {
142 using namespace JPP;
143
144 double flux = 0.0;
145
146 const Trk& neutrino = get_neutrino(evt);
147 const double costh = -neutrino.dir.z;
148
149 const int interactionType = evt.w2list[W2LIST_GSEAGEN_CC];
150
151 if (interactionType == (int) JInteractionTypeGENIE_t::WEAK_CHARGED_CURRENT) {
152
153 for (int i = 0; i != NUMBER_OF_OSCCHANNELS; ++i) {
154
155 const JOscChannel& channel = getOscChannel[i];
156
157 const int inType = ((int) channel.Cparity) * ((int) channel.in);
158 const int outType = ((int) channel.Cparity) * ((int) channel.out);
159
160 if (outType == neutrino.type) {
161
162 flux += ( F.getFlux(inType, log10(neutrino.E), costh) *
163 P.getP (channel, neutrino.E, costh) );
164 }
165 }
166
167 } else if (interactionType == (int) JInteractionTypeGENIE_t::WEAK_NEUTRAL_CURRENT) { // For NC events, the neutrino flavour is irrelevant
168
169 const int Cparity = (int) getChargeParity(neutrino);
170
171 flux += (F.getFlux(Cparity * TRACK_TYPE_NUE, log10(neutrino.E), costh) +
172 F.getFlux(Cparity * TRACK_TYPE_NUMU, log10(neutrino.E), costh) +
173 F.getFlux(Cparity * TRACK_TYPE_NUTAU, log10(neutrino.E), costh));
174 }
175
176 return flux;
177 }
178
179
180 /**
181 * Get properties of this class.
182 *
183 * \param eqpars equation parameters
184 */
186 {
187 return JOscFluxHelper(*this, eqpars);
188 }
189
190
191 /**
192 * Get properties of this class.
193 *
194 * \param eqpars equation parameters
195 */
197 {
198 return JOscFluxHelper(*this, eqpars);
199 }
200
201
202 private:
203
204 /**
205 * Auxiliary class for I/O of oscillated flux.
206 */
208 public JProperties
209 {
210 /**
211 * Constructor.
212 *
213 * \param oscflux oscillated flux
214 * \param eqpars equation parameters
215 */
216 template<class JOscFlux_t>
217 JOscFluxHelper(JOscFlux_t& oscflux,
218 const JEquationParameters& eqpars) :
219 JProperties(eqpars, 1)
220 {
221 (*this)[JEvtWeightFactor::getTypeKey()] = "oscillated neutrino flux";
222
223 if (oscflux.F) {
224
225 JProperties properties = oscflux.F.getProperties(eqpars);
226
227 (*this)["flux"] = properties;
228 }
229
230 if (oscflux.P) {
231
232 JProperties properties = oscflux.P.getProperties(eqpars);
233
234 (*this)["oscprob"] = properties;
235 }
236 }
237 };
238
239
240 JOscProbHelper P; //!< Oscillation probability calculator
241 JDiffuseFluxHelper F; //!< Diffuse flux function
242 };
243}
244
245#endif
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition of GENIE neutrino interaction types.
Definition of particle types.
Utility class to parse parameter values.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Exception for null pointer operation.
Exception for accessing a value in a collection that is outside of its range.
Low-level interface for oscillation probability calculators.
Extensions to Evt data format.
@ WEAK_NEUTRAL_CURRENT
Weak neutral current interaction.
@ WEAK_CHARGED_CURRENT
Weak charged current interaction.
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
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
Helper class for diffuse flux factor.
double getFlux(const int type, const double log10E, const double costh) const
Get flux for given particle PDG-identifier, energy and zenith-angle.
bool is_valid() const
Check whether this event-weight factor is valid.
static const char *const getTypeKey()
Get type keyword.
static JEquationParameters & getEquationParameters()
Get equation parameters.
Auxiliary class for I/O of oscillated flux.
Definition JOscFlux.hh:209
JOscFluxHelper(JOscFlux_t &oscflux, const JEquationParameters &eqpars)
Constructor.
Definition JOscFlux.hh:217
Implementation of oscillated neutrino flux.
Definition JOscFlux.hh:44
bool is_valid() const override final
Check whether this oscillated neutrino flux object is valid.
Definition JOscFlux.hh:124
JOscFlux(const JDiffuseFluxHelper &diffuseFlux, const JOscProbHelper &oscProb)
Constructor.
Definition JOscFlux.hh:51
void setOscProb(const JOscProbHelper oscProb)
Set oscillation probability calculator.
Definition JOscFlux.hh:76
double getFactor(const Evt &evt) const override final
Get flux for given event.
Definition JOscFlux.hh:140
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
Definition JOscFlux.hh:185
void setDiffuseFlux(const JDiffuseFluxHelper flux)
Set diffuse flux function.
Definition JOscFlux.hh:104
const JDiffuseFluxHelper & getDiffuseFlux() const
Get diffuse flux function.
Definition JOscFlux.hh:93
const JOscProbHelper & getOscProb() const
Get oscillation probability calculator.
Definition JOscFlux.hh:65
JOscProbHelper P
Oscillation probability calculator.
Definition JOscFlux.hh:240
JDiffuseFluxHelper F
Diffuse flux function.
Definition JOscFlux.hh:241
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const override final
Get properties of this class.
Definition JOscFlux.hh:196
Neutrino flux.
Definition JHead.hh:906
Template class for object cloning.
Definition JClonable.hh:59
Neutrino oscillation channel.
JChargeParity_t Cparity
Charge-parity.
JFlavour_t in
Incoming flavour.
JFlavour_t out
Outcoming flavour.
Helper class for oscillation probability calculators.
double getP(const JOscChannel &channel, const double energy, const double costh) const
Get oscillation probability corresponding to given oscillation channel, neutrino energy and zenith an...
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
int type
MC: particle type in PDG encoding.
Definition Trk.hh:24
Vec dir
track direction
Definition Trk.hh:18
double E
Energy [GeV] (either MC truth or reconstructed)
Definition Trk.hh:20
double z
Definition Vec.hh:14
static const int W2LIST_GSEAGEN_CC
Charged current interaction flag.