Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JBaselineComputer.hh
Go to the documentation of this file.
1#ifndef __JOSCPROB__JBASELINECOMPUTER__
2#define __JOSCPROB__JBASELINECOMPUTER__
3
4#include <cmath>
5
6#include "JLang/JManip.hh"
7
9
11
12
13/**
14 * \author bjung
15 * Auxiliary data structure for storing and computing oscillation baselines.
16 */
17
18namespace JOSCPROB {}
19namespace JPP { using namespace JOSCPROB; }
20
21namespace JOSCPROB {
22
23 using JIO::JReader;
24 using JIO::JWriter;
26
27
28 /**
29 * Auxiliary data structure for storing and calculating baselines.
30 */
31 struct JBaselineComputer final :
33 public JSerialisable
34 {
35 /**
36 * Default constructor.
37 */
39 Lmin(0.0),
40 Lmax(0.0)
41 {}
42
43
44 /**
45 * Constructor.
46 *
47 * \param Lmin Minimum baseline [km]
48 * \param Lmax Maximum baseline [km]
49 */
50 JBaselineComputer(const double Lmin,
51 const double Lmax) :
52 Lmin(Lmin),
53 Lmax(Lmax)
54 {}
55
56
57 /**
58 * Get minimum baseline.
59 *
60 * \return maximum baseline [km]
61 */
62 double getMinimumBaseline() const
63 {
64 return Lmin;
65 }
66
67
68 /**
69 * Get maximum baseline.
70 *
71 * \return maximum baseline [km]
72 */
73 double getMaximumBaseline() const
74 {
75 return Lmax;
76 }
77
78
79 /**
80 * Get inner radius.
81 *
82 * \return inner radius [km]
83 */
84 double getInnerRadius() const
85 {
86 return 0.5 * (Lmax - Lmin);
87 }
88
89
90 /**
91 * Get outer radius.
92 *
93 * \return outer radius [km]
94 */
95 double getOuterRadius() const
96 {
97 return 0.5 * (Lmax + Lmin);;
98 }
99
100
101 /**
102 * Get cosine zenith angle for a given baseline.
103 *
104 * \param L baseline [km]
105 * \return cosine zenith angle
106 */
107 double getCosth(const double L) const override final
108 {
109 const double r = getInnerRadius();
110 const double R = getOuterRadius();
111
112 return (R*R - r*r - L*L) / (2*L*r);
113 }
114
115
116 /**
117 * Get baseline for a given cosine zenith angle.
118 *
119 * \param costh cosine zenith angle
120 * \return baseline [km]
121 */
122 double getBaseline(const double costh) const override final
123 {
124 const double r = getInnerRadius();
125 const double R = getOuterRadius();
126
127 const double ct = (fabs(costh) < 1.0 ? costh : (costh < 0 ? -1.0 : 1.0));
128
129 return (-r * ct + sqrt(R*R - r*r * (1 - ct) * (1 + ct)));
130 }
131
132
133 /**
134 * Get baseline for a given cosine zenith angle.
135 *
136 * \param costh cosine zenith angle
137 * \return baseline [km]
138 */
139 double operator()(const double costh) const
140 {
141 return getBaseline(costh);
142 }
143
144
145 /**
146 * Binary stream input of baseline extrema.
147 *
148 * \param in input stream
149 * \return input stream
150 */
151 JReader& read(JReader& in) override final
152 {
153 return in >> Lmin >> Lmax;
154 }
155
156
157 /**
158 * Binary stream output of oscillation parameters.
159 *
160 * \param out output stream
161 * \return output stream
162 */
163 JWriter& write(JWriter& out) const override final
164 {
165 return out << Lmin << Lmax;
166 }
167
168
169 /**
170 * Stream input of baseline calculator.
171 *
172 * \param in input stream
173 * \param object object
174 * \return input stream
175 */
176 friend inline std::istream& operator>>(std::istream& in, JBaselineComputer& object)
177 {
178 return in >> object.Lmin >> object.Lmax;
179 }
180
181
182 /**
183 * Stream output of baseline calculator.
184 *
185 * \param out output stream
186 * \param object object
187 * \return output stream
188 */
189 friend inline std::ostream& operator<<(std::ostream& out, const JBaselineComputer& object)
190 {
191 using namespace JPP;
192
193 return out << FIXED(15,5) << object.Lmin << FIXED(15,5) << object.Lmax;
194 }
195
196
197 protected:
198
199 double Lmin; //!< Minimum baseline [km]
200 double Lmax; //!< Maximum baseline [km]
201 };
202}
203
204#endif
I/O manipulators.
Interface for binary input.
Forward declaration of binary output.
Interface for binary output.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Low-level interface for oscillation baseline calculators.
Auxiliary data structure for storing and calculating baselines.
double operator()(const double costh) const
Get baseline for a given cosine zenith angle.
JWriter & write(JWriter &out) const override final
Binary stream output of oscillation parameters.
double getInnerRadius() const
Get inner radius.
double getOuterRadius() const
Get outer radius.
friend std::istream & operator>>(std::istream &in, JBaselineComputer &object)
Stream input of baseline calculator.
JReader & read(JReader &in) override final
Binary stream input of baseline extrema.
JBaselineComputer()
Default constructor.
JBaselineComputer(const double Lmin, const double Lmax)
Constructor.
double getCosth(const double L) const override final
Get cosine zenith angle for a given baseline.
double getMinimumBaseline() const
Get minimum baseline.
double getMaximumBaseline() const
Get maximum baseline.
double Lmax
Maximum baseline [km].
friend std::ostream & operator<<(std::ostream &out, const JBaselineComputer &object)
Stream output of baseline calculator.
double getBaseline(const double costh) const override final
Get baseline for a given cosine zenith angle.
double Lmin
Minimum baseline [km].