Jpp  15.0.1-rc.1-highqe
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  toa(0.0),
35  toe(0.0)
36  {}
37 
38 
39  /**
40  * Constructor.
41  *
42  * \param run run number
43  * \param id identifier
44  * \param Q quality
45  * \param toa_s time-of-arrival [s]
46  * \param toe_s time-of-emission [s]
47  */
48  JTransmission(const int run,
49  const int id,
50  const double Q,
51  const double toa_s,
52  const double toe_s) :
53  run(run),
54  id (id),
55  q (Q),
56  toa(toa_s),
57  toe(toe_s)
58  {}
59 
60 
61  /**
62  * Virtual destructor.
63  */
64  virtual ~JTransmission()
65  {}
66 
67 
68  /**
69  * Get run number.
70  *
71  * \return run number
72  */
73  int getRunNumber() const
74  {
75  return run;
76  }
77 
78 
79  /**
80  * Get identifier.
81  *
82  * \return identifier
83  */
84  int getID() const
85  {
86  return id;
87  }
88 
89 
90  /**
91  * Get quality.
92  *
93  * \return quality
94  */
95  double getQ() const
96  {
97  return q;
98  }
99 
100 
101  /**
102  * Get calibrated time of arrival.
103  *
104  * \return time [s]
105  */
106  double getToA() const
107  {
108  return toa;
109  }
110 
111 
112  /**
113  * Get estimated time of emission.
114  *
115  * \return time [s]
116  */
117  double getToE() const
118  {
119  return toe;
120  }
121 
122 
123  /**
124  * Set estimated time of emission.
125  *
126  * \param toe time [s]
127  */
128  void setToE(const double toe)
129  {
130  this->toe = toe;
131  }
132 
134 
135 
136  /**
137  * Auxiliary class to compare transmissions.
138  */
139  struct equals {
140  /**
141  * Constructor.
142  *
143  * \param precision precision
144  */
145  equals(const double precision) :
146  precision(precision)
147  {}
148 
149 
150  /**
151  * Compare two transmissions.
152  *
153  * \param first first transmission
154  * \param second second transmission
155  * \return true if times-of-arrival are similar; else false
156  */
157  bool operator()(const JTransmission& first, const JTransmission& second) const
158  {
159  return fabs(first.getToA() - second.getToA()) <= precision;
160  }
161 
162  const double precision;
163  };
164 
165 
166  /**
167  * Auxiliary class to compare transmissions.
168  */
169  struct compare :
170  public equals
171  {
172  /**
173  * Constructor.
174  *
175  * \param precision precision
176  */
177  compare(const double precision) :
178  equals(precision)
179  {}
180 
181 
182  /**
183  * Compare two transmissions.
184  *
185  * The transmission wih the earliest time-of-arrival comes first.\n
186  * If the two transmissions are equal within the specified precision,
187  * the transmission with the highest quality comes first.
188  *
189  * \param first first transmission
190  * \param second second transmission
191  * \return true if time-of-arrival of first transmission earlier than that of second; else false
192  */
193  bool operator()(const JTransmission& first, const JTransmission& second) const
194  {
195  if (static_cast<const equals&>(*this)(first, second))
196  return first.getQ() > second.getQ();
197  else
198  return first.getToA() < second.getToA();
199  }
200  };
201 
202  protected:
203  int run;
204  int id;
205  double q;
206  double toa;
207  double toe;
208  };
209 
210 
211  /**
212  * Less-than operator for two transmissions.
213  *
214  * The less-than operator is first applied to the time-of-emission and then to the identifier.
215  *
216  * \param first first transmission
217  * \param second second transmission
218  * \return true if first transmission earlier than second; else false
219  */
220  static inline bool operator<(const JTransmission& first, const JTransmission& second)
221  {
222  if (first.getToE() == second.getToE())
223  return first.getID() < second.getID();
224  else
225  return first.getToE() < second.getToE();
226  }
227 
228 
229  /**
230  * Equals operator for two transmissions.
231  *
232  * The equal operator is applied to the time-of-emission and the identifier.
233  *
234  * \param first first transmission
235  * \param second second transmission
236  * \return true if first transmission equal to second; else false
237  */
238  static inline bool operator==(const JTransmission& first, const JTransmission& second)
239  {
240  return (first.getID() == second.getID() &&
241  first.getToE() == second.getToE());
242  }
243 }
244 
245 #endif
Q(UTCMax_s-UTCMin_s)-livetime_s
double getQ() const
Get quality.
JTransmission(const int run, const int id, const double Q, const double toa_s, const double toe_s)
Constructor.
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:1603
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
Acoustic transmission.
bool operator==(Packet const &p, ID const &id)
void setToE(const double toe)
Set estimated time of emission.
Auxiliary class to compare transmissions.
JTransmission()
Default constructor.
virtual ~JTransmission()
Virtual destructor.
ClassDef(JTransmission, 2)
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.