#ifndef __JOSCPROB__JOSCPROBHELPER__ #define __JOSCPROB__JOSCPROBHELPER__ #include #include "JLang/JException.hh" #include "JOscProb/JOscChannel.hh" #include "JOscProb/JOscParameters.hh" #include "JOscProb/JOscProbInterface.hh" /** * \author bjung */ namespace JOSCPROB {} namespace JPP { using namespace JOSCPROB; } namespace JOSCPROB { /** * Helper class for oscillation probabilities. */ struct JOscProbHelper : public std::shared_ptr { typedef typename JOscProbInterface::JOscParameters_t JOscParameters_t; typedef typename JOscProbInterface::JOscParameterReferences_t JOscParameterReferences_t; typedef typename JOscProbInterface::JParameter_t JParameter_t; typedef typename JOscProbInterface::argument_type argument_type; typedef typename JOscProbInterface::value_type value_type; typedef std::shared_ptr pointer_type; /** * Default constructor. */ JOscProbHelper() {} /** * Constructor. * * \param pOscProb shared pointer to oscillation probability function */ JOscProbHelper(const pointer_type& pOscProb) : pointer_type(pOscProb) {} /** * Constructor. * * \param oscProb oscillation probability function */ JOscProbHelper(const JOscProbInterface& oscProb) { configure(oscProb); } /** * Configure oscillation probability function. * * \param oscProb oscillation probability function */ void configure(const pointer_type& pOscProb) { static_cast(*this) = pOscProb; } /** * Configure oscillation probability function. * * \param oscProb oscillation probability function */ void configure(const JOscProbInterface& oscProb) { this->reset(oscProb.clone()); } /** * Get reference to oscillation probability interface. * * \return oscillation parameters */ JOscProbInterface& getOscProbInterface() const { using namespace JPP; if (static_cast(*this)) { return *(this->get()); } else { THROW(JNullPointerException, "JOscProbHelper::getOscProbInterface(): Oscillation probability interface is not set."); } } /** * Get reference to oscillation parameters interface. * * \return reference to oscillation parameters interface */ JOscParameterReferences_t& getParameters() const { return getOscProbInterface().getParameters(); } /** * Set oscillation parameters. * * \param parameters oscillation parameters */ void set(const JOscParameters_t& parameters) const { return getParameters().set(parameters); } /** * Set value for a given oscillation parameter. * * \param name parameter name * \param value parameter value */ void set(const std::string& name, const value_type& value) const { getParameters().set(name, value); } /** * Set value for given list of oscillation parameters. * * \param name parameter name * \param value parameter value * \param args remaining pairs of parameter names and values */ template void set(const std::string& name, const value_type& value, const Args& ...args) const { getParameters().set(name, value, args...); } /** * Get oscillation probability corresponding to given oscillation channel, * neutrino energy and zenith angle. * * \param channel oscillation channel * \param energy neutrino energy [GeV] * \param costh cosine zenith angle * \return oscillation probability */ double getP(const JOscChannel& channel, const double energy, const double costh) const { return getOscProbInterface().getP(channel, energy, costh); } /** * Get oscillation probability for a given set of oscillation parameters\n * and a given oscillation channel. * * \param channel oscillation channel * \param parameters oscillation parameters * \param energy neutrino energy [GeV] * \param costh cosine zenith angle * \return oscillation probability */ double getP(const JOscParameters_t& parameters, const JOscChannel& channel, const double energy, const double costh) const { return getOscProbInterface().getP(parameters, channel, energy, costh); } /** * Get oscillation probability for a given oscillation parameter\n * and a given oscillation channel. * * \param name parameter name * \param value parameter value * \param channel oscillation channel * \param E neutrino energy [GeV] * \param costh cosine zenith angle * \return oscillation probability */ double getP(const std::string& name, const double value, const JOscChannel& channel, const double E, const double costh) const { return getOscProbInterface().getP(name, value, channel, E, costh); } /** * Get oscillation probability for a given set of oscillation parameters\n * and a given oscillation channel. * * \param name parameter name * \param value parameter value * \param args remaining arguments */ template double getP(const std::string& name, const double value, const Args& ...args) const { return getOscProbInterface().getP(name, value, args...); } /** * Get cosine zenith angle for a given baseline. * * \param L baseline [km] * \return cosine zenith angle */ double getCosth(const double L) const { return getOscProbInterface().getCosth(L); } /** * Get baseline for a given cosine zenith angle. * * \param costh cosine zenith angle * \return baseline [km] */ double getBaseline(const double costh) const { return getOscProbInterface().getBaseline(costh); } }; } #endif