#ifndef __JOSCPROB__JOSCPROBFUNCTION__ #define __JOSCPROB__JOSCPROBFUNCTION__ #include "JLang/JClonable.hh" #include "JOscProb/JOscProb.hh" #include "JOscProb/JOscChannel.hh" /** * \author bjung */ namespace JOSCPROB { using JLANG::JClonable; /** * Implementation of oscillation probability function interface. * * The template argument refers to a function of which the copy constuctor needs to be defined. */ template struct JOscProbFunction : public JClonable > { /** * Constructor. * * \param function oscillation probability function */ JOscProbFunction(const JFunction_t& function) : function(function) {} /** * Get oscillation probability for given oscillation channel. * * \param channel oscillation channel * \param energy neutrino energy [GeV] * \param costh cosine zenith angle * \return oscillation probability */ double getOscProb(const JOscChannel& channel, const double energy, const double costh) const override { return function(channel, energy, costh); } private: JFunction_t function; //!< oscillation probability function }; /* Type definition of pointer to oscillation probability function. */ typedef double (*pOscProb)(const JOscChannel&, const double, const double); /** * Implementation of C-style oscillation probability function. */ template<> struct JOscProbFunction : public JClonable< JOscProb, JOscProbFunction > { /** * Constructor. * * \param pFunction oscillation probability function */ JOscProbFunction(pOscProb pFunction) : pFunction(pFunction) {} /** * Get oscillation probability for given oscillation channel. * * \param channel oscillation channel * \param energy neutrino energy [GeV] * \param costh cosine zenith angle * \return oscillation probability */ double getOscProb(const JOscChannel& channel, const double energy, const double costh) const override { return (*pFunction)(channel, energy, costh); } private: pOscProb pFunction; }; /** * Auxiliary method for creating an interface to an oscillation probability function. * * \param function oscillation probability function object * \return oscillation probability function interface */ template inline JOscProbFunction make_oscProbFunction(const JFunction_t& function) { return JOscProbFunction(function); } /** * Auxiliary method for creating an interface to an oscillation probability function. * * \param function oscillation probability function pointer * \return oscillation probability function interface */ inline JOscProbFunction make_oscProbFunction(pOscProb function) { return JOscProbFunction(function); } } #endif