Jpp  18.3.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMixingAngle.hh
Go to the documentation of this file.
1 #ifndef __JOSCPROB__JMIXINGANGLE__
2 #define __JOSCPROB__JMIXINGANGLE__
3 
4 #include "JLang/JException.hh"
5 
6 #include "JTools/JGrid.hh"
7 
9 
10 
11 /**
12  * \author bjung, mdejong
13  */
14 
15 namespace JOSCPROB {}
16 namespace JPP { using namespace JOSCPROB; }
17 
18 namespace JOSCPROB {
19 
20  using JTOOLS::JGrid;
21 
22 
23  /**
24  * Implementation of oscillation mixing angle.
25  */
26  template<class T = double>
27  struct JMixingAngle :
28  public JOscParameter<T>
29  {
32 
35 
36 
37  /**
38  * Default constructor.
39  */
42  {}
43 
44 
45  /**
46  * Constructor.
47  *
48  * \param value mixing angle value [rad]
49  */
50  explicit JMixingAngle(argument_type value) :
51  JOscParameter_t(value)
52  {
53  using namespace JPP;
54 
55  if (!is_valid()) {
56  THROW(JValueOutOfRange, "JMixingAngle::JMixingAngle(): Invalid mixing angle " << value);
57  }
58  }
59 
60 
61  /**
62  * Assignment operator.
63  *
64  * \param value mixing angle value [rad]
65  * \return mixing angle
66  */
68  {
69  this->setValue(value);
70 
71  return *this;
72  }
73 
74 
75  /**
76  * Check validity of oscillation parameter.
77  *
78  * \return true if valid; else false
79  */
80  bool is_valid() const override
81  {
82  const T& angle = this->getValue();
83 
84  return this->isDefined() ? !(angle < 0.0 || angle > M_PI / 2.0) : true;
85  }
86 
87 
88  /**
89  * Auxiliary function to create a mixing angle parameter.
90  *
91  * \param value mixing angle value [rad]
92  * \return mixing angle parameter
93  */
95  {
96  return JMixingAngle_t(value);
97  }
98  };
99 
100 
101  /**
102  * Template specialization for parameter grid.
103  */
104  template<>
105  struct JMixingAngle<JGrid<double> > :
106  public JOscParameter<JGrid<double> >
107  {
111 
114 
116 
117 
118  /**
119  * Default constructor.
120  */
122  {}
123 
124 
125  /**
126  * Constructor.
127  *
128  * \param grid mixing angle parameter grid [rad]
129  */
130  explicit JMixingAngle(argument_type grid) :
131  JOscParameter_t(grid)
132  {
133  using namespace JPP;
134 
135  if (!is_valid()) {
136  THROW(JValueOutOfRange, "JMixingAngle::JMixingAngle(): Invalid mixing angle parameter grid " << grid);
137  }
138  }
139 
140 
141  /**
142  * Constructor.
143  *
144  * \param nx number of elements
145  * \param Xmin lower limit
146  * \param Xmax upper limit
147  */
148  JMixingAngle(const int nx,
149  const abscissa_type& xmin,
150  const abscissa_type& xmax) :
151  JOscParameter_t(JGrid_t(nx, xmin, xmax))
152  {}
153 
154 
155  /**
156  * Constructor.
157  *
158  * \param value value
159  */
160  explicit JMixingAngle(const abscissa_type& value) :
161  JMixingAngle(1, value, value)
162  {}
163 
164 
165  /**
166  * Assignment operator.
167  *
168  * \param value mixing angle parameter grid [rad]
169  * \return mixing angle
170  */
172  {
173  this->setValue(grid);
174 
175  return *this;
176  }
177 
178 
179  /**
180  * Check validity of oscillation parameter.
181  *
182  * \return true if valid; else false
183  */
184  bool is_valid() const override
185  {
186  const abscissa_type minAngle = this->getValue().getXmin();
187  const abscissa_type maxAngle = this->getValue().getXmax();
188 
189  return (this->isDefined() ? !(minAngle < 0.0 || minAngle > M_PI / 2.0 ||
190  maxAngle < 0.0 || maxAngle > M_PI / 2.0) : true);
191  }
192 
193 
194  /**
195  * Auxiliary function to create a mixing angle parameter grid.
196  *
197  * \param value mixing angle value [rad]
198  * \return mixing angle parameter grid
199  */
201  {
202  return JMixingAngle_t(value);
203  }
204  };
205 }
206 
207 #endif
JMixingAngle(argument_type grid)
Constructor.
const double xmax
Definition: JQuadrature.cc:24
Abstract base class for oscillation parameter.
Exceptions.
Parameter class.
Definition: JParameter.hh:34
JOscParameter_t::argument_type argument_type
JMixingAngle()
Default constructor.
Definition: JMixingAngle.hh:40
bool is_valid() const override
Check validity of oscillation parameter.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JMixingAngle< T > JMixingAngle_t
Definition: JMixingAngle.hh:30
void setValue(argument_type value)
Set parameter.
static JMixingAngle_t make_parameter(const abscissa_type &value)
Auxiliary function to create a mixing angle parameter grid.
JOscParameter< T > JOscParameter_t
Definition: JMixingAngle.hh:31
const bool isDefined() const
Get status of parameter.
Definition: JParameter.hh:137
JParameter_t::argument_type argument_type
JMixingAngle(const abscissa_type &value)
Constructor.
static JMixingAngle_t make_parameter(argument_type value)
Auxiliary function to create a mixing angle parameter.
Definition: JMixingAngle.hh:94
JMixingAngle(const int nx, const abscissa_type &xmin, const abscissa_type &xmax)
Constructor.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JOscParameter_t::JParameter_t JParameter_t
Definition: JMixingAngle.hh:33
JMixingAngle_t & operator=(argument_type value)
Assignment operator.
Definition: JMixingAngle.hh:67
JClass< T >::argument_type argument_type
Definition: JParameter.hh:39
JMixingAngle(argument_type value)
Constructor.
Definition: JMixingAngle.hh:50
JMixingAngle_t & operator=(argument_type grid)
Assignment operator.
const double xmin
Definition: JQuadrature.cc:23
JOscParameter_t::JParameter_t JParameter_t
JAbstractCollection< JAbscissa_t >::abscissa_type abscissa_type
Definition: JGrid.hh:41
Simple data structure for an abstract collection of equidistant abscissa values.
Definition: JGrid.hh:38
JOscParameter< JGrid_t > JOscParameter_t
const T & getValue() const
Get value of parameter.
Definition: JParameter.hh:81
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:178
Implementation of oscillation mixing angle.
Definition: JMixingAngle.hh:27
JOscParameter_t::argument_type argument_type
Definition: JMixingAngle.hh:34
bool is_valid() const override
Check validity of oscillation parameter.
Definition: JMixingAngle.hh:80