Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JOscProbInterface.hh
Go to the documentation of this file.
1#ifndef __JOSCPROB__JOSCPROBINTERFACE__
2#define __JOSCPROB__JOSCPROBINTERFACE__
3
4#include <memory>
5
6#include "JLang/JClonable.hh"
7#include "JLang/JException.hh"
10
14
15
16/**
17 * \author bjung, mdejong
18 */
19
20namespace JOSCPROB {}
21namespace JPP { using namespace JOSCPROB; }
22
23namespace JOSCPROB {
24
25 using JLANG::JClonable;
26
27
28 /**
29 * Low-level interface for oscillation probability calculators.
30 */
33 public JOscParametersHelper<double&>,
34 public JClonable<JOscProbInterface>
35 {
36 public:
37
39
42
45
46
47 /**
48 * Default constructor.
49 */
52
53
54 /**
55 * Constructor.
56 *
57 * \param parameters oscillation parameters
58 */
60 JOscParametersHelper_t(parameters)
61 {}
62
63
64 /**
65 * Constructor.
66 *
67 * \param parameters oscillation parameters
68 * \param name parameter name
69 * \param value parameter value
70 * \param args remaining pairs of parameter names and values
71 */
72 template<class ...Args>
74 const std::string& name,
75 double& value,
76 const Args& ...args) :
77 JOscParametersHelper_t(parameters, name, value, args...)
78 {}
79
80
81 /**
82 * Virtual destructor.
83 */
85 {}
86
87
88 /**
89 * Get type keyword.
90 *
91 * \return type keyword
92 */
93 static const char* const getTypeKey()
94 {
95 return "type";
96 }
97
98
99 /**
100 * Get oscillation probability for a given oscillation channel.
101 *
102 * \param channel oscillation channel
103 * \param E neutrino energy [GeV]
104 * \param costh cosine zenith angle
105 * \return oscillation probability
106 */
107 virtual double getP(const JOscChannel& channel,
108 const double E,
109 const double costh) const = 0;
110
111
112 /**
113 * Get oscillation probability for a given set of oscillation parameters\n
114 * and a given oscillation channel.
115 *
116 * \param channel oscillation channel
117 * \param parameters oscillation parameters
118 * \param E neutrino energy [GeV]
119 * \param costh cosine zenith angle
120 * \return oscillation probability
121 */
122 double getP(const JOscParameters_t& parameters,
123 const JOscChannel& channel,
124 const double E,
125 const double costh) const
126 {
127 this->set(parameters);
128
129 return getP(channel, E, costh);
130 }
131
132
133 /**
134 * Get oscillation probability for a given oscillation parameter\n
135 * and a given oscillation channel.
136 *
137 * \param name parameter name
138 * \param value parameter value
139 * \param channel oscillation channel
140 * \param E neutrino energy [GeV]
141 * \param costh cosine zenith angle
142 * \return oscillation probability
143 */
144 double getP(const std::string& name,
145 const double value,
146 const JOscChannel& channel,
147 const double E,
148 const double costh) const
149 {
150 this->set(name, value);
151
152 return getP(channel, E, costh);
153 }
154
155
156 /**
157 * Get oscillation probability for a given set of oscillation parameters\n
158 * and a given oscillation channel.
159 *
160 * \param name parameter name
161 * \param value parameter value
162 * \param args remaining arguments
163 */
164 template<class ...Args>
165 double getP(const std::string& name,
166 const double value,
167 const Args& ...args) const
168 {
169 this->set(name, value);
170
171 return getP(args...);
172 }
173
174
175 /**
176 * Get oscillation probability for a given oscillation channel.
177 *
178 * \param channel oscillation channel
179 * \param E neutrino energy [GeV]
180 * \param costh cosine zenith angle
181 * \return oscillation probability
182 */
183 double operator()(const JOscChannel& channel,
184 const double E,
185 const double costh) const
186 {
187 return getP(channel, E, costh);
188 }
189
190
191 /**
192 * Get oscillation probability for a given set of oscillation parameters\n
193 * and a given oscillation channel.
194 *
195 * \param channel oscillation channel
196 * \param parameters oscillation parameters
197 * \param E neutrino energy [GeV]
198 * \param costh cosine zenith angle
199 * \return oscillation probability
200 */
201 double operator()(const JOscParameters_t& parameters,
202 const JOscChannel& channel,
203 const double E,
204 const double costh) const
205 {
206 return getP(parameters, channel, E, costh);
207 }
208
209
210 /**
211 * Get oscillation probability for a given oscillation parameter\n
212 * and a given oscillation channel.
213 *
214 * \param name parameter name
215 * \param value parameter value
216 * \param channel oscillation channel
217 * \param E neutrino energy [GeV]
218 * \param costh cosine zenith angle
219 * \return oscillation probability
220 */
221 double operator()(const std::string& name,
222 const double value,
223 const JOscChannel& channel,
224 const double E,
225 const double costh) const
226 {
227 return getP(name, value, channel, E, costh);
228 }
229
230
231 /**
232 * Get oscillation probability for a given set of oscillation parameters\n
233 * and a given oscillation channel.
234 *
235 * \param name parameter name
236 * \param value parameter value
237 * \param args remaining arguments
238 */
239 template<class ...Args>
240 double operator()(const std::string& name,
241 const double value,
242 const Args& ...args) const
243 {
244 return getP(name, value, args...);
245 }
246
247
248 /**
249 * Get equation parameters.
250 *
251 * \return equation parameters
252 */
254 {
255 static JEquationParameters equation("=", "\n\t\v\f\r, ", "./", "#");
256
257 return equation;
258 }
259
260
261 /**
262 * Set equation parameters.
263 *
264 * \param eqpars equation parameters
265 */
266 static inline void setEquationParameters(const JEquationParameters& eqpars)
267 {
268 getEquationParameters() = eqpars;
269 }
270
271
272 /**
273 * Read configuration of oscillation probability calculator from input.
274 *
275 * \param in input stream
276 * \return input stream
277 */
278 virtual std::istream& read(std::istream& in)
279 {
280 using namespace std;
281 using namespace JPP;
282
283 JStringStream is(in);
284
285 is >> getProperties();
286
287 return in;
288 }
289
290
291 /**
292 * Write configuration of oscillation probability calculator to output.
293 *
294 * \param out output stream
295 * \return output stream
296 */
297 virtual std::ostream& write(std::ostream& out) const
298 {
299 return out << getProperties();
300 }
301
302
303 /**
304 * Read oscillation probability calculator from input.
305 *
306 * \param in input stream
307 * \param object oscillation probability calculator
308 * \return input stream
309 */
310 friend inline std::istream& operator>>(std::istream& in, JOscProbInterface& object)
311 {
312 return object.read(in);
313 }
314
315
316 /**
317 * Write oscillation probability calculator to output.
318 *
319 * \param out output stream
320 * \param object oscillation probability calculator
321 * \return output stream
322 */
323 friend inline std::ostream& operator<<(std::ostream& out, const JOscProbInterface& object)
324 {
325 return object.write(out);
326 }
327 };
328}
329
330#endif
Exceptions.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Parameter class.
Definition JParameter.hh:36
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
Interface class for sets of oscillation parameters.
Low-level interface for oscillation probability calculators.
double operator()(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.
double getP(const JOscParameters_t &parameters, const JOscChannel &channel, const double E, const double costh) const
Get oscillation probability for a given set of oscillation parameters and a given oscillation channel...
friend std::ostream & operator<<(std::ostream &out, const JOscProbInterface &object)
Write oscillation probability calculator to output.
JOscProbInterface()
Default constructor.
JOscParametersHelper< double & > JOscParametersHelper_t
virtual std::ostream & write(std::ostream &out) const
Write configuration of oscillation probability calculator to output.
double operator()(const JOscParameters_t &parameters, const JOscChannel &channel, const double E, const double costh) const
Get oscillation probability for a given set of oscillation parameters and a given oscillation channel...
static const char *const getTypeKey()
Get type keyword.
JOscParameters_t::JOscParameter_t JOscParameter_t
double operator()(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...
virtual double getP(const JOscChannel &channel, const double E, const double costh) const =0
Get oscillation probability for a given oscillation channel.
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.
virtual ~JOscProbInterface()
Virtual destructor.
friend std::istream & operator>>(std::istream &in, JOscProbInterface &object)
Read oscillation probability calculator from input.
JOscProbInterface(const JOscParameterReferences_t &parameters, const std::string &name, double &value, const Args &...args)
Constructor.
JOscParametersInterface< double & > JOscParameterReferences_t
static JEquationParameters & getEquationParameters()
Get equation parameters.
JOscParameters_t::JParameter_t JParameter_t
double operator()(const JOscChannel &channel, const double E, const double costh) const
Get oscillation probability for a given oscillation channel.
JOscParametersInterface< double > JOscParameters_t
static void setEquationParameters(const JEquationParameters &eqpars)
Set equation parameters.
JOscProbInterface(const JOscParameterReferences_t &parameters)
Constructor.
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...
virtual std::istream & read(std::istream &in)
Read configuration of oscillation probability calculator from input.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Template class for object cloning.
Definition JClonable.hh:59
Low-level interface for oscillation baseline calculators.
Neutrino oscillation channel.
Abstract base class for oscillation parameter.
Helper class for oscillation parameters.
virtual JProperties getProperties(const JEquationParameters &equation=JOscParameters_t::getEquationParameters())
void set(const std::string &name, const value_type &value) const