Jpp  18.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JOscProbFunction.hh
Go to the documentation of this file.
1 #ifndef __JOSCPROB__JOSCPROBFUNCTION__
2 #define __JOSCPROB__JOSCPROBFUNCTION__
3 
4 #include "JLang/JClonable.hh"
5 
6 #include "JOscProb/JOscProb.hh"
8 
9 
10 /**
11  * \author bjung
12  */
13 
14 namespace JOSCPROB {}
15 namespace JPP { using namespace JOSCPROB; }
16 
17 namespace JOSCPROB {
18 
19  using JLANG::JClonable;
20 
21 
22  /**
23  * Implementation of oscillation probability function interface.
24  *
25  * The template argument refers to a function of which the copy constuctor needs to be defined.
26  */
27  template<class JFunction_t>
29  public JClonable<JOscProb, JOscProbFunction<JFunction_t> >
30  {
31  /**
32  * Constructor.
33  *
34  * \param function oscillation probability function
35  */
36  JOscProbFunction(const JFunction_t& function) :
38  {}
39 
40 
41  /**
42  * Get oscillation probability for given oscillation channel.
43  *
44  * \param channel oscillation channel
45  * \param energy neutrino energy [GeV]
46  * \param costh cosine zenith angle
47  * \return oscillation probability
48  */
49  double getOscProb(const JOscChannel& channel,
50  const double energy,
51  const double costh) const override
52  {
53  return function(channel, energy, costh);
54  }
55 
56  private:
57 
58  JFunction_t function; //!< oscillation probability function
59  };
60 
61 
62  /* Type definition of pointer to oscillation probability function. */
63  typedef double (*pOscProb)(const JOscChannel&, const double, const double);
64 
65 
66  /**
67  * Implementation of C-style oscillation probability function.
68  */
69  template<>
71  public JClonable< JOscProb, JOscProbFunction<pOscProb> >
72  {
73  /**
74  * Constructor.
75  *
76  * \param pFunction oscillation probability function
77  */
79  pFunction(pFunction)
80  {}
81 
82 
83  /**
84  * Get oscillation probability for given oscillation channel.
85  *
86  * \param channel oscillation channel
87  * \param energy neutrino energy [GeV]
88  * \param costh cosine zenith angle
89  * \return oscillation probability
90  */
91  double getOscProb(const JOscChannel& channel,
92  const double energy,
93  const double costh) const override
94  {
95  return (*pFunction)(channel, energy, costh);
96  }
97 
98  private:
99 
101  };
102 
103 
104  /**
105  * Auxiliary method for creating an interface to an oscillation probability function.
106  *
107  * \param function oscillation probability function object
108  * \return oscillation probability function interface
109  */
110  template<class JFunction_t>
111  inline JOscProbFunction<JFunction_t> make_oscProbFunction(const JFunction_t& function) {
112  return JOscProbFunction<JFunction_t>(function);
113  }
114 
115 
116  /**
117  * Auxiliary method for creating an interface to an oscillation probability function.
118  *
119  * \param function oscillation probability function pointer
120  * \return oscillation probability function interface
121  */
123  return JOscProbFunction<pOscProb>(function);
124  }
125 }
126 
127 #endif
Implementation of C-style oscillation probability function.
double(* pOscProb)(const JOscChannel &, const double, const double)
Implementation of oscillation probability function interface.
Neutrino oscillation channel.
Definition: JOscChannel.hh:110
JFunction_t function
oscillation probability function
JOscProbFunction< JFunction_t > make_oscProbFunction(const JFunction_t &function)
Auxiliary method for creating an interface to an oscillation probability function.
Template class for object cloning.
Definition: JClonable.hh:20
JOscProbFunction(const JFunction_t &function)
Constructor.
double getOscProb(const JOscChannel &channel, const double energy, const double costh) const override
Get oscillation probability for given oscillation channel.
then for APP in event gandalf start energy
Definition: JMuonMCEvt.sh:44
double getOscProb(const JOscChannel &channel, const double energy, const double costh) const override
Get oscillation probability for given oscillation channel.
JOscProbFunction(pOscProb pFunction)
Constructor.