Jpp  19.0.0
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>
27  struct JMixingAngle :
28  public JOscParameter<T>
29  {
32 
36 
37 
38  /**
39  * Default constructor.
40  */
43  {}
44 
45 
46  /**
47  * Constructor.
48  *
49  * \param value mixing angle value [rad]
50  */
51  explicit JMixingAngle(argument_type value) :
52  JOscParameter_t(value)
53  {
54  using namespace JPP;
55 
56  if (!is_valid()) {
57  THROW(JValueOutOfRange, "JMixingAngle::JMixingAngle(): Invalid mixing angle " << value);
58  }
59  }
60 
61 
62  /**
63  * Assignment operator.
64  *
65  * \param value mixing angle value [rad]
66  * \return mixing angle
67  */
69  {
70  this->setValue(value);
71 
72  return *this;
73  }
74 
75 
76  /**
77  * Check validity of oscillation parameter.
78  *
79  * \return true if valid; else false
80  */
81  bool is_valid() const override
82  {
83  const value_type angle = this->getValue();
84 
85  return this->isDefined() ? !(angle < 0.0 || angle > M_PI / 2.0) : true;
86  }
87 
88 
89  /**
90  * Auxiliary function to create a mixing angle parameter.
91  *
92  * \param value mixing angle value [rad]
93  * \return mixing angle parameter
94  */
96  {
97  return JMixingAngle_t(value);
98  }
99  };
100 
101 
102  /**
103  * Template specialization for parameter grid.
104  */
105  template<>
106  struct JMixingAngle<JGrid<double> > :
107  public JOscParameter<JGrid<double> >
108  {
112 
114 
115 
116  /**
117  * Default constructor.
118  */
120  {}
121 
122 
123  /**
124  * Constructor.
125  *
126  * \param grid mixing angle parameter grid [rad]
127  */
128  explicit JMixingAngle(const JGrid_t& grid) :
129  JOscParameter_t(grid)
130  {
131  using namespace JPP;
132 
133  if (!is_valid()) {
134  THROW(JValueOutOfRange, "JMixingAngle::JMixingAngle(): Invalid mixing angle parameter grid " << grid);
135  }
136  }
137 
138 
139  /**
140  * Constructor.
141  *
142  * \param nx number of elements
143  * \param xmin lower limit
144  * \param xmax upper limit
145  */
146  JMixingAngle(const int nx,
147  const double xmin,
148  const double xmax) :
149  JOscParameter_t(JGrid_t(nx, xmin, xmax))
150  {}
151 
152 
153  /**
154  * Constructor.
155  *
156  * \param value value
157  */
158  explicit JMixingAngle(const double value) :
159  JMixingAngle(1, value, value)
160  {}
161 
162 
163  /**
164  * Assignment operator.
165  *
166  * \param grid mixing angle parameter grid [rad]
167  * \return mixing angle
168  */
170  {
171  this->setValue(grid);
172 
173  return *this;
174  }
175 
176 
177  /**
178  * Check validity of oscillation parameter.
179  *
180  * \return true if valid; else false
181  */
182  bool is_valid() const override
183  {
184  const double minAngle = this->getValue().getXmin();
185  const double maxAngle = this->getValue().getXmax();
186 
187  return (this->isDefined() ? !(minAngle < 0.0 || minAngle > M_PI / 2.0 ||
188  maxAngle < 0.0 || maxAngle > M_PI / 2.0) : true);
189  }
190 
191 
192  /**
193  * Auxiliary function to create a mixing angle parameter grid.
194  *
195  * \param value mixing angle value [rad]
196  * \return mixing angle parameter grid
197  */
198  static JMixingAngle_t make_parameter(const double value)
199  {
200  return JMixingAngle_t(value);
201  }
202  };
203 }
204 
205 #endif
const double xmax
Definition: JQuadrature.cc:24
Abstract base class for oscillation parameter.
Exceptions.
Parameter class.
Definition: JParameter.hh:34
JMixingAngle()
Default constructor.
Definition: JMixingAngle.hh:41
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(const JGrid_t &grid)
Constructor.
JMixingAngle< T > JMixingAngle_t
Definition: JMixingAngle.hh:30
static JMixingAngle_t make_parameter(const double 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:116
JParameter_t::argument_type argument_type
JParameter_t::value_type value_type
static JMixingAngle_t make_parameter(argument_type value)
Auxiliary function to create a mixing angle parameter.
Definition: JMixingAngle.hh:95
JOscParameter_t::JParameter_t JParameter_t
Definition: JMixingAngle.hh:33
JClass< T >::argument_type argument_type
Definition: JParameter.hh:39
JMixingAngle(argument_type value)
Constructor.
Definition: JMixingAngle.hh:51
JMixingAngle_t & operator=(const value_type &value)
Assignment operator.
Definition: JMixingAngle.hh:68
void setValue(const value_type &value)
Set parameter.
JOscParameter_t::value_type value_type
Definition: JMixingAngle.hh:35
const double xmin
Definition: JQuadrature.cc:23
JOscParameter_t::JParameter_t JParameter_t
JMixingAngle(const double value)
Constructor.
Simple data structure for an abstract collection of equidistant abscissa values.
Definition: JGrid.hh:38
JOscParameter< JGrid_t > JOscParameter_t
JMixingAngle(const int nx, const double xmin, const double xmax)
Constructor.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:178
JClass< T >::value_type value_type
Definition: JParameter.hh:40
Implementation of oscillation mixing angle.
Definition: JMixingAngle.hh:27
JOscParameter_t::argument_type argument_type
Definition: JMixingAngle.hh:34
JMixingAngle_t & operator=(const JGrid_t &grid)
Assignment operator.
const value_type getValue() const
Get value of parameter.
Definition: JParameter.hh:82
bool is_valid() const override
Check validity of oscillation parameter.
Definition: JMixingAngle.hh:81