Jpp  19.1.0-rc.1
the software that should make you happy
JOscProbHelper.hh
Go to the documentation of this file.
1 #ifndef __JOSCPROB__JOSCPROBHELPER__
2 #define __JOSCPROB__JOSCPROBHELPER__
3 
4 #include <memory>
5 
6 #include "JLang/JException.hh"
7 
11 
12 
13 /**
14  * \author bjung
15  */
16 
17 namespace JOSCPROB {}
18 namespace JPP { using namespace JOSCPROB; }
19 
20 namespace JOSCPROB {
21 
22  /**
23  * Helper class for oscillation probabilities.
24  */
25  struct JOscProbHelper :
26  public std::shared_ptr<JOscProbInterface>
27  {
31 
34 
35  typedef std::shared_ptr<JOscProbInterface> pointer_type;
36 
37 
38  /**
39  * Default constructor.
40  */
42  {}
43 
44 
45  /**
46  * Constructor.
47  *
48  * \param pOscProb shared pointer to oscillation probability function
49  */
50  JOscProbHelper(const pointer_type& pOscProb) :
51  pointer_type(pOscProb)
52  {}
53 
54 
55  /**
56  * Constructor.
57  *
58  * \param oscProb oscillation probability function
59  */
61  {
62  configure(oscProb);
63  }
64 
65 
66  /**
67  * Configure oscillation probability function.
68  *
69  * \param oscProb oscillation probability function
70  */
71  void configure(const pointer_type& pOscProb)
72  {
73  static_cast<pointer_type&>(*this) = pOscProb;
74  }
75 
76 
77  /**
78  * Configure oscillation probability function.
79  *
80  * \param oscProb oscillation probability function
81  */
82  void configure(const JOscProbInterface& oscProb)
83  {
84  this->reset(oscProb.clone());
85  }
86 
87 
88  /**
89  * Get reference to oscillation probability interface.
90  *
91  * \return oscillation parameters
92  */
94  {
95  using namespace JPP;
96 
97  if (static_cast<const JOscProbHelper&>(*this)) {
98  return *(this->get());
99  } else {
100  THROW(JNullPointerException, "JOscProbHelper::getOscProbInterface(): Oscillation probability interface is not set.");
101  }
102  }
103 
104 
105  /**
106  * Get reference to oscillation parameters interface.
107  *
108  * \return reference to oscillation parameters interface
109  */
111  {
113  }
114 
115 
116  /**
117  * Set oscillation parameters.
118  *
119  * \param parameters oscillation parameters
120  */
121  void set(const JOscParameters_t& parameters) const
122  {
123  return getParameters().set(parameters);
124  }
125 
126 
127  /**
128  * Set value for a given oscillation parameter.
129  *
130  * \param name parameter name
131  * \param value parameter value
132  */
133  void set(const std::string& name,
134  const value_type& value) const
135  {
136  getParameters().set(name, value);
137  }
138 
139 
140  /**
141  * Set value for given list of oscillation parameters.
142  *
143  * \param name parameter name
144  * \param value parameter value
145  * \param args remaining pairs of parameter names and values
146  */
147  template<class ...Args>
148  void set(const std::string& name,
149  const value_type& value,
150  const Args& ...args) const
151  {
152  getParameters().set(name, value, args...);
153  }
154 
155 
156  /**
157  * Get oscillation probability corresponding to given oscillation channel,
158  * neutrino energy and zenith angle.
159  *
160  * \param channel oscillation channel
161  * \param energy neutrino energy [GeV]
162  * \param costh cosine zenith angle
163  * \return oscillation probability
164  */
165  double getP(const JOscChannel& channel,
166  const double energy,
167  const double costh) const
168  {
169  return getOscProbInterface().getP(channel, energy, costh);
170  }
171 
172 
173  /**
174  * Get oscillation probability for a given set of oscillation parameters\n
175  * and a given oscillation channel.
176  *
177  * \param channel oscillation channel
178  * \param parameters oscillation parameters
179  * \param energy neutrino energy [GeV]
180  * \param costh cosine zenith angle
181  * \return oscillation probability
182  */
183  double getP(const JOscParameters_t& parameters,
184  const JOscChannel& channel,
185  const double energy,
186  const double costh) const
187  {
188  return getOscProbInterface().getP(parameters, channel, energy, costh);
189  }
190 
191 
192  /**
193  * Get oscillation probability for a given oscillation parameter\n
194  * and a given oscillation channel.
195  *
196  * \param name parameter name
197  * \param value parameter value
198  * \param channel oscillation channel
199  * \param E neutrino energy [GeV]
200  * \param costh cosine zenith angle
201  * \return oscillation probability
202  */
203  double getP(const std::string& name,
204  const double value,
205  const JOscChannel& channel,
206  const double E,
207  const double costh) const
208  {
209  return getOscProbInterface().getP(name, value, channel, E, costh);
210  }
211 
212 
213  /**
214  * Get oscillation probability for a given set of oscillation parameters\n
215  * and a given oscillation channel.
216  *
217  * \param name parameter name
218  * \param value parameter value
219  * \param args remaining arguments
220  */
221  template<class ...Args>
222  double getP(const std::string& name,
223  const double value,
224  const Args& ...args) const
225  {
226  return getOscProbInterface().getP(name, value, args...);
227  }
228 
229 
230  /**
231  * Get cosine zenith angle for a given baseline.
232  *
233  * \param L baseline [km]
234  * \return cosine zenith angle
235  */
236  double getCosth(const double L) const
237  {
238  return getOscProbInterface().getCosth(L);
239  }
240 
241 
242  /**
243  * Get baseline for a given cosine zenith angle.
244  *
245  * \param costh cosine zenith angle
246  * \return baseline [km]
247  */
248  double getBaseline(const double costh) const
249  {
250  return getOscProbInterface().getBaseline(costh);
251  }
252  };
253 }
254 
255 #endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Exception for null pointer operation.
Definition: JException.hh:234
Parameter class.
Definition: JParameter.hh:36
Interface class for sets of oscillation parameters.
void set(const std::string &name, const value_type &value)
Set value for a given oscillation parameter.
Low-level interface for oscillation probability calculators.
virtual double getP(const JOscChannel &channel, const double E, const double costh) const =0
Get oscillation probability for a given oscillation channel.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void reset(T &value)
Reset value.
virtual clone_type clone() const override
Get clone of this object.
Definition: JClonable.hh:69
double getCosth(const double L) const
Get cosine zenith angle for a given baseline.
double getBaseline(const double costh) const
Get baseline for a given cosine zenith angle.
Neutrino oscillation channel.
Definition: JOscChannel.hh:112
JOscParameters_t & getParameters() const
Get reference to oscillation parameters interface.
JOscParameters_t::argument_type argument_type
Helper class for oscillation probabilities.
JOscParameterReferences_t & getParameters() const
Get reference to oscillation parameters interface.
void set(const std::string &name, const value_type &value) const
Set value for a given oscillation parameter.
void set(const JOscParameters_t &parameters) const
Set oscillation parameters.
double getP(const std::string &name, const double value, const Args &...args) const
Get oscillation probability for a given set of oscillation parameters and a given oscillation channel...
JOscProbHelper(const pointer_type &pOscProb)
Constructor.
JOscProbHelper(const JOscProbInterface &oscProb)
Constructor.
JOscProbInterface::JOscParameterReferences_t JOscParameterReferences_t
std::shared_ptr< JOscProbInterface > pointer_type
JOscProbInterface & getOscProbInterface() const
Get reference to oscillation probability interface.
double getBaseline(const double costh) const
Get baseline for a given cosine zenith angle.
JOscProbHelper()
Default constructor.
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...
double getP(const std::string &name, const double value, const JOscChannel &channel, const double E, const double costh) const
Get oscillation probability for a given oscillation parameter and a given oscillation channel.
JOscProbInterface::JOscParameters_t JOscParameters_t
JOscProbInterface::JParameter_t JParameter_t
double getP(const JOscParameters_t &parameters, const JOscChannel &channel, const double energy, const double costh) const
Get oscillation probability for a given set of oscillation parameters and a given oscillation channel...
void configure(const JOscProbInterface &oscProb)
Configure oscillation probability function.
void configure(const pointer_type &pOscProb)
Configure oscillation probability function.
void set(const std::string &name, const value_type &value, const Args &...args) const
Set value for given list of oscillation parameters.
JOscProbInterface::value_type value_type
double getCosth(const double L) const
Get cosine zenith angle for a given baseline.
JOscProbInterface::argument_type argument_type