Jpp  18.3.0-rc.1
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 
32 
33  /**
34  * Default constructor.
35  */
37  {}
38 
39 
40  /**
41  * Constructor.
42  *
43  * \param pOscProb pointer to oscillation probability function
44  */
46  std::shared_ptr<JOscProbInterface>(pOscProb)
47  {}
48 
49 
50  /**
51  * Constructor.
52  *
53  * \param oscProb oscillation probability function
54  */
56  {
57  configure(oscProb);
58  }
59 
60 
61  /**
62  * Configure oscillation probability function.
63  *
64  * \param oscProb oscillation probability function
65  */
66  void configure(const JOscProbInterface& oscProb)
67  {
68  this->reset(oscProb.clone());
69  }
70 
71 
72  /**
73  * Get reference to oscillation probability interface.
74  *
75  * \return oscillation parameters
76  */
78  {
79  using namespace JPP;
80 
81  if (static_cast<const JOscProbHelper&>(*this)) {
82  return *(this->get());
83  } else {
84  THROW(JNullPointerException, "JOscProbHelper::getOscProbInterface(): Oscillation probability interface is not set.");
85  }
86  }
87 
88 
89  /**
90  * Get reference to oscillation parameters interface.
91  *
92  * \return reference to oscillation parameters interface
93  */
95  {
97  }
98 
99 
100  /**
101  * Set oscillation parameters.
102  *
103  * \param parameters oscillation parameters
104  */
105  void set(const JOscParameters_t& parameters) const
106  {
107  return getParameters().set(parameters);
108  }
109 
110 
111  /**
112  * Set value for a given oscillation parameter.
113  *
114  * \param name parameter name
115  * \param value parameter value
116  */
117  virtual void set(const std::string& name,
118  const argument_type& value) const
119  {
120  getParameters().set(name, value);
121  }
122 
123 
124  /**
125  * Set value for given list of oscillation parameters.
126  *
127  * \param name parameter name
128  * \param value parameter value
129  * \param args remaining pairs of parameter names and values
130  */
131  template<class ...Args>
132  void set(const std::string& name,
133  const argument_type& value,
134  const Args& ...args) const
135  {
136  getParameters().set(name, value, args...);
137  }
138 
139 
140  /**
141  * Get oscillation probability corresponding to given oscillation channel,
142  * neutrino energy and zenith angle.
143  *
144  * \param channel oscillation channel
145  * \param energy neutrino energy [GeV]
146  * \param costh cosine zenith angle
147  * \return oscillation probability
148  */
149  double getP(const JOscChannel& channel,
150  const double energy,
151  const double costh) const
152  {
153  return getOscProbInterface().getP(channel, energy, costh);
154  }
155 
156 
157  /**
158  * Get oscillation probability for a given set of oscillation parameters\n
159  * and a given oscillation channel.
160  *
161  * \param channel oscillation channel
162  * \param parameters oscillation parameters
163  * \param energy neutrino energy [GeV]
164  * \param costh cosine zenith angle
165  * \return oscillation probability
166  */
168  const JOscChannel& channel,
169  const double energy,
170  const double costh) const
171  {
172  return getOscProbInterface().getP(parameters, channel, energy, costh);
173  }
174 
175 
176  /**
177  * Get oscillation probability for a given oscillation parameter\n
178  * and a given oscillation channel.
179  *
180  * \param name parameter name
181  * \param value parameter value
182  * \param channel oscillation channel
183  * \param E neutrino energy [GeV]
184  * \param costh cosine zenith angle
185  * \return oscillation probability
186  */
187  double getP(const std::string& name,
188  const double value,
189  const JOscChannel& channel,
190  const double E,
191  const double costh) const
192  {
193  return getOscProbInterface().getP(name, value, channel, E, costh);
194  }
195 
196 
197  /**
198  * Get oscillation probability for a given set of oscillation parameters\n
199  * and a given oscillation channel.
200  *
201  * \param name parameter name
202  * \param value parameter value
203  * \param args remaining arguments
204  */
205  template<class ...Args>
206  double getP(const std::string& name,
207  const double value,
208  const Args& ...args) const
209  {
210  return getOscProbInterface().getP(name, value, args...);
211  }
212 
213 
214  /**
215  * Get cosine zenith angle for a given baseline.
216  *
217  * \param L baseline [km]
218  * \return cosine zenith angle
219  */
220  virtual double getCosth(const double L) const
221  {
222  return getOscProbInterface().getCosth(L);
223  }
224 
225 
226  /**
227  * Get baseline for a given cosine zenith angle.
228  *
229  * \param costh cosine zenith angle
230  * \return baseline [km]
231  */
232  virtual double getBaseline(const double costh) const
233  {
234  return getOscProbInterface().getBaseline(costh);
235  }
236  };
237 }
238 
239 #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
JOscParameters_t & getParameters() const
Get reference to oscillation parameters interface.
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...
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
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
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.
virtual clone_type clone() const override
Get clone of this object.
Definition: JClonable.hh:69
JOscProbInterface::JParameter_t JParameter_t
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.
void set(const std::string &name, const argument_type &value, const Args &...args) const
Set value for given list of oscillation parameters.
then awk string
virtual double getBaseline(const double costh) const =0
Get baseline for a given cosine zenith angle.
JOscParametersHelper_t::argument_type argument_type
void set(const JOscParameters_t &parameters) const
Set oscillation parameters.
JOscProbInterface::JOscParameters_t JOscParameters_t
JOscProbInterface::argument_type argument_type
then for APP in event gandalf start energy
Definition: JMuonMCEvt.sh:44
void reset(T &value)
Reset value.
virtual void set(const std::string &name, const argument_type &value) const
Set value for a given oscillation parameter.
void set(const std::string &name, argument_type value)
Set value for a given oscillation parameter.
virtual double getBaseline(const double costh) const
Get baseline for a given cosine zenith angle.
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...