Jpp  18.5.2
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 "JLang/JManip.hh"
5 
6 #include "JIO/JSerialisable.hh"
7 
9 
10 
11 /**
12  * \author bjung
13  * Auxiliary data structure for storing and computing oscillation baselines.
14  */
15 
16 namespace JOSCPROB {}
17 namespace JPP { using namespace JOSCPROB; }
18 
19 namespace JOSCPROB {
20 
21  using JIO::JReader;
22  using JIO::JWriter;
23  using JIO::JSerialisable;
24 
25 
26  /**
27  * Auxiliary data structure for storing and calculating baselines.
28  */
31  public JSerialisable
32  {
33  /**
34  * Default constructor.
35  */
37  Lmin(0.0),
38  Lmax(0.0)
39  {}
40 
41 
42  /**
43  * Constructor.
44  *
45  * \param Lmin Minimum baseline [km]
46  * \param Lmax Maximum baseline [km]
47  */
48  JBaselineComputer(const double Lmin,
49  const double Lmax) :
50  Lmin(Lmin),
51  Lmax(Lmax)
52  {}
53 
54 
55  /**
56  * Get minimum baseline.
57  *
58  * \return maximum baseline [km]
59  */
60  double getMinimumBaseline() const
61  {
62  return Lmin;
63  }
64 
65 
66  /**
67  * Get maximum baseline.
68  *
69  * \return maximum baseline [km]
70  */
71  double getMaximumBaseline() const
72  {
73  return Lmax;
74  }
75 
76 
77  /**
78  * Get inner radius.
79  *
80  * \return inner radius [km]
81  */
82  double getInnerRadius() const
83  {
84  return 0.5 * (Lmax - Lmin);
85  }
86 
87 
88  /**
89  * Get outer radius.
90  *
91  * \return outer radius [km]
92  */
93  double getOuterRadius() const
94  {
95  return 0.5 * (Lmax + Lmin);;
96  }
97 
98 
99  /**
100  * Get cosine zenith angle for a given baseline.
101  *
102  * \param L baseline [km]
103  * \return cosine zenith angle
104  */
105  double getCosth(const double L) const override
106  {
107  const double r = getInnerRadius();
108  const double R = getOuterRadius();
109 
110  return (R*R - r*r - L*L) / (2*L*r);
111  }
112 
113 
114  /**
115  * Get baseline for a given cosine zenith angle.
116  *
117  * \param costh cosine zenith angle
118  * \return baseline [km]
119  */
120  double getBaseline(const double costh) const override
121  {
122  const double r = getInnerRadius();
123  const double R = getOuterRadius();
124 
125  const double ct = (fabs(costh) < 1.0 ? costh : (costh < 0 ? -1.0 : 1.0));
126 
127  return (-r * ct + sqrt(R*R - r*r * (1 - ct) * (1 + ct)));
128  }
129 
130 
131  /**
132  * Get baseline for a given cosine zenith angle.
133  *
134  * \param costh cosine zenith angle
135  * \return baseline [km]
136  */
137  double operator()(const double costh) const
138  {
139  return getBaseline(costh);
140  }
141 
142 
143  /**
144  * Binary stream input of baseline extrema.
145  *
146  * \param in input stream
147  * \return input stream
148  */
149  JReader& read(JReader& in) override
150  {
151  return in >> Lmin >> Lmax;
152  }
153 
154 
155  /**
156  * Binary stream output of oscillation parameters.
157  *
158  * \param out output stream
159  * \return output stream
160  */
161  JWriter& write(JWriter& out) const override
162  {
163  return out << Lmin << Lmax;
164  }
165 
166 
167  /**
168  * Stream input of baseline calculator.
169  *
170  * \param in input stream
171  * \param object object
172  * \return input stream
173  */
174  friend inline std::istream& operator>>(std::istream& in, JBaselineComputer& object)
175  {
176  return in >> object.Lmin >> object.Lmax;
177  }
178 
179 
180  /**
181  * Stream output of baseline calculator.
182  *
183  * \param out output stream
184  * \param object object
185  * \return output stream
186  */
187  friend inline std::ostream& operator<<(std::ostream& out, const JBaselineComputer& object)
188  {
189  using namespace JPP;
190 
191  return out << FIXED(15,5) << object.Lmin << FIXED(15,5) << object.Lmax;
192  }
193 
194 
195  protected:
196 
197  double Lmin; //!< Minimum baseline [km]
198  double Lmax; //!< Maximum baseline [km]
199  };
200 }
201 
202 #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 Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] 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.