#ifndef __JOSCPROB__JMIXINGANGLE__ #define __JOSCPROB__JMIXINGANGLE__ #include "JLang/JException.hh" #include "JTools/JGrid.hh" #include "JOscProb/JOscParameter.hh" /** * \author bjung, mdejong */ namespace JOSCPROB {} namespace JPP { using namespace JOSCPROB; } namespace JOSCPROB { using JTOOLS::JGrid; /** * Implementation of oscillation mixing angle. */ template struct JMixingAngle : public JOscParameter { typedef JMixingAngle JMixingAngle_t; typedef JOscParameter JOscParameter_t; typedef typename JOscParameter_t::JParameter_t JParameter_t; typedef typename JOscParameter_t::argument_type argument_type; typedef typename JOscParameter_t::value_type value_type; /** * Default constructor. */ JMixingAngle() : JOscParameter_t() {} /** * Constructor. * * \param value mixing angle value [rad] */ explicit JMixingAngle(argument_type value) : JOscParameter_t(value) { using namespace JPP; if (!is_valid()) { THROW(JValueOutOfRange, "JMixingAngle::JMixingAngle(): Invalid mixing angle " << value); } } /** * Assignment operator. * * \param value mixing angle value [rad] * \return mixing angle */ JMixingAngle_t& operator=(const value_type& value) { this->setValue(value); return *this; } /** * Check validity of oscillation parameter. * * \return true if valid; else false */ bool is_valid() const override { const value_type angle = this->getValue(); return this->isDefined() ? !(angle < 0.0 || angle > M_PI / 2.0) : true; } /** * Auxiliary function to create a mixing angle parameter. * * \param value mixing angle value [rad] * \return mixing angle parameter */ static JMixingAngle_t make_parameter(argument_type value) { return JMixingAngle_t(value); } }; /** * Template specialization for parameter grid. */ template<> struct JMixingAngle > : public JOscParameter > { typedef JGrid JGrid_t; typedef JMixingAngle JMixingAngle_t; typedef JOscParameter JOscParameter_t; typedef typename JOscParameter_t::JParameter_t JParameter_t; /** * Default constructor. */ JMixingAngle() {} /** * Constructor. * * \param grid mixing angle parameter grid [rad] */ explicit JMixingAngle(const JGrid_t& grid) : JOscParameter_t(grid) { using namespace JPP; if (!is_valid()) { THROW(JValueOutOfRange, "JMixingAngle::JMixingAngle(): Invalid mixing angle parameter grid " << grid); } } /** * Constructor. * * \param nx number of elements * \param xmin lower limit * \param xmax upper limit */ JMixingAngle(const int nx, const double xmin, const double xmax) : JOscParameter_t(JGrid_t(nx, xmin, xmax)) {} /** * Constructor. * * \param value value */ explicit JMixingAngle(const double value) : JMixingAngle(1, value, value) {} /** * Assignment operator. * * \param grid mixing angle parameter grid [rad] * \return mixing angle */ JMixingAngle_t& operator=(const JGrid_t& grid) { this->setValue(grid); return *this; } /** * Check validity of oscillation parameter. * * \return true if valid; else false */ bool is_valid() const override { const double minAngle = this->getValue().getXmin(); const double maxAngle = this->getValue().getXmax(); return (this->isDefined() ? !(minAngle < 0.0 || minAngle > M_PI / 2.0 || maxAngle < 0.0 || maxAngle > M_PI / 2.0) : true); } /** * Auxiliary function to create a mixing angle parameter grid. * * \param value mixing angle value [rad] * \return mixing angle parameter grid */ static JMixingAngle_t make_parameter(const double value) { return JMixingAngle_t(value); } }; } #endif