Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
8 #include "JIO/JSerialisable.hh"
9 
11 
12 
13 /**
14  * \author bjung
15  * Auxiliary data structure for storing and computing oscillation baselines.
16  */
17 
18 namespace JOSCPROB {}
19 namespace JPP { using namespace JOSCPROB; }
20 
21 namespace JOSCPROB {
22 
23  using JIO::JReader;
24  using JIO::JWriter;
25  using JIO::JSerialisable;
26 
27 
28  /**
29  * Auxiliary data structure for storing and calculating baselines.
30  */
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
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
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
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
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
Interface for binary output.
double getInnerRadius() const
Get inner radius.
Low-level interface for oscillation baseline calculators.
JReader & read(JReader &in) override
Binary stream input of baseline extrema.
friend std::ostream & operator<<(std::ostream &out, const JBaselineComputer &object)
Stream output of baseline calculator.
double getOuterRadius() const
Get outer radius.
data_type r[M+1]
Definition: JPolint.hh:868
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
double Lmax
Maximum baseline [km].
Forward declaration of binary output.
double getMinimumBaseline() const
Get minimum baseline.
JBaselineComputer()
Default constructor.
double getCosth(const double L) const override
Get cosine zenith angle for a given baseline.
double Lmin
Minimum baseline [km].
double getBaseline(const double costh) const override
Get baseline for a given cosine zenith angle.
friend std::istream & operator>>(std::istream &in, JBaselineComputer &object)
Stream input of baseline calculator.
JBaselineComputer(const double Lmin, const double Lmax)
Constructor.
Interface for binary input.
I/O manipulators.
Auxiliary data structure for storing and calculating baselines.
double getMaximumBaseline() const
Get maximum baseline.
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
double operator()(const double costh) const
Get baseline for a given cosine zenith angle.
JWriter & write(JWriter &out) const override
Binary stream output of oscillation parameters.