Jpp  17.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTransmission.hh
Go to the documentation of this file.
1 #ifndef __JACOUSTICS__JTRANSMISSION__
2 #define __JACOUSTICS__JTRANSMISSION__
3 
4 #include <cmath>
5 
6 #include <TROOT.h>
7 #include <TObject.h>
8 
9 
10 /**
11  * \file
12  *
13  * Acoustic transmission.
14  * \author mdejong
15  */
16 namespace JACOUSTICS {}
17 namespace JPP { using namespace JACOUSTICS; }
18 
19 namespace JACOUSTICS {
20 
21  /**
22  * Acoustic transmission.
23  */
24  struct JTransmission :
25  public TObject
26  {
27  /**
28  * Default constructor.
29  */
31  run(-1),
32  id (-1),
33  q (0.0),
34  w (0.0),
35  toa(0.0),
36  toe(0.0)
37  {}
38 
39 
40  /**
41  * Constructor.
42  *
43  * \param run run number
44  * \param id identifier
45  * \param Q quality
46  * \param W normalisation
47  * \param toa_s time-of-arrival [s]
48  * \param toe_s time-of-emission [s]
49  */
50  JTransmission(const int run,
51  const int id,
52  const double Q,
53  const double W,
54  const double toa_s,
55  const double toe_s) :
56  run(run),
57  id (id),
58  q (Q),
59  w (W),
60  toa(toa_s),
61  toe(toe_s)
62  {}
63 
64 
65  /**
66  * Virtual destructor.
67  */
68  virtual ~JTransmission()
69  {}
70 
71 
72  /**
73  * Get run number.
74  *
75  * \return run number
76  */
77  int getRunNumber() const
78  {
79  return run;
80  }
81 
82 
83  /**
84  * Get identifier.
85  *
86  * \return identifier
87  */
88  int getID() const
89  {
90  return id;
91  }
92 
93 
94  /**
95  * Get quality.
96  *
97  * \return quality
98  */
99  double getQ() const
100  {
101  return q;
102  }
103 
104 
105  /**
106  * Get normalisation.
107  *
108  * \return normalisation
109  */
110  double getW() const
111  {
112  return w;
113  }
114 
115 
116  /**
117  * Get calibrated time of arrival.
118  *
119  * \return time [s]
120  */
121  double getToA() const
122  {
123  return toa;
124  }
125 
126 
127  /**
128  * Get estimated time of emission.
129  *
130  * \return time [s]
131  */
132  double getToE() const
133  {
134  return toe;
135  }
136 
137 
138  /**
139  * Set estimated time of emission.
140  *
141  * \param toe time [s]
142  */
143  void setToE(const double toe)
144  {
145  this->toe = toe;
146  }
147 
149 
150 
151  /**
152  * Auxiliary class to compare transmissions.
153  */
154  struct equals {
155  /**
156  * Constructor.
157  *
158  * \param precision time-of-arrival precision [s]
159  */
160  equals(const double precision) :
161  precision(precision)
162  {}
163 
164 
165  /**
166  * Compare two transmissions.
167  *
168  * \param first first transmission
169  * \param second second transmission
170  * \return true if times-of-arrival are similar; else false
171  */
172  bool operator()(const JTransmission& first, const JTransmission& second) const
173  {
174  return fabs(first.getToA() - second.getToA()) <= precision;
175  }
176 
177  const double precision;
178  };
179 
180 
181  /**
182  * Auxiliary class to compare transmissions.
183  */
184  struct compare :
185  public equals
186  {
187  /**
188  * Constructor.
189  *
190  * \param precision time-of-arrival precision [s]
191  */
192  compare(const double precision) :
193  equals(precision)
194  {}
195 
196 
197  /**
198  * Compare two transmissions.
199  *
200  * The transmission wih the earliest time-of-arrival comes first.\n
201  * If the two transmissions are equal within the specified precision,
202  * the transmission with the highest quality comes first.\n
203  * If also the qualities are the same, the time-of-arrival is again used.
204  *
205  * \param first first transmission
206  * \param second second transmission
207  * \return true if time-of-arrival of first transmission earlier than that of second; else false
208  */
209  bool operator()(const JTransmission& first, const JTransmission& second) const
210  {
211  if (static_cast<const equals&>(*this)(first, second)) {
212 
213  if (first.getQ() == second.getQ())
214  return first.getToA() < second.getToA();
215  else
216  return first.getQ() > second.getQ();
217 
218  } else {
219 
220  return first.getToA() < second.getToA();
221  }
222  }
223  };
224 
225  protected:
226  int run;
227  int id;
228  double q;
229  double w;
230  double toa;
231  double toe;
232  };
233 
234 
235  /**
236  * Less-than operator for two transmissions.
237  *
238  * The less-than operator is first applied to the time-of-emission and then to the identifier.
239  *
240  * \param first first transmission
241  * \param second second transmission
242  * \return true if first transmission earlier than second; else false
243  */
244  static inline bool operator<(const JTransmission& first, const JTransmission& second)
245  {
246  if (first.getToE() == second.getToE())
247  return first.getID() < second.getID();
248  else
249  return first.getToE() < second.getToE();
250  }
251 
252 
253  /**
254  * Equals operator for two transmissions.
255  *
256  * The equal operator is applied to the time-of-emission and the identifier.
257  *
258  * \param first first transmission
259  * \param second second transmission
260  * \return true if first transmission equal to second; else false
261  */
262  static inline bool operator==(const JTransmission& first, const JTransmission& second)
263  {
264  return (first.getID() == second.getID() &&
265  first.getToE() == second.getToE());
266  }
267 }
268 
269 #endif
Q(UTCMax_s-UTCMin_s)-livetime_s
double getQ() const
Get quality.
int getRunNumber() const
Get run number.
equals(const double precision)
Constructor.
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1741
Definition: JRoot.hh:19
double getToE() const
Get estimated time of emission.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
double getW() const
Get normalisation.
Acoustic transmission.
bool operator==(Packet const &p, ID const &id)
ClassDef(JTransmission, 3)
JTransmission(const int run, const int id, const double Q, const double W, const double toa_s, const double toe_s)
Constructor.
void setToE(const double toe)
Set estimated time of emission.
Auxiliary class to compare transmissions.
JTransmission()
Default constructor.
virtual ~JTransmission()
Virtual destructor.
double getToA() const
Get calibrated time of arrival.
int getID() const
Get identifier.
Auxiliary class to compare transmissions.
bool operator()(const JTransmission &first, const JTransmission &second) const
Compare two transmissions.
bool operator()(const JTransmission &first, const JTransmission &second) const
Compare two transmissions.
compare(const double precision)
Constructor.