Jpp  17.1.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"
12 #include "JAAnet/JDiffuseFlux.hh"
13 
14 
15 /**
16  * \author bjung
17  */
18 
19 namespace JAANET {
20 
21  using JLANG::JClonable;
22 
23 
24  /**
25  * Implementation of event-weight factor interface.
26  *
27  * The first template argument refers to a function of which the copy constuctor needs to be defined.
28  * The second template argument corresponds to the desired event-weight factor interface class.
29  */
30  template<class JFunction_t,
31  class JEvtWeightFactor_t>
33  public JClonable<JEvtWeightFactor_t, JEvtWeightFactorFunction<JFunction_t,
34  JEvtWeightFactor_t> >
35  {
36  /**
37  * Constructor.
38  *
39  * \param function function for event-weight factor
40  */
41  JEvtWeightFactorFunction(const JFunction_t& function) :
43  {}
44 
45 
46  /**
47  * Get weight-factor for given event.
48  *
49  * \param evt event
50  * \return event-weight factor
51  */
52  double getFactor(const Evt& evt) const override
53  {
54  return function(evt);
55  }
56 
57  private:
58 
59  JFunction_t function; //!< event-weight factor object.
60  };
61 
62 
63  /**
64  * Implementation of event-weight factor interface for diffuse flux objects.
65  *
66  * The template argument corresponds to a function of which the copy constructor needs to be defined.
67  */
68  template<class JDiffuseFluxFunction_t>
69  struct JEvtWeightFactorFunction<JDiffuseFluxFunction_t, JDiffuseFlux> :
70  public JClonable<JDiffuseFlux, JEvtWeightFactorFunction<JDiffuseFluxFunction_t,
71  JDiffuseFlux> >
72  {
73  /**
74  * Constructor.
75  *
76  * \param function flux function
77  */
78  JEvtWeightFactorFunction(const JDiffuseFluxFunction_t& function) :
80  {}
81 
82 
83  /**
84  * Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
85  *
86  * \param type PDG particle type
87  * \param log10E logarithmic neutrino energy [GeV]
88  * \param costh cosine zenith angle
89  * \return event-weight factor
90  */
91  double dNdEdOmega(int type,
92  double log10E,
93  double costh) const override
94  {
95  return function.dNdEdOmega(type, log10E, costh);
96  }
97 
98  private:
99 
100  JDiffuseFluxFunction_t function; //!< diffuse flux function object
101  };
102 
103 
104  /** Type definition of event-weight factor pointer. */
105  typedef double (*pEvtWeightFactor)(const Evt&);
106 
107 
108  /** Type definition of flux function pointer. */
110 
111 
112  /**
113  * Implementation of C-style event-weight factor.
114  *
115  * The template argument refers to the desired event-weight factor interface class.
116  */
117  template<class JEvtWeightFactor_t>
118  struct JEvtWeightFactorFunction<pEvtWeightFactor, JEvtWeightFactor_t> :
119  public JClonable<JEvtWeightFactor_t, JEvtWeightFactorFunction<pEvtWeightFactor,
120  JEvtWeightFactor_t> >
121  {
122  /**
123  * Constructor.
124  *
125  * \param pFunction pointer to event-weight factor
126  */
128  pFunction(pFunction)
129  {}
130 
131 
132  /**
133  * Get weight-factor for given event.
134  *
135  * \param evt event
136  * \return event-weight factor
137  */
138  double getFactor(const Evt& evt) const override
139  {
140  return (*pFunction)(evt);
141  }
142 
143  private:
144 
145  pEvtWeightFactor pFunction; //!< Event-weight factor pointer.
146  };
147 
148 
149  /** Type definition of pointer to diffuse flux function. */
150  typedef double (*pDiffuseFlux)(int, double, double);
151 
152 
153  /**
154  * Implementation of C-style diffuse flux event-weight factor.
155  */
156  template<>
158  public JClonable<JDiffuseFlux, JEvtWeightFactorFunction<pDiffuseFlux,
159  JDiffuseFlux> >
160  {
161  /**
162  * Constructor.
163  *
164  * \param pFunction pointer to diffuse flux function
165  */
167  pFunction(pFunction)
168  {}
169 
170  /**
171  * Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
172  *
173  * \param type PDG particle type
174  * \param log10E logarithmic neutrino energy [GeV]
175  * \param costh cosine zenith angle
176  * \return event-weight factor
177  */
178  double dNdEdOmega(int type,
179  double log10E,
180  double costh) const override
181  {
182  return (*pFunction)(type, log10E, costh);
183  }
184 
185  private:
186 
187  pDiffuseFlux pFunction; //!< Pointer to diffuse flux function.
188  };
189 
190 
191 
192  /**
193  * Auxiliary method for creating an interface to an event-weight factor.
194  *
195  * \param function function object
196  * \return event-weight factor interface
197  */
198  template<class JFunction_t, class JEvtWeightFactor_t = JEvtWeightFactor>
201  }
202 
203 
204  /**
205  * Auxiliary method for creating an interface to an event-weight factor.
206  *
207  * \param function function pointer
208  * \return event-weight factor interface
209  */
210  template<class JEvtWeightFactor_t = JEvtWeightFactor>
213  }
214 
215 
216  /**
217  * Auxiliary method for creating an interface to a flux function.
218  *
219  * \param flux flux function object
220  * \return flux function interface
221  */
222  template<class JFunction_t>
225  }
226 
227 
228  /**
229  * Auxiliary method for creating an interface to a flux function.
230  *
231  * \param flux flux function pointer
232  * \return flux function interface
233  */
236  }
237 
238 
239  /**
240  * Auxiliary method for creating an interface to a diffuse flux function.
241  *
242  * \param flux diffuse flux function object
243  * \return diffuse flux function interface
244  */
245  template<class JFunction_t>
248  }
249 
250 
251  /**
252  * Auxiliary method for creating an interface to a diffuse flux function.
253  *
254  * \param flux diffuse flux function pointer
255  * \return diffuse flux function interface
256  */
259  }
260 }
261 
262 #endif
double dNdEdOmega(int type, double log10E, double costh) const override
Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
Implementation of C-style diffuse flux event-weight factor.
JEvtWeightFactorFunction(const JDiffuseFluxFunction_t &function)
Constructor.
Implementation of event-weight factor interface.
JEvtWeightFactorFunction< JFunction_t, JFlux > make_fluxFunction(const JFunction_t &flux)
Auxiliary method for creating an interface to a flux function.
double getFactor(const Evt &evt) const override
Get weight-factor for given event.
JFunction_t function
event-weight factor object.
JEvtWeightFactorFunction< JFunction_t, JEvtWeightFactor_t > make_weightFactor(const JFunction_t &function)
Auxiliary method for creating an interface to an event-weight factor.
JEvtWeightFactorFunction< JFunction_t, JDiffuseFlux > make_diffuseFluxFunction(const JFunction_t &flux)
Auxiliary method for creating an interface to a diffuse flux function.
pEvtWeightFactor pFlux
Type definition of flux function pointer.
Neutrino flux.
Definition: JHead.hh:893
Template class for object cloning.
Definition: JClonable.hh:20
Low-level interface for diffuse fluxes.
Definition: JDiffuseFlux.hh:24
JEvtWeightFactorFunction(const JFunction_t &function)
Constructor.
double(* pDiffuseFlux)(int, double, double)
Type definition of pointer to diffuse flux function.
double dNdEdOmega(int type, double log10E, double costh) const override
Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
double getFactor(const Evt &evt) const override
Get weight-factor for given event.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
double(* pEvtWeightFactor)(const Evt &)
Type definition of event-weight factor pointer.