Jpp  18.2.0
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 namespace JPP { using namespace JAANET; }
21 
22 namespace JAANET {
23 
24  using JLANG::JClonable;
25 
26 
27  /**
28  * Implementation of event-weight factor interface.
29  *
30  * The first template argument refers to a function of which the copy constuctor needs to be defined.
31  * The second template argument corresponds to the desired event-weight factor interface class.
32  */
33  template<class JFunction_t,
34  class JEvtWeightFactor_t>
36  public JClonable<JEvtWeightFactor_t, JEvtWeightFactorFunction<JFunction_t,
37  JEvtWeightFactor_t> >
38  {
39  /**
40  * Constructor.
41  *
42  * \param function function for event-weight factor
43  */
44  JEvtWeightFactorFunction(const JFunction_t& function) :
46  {}
47 
48 
49  /**
50  * Get weight-factor for given event.
51  *
52  * \param evt event
53  * \return event-weight factor
54  */
55  double getFactor(const Evt& evt) const override
56  {
57  return function(evt);
58  }
59 
60  private:
61 
62  JFunction_t function; //!< event-weight factor object.
63  };
64 
65 
66  /**
67  * Implementation of event-weight factor interface for diffuse flux objects.
68  *
69  * The template argument corresponds to a function of which the copy constructor needs to be defined.
70  */
71  template<class JDiffuseFluxFunction_t>
72  struct JEvtWeightFactorFunction<JDiffuseFluxFunction_t, JDiffuseFlux> :
73  public JClonable<JDiffuseFlux, JEvtWeightFactorFunction<JDiffuseFluxFunction_t,
74  JDiffuseFlux> >
75  {
76  /**
77  * Constructor.
78  *
79  * \param function flux function
80  */
81  JEvtWeightFactorFunction(const JDiffuseFluxFunction_t& function) :
83  {}
84 
85 
86  /**
87  * Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
88  *
89  * \param type PDG particle type
90  * \param log10E logarithmic neutrino energy [GeV]
91  * \param costh cosine zenith angle
92  * \return event-weight factor
93  */
94  double dNdEdOmega(int type,
95  double log10E,
96  double costh) const override
97  {
98  return function.dNdEdOmega(type, log10E, costh);
99  }
100 
101  private:
102 
103  JDiffuseFluxFunction_t function; //!< diffuse flux function object
104  };
105 
106 
107  /** Type definition of event-weight factor pointer. */
108  typedef double (*pEvtWeightFactor)(const Evt&);
109 
110 
111  /** Type definition of flux function pointer. */
113 
114 
115  /**
116  * Implementation of C-style event-weight factor.
117  *
118  * The template argument refers to the desired event-weight factor interface class.
119  */
120  template<class JEvtWeightFactor_t>
121  struct JEvtWeightFactorFunction<pEvtWeightFactor, JEvtWeightFactor_t> :
122  public JClonable<JEvtWeightFactor_t, JEvtWeightFactorFunction<pEvtWeightFactor,
123  JEvtWeightFactor_t> >
124  {
125  /**
126  * Constructor.
127  *
128  * \param pFunction pointer to event-weight factor
129  */
131  pFunction(pFunction)
132  {}
133 
134 
135  /**
136  * Get weight-factor for given event.
137  *
138  * \param evt event
139  * \return event-weight factor
140  */
141  double getFactor(const Evt& evt) const override
142  {
143  return (*pFunction)(evt);
144  }
145 
146  private:
147 
148  pEvtWeightFactor pFunction; //!< Event-weight factor pointer.
149  };
150 
151 
152  /** Type definition of pointer to diffuse flux function. */
153  typedef double (*pDiffuseFlux)(int, double, double);
154 
155 
156  /**
157  * Implementation of C-style diffuse flux event-weight factor.
158  */
159  template<>
161  public JClonable<JDiffuseFlux, JEvtWeightFactorFunction<pDiffuseFlux,
162  JDiffuseFlux> >
163  {
164  /**
165  * Constructor.
166  *
167  * \param pFunction pointer to diffuse flux function
168  */
170  pFunction(pFunction)
171  {}
172 
173  /**
174  * Get event-weight factor for given particle PDG-identifier, energy and zenith-angle.
175  *
176  * \param type PDG particle type
177  * \param log10E logarithmic neutrino energy [GeV]
178  * \param costh cosine zenith angle
179  * \return event-weight factor
180  */
181  double dNdEdOmega(int type,
182  double log10E,
183  double costh) const override
184  {
185  return (*pFunction)(type, log10E, costh);
186  }
187 
188  private:
189 
190  pDiffuseFlux pFunction; //!< Pointer to diffuse flux function.
191  };
192 
193 
194 
195  /**
196  * Auxiliary method for creating an interface to an event-weight factor.
197  *
198  * \param function function object
199  * \return event-weight factor interface
200  */
201  template<class JFunction_t, class JEvtWeightFactor_t = JEvtWeightFactor>
204  }
205 
206 
207  /**
208  * Auxiliary method for creating an interface to an event-weight factor.
209  *
210  * \param function function pointer
211  * \return event-weight factor interface
212  */
213  template<class JEvtWeightFactor_t = JEvtWeightFactor>
216  }
217 
218 
219  /**
220  * Auxiliary method for creating an interface to a flux function.
221  *
222  * \param flux flux function object
223  * \return flux function interface
224  */
225  template<class JFunction_t>
228  }
229 
230 
231  /**
232  * Auxiliary method for creating an interface to a flux function.
233  *
234  * \param flux flux function pointer
235  * \return flux function interface
236  */
239  }
240 
241 
242  /**
243  * Auxiliary method for creating an interface to a diffuse flux function.
244  *
245  * \param flux diffuse flux function object
246  * \return diffuse flux function interface
247  */
248  template<class JFunction_t>
251  }
252 
253 
254  /**
255  * Auxiliary method for creating an interface to a diffuse flux function.
256  *
257  * \param flux diffuse flux function pointer
258  * \return diffuse flux function interface
259  */
262  }
263 }
264 
265 #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:906
Template class for object cloning.
Definition: JClonable.hh:20
Low-level interface for diffuse fluxes.
Definition: JDiffuseFlux.hh:27
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.