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