Jpp  test_elongated_shower_pde
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:\n
186  * 1. \f$sin^2(\theta_{12})\f$
187  * 2. \f$\Delta m_{21}^2\f$ [eV2]
188  * 3. \f$sin^2(\theta_{13})\f$
189  * 4. \f$\Delta m_{31}^2\f$ [eV2]
190  * 5. \f$sin^2(\theta_{23})\f$
191  * 6. \f$\delta_{\text{CP}}\f$ [pi * rad]
192  */
193  template< class JDistance_t = JTOOLS::JDistance<typename JOscProbTable6D_t::argument_type> >
195  public JOscProbTable< typename JOscProbTable6D_t::JConstantFunction1D_t,
196  typename JOscProbTable6D_t::JMaplist6D_t,
197  JDistance_t >
198  {
201 
204 
208 
210 
212 
215 
216 
217  /**
218  * Default constructor.
219  */
222  {}
223 
224 
225  /**
226  * Constructor.
227  *
228  * \param input multi-dimensional function
229  */
230  template<class JOscProb_t, class JOscProbMaplist_t, class JOscProbDistance_t>
233  {}
234 
235 
236  /**
237  * Constructor.
238  *
239  * \param fileName 2D oscillation probability table filename
240  */
241  JOscProbTable6D(const char* fileName) :
243  {}
244  };
245 
246 
247  /**
248  * Explicit template specialization for 2D interpolation table in:\n
249  * 1. \f$L/E\f$ [km * GeV-1]
250  * 2. \f$sin(\theta)\f$
251  */
252  template< class JDistance_t = JTOOLS::JDistance<typename JOscProbTable2D_t::JFunction2D_t::argument_type> >
254  public JOscProbTable< typename JOscProbTable2D_t::JFunction1D_t,
255  typename JOscProbTable2D_t::JMaplist1D_t,
256  JDistance_t>
257  {
260 
263 
267 
269 
271 
274 
276 
277 
278  /**
279  * Default constructor.
280  */
283  {}
284 
285 
286  /**
287  * Constructor.
288  *
289  * \param input multi-dimensional function
290  */
291  template<class JOscProb_t, class JOscProbMaplist_t, class JOscProbDistance_t>
294 
295  {}
296 
297 
298  /**
299  * Constructor.
300  *
301  * \param fileName 2D oscillation probability table filename
302  */
303  JOscProbTable2D(const char* fileName) :
305  {}
306 
307 
308  /**
309  * Constructor.
310  *
311  * \param table 6D oscillation probability table
312  * \param parameters oscillation parameters
313  */
315  const JOscParameters& parameters) :
317  {
318  this->load(table, parameters);
319  }
320 
321 
322  /**
323  * Load 2D oscillation probability table from 6D oscillation probability table.
324  *
325  * \param table 6D oscillation probability table
326  * \param parameters oscillation parameters
327  */
329  const JOscParameters& parameters)
330  {
331  using namespace std;
332  using namespace JPP;
333 
334  NOTICE("Extracting 2D interpolation table for:\n" << parameters.getProperties() << flush);
335 
336  typename JOscProbTable6D<JDistance_t>::result_type result = table(parameters.sinsqTh12,
337  parameters.dM21sq,
338  parameters.sinsqTh13,
339  parameters.dM31sq,
340  parameters.sinsqTh23,
341  parameters.deltaCP);
342 
343  copy(result, static_cast<multimap_type&>(*this));
344 
345  this->compile();
346 
347  NOTICE("OK" << endl);
348  }
349  };
350 
351 
352  /**
353  * Explicit template specialization for 8D interpolation table in:\n
354  * 1. \f$sin^2(\theta_{12})\f$
355  * 2. \f$\Delta m_{21}^2\f$ [eV2]
356  * 3. \f$sin^2(\theta_{13})\f$
357  * 4. \f$\Delta m_{31}^2\f$ [eV2]
358  * 5. \f$sin^2(\theta_{23})\f$
359  * 6. \f$\delta_{\text{CP}}\f$ [pi * rad]
360  * 7. \f$L/E\f$ [km * GeV-1]
361  * 8. \f$sin(\theta)\f$
362  */
363  template< class JDistance_t = JTOOLS::JDistance<typename JOscProbTable8D_t::JFunction2D_t::argument_type> >
365  public JOscProbTable< typename JOscProbTable8D_t::JFunction2D_t,
366  typename JOscProbTable8D_t::JMaplist6D_t,
367  JDistance_t>
368  {
371 
374 
378 
380 
382 
385 
386 
387  /**
388  * Default constructor.
389  */
392  {}
393 
394 
395  /**
396  * Constructor.
397  *
398  * \param input multi-dimensional function
399  */
400  template<class JOscProb_t, class JOscProbMaplist_t, class JOscProbDistance_t>
403  {}
404 
405 
406  /**
407  * Constructor.
408  *
409  * \param fileName 2D oscillation probability table filename
410  */
411  JOscProbTable8D(const char* fileName) :
413  {}
414  };
415 
416 
417  /**
418  * Default debug-levels for oscillation probability tables.
419  */
420  template<>
421  int JMessage<typename JOscProbTable2D<>::table_type>::debug = (int) JEEP::notice_t;
422 
423  template<>
424  int JMessage<typename JOscProbTable6D<>::table_type>::debug = (int) JEEP::notice_t;
425 
426  template<>
427  int JMessage<typename JOscProbTable8D<>::table_type>::debug = (int) JEEP::notice_t;
428 }
429 
430 #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.
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
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