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