Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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),
72  counter(counter),
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
Acoustics transmission.
Definition: JSuperEvt.hh:118
Interface for binary output.
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 std::ostream & operator<<(std::ostream &out, const JSuperEvt &event)
Write super event to output.
Definition: JSuperEvt.hh:203
friend JWriter & operator<<(JWriter &out, const rx_t &object)
Write transmission to output.
Definition: JSuperEvt.hh:170
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
ClassDefOverride(JSuperEvt, 1)
virtual JWriter & write(JWriter &out) const override
Write to output.
Definition: JSuperEvt.hh:251
Forward declaration of binary output.
friend JWriter & operator<<(JWriter &out, const tx_t &object)
Write emission to output.
Definition: JSuperEvt.hh:101
tx_t(const int id, const int counter, const double toe)
Definition: JSuperEvt.hh:68
Acoustic event fit.
friend JReader & operator>>(JReader &in, tx_t &object)
Read emission from input.
Definition: JSuperEvt.hh:84
Interface for binary input.
JSuperEvt()
Default constructor.
Definition: JSuperEvt.hh:43
I/O manipulators.
Acoustic super event fit.
Definition: JSuperEvt.hh:36
std::vector< rx_t > rx_type
Definition: JSuperEvt.hh:191
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
Acoustics emission.
Definition: JSuperEvt.hh:61
virtual JWriter & write(JWriter &out) const override
Write to output.
Acoustic event fit.
virtual JReader & read(JReader &in) override
Read from input.
friend JReader & operator>>(JReader &in, rx_t &object)
Read transmission from input.
Definition: JSuperEvt.hh:150
JSuperEvt(const JEvt &event)
Constructor.
Definition: JSuperEvt.hh:53
std::vector< tx_t > tx_type
Definition: JSuperEvt.hh:190
STD extensions for binary I/O.
virtual JReader & read(JReader &in) override
Read from input.
Definition: JSuperEvt.hh:234