Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JEvtWeightFactorFunction.hh
Go to the documentation of this file.
1#ifndef __JAANET__JEVTWEIGHTFACTORFUNCTION__
2#define __JAANET__JEVTWEIGHTFACTORFUNCTION__
3
5
6#include "flux/Flux.hh"
7
8#include "JLang/JClonable.hh"
9
11#include "JAAnet/JFlux.hh"
13
14
15/**
16 * \author bjung
17 */
18namespace JAANET {}
19namespace JPP { using namespace JAANET; }
20
21namespace JAANET {
22
23 using JLANG::JClonable;
24
25
26 /**
27 * Implementation of event-weight factor interface.
28 *
29 * The first template argument refers to a function of which the copy constructor needs to be defined.
30 * The second template argument corresponds to the desired event-weight factor interface class.
31 */
32 template<class JFunction_t,
33 class JEvtWeightFactor_t>
35 public JClonable<JEvtWeightFactor_t, JEvtWeightFactorFunction<JFunction_t,
36 JEvtWeightFactor_t> >
37 {
39
40
41 /**
42 * Constructor.
43 *
44 * \param function function for event-weight factor
45 */
46 JEvtWeightFactorFunction(const JFunction_t& function) :
48 {}
49
50
51 /**
52 * Get weight-factor for given event.
53 *
54 * \param evt event
55 * \return event-weight factor
56 */
57 double getFactor(const Evt& evt) const override final
58 {
59 return function(evt);
60 }
61
62
63 private:
64
65 JFunction_t function; //!< event-weight factor object.
66 };
67
68
69 /**
70 * Implementation of event-weight factor interface for diffuse flux objects.
71 *
72 * The template argument corresponds to a function of which the copy constructor needs to be defined.
73 */
74 template<class JDiffuseFluxFunction_t>
75 struct JEvtWeightFactorFunction<JDiffuseFluxFunction_t, JDiffuseFlux> final :
76 public JClonable<JDiffuseFlux, JEvtWeightFactorFunction<JDiffuseFluxFunction_t,
77 JDiffuseFlux> >
78 {
80
81
82 /**
83 * Constructor.
84 *
85 * \param function flux function
86 */
87 JEvtWeightFactorFunction(const JDiffuseFluxFunction_t& function) :
89 {}
90
91
92 /**
93 * Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
94 *
95 * \param type PDG particle type
96 * \param log10E logarithmic neutrino energy [GeV]
97 * \param costh cosine zenith angle
98 * \return event-weight factor
99 */
100 double dNdEdOmega(int type,
101 double log10E,
102 double costh) const override final
103 {
104 return function.dNdEdOmega(type, log10E, costh);
105 }
106
107 private:
108
109 JDiffuseFluxFunction_t function; //!< diffuse flux function object
110 };
111
112
113 /**
114 * Specialisation of event-weight factor interface for atmospheric neutrino flux.
115 */
116 template<>
117 struct JEvtWeightFactorFunction<Flux_Atmospheric, JDiffuseFlux> final :
118 public JClonable<JDiffuseFlux, JEvtWeightFactorFunction<Flux_Atmospheric, JDiffuseFlux> >
119 {
121
122
123 /**
124 * Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
125 *
126 * \param type PDG particle type
127 * \param log10E logarithmic neutrino energy [GeV]
128 * \param costh cosine zenith angle
129 * \return event-weight factor
130 */
131 double dNdEdOmega(int type,
132 double log10E,
133 double costh) const override final
134 {
135 return flux.dNdEdOmega(type, log10E, costh);
136 }
137
138
139 /**
140 * Get properties of this class.
141 *
142 * \param eqpars equation parameters
143 */
145 {
146 return JFluxFunctionHelper(eqpars);
147 }
148
149
150 /**
151 * Get properties of this class.
152 *
153 * \param eqpars equation parameters
154 */
156 {
157 return JFluxFunctionHelper(eqpars);
158 }
159
160
161 private:
162
163 /**
164 * Auxiliary class for I/O of atmospheric neutrino flux function.
165 */
167 public JProperties
168 {
169 /**
170 * Constructor.
171 *
172 * \param eqpars equation parameters
173 */
175 JProperties(eqpars, 1)
176 {
177 (*this)[JEvtWeightFactor::getTypeKey()] = "atmospheric neutrino flux";
178 }
179 };
180
181 static const Flux_Atmospheric flux; //!< atmospheric flux function
182 };
183
184
185 const Flux_Atmospheric JEvtWeightFactorFunction<Flux_Atmospheric, JDiffuseFlux>::flux = Flux_Atmospheric(); //!< Atmospheric flux function initialisation
186
187
188 /** Type alias for atmospheric flux function interface **/
190
191
192 /** Type definition of event-weight factor pointer. */
193 typedef double (*pEvtWeightFactor)(const Evt&);
194
195
196 /** Type definition of flux function pointer. */
198
199
200 /**
201 * Implementation of C-style event-weight factor.
202 *
203 * The template argument refers to the desired event-weight factor interface class.
204 */
205 template<class JEvtWeightFactor_t>
206 struct JEvtWeightFactorFunction<pEvtWeightFactor, JEvtWeightFactor_t> final :
207 public JClonable<JEvtWeightFactor_t, JEvtWeightFactorFunction<pEvtWeightFactor,
208 JEvtWeightFactor_t> >
209 {
210 /**
211 * Constructor.
212 *
213 * \param pFunction pointer to event-weight factor
214 */
216 pFunction(pFunction)
217 {}
218
219
220 /**
221 * Get weight-factor for given event.
222 *
223 * \param evt event
224 * \return event-weight factor
225 */
226 double getFactor(const Evt& evt) const override final
227 {
228 return (*pFunction)(evt);
229 }
230
231 private:
232
233 pEvtWeightFactor pFunction; //!< Event-weight factor pointer.
234 };
235
236
237 /** Type definition of pointer to diffuse flux function. */
238 typedef double (*pDiffuseFlux)(int, double, double);
239
240
241 /**
242 * Implementation of C-style diffuse flux event-weight factor.
243 */
244 template<>
246 public JClonable<JDiffuseFlux, JEvtWeightFactorFunction<pDiffuseFlux,
247 JDiffuseFlux> >
248 {
249 /**
250 * Constructor.
251 *
252 * \param pFunction pointer to diffuse flux function
253 */
255 pFunction(pFunction)
256 {}
257
258
259 /**
260 * Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
261 *
262 * \param type PDG particle type
263 * \param log10E logarithmic neutrino energy [GeV]
264 * \param costh cosine zenith angle
265 * \return event-weight factor
266 */
267 double dNdEdOmega(int type,
268 double log10E,
269 double costh) const override final
270 {
271 return (*pFunction)(type, log10E, costh);
272 }
273
274 private:
275
276 pDiffuseFlux pFunction; //!< Pointer to diffuse flux function.
277 };
278
279
280
281 /**
282 * Auxiliary method for creating an interface to an event-weight factor.
283 *
284 * \param function function object
285 * \return event-weight factor interface
286 */
287 template<class JFunction_t, class JEvtWeightFactor_t = JEvtWeightFactor>
291
292
293 /**
294 * Auxiliary method for creating an interface to an event-weight factor.
295 *
296 * \param function function pointer
297 * \return event-weight factor interface
298 */
299 template<class JEvtWeightFactor_t = JEvtWeightFactor>
303
304
305 /**
306 * Auxiliary method for creating an interface to a flux function.
307 *
308 * \param flux flux function object
309 * \return flux function interface
310 */
311 template<class JFunction_t>
315
316
317 /**
318 * Auxiliary method for creating an interface to a flux function.
319 *
320 * \param flux flux function pointer
321 * \return flux function interface
322 */
326
327
328 /**
329 * Auxiliary method for creating an interface to a diffuse flux function.
330 *
331 * \param flux diffuse flux function object
332 * \return diffuse flux function interface
333 */
334 template<class JFunction_t>
338
339
340 /**
341 * Auxiliary method for creating an interface to a diffuse flux function.
342 *
343 * \param flux diffuse flux function pointer
344 * \return diffuse flux function interface
345 */
349}
350
351#endif
Utility class to parse parameter values.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Extensions to Evt data format.
JEvtWeightFactorFunction< JFunction_t, JDiffuseFlux > make_diffuseFluxFunction(const JFunction_t &flux)
Auxiliary method for creating an interface to a diffuse flux function.
JEvtWeightFactorFunction< JFunction_t, JFlux > make_fluxFunction(const JFunction_t &flux)
Auxiliary method for creating an interface to a flux function.
double(* pDiffuseFlux)(int, double, double)
Type definition of pointer to diffuse flux function.
pEvtWeightFactor pFlux
Type definition of flux function pointer.
double(* pEvtWeightFactor)(const Evt &)
Type definition of event-weight factor pointer.
JEvtWeightFactorFunction< JFunction_t, JEvtWeightFactor_t > make_weightFactor(const JFunction_t &function)
Auxiliary method for creating an interface to an event-weight factor.
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
Low-level interface for diffuse fluxes.
Specialisation of event-weight factor interface for atmospheric neutrino flux.
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
static const Flux_Atmospheric flux
atmospheric flux function
double dNdEdOmega(int type, double log10E, double costh) const override final
Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
JEvtWeightFactorFunction< Flux_Atmospheric, JDiffuseFlux > JEvtWeightFactorFunction_t
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const override final
Get properties of this class.
JEvtWeightFactorFunction(const JDiffuseFluxFunction_t &function)
Constructor.
double dNdEdOmega(int type, double log10E, double costh) const override final
Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
JEvtWeightFactorFunction< JDiffuseFluxFunction_t, JDiffuseFlux > JEvtWeightFactorFunction_t
double dNdEdOmega(int type, double log10E, double costh) const override final
Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
double getFactor(const Evt &evt) const override final
Get weight-factor for given event.
Implementation of event-weight factor interface.
JEvtWeightFactorFunction< JFunction_t, JEvtWeightFactor_t > JEvtWeightFactorFunction_t
double getFactor(const Evt &evt) const override final
Get weight-factor for given event.
JEvtWeightFactorFunction(const JFunction_t &function)
Constructor.
JFunction_t function
event-weight factor object.
static JEquationParameters & getEquationParameters()
Get equation parameters.
Neutrino flux.
Definition JHead.hh:906
Template class for object cloning.
Definition JClonable.hh:59