Jpp 21.0.0
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<JDiffuseFlux, 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 diffuse oscillated flux for given neutrino PDG-identifier, energy and zenith-angle.
132 *
133 * \param type PDG type
134 * \param log10E logarithmic neutrino energy [GeV]
135 * \param costh cosine zenith angle
136 * \return diffuse flux [GeV^-1 * m^-2 * sr^-1 * s^-1]
137 */
138 double dNdEdOmega(int type,
139 double log10E,
140 double costh) const override final
141 {
142 using namespace JPP;
143
144 double flux = 0.0;
145
146 const double E = pow(10.0, log10E);
147
148 for (int i = 0; i != NUMBER_OF_OSCCHANNELS; ++i) {
149
150 const JOscChannel& channel = getOscChannel[i];
151
152 const int inType = ((int) channel.Cparity) * ((int) channel.in);
153 const int outType = ((int) channel.Cparity) * ((int) channel.out);
154
155 if (outType == type) {
156
157 flux += ( F.getFlux(inType, log10E, costh) *
158 P.getP (channel, E, costh) );
159 }
160 }
161
162 return flux;
163 }
164
165
166 /**
167 * Get flux for given event.
168 *
169 * Note that in this evaluation the zenith-angle is defined\n
170 * with respect to the negative z-axis (i.e. a neutrino pointing straight at you\n
171 * from the center of the Earth has \f$ cos(\theta) = -1.0 \f$).
172 *
173 * \param evt event
174 * \return flux \f$ \left[\mathrm{GeV}^{-1} \, \mathrm{m}^{-2} \, \mathrm{sr}^{-1} \, \mathrm{s}^{-1}\right] \f$
175 */
176 double getFactor(const Evt& evt) const override final
177 {
178 using namespace JPP;
179
180 double flux = 0.0;
181
182 const Trk& neutrino = get_neutrino(evt);
183
184 const double costh = -neutrino.dir.z;
185 const double log10E = log10(neutrino.E);
186
187 const int interactionType = evt.w2list[W2LIST_GSEAGEN_CC];
188
189 if (interactionType == (int) JGENIEInteractionType_t::WEAK_CHARGED_CURRENT) {
190
191 return dNdEdOmega(neutrino.type, log10E, costh);
192
193 } else if (interactionType == (int) JGENIEInteractionType_t::WEAK_NEUTRAL_CURRENT) { // For NC events, the neutrino flavour is irrelevant
194
195 const int Cparity = (int) getChargeParity(neutrino);
196
197 flux += (F.getFlux(Cparity * TRACK_TYPE_NUE, log10E, costh) +
198 F.getFlux(Cparity * TRACK_TYPE_NUMU, log10E, costh) +
199 F.getFlux(Cparity * TRACK_TYPE_NUTAU, log10E, costh));
200 }
201
202 return flux;
203 }
204
205
206 /**
207 * Get properties of this class.
208 *
209 * \param eqpars equation parameters
210 */
212 {
213 return JOscFluxHelper(*this, eqpars);
214 }
215
216
217 /**
218 * Get properties of this class.
219 *
220 * \param eqpars equation parameters
221 */
223 {
224 return JOscFluxHelper(*this, eqpars);
225 }
226
227
228 private:
229
230 /**
231 * Auxiliary class for I/O of oscillated flux.
232 */
234 public JProperties
235 {
236 /**
237 * Constructor.
238 *
239 * \param oscflux oscillated flux
240 * \param eqpars equation parameters
241 */
242 template<class JOscFlux_t>
243 JOscFluxHelper(JOscFlux_t& oscflux,
244 const JEquationParameters& eqpars) :
245 JProperties(eqpars, 1)
246 {
247 (*this)[JEvtWeightFactor::getTypeKey()] = "oscillated neutrino flux";
248
249 if (oscflux.F) {
250
251 JProperties properties = oscflux.F.getProperties(eqpars);
252
253 (*this)["flux"] = properties;
254 }
255
256 if (oscflux.P) {
257
258 JProperties properties = oscflux.P.getProperties(eqpars);
259
260 (*this)["oscprob"] = properties;
261 }
262 }
263 };
264
265
266 JOscProbHelper P; //!< Oscillation probability calculator
267 JDiffuseFluxHelper F; //!< Diffuse flux function
268 };
269}
270
271#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:235
JOscFluxHelper(JOscFlux_t &oscflux, const JEquationParameters &eqpars)
Constructor.
Definition JOscFlux.hh:243
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:176
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
Definition JOscFlux.hh:211
void setDiffuseFlux(const JDiffuseFluxHelper flux)
Set diffuse flux function.
Definition JOscFlux.hh:104
double dNdEdOmega(int type, double log10E, double costh) const override final
Get diffuse oscillated flux for given neutrino PDG-identifier, energy and zenith-angle.
Definition JOscFlux.hh:138
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:266
JDiffuseFluxHelper F
Diffuse flux function.
Definition JOscFlux.hh:267
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const override final
Get properties of this class.
Definition JOscFlux.hh:222
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.