1 #ifndef __JAANET__JHONDAFLUXINTERPOLATOR__
2 #define __JAANET__JHONDAFLUXINTERPOLATOR__
86 const double maximum) :
118 if (in >> min >> buffer >> max &&
138 coszRange(-1.0, 1.0),
139 phiRange ( 0.0, 360.0)
152 const double maxCosz,
154 const double maxPhi) :
155 coszRange(minCosz, maxCosz),
156 phiRange (minPhi, 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> >
205 enum { NUMBER_OF_DIMENSIONS = multifunction_type::NUMBER_OF_DIMENSIONS };
226 coszRange(0.0, -1.0),
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);
275 coszRange.include(cosz);
276 phiRange .include(phi);
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) {
317 return this->size() > 0 && coszRange.getLength() > 0.0 && phiRange.getLength() > 0.0;
333 const double phi)
const
338 static const double epsilon_costh = 1.0e-3;
339 static const double epsilon_phi = 1.0;
345 const double _costh = min(max(costh, -1.0), 1.0);
346 const double _phi =
mod.mod(180.0 - phi);
351 if (coszRange(_costh) && phiRange(_phi)) {
353 lnFluxes =
function(log10E, _costh, _phi);
357 if (_costh > coszRange.getUpperLimit() && phiRange(_phi)) {
360 const abscissa_type x2 = coszRange.getUpperLimit() - epsilon_costh;
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);
367 }
else if (_costh < coszRange.getLowerLimit() && phiRange(_phi)) {
370 const abscissa_type x2 = coszRange.getLowerLimit() + epsilon_costh;
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);
377 }
else if (coszRange(_costh) && _phi > phiRange.getUpperLimit()) {
380 const abscissa_type x2 = phiRange.getUpperLimit() - epsilon_costh;
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);
387 }
else if (coszRange(_costh) && _phi < phiRange.getLowerLimit()) {
390 const abscissa_type x2 = phiRange.getLowerLimit() + epsilon_costh;
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);
397 }
else if (_costh > coszRange.getUpperLimit() && _phi > phiRange.getUpperLimit()) {
400 const abscissa_type c2 = coszRange.getUpperLimit() - epsilon_costh;
403 const abscissa_type p2 = phiRange .getUpperLimit() - epsilon_phi;
408 lnFluxes = y1 + ((y2 - y1) / (c2 -
c1) / (p2 -
p1)) * (_costh -
p1) * (_phi -
p1);
410 }
else if (_costh > coszRange.getUpperLimit() && _phi < phiRange.getUpperLimit()) {
413 const abscissa_type c2 = coszRange.getUpperLimit() - epsilon_costh;
416 const abscissa_type p2 = phiRange .getLowerLimit() + epsilon_phi;
421 lnFluxes = y1 + ((y2 - y1) / (c2 -
c1) / (p2 -
p1)) * (_costh -
p1) * (_phi -
p1);
423 }
else if (_costh < coszRange.getLowerLimit() && phi > phiRange.getUpperLimit()) {
426 const abscissa_type c2 = coszRange.getLowerLimit() + epsilon_costh;
429 const abscissa_type p2 = phiRange .getUpperLimit() - epsilon_phi;
434 lnFluxes = y1 + ((y2 - y1) / (c2 -
c1) / (p2 -
p1)) * (_costh -
p1) * (_phi -
p1);
439 const abscissa_type c2 = coszRange.getLowerLimit() + epsilon_costh;
442 const abscissa_type p2 = phiRange .getLowerLimit() + epsilon_phi;
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;
518 return getFactor(neutrino.
type, log10E, costh, phi);
530 return getFactor(event);
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> >
641 enum { NUMBER_OF_DIMENSIONS = multifunction_type::NUMBER_OF_DIMENSIONS };
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);
708 coszRange.include(cosz);
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) {
751 return this->size() > 0 && coszRange.getLength();
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);
778 if (coszRange(_costh)) {
780 lnFluxes =
function(log10E, _costh);
784 if (_costh > coszRange.getUpperLimit()) {
787 const abscissa_type x2 = coszRange.getUpperLimit() - epsilon_costh;
792 lnFluxes = y1 + ((y2 - y1) / (x2 - x1)) * (_costh - x1);
797 const abscissa_type x2 = coszRange.getLowerLimit() + epsilon_costh;
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]);
828 return JHondaFluxInterpolatorHelper(*
this, eqpars);
839 return JHondaFluxInterpolatorHelper(*
this, eqpars);
849 std::istream&
read(std::istream& in)
override final
853 streampos pos = in.tellg();
855 if (!(in >> table)) {
867 this->check_validity();
877 struct JHondaFluxInterpolatorHelper :
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.
JConstantFunction1D< double, JArray< 4, double > > JPhiFunction_t
JHondaFluxInterpolator< JPhiFunction_t, JCoszFunctionalMap_t, JEnergyFunctionalMap_t > interpolator_type
multifunction_type::multimap_type multimap_type
JHondaFluxInterpolator()
Default constructor.
std::istream & read(std::istream &in) override final
Stream input.
void load(const char *const fileName)
Load oscillation probability table from file.
multifunction_type::value_type value_type
multifunction_type::abscissa_type abscissa_type
JMultiFunction< JPhiFunction_t, JFunctionalMaplist_t > multifunction_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.
JRange_t coszRange
Cosine zenith angle range.
JHondaFluxInterpolator(const char *fileName)
Constructor.
multifunction_type::super_iterator super_iterator
bool is_valid() const override final
Check whether this interpolator is valid.
JMAPLIST< JEnergyFunctionalMap_t, JCoszFunctionalMap_t >::maplist JFunctionalMaplist_t
multifunction_type::argument_type argument_type
JRange< abscissa_type > JRange_t
std::string table
Table filename.
multifunction_type::result_type result_type
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
multifunction_type::function_type function_type
multifunction_type::super_const_iterator super_const_iterator
Template definition for Honda flux table interpolator.
bool is_valid() const override final
Check whether this interpolator is valid.
double getFlux(const Evt &event) const
Get flux of given event.
multifunction_type::value_type value_type
multifunction_type::argument_type argument_type
double getFactor(const Evt &evt) const override final
Get flux of given event.
multifunction_type::abscissa_type abscissa_type
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::function_type function_type
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
multifunction_type::super_const_iterator super_const_iterator
std::istream & read(std::istream &in) override final
Stream input.
double getFlux(const int type, const double log10E, const double costh, const double phi) const
Get flux of given event.
JRange< abscissa_type > JRange_t
JHondaFluxInterpolator()
Default constructor.
JMAPLIST< JEnergyFunctionalMap_t, JCoszFunctionalMap_t >::maplist JFunctionalMaplist_t
multifunction_type::result_type result_type
JRange_t phiRange
Azimuth angle range [deg].
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const override final
Get properties of this class.
multifunction_type::multimap_type multimap_type
JRange_t coszRange
Zenith angle range.
JMultiFunction< JPhiFunction_t, JFunctionalMaplist_t > multifunction_type
multifunction_type::super_iterator super_iterator
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.
JHondaFluxInterpolator< JPhiFunction_t, JCoszFunctionalMap_t, JEnergyFunctionalMap_t > interpolator_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
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
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
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
General puprpose classes and methods.
JProperties & getProperties(T &object, const JEquationParameters ¶meters=JEquationParameters(), const int debug=1)
Get properties of a given object.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
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 JEquationParameters & getEquationParameters()
Get equation parameters.
static const char *const getTypeKey()
Get type keyword.
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.
JHondaBinRange()
Default constructor.
JHondaBinRange(const double minimum, const double maximum)
Constructor.
friend std::istream & operator>>(std::istream &in, JHondaBinRange &object)
Read bin range from input.
double getCentralValue() const
Get central value of this range.
JRange< double > JRange_t
Auxiliary class for I/O of Honda flux interpolator.
JHondaFluxInterpolatorHelper(const JHondaFluxInterpolator_t &interpolator, const JEquationParameters &eqpars)
Constructor.
JHondaFluxInterpolatorHelper(const JHondaFluxInterpolator_t &interpolator, const JEquationParameters &eqpars)
Constructor.
static int debug
Default verbosity for oscillation probability interpolators.
Auxiliary class for handling debug parameter within a class.
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)