1#ifndef __JAANET__JHONDAFLUXINTERPOLATOR__
2#define __JAANET__JHONDAFLUXINTERPOLATOR__
86 const double maximum) :
118 if (in >> min >> buffer >> max &&
152 const double maxCosz,
154 const double maxPhi) :
178 return in >> properties;
190 template<
class JPhiFunction_t = JConstantFunction1D<
double, JArray<4,
double> >,
194 public JMultiFunction <JPhiFunction_t, typename JMAPLIST<JEnergyFunctionalMap_t, JCoszFunctionalMap_t>::maplist>,
195 public JClonable<JFlux, JHondaFluxInterpolator <JPhiFunction_t, JCoszFunctionalMap_t, JEnergyFunctionalMap_t> >,
196 public JMessage <JHondaFluxInterpolator <JPhiFunction_t, JCoszFunctionalMap_t, JEnergyFunctionalMap_t> >
239 this->
load(fileName);
240 this->check_validity();
249 void load(
const char*
const fileName)
256 NOTICE(
"Loading Honda flux table from file " << fileName <<
"... " << flush);
260 ifstream ifs(fileName);
264 for (
string line; getline(ifs, line); ) {
270 istringstream iss1(line);
278 if (iss1 >> energy >> values) {
280 const double log10E = log10(energy);
282 for (
typename result_type::iterator i = values.begin(); i != values.end(); ++i) {
286 zmap[log10E][cosz][phi] = values;
293 if (
p1 != string::npos && p2 != string::npos) {
295 const string binspecstr = line.substr(
p1 + 1, p2 -
p1 - 1);
297 istringstream iss2(binspecstr);
304 catch(
const exception& error) {
333 const double phi)
const
338 static const double epsilon_costh = 1.0e-3;
339 static const double epsilon_phi = 1.0;
341 static const JRange_t mod(0.0, 360.0);
345 const double _costh = min(max(costh, -1.0), 1.0);
346 const double _phi = mod.
mod(180.0 - phi);
353 lnFluxes = function(log10E, _costh, _phi);
362 const result_type& y1 = function(log10E, x1, _phi);
363 const result_type& y2 = function(log10E, x2, _phi);
365 lnFluxes = y1 + ((y2 - y1) / (x2 - x1)) * (_costh - x1);
372 const result_type& y1 = function(log10E, x1, _phi);
373 const result_type& y2 = function(log10E, x2, _phi);
375 lnFluxes = y1 + ((y2 - y1) / (x2 - x1)) * (_costh - x1);
382 const result_type& y1 = function(log10E, _costh, x1);
383 const result_type& y2 = function(log10E, _costh, x2);
385 lnFluxes = y1 + ((y2 - y1) / (x2 - x1)) * (_phi - x1);
392 const result_type& y1 = function(log10E, _costh, x1);
393 const result_type& y2 = function(log10E, _costh, x2);
395 lnFluxes = y1 + ((y2 - y1) / (x2 - x1)) * (_phi - x1);
408 lnFluxes = y1 + ((y2 - y1) / (c2 -
c1) / (p2 -
p1)) * (_costh -
p1) * (_phi -
p1);
421 lnFluxes = y1 + ((y2 - y1) / (c2 -
c1) / (p2 -
p1)) * (_costh -
p1) * (_phi -
p1);
434 lnFluxes = y1 + ((y2 - y1) / (c2 -
c1) / (p2 -
p1)) * (_costh -
p1) * (_phi -
p1);
447 lnFluxes = y1 + ((y2 - y1) / (c2 -
c1) / (p2 -
p1)) * (_costh -
p1) * (_phi -
p1);
453 return exp(lnFluxes[0]);
455 return exp(lnFluxes[1]);
457 return exp(lnFluxes[2]);
459 return exp(lnFluxes[3]);
478 const double phi)
const
480 return getFactor(type, log10E, costh, phi);
496 const double phi)
const
498 return getFactor(type, log10E, costh, phi);
512 const double log10E = log10(neutrino.
E);
513 const double costh = neutrino.
dir.
z;
516 const double phi = atan(neutrino.
dir.
y / neutrino.
dir.
x) * 180.0 / M_PI;
562 std::istream&
read(std::istream& in)
override final
566 streampos pos = in.tellg();
568 if (!(in >>
table)) {
580 this->check_validity();
600 template<
class JHondaFluxInterpolator_t>
625 template<
template<
class,
class,
class>
class JCoszFunctionalMap_t,
626 template<
class,
class,
class>
class JEnergyFunctionalMap_t>
628 public JMultiFunction <JConstantFunction1D<double, JArray<4, double> >, typename JMAPLIST<JEnergyFunctionalMap_t, JCoszFunctionalMap_t>::maplist>,
629 public JClonable<JDiffuseFlux, JHondaFluxInterpolator <JConstantFunction1D<double, JArray<4, double> >, JCoszFunctionalMap_t, JEnergyFunctionalMap_t> >,
630 public JMessage <JHondaFluxInterpolator <JConstantFunction1D<double, JArray<4, double> >, JCoszFunctionalMap_t, JEnergyFunctionalMap_t> >
674 this->
load(fileName);
675 this->check_validity();
684 void load(
const char*
const fileName)
691 NOTICE(
"Loading Honda flux table from file " << fileName <<
"... " << flush);
695 ifstream ifs(fileName);
699 for (
string line; getline(ifs, line); ) {
705 istringstream iss1(line);
710 if (iss1 >> energy >> values) {
712 const double log10E = log10(energy);
714 for (
typename result_type::iterator i = values.begin(); i != values.end(); ++i) {
718 zmap[log10E][cosz] = values;
725 if (
p1 != string::npos && p2 != string::npos) {
727 const string binspecstr = line.substr(
p1 + 1, p2 -
p1 - 1);
729 istringstream iss2(binspecstr);
738 catch(
const exception& error) {
765 const double costh)
const override final
770 static const double epsilon_costh = 1.0e-3;
774 const double _costh = min(max(costh, -1.0), 1.0);
780 lnFluxes = function(log10E, _costh);
792 lnFluxes = y1 + ((y2 - y1) / (x2 - x1)) * (_costh - x1);
802 lnFluxes = y1 + ((y2 - y1) / (x2 - x1)) * (_costh - x1);
808 return exp(lnFluxes[0]);
810 return exp(lnFluxes[1]);
812 return exp(lnFluxes[2]);
814 return exp(lnFluxes[3]);
849 std::istream&
read(std::istream& in)
override final
853 streampos pos = in.tellg();
855 if (!(in >>
table)) {
867 this->check_validity();
886 template<
class JHondaFluxInterpolator_t>
912 JCoszFunctionalMap_t,
913 JEnergyFunctionalMap_t>;
922 template<
class JPhiFunction_t,
923 template<
class,
class,
class>
class JCoszFunctionalMap_t,
924 template<
class,
class,
class>
class JEnergyFunctionalMap_t>
934 template<
class JPhiFunction_t,
935 template<
class,
class,
class>
class JCoszFunctionalMap_t,
936 template<
class,
class,
class>
class JEnergyFunctionalMap_t>
General purpose class for a collection of sorted elements.
TCanvas * c1
Global variables to handle mouse events.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Various implementations of functional maps.
General purpose messaging.
I/O formatting auxiliaries.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Auxiliary class to define a range between two values.
Template specialisation for interpolator of azimuth-averaged Honda flux table.
multifunction_type::result_type result_type
multifunction_type::super_const_iterator super_const_iterator
JMultiFunction< JPhiFunction_t, JFunctionalMaplist_t > multifunction_type
JHondaFluxInterpolator()
Default constructor.
multifunction_type::value_type value_type
multifunction_type::multimap_type multimap_type
void load(const char *const fileName)
Load oscillation probability table from file.
multifunction_type::function_type function_type
double dNdEdOmega(const int type, const double log10E, const double costh) const override final
Get diffuse flux for given particle PDG-identifier, energy and zenith-angle.
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const override final
Get properties of this class.
multifunction_type::argument_type argument_type
JRange< abscissa_type > JRange_t
JRange_t coszRange
Cosine zenith angle range.
JHondaFluxInterpolator(const char *fileName)
Constructor.
JHondaFluxInterpolator< JPhiFunction_t, JCoszFunctionalMap_t, JEnergyFunctionalMap_t > interpolator_type
multifunction_type::super_iterator super_iterator
JConstantFunction1D< double, JArray< 4, double > > JPhiFunction_t
bool is_valid() const override final
Check whether this interpolator is valid.
std::istream & read(std::istream &in) override final
Stream input.
std::string table
Table filename.
JMAPLIST< JEnergyFunctionalMap_t, JCoszFunctionalMap_t >::maplist JFunctionalMaplist_t
multifunction_type::abscissa_type abscissa_type
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
Template definition for Honda flux table interpolator.
multifunction_type::super_iterator super_iterator
bool is_valid() const override final
Check whether this interpolator is valid.
multifunction_type::multimap_type multimap_type
multifunction_type::function_type function_type
JMAPLIST< JEnergyFunctionalMap_t, JCoszFunctionalMap_t >::maplist JFunctionalMaplist_t
double getFlux(const Evt &event) const
Get flux of given event.
double getFactor(const Evt &evt) const override final
Get flux of given event.
double getFactor(const int type, const double log10E, const double costh, const double phi) const
Get diffuse flux for given particle PDG-identifier, energy, cosine zenith angle and azimuth angle.
multifunction_type::result_type result_type
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
double getFlux(const int type, const double log10E, const double costh, const double phi) const
Get flux of given event.
JHondaFluxInterpolator()
Default constructor.
multifunction_type::abscissa_type abscissa_type
std::istream & read(std::istream &in) override final
Stream input.
multifunction_type::super_const_iterator super_const_iterator
JRange_t phiRange
Azimuth angle range [deg].
JHondaFluxInterpolator< JPhiFunction_t, JCoszFunctionalMap_t, JEnergyFunctionalMap_t > interpolator_type
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const override final
Get properties of this class.
multifunction_type::value_type value_type
JRange_t coszRange
Zenith angle range.
multifunction_type::argument_type argument_type
void load(const char *const fileName)
Load oscillation probability table from file.
double operator()(const int type, const double log10E, const double costh, const double phi) const
Get diffuse flux for given particle PDG-identifier, energy, cosine zenith angle and azimuth angle.
std::string table
Table filename.
JHondaFluxInterpolator(const char *fileName)
Constructor.
JRange< abscissa_type > JRange_t
JMultiFunction< JPhiFunction_t, JFunctionalMaplist_t > multifunction_type
Utility class to parse parameter values.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Exception for reading of file.
Extensions to Evt data format.
static const char *const HONDA_MUON_ANTINEUTRINO_FLUX_KEYWORD
static const char *const HONDA_MUON_NEUTRINO_FLUX_KEYWORD
static const char *const HONDA_ENERGY_KEYWORD
static const char *const HONDA_ELECTRON_ANTINEUTRINO_FLUX_KEYWORD
static const char *const HONDA_AZIMUTH_ANGLE_KEYWORD
static const char *const HONDA_ELECTRON_NEUTRINO_FLUX_KEYWORD
static const char *const HONDA_COSINE_ZENITH_ANGLE_KEYWORD
static const char HONDA_BINSPECS_END
static const char *const HONDA_BINSPECS_SEPARATOR
static const char HONDA_BINSPECS_BEGIN
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
General puprpose classes and methods.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
static const char *const getTypeKey()
Get type keyword.
static JEquationParameters & getEquationParameters()
Get equation parameters.
Auxiliary data structure for reading angular binning specifications of Honda flux table.
JHondaBinRange coszRange
Cosine zenith-angle range.
JHondaBinRange phiRange
Azimuthal angle range [deg].
JHondaAngularBinSpecs(const double minCosz, const double maxCosz, const double minPhi, const double maxPhi)
Constructor.
friend std::istream & operator>>(std::istream &in, JHondaAngularBinSpecs &binspecs)
Read bin specifications from input.
JHondaAngularBinSpecs()
Default constructor.
Auxiliary data structure for reading Honda bin ranges.
friend std::istream & operator>>(std::istream &in, JHondaBinRange &object)
Read bin range from input.
JHondaBinRange()
Default constructor.
JHondaBinRange(const double minimum, const double maximum)
Constructor.
JRange< double > JRange_t
double getCentralValue() const
Get central value of this range.
Auxiliary class for I/O of Honda flux interpolator.
JHondaFluxInterpolatorHelper(const JHondaFluxInterpolator_t &interpolator, const JEquationParameters &eqpars)
Constructor.
Auxiliary class for I/O of Honda flux interpolator.
JHondaFluxInterpolatorHelper(const JHondaFluxInterpolator_t &interpolator, const JEquationParameters &eqpars)
Constructor.
Auxiliary class for handling debug parameter within a class.
static int debug
debug level (default is off).
Template class for object cloning.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
int type
MC: particle type in PDG encoding.
double E
Energy [GeV] (either MC truth or reconstructed)