#ifndef __JOSCPROB__JMASSSQUAREDDIFFERENCE__ #define __JOSCPROB__JMASSSQUAREDDIFFERENCE__ #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 mass-squared difference. */ template struct JMassSquaredDifference : public JOscParameter { typedef JMassSquaredDifference JMassSquaredDifference_t; typedef JOscParameter JOscParameter_t; typedef typename JOscParameter_t::JParameter_t JParameter_t; typedef typename JOscParameter_t::argument_type argument_type; /** * Default constructor. */ JMassSquaredDifference() : JOscParameter_t() {} /** * Constructor. * * \param value mass-squared difference value [eV2] */ explicit JMassSquaredDifference(argument_type value) : JOscParameter_t(value) { using namespace JPP; if (!is_valid()) { THROW(JValueOutOfRange, "JMassSquaredDifference::JMassSquaredDifference(): Invalid mass-squared difference " << value); } } /** * Assignment operator. * * \param value mass-squared difference value [eV2] * \return mass-squared difference */ JMassSquaredDifference_t& operator=(argument_type value) { this->setValue(value); return *this; } /** * Check validity of oscillation parameter. * * \return true if valid; else false */ bool is_valid() const override { return true; } /** * Auxiliary function to create an mass-squared difference parameter grid. * * \param value mass-squared difference value [eV2] * \return mass-squared difference parameter */ static JMassSquaredDifference_t make_parameter(argument_type value) { return JMassSquaredDifference_t(value); } }; /** * Template specialization for parameter grid. */ template<> struct JMassSquaredDifference > : public JOscParameter > { typedef JGrid JGrid_t; typedef JMassSquaredDifference JMassSquaredDifference_t; typedef JOscParameter JOscParameter_t; typedef typename JOscParameter_t::JParameter_t JParameter_t; typedef typename JOscParameter_t::argument_type argument_type; typedef typename JGrid_t::abscissa_type abscissa_type; /** * Default constructor. */ JMassSquaredDifference() {} /** * Constructor. * * \param grid mass-squared difference parameter grid [eV2] */ explicit JMassSquaredDifference(argument_type grid) : JOscParameter(grid) { using namespace JPP; if (!is_valid()) { THROW(JValueOutOfRange, "JMassSquaredDifference::JMassSquaredDifference(): Invalid mass-squared difference grid " << grid); } } /** * Constructor. * * \param nx number of elements * \param Xmin lower limit [eV2] * \param Xmax upper limit [eV2] */ JMassSquaredDifference(const int nx, const abscissa_type& xmin, const abscissa_type& xmax) : JOscParameter(JGrid_t(nx, xmin, xmax)) {} /** * Constructor. * * \param value value */ explicit JMassSquaredDifference(const abscissa_type& value) : JMassSquaredDifference(1, value, value) {} /** * Assignment operator. * * \param value mass-squared difference parameter grid [eV2] * \return mass-squared difference */ JMassSquaredDifference_t& operator=(argument_type grid) { this->setValue(grid); return *this; } /** * Check validity of oscillation parameter. * * \return true if valid; else false */ bool is_valid() const override { const abscissa_type mindM2 = this->getValue().getXmin(); const abscissa_type maxdM2 = this->getValue().getXmax(); return this->isDefined() ? !(mindM2 < 0.0 || maxdM2 < 0.0) : true; } /** * Auxiliary function to create an mass-squared difference parameter grid. * * \param value mass-squared difference value [eV2] * \return mass-squared difference parameter */ static JMassSquaredDifference_t make_parameter(const abscissa_type& value) { return JMassSquaredDifference_t(value); } }; } #endif