Jpp  17.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JOscProbTable.hh
Go to the documentation of this file.
1 #ifndef __JOSCPROB__JOSCPROBTABLE__
2 #define __JOSCPROB__JOSCPROBTABLE__
3 
4 #include "Jeep/JMessage.hh"
5 
6 #include "JLang/JException.hh"
7 
8 #include "JIO/JFileStreamIO.hh"
9 #include "JIO/JObjectBinaryIO.hh"
10 
11 #include "JTools/JRange.hh"
12 #include "JTools/JArray.hh"
13 #include "JTools/JDistance.hh"
14 #include "JTools/JToolsToolkit.hh"
15 #include "JTools/JMultiFunction.hh"
16 
19 
20 
21 /**
22  * \author bjung, mdejong
23  */
24 
25 namespace JOSCPROB {}
26 namespace JPP { using namespace JOSCPROB; }
27 
28 namespace JOSCPROB {
29 
30  using JEEP::JMessage;
31 
33 
34  using JIO::JReader;
35  using JIO::JWriter;
36  using JIO::JSerialisable;
38 
39  using JTOOLS::JArray;
40  using JTOOLS::JRange;
42 
43 
44  /**
45  * Template definition of a multi-dimensional interpolation table for oscillation probabilities.
46  */
47  template<class JFunction1D_t,
48  class JMaplist_t,
50  struct JOscProbTable :
51  public JSerialisable,
52  public JMultiFunction<JFunction1D_t, JMaplist_t, JDistance_t>,
53  public JMessage< JOscProbTable <JFunction1D_t, JMaplist_t, JDistance_t> >,
54  public JObjectBinaryIO< JOscProbTable <JFunction1D_t, JMaplist_t, JDistance_t> >
55  {
58 
62 
64 
66 
70 
72 
73 
74  /**
75  * Constructor.
76  */
79  {}
80 
81 
82  /**
83  * Constructor.
84  *
85  * \param fileName oscillation probability table filename
86  */
87  JOscProbTable(const char* fileName) :
89  {
90  this->load(fileName);
91  }
92 
93 
94  /**
95  * Constructor.
96  *
97  * \param input multi-dimensional function
98  */
99  template<class JOscProb_t, class JOscProbMaplist_t, class JOscProbDistance_t>
101  multifunction_type(input)
102  {}
103 
104 
105  /**
106  * Load oscillation probability table from file.
107  *
108  * \param fileName oscillation probability table fileName
109  */
110  void load(const char* fileName)
111  {
112  using namespace std;
113  using namespace JPP;
114 
115  try {
116  NOTICE("loading " << NUMBER_OF_DIMENSIONS <<
117  "D oscillation probability table from file " << fileName << "... " << flush);
118 
120 
121  NOTICE("OK" << endl);
122  }
123  catch(const JException& error) {
124  THROW(JFileReadException, "JOscProbTable::load(): Error reading file " << fileName << endl);
125  }
126  }
127 
128 
129  /**
130  * Compresses OscProb table to given abscissa range.
131  *
132  * \param range abscissa range
133  */
135  {
136  for (super_iterator i = this->super_begin(); i != this->super_end(); ++i) {
137 
138  function_type& f1 = i.getValue();
139 
140  typename function_type::iterator p = f1.lower_bound(range.getLowerLimit());
141 
142  f1.function_type::container_type::erase(f1.begin(), p);
143 
144  typename function_type::iterator q = f1.lower_bound(range.getUpperLimit());
145 
146  f1.function_type::container_type::erase(++q, f1.end());
147  }
148 
149  this->compile();
150  }
151 
152 
153  /**
154  * Read from input.
155  *
156  * \param in reader
157  * \return reader
158  */
159  virtual JReader& read(JReader& in) override
160  {
161  in >> static_cast<multifunction_type&>(*this);
162 
163  this->compile();
164 
165  return in;
166  }
167 
168 
169  /**
170  * Write from input.
171  *
172  * \param out writer
173  * \return writer
174  */
175  virtual JWriter& write(JWriter& out) const override
176  {
177  out << static_cast<const multifunction_type&>(*this);
178 
179  return out;
180  }
181  };
182 
183 
184  /**
185  * Explicit template specialization for 6D interpolation table in:
186  *
187  * 1. \f$ \sin^{2}(\theta_{12}) \f$
188  * 2. \f$ \Delta m_{21}^{2} \left[\mathrm{eV}^{2}\right] \f$
189  * 3. \f$ \sin^{2}(\theta_{13}) \f$
190  * 4. \f$ \Delta m_{31}^{2}\ \left[\mathrm{eV}^{2}\right] \f$
191  * 5. \f$ \sin^{2}(\theta_{23}) \f$
192  * 6. \f$ \delta_{\mathrm{CP}} \left[\pi\right] \f$
193  */
194  template< class JDistance_t = JTOOLS::JDistance<typename JOscProbTable6D_t::argument_type> >
196  public JOscProbTable< typename JOscProbTable6D_t::JConstantFunction1D_t,
197  typename JOscProbTable6D_t::JMaplist6D_t,
198  JDistance_t >
199  {
202 
205 
209 
211 
213 
216 
217 
218  /**
219  * Default constructor.
220  */
223  {}
224 
225 
226  /**
227  * Constructor.
228  *
229  * \param input multi-dimensional function
230  */
231  template<class JOscProb_t, class JOscProbMaplist_t, class JOscProbDistance_t>
234  {}
235 
236 
237  /**
238  * Constructor.
239  *
240  * \param fileName 2D oscillation probability table filename
241  */
242  JOscProbTable6D(const char* fileName) :
244  {}
245  };
246 
247 
248  /**
249  * Explicit template specialization for 2D interpolation table in:
250  *
251  * 1. \f$ L/E \left[\mathrm{km}/\mathrm{GeV}\right] \f$
252  * 2. \f$ \sin(\theta)\f$
253  */
254  template< class JDistance_t = JTOOLS::JDistance<typename JOscProbTable2D_t::JFunction2D_t::argument_type> >
256  public JOscProbTable< typename JOscProbTable2D_t::JFunction1D_t,
257  typename JOscProbTable2D_t::JMaplist1D_t,
258  JDistance_t>
259  {
262 
265 
269 
271 
273 
276 
278 
279 
280  /**
281  * Default constructor.
282  */
285  {}
286 
287 
288  /**
289  * Constructor.
290  *
291  * \param input multi-dimensional function
292  */
293  template<class JOscProb_t, class JOscProbMaplist_t, class JOscProbDistance_t>
296 
297  {}
298 
299 
300  /**
301  * Constructor.
302  *
303  * \param fileName 2D oscillation probability table filename
304  */
305  JOscProbTable2D(const char* fileName) :
307  {}
308 
309 
310  /**
311  * Constructor.
312  *
313  * \param table 6D oscillation probability table
314  * \param parameters oscillation parameters
315  */
317  const JOscParameters& parameters) :
319  {
320  this->load(table, parameters);
321  }
322 
323 
324  /**
325  * Load 2D oscillation probability table from 6D oscillation probability table.
326  *
327  * \param table 6D oscillation probability table
328  * \param parameters oscillation parameters
329  */
331  const JOscParameters& parameters)
332  {
333  using namespace std;
334  using namespace JPP;
335 
336  NOTICE("Extracting 2D interpolation table for:\n" << parameters.getProperties() << flush);
337 
338  typename JOscProbTable6D<JDistance_t>::result_type result = table(parameters.sinsqTh12,
339  parameters.dM21sq,
340  parameters.sinsqTh13,
341  parameters.dM31sq,
342  parameters.sinsqTh23,
343  parameters.deltaCP);
344 
345  copy(result, static_cast<multimap_type&>(*this));
346 
347  this->compile();
348 
349  NOTICE("OK" << endl);
350  }
351  };
352 
353 
354  /**
355  * Explicit template specialization for 8D interpolation table in:
356  *
357  * 1. \f$ \sin^{2}(\theta_{12}) \f$
358  * 2. \f$ \Delta m_{21}^{2} \left[\mathrm{eV}^{2}\right] \f$
359  * 3. \f$ \sin^{2}(\theta_{13}) \f$
360  * 4. \f$ \Delta m_{31}^{2} \left[\mathrm{eV}^{2}\right] \f$
361  * 5. \f$ \sin^{2}(\theta_{23}) \f$
362  * 6. \f$ \delta_{\mathrm{CP}} \left[\pi\right] \f$
363  * 7. \f$ L/E \left[\mathrm{km}/\mathrm{GeV}\right] \f$
364  * 8. \f$ \sin(\theta)\f$
365  */
366  template< class JDistance_t = JTOOLS::JDistance<typename JOscProbTable8D_t::JFunction2D_t::argument_type> >
368  public JOscProbTable< typename JOscProbTable8D_t::JFunction2D_t,
369  typename JOscProbTable8D_t::JMaplist6D_t,
370  JDistance_t>
371  {
374 
377 
381 
383 
385 
388 
389 
390  /**
391  * Default constructor.
392  */
395  {}
396 
397 
398  /**
399  * Constructor.
400  *
401  * \param input multi-dimensional function
402  */
403  template<class JOscProb_t, class JOscProbMaplist_t, class JOscProbDistance_t>
406  {}
407 
408 
409  /**
410  * Constructor.
411  *
412  * \param fileName 2D oscillation probability table filename
413  */
414  JOscProbTable8D(const char* fileName) :
416  {}
417  };
418 
419 
420  /**
421  * Default debug-levels for oscillation probability tables.
422  */
423  template<>
424  int JMessage<typename JOscProbTable2D<>::table_type>::debug = (int) JEEP::notice_t;
425 
426  template<>
427  int JMessage<typename JOscProbTable6D<>::table_type>::debug = (int) JEEP::notice_t;
428 
429  template<>
430  int JMessage<typename JOscProbTable8D<>::table_type>::debug = (int) JEEP::notice_t;
431 }
432 
433 #endif
multifunction_type::argument_type argument_type
function_type::argument_type argument_type
static int debug
debug level (default is off).
Definition: JMessage.hh:45
void compile()
Compilation.
multifunction_type::multimap_type multimap_type
Exception for reading of file.
Definition: JException.hh:378
Exceptions.
Interface for binary output.
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
multimap_type::super_iterator super_iterator
multifunction_type::value_type value_type
Auxiliary base class for storing and loading a single object to and from a binary file...
JOscProbTable< function_type, maplist_type, JDistance_t > table_type
Explicit template specialization for 6D interpolation table in:
void compress(const JRange< typename function_type::argument_type > &range)
Compresses OscProb table to given abscissa range.
multimap_type::super_const_iterator super_const_iterator
JOscProbTable6D_t::JConstantFunction1D_t function_type
JOscProbTable8D_t::JMaplist6D_t maplist_type
Template class for distance evaluation.
Definition: JDistance.hh:24
JOscProbTable6D()
Default constructor.
multifunction_type::multimap_type multimap_type
multifunction_type::super_iterator super_iterator
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
Template definition of a multi-dimensional interpolation table for oscillation probabilities.
Explicit template specialization for 8D interpolation table in:
notice
Definition: JMessage.hh:32
JMultiFunction< JFunction1D_t, JMaplist_t, JDistance_t > multifunction_type
multifunction_type::super_iterator super_iterator
void load(const char *fileName)
Load oscillation probability table from file.
Data structure for oscillation parameters.
multifunction_type::super_iterator super_iterator
*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
virtual JWriter & write(JWriter &out) const override
Write from input.
JOscProbTable2D_t::JFunction1D_t function_type
multifunction_type::argument_type argument_type
JOscProbTable< function_type, maplist_type, JDistance_t > table_type
multifunction_type::argument_type argument_type
double sinsqTh23
Squared sine of the PMNS mixing angle between the second and third neutrino mass eigenstates [-]...
JOscProbTable2D()
Default constructor.
JOscProbTable< JFunction1D_t, JMaplist_t, JDistance_t > table_type
multifunction_type::super_const_iterator super_const_iterator
multifunction_type::value_type value_type
JOscProbTable8D_t::JFunction2D_t function_type
JProperties getProperties(const JEquationParameters &equation=JOscParameters::getEquationParameters())
Get properties of this class.
multifunction_type::value_type value_type
JMultiMap< typename JFunction_t::argument_type, JFunction_t, JMaplist_t, JDistance_t > multimap_type
JOscProbTable2D(const char *fileName)
Constructor.
Forward declaration of binary output.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
double deltaCP
PMNS phase angle [pi * rad].
void load(const JOscProbTable6D< JDistance_t > &table, const JOscParameters &parameters)
Load 2D oscillation probability table from 6D oscillation probability table.
double dM31sq
Squared mass difference between the first and third neutrino mass eigenstates [eV2].
JOscProbTable6D(const char *fileName)
Constructor.
Template implementation of function object in one dimension returning a constant value.
function_type::value_type value_type
double sinsqTh12
Squared sine of the PMNS mixing angle between the first and second neutrino mass eigenstates [-]...
Multidimensional interpolation method.
JOscProbTable2D_t::JMaplist1D_t maplist_type
Map list.
Definition: JMapList.hh:24
multifunction_type::argument_type argument_type
return result
Definition: JPolint.hh:743
double dM21sq
Squared mass difference between the first and second neutrino mass eigenstates [eV2].
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:213
This include file contains various recursive methods to operate on multi-dimensional collections...
#define NOTICE(A)
Definition: JMessage.hh:64
multifunction_type::function_type function_type
Interface for binary input.
JMultiFunction< function_type, maplist_type, JDistance_t > multifunction_type
multifunction_type::result_type result_type
One dimensional array of template objects with fixed length.
Definition: JArray.hh:40
Range of values.
Definition: JRange.hh:38
General purpose messaging.
multifunction_type::result_type result_type
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
multimap_type::result_type result_type
JOscProbTable2D(const JOscProbTable6D< JDistance_t > &table, const JOscParameters &parameters)
Constructor.
Explicit template specialization for 2D interpolation table in:
multifunction_type::super_iterator super_iterator
JMultiFunction< function_type, maplist_type, JDistance_t > multifunction_type
virtual JReader & read(JReader &in) override
Read from input.
Auxiliary class to define a range between two values.
JOscProbTable(const char *fileName)
Constructor.
JOscProbTable()
Constructor.
multifunction_type::result_type result_type
JOscProbTable8D(const char *fileName)
Constructor.
multifunction_type::super_const_iterator super_const_iterator
JOscProbTable(const JMultiFunction< JOscProb_t, JOscProbMaplist_t, JOscProbDistance_t > &input)
Constructor.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
JOscProbTable6D(const JMultiFunction< JOscProb_t, JOscProbMaplist_t, JOscProbDistance_t > &input)
Constructor.
multifunction_type::super_const_iterator super_const_iterator
JOscProbTable8D(const JMultiFunction< JOscProb_t, JOscProbMaplist_t, JOscProbDistance_t > &input)
Constructor.
multifunction_type::result_type result_type
JOscProbTable6D_t::JMaplist6D_t maplist_type
JOscProbTable2D(const JMultiFunction< JOscProb_t, JOscProbMaplist_t, JOscProbDistance_t > &input)
Constructor.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
Template class for polynomial interpolation in 1D.
Definition: JPolint.hh:982
JMultiFunction< function_type, maplist_type, JDistance_t > multifunction_type
Multidimensional map.
Definition: JMultiMap.hh:52
double sinsqTh13
Squared sine of the PMNS mixing angle between the first and third neutrino mass eigenstates [-]...
multifunction_type::multimap_type multimap_type
multifunction_type::super_const_iterator super_const_iterator
multifunction_type::value_type value_type
Auxiliary class for handling debug parameter within a class.
Definition: JMessage.hh:44
JOscProbTable< function_type, maplist_type, JDistance_t > table_type
JOscProbTable8D()
Default constructor.
multifunction_type::multimap_type multimap_type
double getValue(const double x) const
Function value.
Definition: JPolynome.hh:233