Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JComplexPhase.hh
Go to the documentation of this file.
1#ifndef __JOSCPROB__JCOMPLEXPHASE__
2#define __JOSCPROB__JCOMPLEXPHASE__
3
4#include "JLang/JException.hh"
5
6#include "JTools/JGrid.hh"
7
9
10
11/**
12 * \author bjung, mdejong
13 */
14
15namespace JOSCPROB {}
16namespace JPP { using namespace JOSCPROB; }
17
18namespace JOSCPROB {
19
20 using JTOOLS::JGrid;
21
22
23 /**
24 * Implementation of oscillation complex phase.
25 */
26 template<class T>
27 struct JComplexPhase final :
28 public JOscParameter<T>
29 {
32
36
37
38 /**
39 * Default constructor.
40 */
44
45
46 /**
47 * Constructor.
48 *
49 * \param value complex phase value [rad]
50 */
51 explicit JComplexPhase(argument_type value) :
52 JOscParameter_t(value)
53 {
54 using namespace JPP;
55
56 if (!is_valid()) {
57 THROW(JValueOutOfRange, "JComplexPhase::JComplexPhase(): Invalid complex phase " << value);
58 }
59 }
60
61
62 /**
63 * Assignment operator.
64 *
65 * \param value complex phase value [rad]
66 * \return complex phase
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 final
82 {
83 const value_type phase = this->getValue();
84
85 return this->isDefined() ? !(phase < 0.0 || phase > 2 * M_PI) : true;
86 }
87 };
88
89
90 /**
91 * Template specialization for parameter grid.
92 */
93 template<>
94 struct JComplexPhase<JGrid<double> > final :
95 public JOscParameter<JGrid<double> >
96 {
100
102
103
104 /**
105 * Default constructor.
106 */
109
110
111 /**
112 * Constructor.
113 *
114 * \param grid complex phase parameter grid [rad]
115 */
116 explicit JComplexPhase(const JGrid_t& grid) :
117 JOscParameter_t(grid)
118 {
119 using namespace JPP;
120
121 if (!is_valid()) {
122 THROW(JValueOutOfRange, "JComplexPhase::JComplexPhase(): Invalid complex phase grid " << grid);
123 }
124 }
125
126
127 /**
128 * Constructor.
129 *
130 * \param nx number of elements
131 * \param xmin lower limit [rad]
132 * \param xmax upper limit [rad]
133 */
134 JComplexPhase(const int nx,
135 const double xmin,
136 const double xmax) :
137 JOscParameter_t(JGrid_t(nx, xmin, xmax))
138 {}
139
140
141 /**
142 * Constructor.
143 *
144 * \param value complex phase value [rad]
145 */
146 explicit JComplexPhase(const double value) :
147 JComplexPhase(1, value, value)
148 {}
149
150
151 /**
152 * Assignment operator.
153 *
154 * \param grid complex phase parameter grid [rad]
155 * \return complex phase
156 */
158 {
159 this->setValue(grid);
160
161 return *this;
162 }
163
164
165 /**
166 * Check validity of oscillation parameter.
167 *
168 * \return true if valid; else false
169 */
170 bool is_valid() const override final
171 {
172 const double minPhase = this->getValue().getXmin();
173 const double maxPhase = this->getValue().getXmax();
174
175 return (this->isDefined() ? !(minPhase < 0.0 || minPhase > 2 * M_PI ||
176 maxPhase < 0.0 || maxPhase > 2 * M_PI) : true);
177 }
178 };
179}
180
181#endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Parameter class.
Definition JParameter.hh:36
const value_type getValue() const
Get value of parameter.
Definition JParameter.hh:82
const bool isDefined() const
Get status of parameter.
Exception for accessing a value in a collection that is outside of its range.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JOscParameter_t::JParameter_t JParameter_t
JComplexPhase(const JGrid_t &grid)
Constructor.
JComplexPhase_t & operator=(const JGrid_t &grid)
Assignment operator.
bool is_valid() const override final
Check validity of oscillation parameter.
JComplexPhase(const int nx, const double xmin, const double xmax)
Constructor.
JComplexPhase(const double value)
Constructor.
Implementation of oscillation complex phase.
JComplexPhase(argument_type value)
Constructor.
JOscParameter< T > JOscParameter_t
bool is_valid() const override final
Check validity of oscillation parameter.
JComplexPhase()
Default constructor.
JComplexPhase_t & operator=(const value_type &value)
Assignment operator.
JOscParameter_t::argument_type argument_type
JComplexPhase< T > JComplexPhase_t
JOscParameter_t::JParameter_t JParameter_t
JOscParameter_t::value_type value_type
Abstract base class for oscillation parameter.
void setValue(const value_type &value)
Set parameter.
JParameter_t::argument_type argument_type
JParameter_t::value_type value_type
Simple data structure for an abstract collection of equidistant abscissa values.
Definition JGrid.hh:40