Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
36  /**
37  * Default constructor.
38  */
40  {}
41 
42 
43  /**
44  * Constructor.
45  *
46  * \param pOscProb pointer to oscillation probability function
47  */
49  std::shared_ptr<JOscProbInterface>(pOscProb)
50  {}
51 
52 
53  /**
54  * Constructor.
55  *
56  * \param oscProb oscillation probability function
57  */
59  {
60  configure(oscProb);
61  }
62 
63 
64  /**
65  * Configure oscillation probability function.
66  *
67  * \param oscProb oscillation probability function
68  */
69  void configure(const JOscProbInterface& oscProb)
70  {
71  this->reset(oscProb.clone());
72  }
73 
74 
75  /**
76  * Get reference to oscillation probability interface.
77  *
78  * \return oscillation parameters
79  */
81  {
82  using namespace JPP;
83 
84  if (static_cast<const JOscProbHelper&>(*this)) {
85  return *(this->get());
86  } else {
87  THROW(JNullPointerException, "JOscProbHelper::getOscProbInterface(): Oscillation probability interface is not set.");
88  }
89  }
90 
91 
92  /**
93  * Get reference to oscillation parameters interface.
94  *
95  * \return reference to oscillation parameters interface
96  */
98  {
100  }
101 
102 
103  /**
104  * Set oscillation parameters.
105  *
106  * \param parameters oscillation parameters
107  */
108  void set(const JOscParameters_t& parameters) const
109  {
110  return getParameters().set(parameters);
111  }
112 
113 
114  /**
115  * Set value for a given oscillation parameter.
116  *
117  * \param name parameter name
118  * \param value parameter value
119  */
120  virtual void set(const std::string& name,
121  const value_type& value) const
122  {
123  getParameters().set(name, value);
124  }
125 
126 
127  /**
128  * Set value for given list of oscillation parameters.
129  *
130  * \param name parameter name
131  * \param value parameter value
132  * \param args remaining pairs of parameter names and values
133  */
134  template<class ...Args>
135  void set(const std::string& name,
136  const value_type& value,
137  const Args& ...args) const
138  {
139  getParameters().set(name, value, args...);
140  }
141 
142 
143  /**
144  * Get oscillation probability corresponding to given oscillation channel,
145  * neutrino energy and zenith angle.
146  *
147  * \param channel oscillation channel
148  * \param energy neutrino energy [GeV]
149  * \param costh cosine zenith angle
150  * \return oscillation probability
151  */
152  double getP(const JOscChannel& channel,
153  const double energy,
154  const double costh) const
155  {
156  return getOscProbInterface().getP(channel, energy, costh);
157  }
158 
159 
160  /**
161  * Get oscillation probability for a given set of oscillation parameters\n
162  * and a given oscillation channel.
163  *
164  * \param channel oscillation channel
165  * \param parameters oscillation parameters
166  * \param energy neutrino energy [GeV]
167  * \param costh cosine zenith angle
168  * \return oscillation probability
169  */
171  const JOscChannel& channel,
172  const double energy,
173  const double costh) const
174  {
175  return getOscProbInterface().getP(parameters, channel, energy, costh);
176  }
177 
178 
179  /**
180  * Get oscillation probability for a given oscillation parameter\n
181  * and a given oscillation channel.
182  *
183  * \param name parameter name
184  * \param value parameter value
185  * \param channel oscillation channel
186  * \param E neutrino energy [GeV]
187  * \param costh cosine zenith angle
188  * \return oscillation probability
189  */
190  double getP(const std::string& name,
191  const double value,
192  const JOscChannel& channel,
193  const double E,
194  const double costh) const
195  {
196  return getOscProbInterface().getP(name, value, channel, E, costh);
197  }
198 
199 
200  /**
201  * Get oscillation probability for a given set of oscillation parameters\n
202  * and a given oscillation channel.
203  *
204  * \param name parameter name
205  * \param value parameter value
206  * \param args remaining arguments
207  */
208  template<class ...Args>
209  double getP(const std::string& name,
210  const double value,
211  const Args& ...args) const
212  {
213  return getOscProbInterface().getP(name, value, args...);
214  }
215 
216 
217  /**
218  * Get cosine zenith angle for a given baseline.
219  *
220  * \param L baseline [km]
221  * \return cosine zenith angle
222  */
223  virtual double getCosth(const double L) const
224  {
225  return getOscProbInterface().getCosth(L);
226  }
227 
228 
229  /**
230  * Get baseline for a given cosine zenith angle.
231  *
232  * \param costh cosine zenith angle
233  * \return baseline [km]
234  */
235  virtual double getBaseline(const double costh) const
236  {
237  return getOscProbInterface().getBaseline(costh);
238  }
239  };
240 }
241 
242 #endif
JOscProbHelper(JOscProbInterface *pOscProb)
Constructor.
JOscProbInterface & getOscProbInterface() const
Get reference to oscillation probability interface.
Exceptions.
JOscParameters_t & getParameters() const
Get reference to oscillation parameters interface.
virtual double getP(const JOscChannel &channel, const double E, const double costh) const =0
Get oscillation probability for a given oscillation channel.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
Neutrino oscillation channel.
Definition: JOscChannel.hh:110
Parameter class.
Definition: JParameter.hh:34
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...
void set(const std::string &name, const value_type &value, const Args &...args) const
Set value for given list of oscillation parameters.
Low-level interface for oscillation probability calculators.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
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...
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Helper class for oscillation probabilities.
JOscProbHelper()
Default constructor.
void configure(const JOscProbInterface &oscProb)
Configure oscillation probability function.
void set(const std::string &name, const value_type &value)
Set value for a given oscillation parameter.
virtual clone_type clone() const override
Get clone of this object.
Definition: JClonable.hh:69
JOscProbInterface::JOscParameterReferences_t JOscParameterReferences_t
JOscProbInterface::JParameter_t JParameter_t
virtual void set(const std::string &name, const value_type &value) const
Set value for a given oscillation parameter.
virtual double getCosth(const double L) const
Get cosine zenith angle for a given baseline.
Exception for null pointer operation.
Definition: JException.hh:232
virtual double getCosth(const double L) const =0
Get cosine zenith angle for a given baseline.
virtual double getBaseline(const double costh) const =0
Get baseline for a given cosine zenith angle.
JOscProbInterface::value_type value_type
void set(const JOscParameters_t &parameters) const
Set oscillation parameters.
JOscProbInterface::JOscParameters_t JOscParameters_t
then fatal The output file must have the wildcard in the name
Definition: JCanberra.sh:31
JOscProbInterface::argument_type argument_type
then for APP in event gandalf start energy
Definition: JMuonMCEvt.sh:44
void reset(T &value)
Reset value.
virtual double getBaseline(const double costh) const
Get baseline for a given cosine zenith angle.
JOscParameterReferences_t & getParameters() const
Get reference to oscillation parameters interface.
JOscParameters_t::argument_type argument_type
JOscProbHelper(const JOscProbInterface &oscProb)
Constructor.
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...
Interface class for sets of oscillation parameters.
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...