Jpp  19.1.0
the software that should make you happy
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 
9 /**
10  * \author bjung
11  * Auxiliary data structure for storing and computing oscillation baselines.
12  */
13 
14 namespace JOSCPROB {}
15 namespace JPP { using namespace JOSCPROB; }
16 
17 namespace JOSCPROB {
18 
19 
20  /**
21  * Auxiliary data structure for storing and calculating baselines.
22  */
24  {
25  /**
26  * Default constructor.
27  */
29  Lmin(0.0),
30  Lmax(0.0)
31  {}
32 
33 
34  /**
35  * Constructor.
36  *
37  * \param Lmin Minimum baseline [km]
38  * \param Lmax Maximum baseline [km]
39  */
40  JBaselineComputer(const double Lmin,
41  const double Lmax) :
42  Lmin(Lmin),
43  Lmax(Lmax)
44  {}
45 
46 
47  /**
48  * Get minimum baseline.
49  *
50  * \return maximum baseline [km]
51  */
52  double getMinimumBaseline() const
53  {
54  return Lmin;
55  }
56 
57 
58  /**
59  * Get maximum baseline.
60  *
61  * \return maximum baseline [km]
62  */
63  double getMaximumBaseline() const
64  {
65  return Lmax;
66  }
67 
68 
69  /**
70  * Get inner radius.
71  *
72  * \return inner radius [km]
73  */
74  double getInnerRadius() const
75  {
76  return 0.5 * (Lmax - Lmin);
77  }
78 
79 
80  /**
81  * Get outer radius.
82  *
83  * \return outer radius [km]
84  */
85  double getOuterRadius() const
86  {
87  return 0.5 * (Lmax + Lmin);;
88  }
89 
90 
91  /**
92  * Get cosine zenith angle for a given baseline.
93  *
94  * \param L baseline [km]
95  * \return cosine zenith angle
96  */
97  double getCosth(const double L) const
98  {
99  const double r = getInnerRadius();
100  const double R = getOuterRadius();
101 
102  return (R*R - r*r - L*L) / (2*L*r);
103  }
104 
105 
106  /**
107  * Get baseline for a given cosine zenith angle.
108  *
109  * \param costh cosine zenith angle
110  * \return baseline [km]
111  */
112  double getBaseline(const double costh) const
113  {
114  const double r = getInnerRadius();
115  const double R = getOuterRadius();
116 
117  const double ct = (fabs(costh) < 1.0 ? costh : (costh < 0 ? -1.0 : 1.0));
118 
119  return (-r * ct + sqrt(R*R - r*r * (1 - ct) * (1 + ct)));
120  }
121 
122 
123  /**
124  * Get baseline for a given cosine zenith angle.
125  *
126  * \param costh cosine zenith angle
127  * \return baseline [km]
128  */
129  double operator()(const double costh) const
130  {
131  return getBaseline(costh);
132  }
133 
134 
135  /**
136  * Stream input of baseline calculator.
137  *
138  * \param in input stream
139  * \param object object
140  * \return input stream
141  */
142  friend inline std::istream& operator>>(std::istream& in, JBaselineComputer& object)
143  {
144  return in >> object.Lmin >> object.Lmax;
145  }
146 
147 
148  /**
149  * Stream output of baseline calculator.
150  *
151  * \param out output stream
152  * \param object object
153  * \return output stream
154  */
155  friend inline std::ostream& operator<<(std::ostream& out, const JBaselineComputer& object)
156  {
157  using namespace JPP;
158 
159  return out << FIXED(15,5) << object.Lmin << FIXED(15,5) << object.Lmax;
160  }
161 
162 
163  protected:
164 
165  double Lmin; //!< Minimum baseline [km]
166  double Lmax; //!< Maximum baseline [km]
167  };
168 }
169 
170 #endif
I/O manipulators.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
data_type r[M+1]
Definition: JPolint.hh:868
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Auxiliary data structure for storing and calculating baselines.
double operator()(const double costh) const
Get baseline for a given cosine zenith angle.
friend std::ostream & operator<<(std::ostream &out, const JBaselineComputer &object)
Stream output of baseline calculator.
double getInnerRadius() const
Get inner radius.
double getOuterRadius() const
Get outer radius.
double getCosth(const double L) const
Get cosine zenith angle for a given baseline.
double getBaseline(const double costh) const
Get baseline for a given cosine zenith angle.
friend std::istream & operator>>(std::istream &in, JBaselineComputer &object)
Stream input of baseline calculator.
JBaselineComputer()
Default constructor.
JBaselineComputer(const double Lmin, const double Lmax)
Constructor.
double getMinimumBaseline() const
Get minimum baseline.
double getMaximumBaseline() const
Get maximum baseline.
double Lmax
Maximum baseline [km].
double Lmin
Minimum baseline [km].