Jpp  master_rocky
the software that should make you happy
JSuperEvt.hh
Go to the documentation of this file.
1 #ifndef __JACOUSTICS__JSUPEREVT__
2 #define __JACOUSTICS__JSUPEREVT__
3 
4 #include <string>
5 #include <ostream>
6 #include <iomanip>
7 #include <vector>
8 
9 #include <TROOT.h>
10 #include <TObject.h>
11 
12 #include "JLang/JManip.hh"
13 #include "JIO/JSerialisable.hh"
14 #include "JIO/JSTDIO.hh"
15 #include "JAcoustics/JEvt.hh"
16 
17 
18 /**
19  * \file
20  *
21  * Acoustic event fit.
22  * \author mdejong
23  */
24 namespace JACOUSTICS {}
25 namespace JPP { using namespace JACOUSTICS; }
26 
27 namespace JACOUSTICS {
28 
29  using JIO::JSerialisable;
30  using JIO::JReader;
31  using JIO::JWriter;
32 
33  /**
34  * Acoustic super event fit.
35  */
36  struct JSuperEvt :
37  public virtual JSerialisable,
38  public JEvt
39  {
40  /**
41  * Default constructor.
42  */
44  JEvt()
45  {}
46 
47 
48  /**
49  * Constructor.
50  *
51  * \param event event
52  */
53  JSuperEvt(const JEvt& event) :
54  JEvt(event)
55  {}
56 
57 
58  /**
59  * Acoustics emission.
60  */
61  struct tx_t {
62  tx_t() :
63  id (-1),
64  counter(-1),
65  toe (0.0)
66  {}
67 
68  tx_t(const int id,
69  const int counter,
70  const double toe) :
71  id (id),
73  toe (toe)
74  {}
75 
76 
77  /**
78  * Read emission from input.
79  *
80  * \param in reader
81  * \param object emission
82  * \return reader
83  */
84  friend inline JReader& operator>>(JReader& in, tx_t& object)
85  {
86  in >> object.id;
87  in >> object.counter;
88  in >> object.toe;
89 
90  return in;
91  }
92 
93 
94  /**
95  * Write emission to output.
96  *
97  * \param out writer
98  * \param object emission
99  * \return writer
100  */
101  friend inline JWriter& operator<<(JWriter& out, const tx_t& object)
102  {
103  out << object.id;
104  out << object.counter;
105  out << object.toe;
106 
107  return out;
108  }
109 
110  int id;
111  int counter;
112  double toe;
113  };
114 
115  /**
116  * Acoustics transmission.
117  */
118  struct rx_t {
119  rx_t() :
120  id (-1),
121  counter(-1),
122  string (-1),
123  floor (-1),
124  toa (0.0),
125  weight (0.0)
126  {}
127 
128  rx_t(const int id,
129  const int counter,
130  const int string,
131  const int floor,
132  const double toa,
133  const double weight) :
134  id (id),
135  counter(counter),
136  string (string),
137  floor (floor),
138  toa (toa),
139  weight (weight)
140  {}
141 
142 
143  /**
144  * Read transmission from input.
145  *
146  * \param in reader
147  * \param object transmission
148  * \return reader
149  */
150  friend inline JReader& operator>>(JReader& in, rx_t& object)
151  {
152  in >> object.id;
153  in >> object.counter;
154  in >> object.string;
155  in >> object.floor;
156  in >> object.toa;
157  in >> object.weight;
158 
159  return in;
160  }
161 
162 
163  /**
164  * Write transmission to output.
165  *
166  * \param out writer
167  * \param object transmission
168  * \return writer
169  */
170  friend inline JWriter& operator<<(JWriter& out, const rx_t& object)
171  {
172  out << object.id;
173  out << object.counter;
174  out << object.string;
175  out << object.floor;
176  out << object.toa;
177  out << object.weight;
178 
179  return out;
180  }
181 
182  int id;
183  int counter;
184  int string;
185  int floor;
186  double toa;
187  double weight;
188  };
189 
192 
195 
196  /**
197  * Write super event to output.
198  *
199  * \param out output stream
200  * \param event super event
201  * \return output stream
202  */
203  friend inline std::ostream& operator<<(std::ostream& out, const JSuperEvt& event)
204  {
205  using namespace std;
206 
207  out << static_cast<const JEvt&>(event);
208 
209  for (JSuperEvt::tx_type::const_iterator i = event.tx.begin(); i != event.tx.end(); ++i) {
210  out << setw(2) << i->id << ' '
211  << setw(6) << i->counter << ' '
212  << FIXED(20,6) << i->toe << endl;
213  }
214 
215  for (JSuperEvt::rx_type::const_iterator i = event.rx.begin(); i != event.rx.end(); ++i) {
216  out << setw(2) << i->id << ' '
217  << setw(6) << i->counter << ' '
218  << setw(4) << i->string << ' '
219  << setw(2) << i->floor << ' '
220  << FIXED(20,6) << i->toa << ' '
221  << FIXED( 5,2) << i->weight << endl;
222  }
223 
224  return out;
225  }
226 
227 
228  /**
229  * Read from input.
230  *
231  * \param in reader
232  * \return reader
233  */
234  virtual JReader& read(JReader& in) override
235  {
236  JEvt::read(in);
237 
238  in >> this->rx;
239  in >> this->tx;
240 
241  return in;
242  }
243 
244 
245  /**
246  * Write to output.
247  *
248  * \param out writer
249  * \return writer
250  */
251  virtual JWriter& write(JWriter& out) const override
252  {
253  JEvt::write(out);
254 
255  out << this->rx;
256  out << this->tx;
257 
258  return out;
259  }
260 
262  };
263 }
264 
265 #endif
Acoustic event fit.
I/O manipulators.
STD extensions for binary I/O.
Interface for binary input.
Forward declaration of binary output.
Interface for binary output.
Auxiliary classes and methods for acoustic position calibration.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Acoustic event fit.
virtual JWriter & write(JWriter &out) const override
Write to output.
virtual JReader & read(JReader &in) override
Read from input.
Acoustics transmission.
Definition: JSuperEvt.hh:118
friend JReader & operator>>(JReader &in, rx_t &object)
Read transmission from input.
Definition: JSuperEvt.hh:150
rx_t(const int id, const int counter, const int string, const int floor, const double toa, const double weight)
Definition: JSuperEvt.hh:128
friend JWriter & operator<<(JWriter &out, const rx_t &object)
Write transmission to output.
Definition: JSuperEvt.hh:170
Acoustics emission.
Definition: JSuperEvt.hh:61
friend JWriter & operator<<(JWriter &out, const tx_t &object)
Write emission to output.
Definition: JSuperEvt.hh:101
friend JReader & operator>>(JReader &in, tx_t &object)
Read emission from input.
Definition: JSuperEvt.hh:84
tx_t(const int id, const int counter, const double toe)
Definition: JSuperEvt.hh:68
Acoustic super event fit.
Definition: JSuperEvt.hh:39
std::vector< tx_t > tx_type
Definition: JSuperEvt.hh:190
JSuperEvt()
Default constructor.
Definition: JSuperEvt.hh:43
JSuperEvt(const JEvt &event)
Constructor.
Definition: JSuperEvt.hh:53
ClassDefOverride(JSuperEvt, 1)
virtual JReader & read(JReader &in) override
Read from input.
Definition: JSuperEvt.hh:234
std::vector< rx_t > rx_type
Definition: JSuperEvt.hh:191
virtual JWriter & write(JWriter &out) const override
Write to output.
Definition: JSuperEvt.hh:251
friend std::ostream & operator<<(std::ostream &out, const JSuperEvt &event)
Write super event to output.
Definition: JSuperEvt.hh:203