Jpp
 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  id (-1),
32  q (0.0),
33  toa(0.0),
34  toe(0.0)
35  {}
36 
37 
38  /**
39  * Constructor.
40  *
41  * \param id identifier
42  * \param Q quality
43  * \param toa_s time-of-arrival [s]
44  * \param toe_s time-of-emission [s]
45  */
46  JTransmission(const int id,
47  const double Q,
48  const double toa_s,
49  const double toe_s) :
50  id (id),
51  q (Q),
52  toa(toa_s),
53  toe(toe_s)
54  {}
55 
56 
57  /**
58  * Virtual destructor.
59  */
60  virtual ~JTransmission()
61  {}
62 
63 
64  /**
65  * Get identifier.
66  *
67  * \return identifier
68  */
69  int getID() const
70  {
71  return id;
72  }
73 
74 
75  /**
76  * Get quality.
77  *
78  * \return quality
79  */
80  double getQ() const
81  {
82  return q;
83  }
84 
85 
86  /**
87  * Get absolute time of arrival.
88  *
89  * \return time [s]
90  */
91  double getToA() const
92  {
93  return toa;
94  }
95 
96 
97  /**
98  * Get absolute time of emission.
99  *
100  * \return time [s]
101  */
102  double getToE() const
103  {
104  return toe;
105  }
106 
108 
109 
110  /**
111  * Auxiliary class to compare transmissions.
112  */
113  struct compare {
114  /**
115  * Constructor.
116  *
117  * \param precision precision
118  */
119  compare(const double precision) :
120  precision(precision)
121  {}
122 
123 
124  /**
125  * Compare two transmissions.
126  *
127  * \param first first transmission
128  * \param second second transmission
129  * \return true if times-of-arrival are similar; else false
130  */
131  bool operator()(const JTransmission& first, const JTransmission& second) const
132  {
133  return fabs(first.getToA() - second.getToA()) <= precision;
134  }
135 
136  const double precision;
137  };
138 
139  protected:
140  int id;
141  double q;
142  double toa;
143  double toe;
144  };
145 
146 
147  /**
148  * Less-than operator for two transmissions.
149  *
150  * The less-than operator is first applied to the time-of-emission and then to the identifier.
151  *
152  * \param first first transmission
153  * \param second second transmission
154  * \return true if first transmission earlier than second; else false
155  */
156  static inline bool operator<(const JTransmission& first, const JTransmission& second)
157  {
158  if (first.getToE() == second.getToE())
159  return first.getID() < second.getID();
160  else
161  return first.getToE() < second.getToE();
162  }
163 
164 
165  /**
166  * Equals operator for two transmissions.
167  *
168  * The equal operator is applied to the time-of-emission and the identifier.
169  *
170  * \param first first transmission
171  * \param second second transmission
172  * \return true if first transmission equal to second; else false
173  */
174  static inline bool operator==(const JTransmission& first, const JTransmission& second)
175  {
176  return (first.getID() == second.getID() &&
177  first.getToE() == second.getToE());
178  }
179 }
180 
181 #endif
double getQ() const
Get quality.
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1263
Definition: JRoot.hh:19
double getToE() const
Get absolute time of emission.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
ClassDef(JTransmission, 1)
Acoustic transmission.
bool operator==(Packet const &p, ID const &id)
JTransmission(const int id, const double Q, const double toa_s, const double toe_s)
Constructor.
JTransmission()
Default constructor.
virtual ~JTransmission()
Virtual destructor.
double getToA() const
Get absolute 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.
compare(const double precision)
Constructor.