Jpp  16.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAcoustics/JEvt.hh
Go to the documentation of this file.
1 #ifndef __JACOUSTICS__JEVT__
2 #define __JACOUSTICS__JEVT__
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 
14 
15 /**
16  * \file
17  *
18  * Acoustic event fit.
19  * \author mdejong
20  */
21 namespace JACOUSTICS {}
22 namespace JPP { using namespace JACOUSTICS; }
23 
24 namespace JACOUSTICS {
25 
26  /**
27  * Acoustic single fit.
28  */
29  struct JFit :
30  public TObject
31  {
32  /**
33  * Default constructor.
34  */
35  JFit() :
36  id(-1),
37  tx(0.0),
38  ty(0.0)
39  {}
40 
41 
42  /**
43  * Constructor.
44  *
45  * \param id string identifier
46  * \param tx slope dx/dz
47  * \param ty slope dy/dz
48  */
49  JFit(const int id,
50  const double tx,
51  const double ty) :
52  id(id),
53  tx(tx),
54  ty(ty)
55  {}
56 
57 
58  /**
59  * Virtual destructor.
60  */
61  virtual ~JFit()
62  {}
63 
64 
65  /**
66  * Write fit to output.
67  *
68  * \param out output stream
69  * \param fit fit
70  * \return output stream
71  */
72  friend inline std::ostream& operator<<(std::ostream& out, const JFit& fit)
73  {
74  using namespace std;
75 
76  out << setw(4) << fit.id << ' '
77  << FIXED(9,6) << fit.tx << ' '
78  << FIXED(9,6) << fit.ty;
79 
80  return out;
81  }
82 
83 
84  ClassDef(JFit, 1);
85 
86  int id; ///< string identifier
87  double tx; ///< slope dx/dz
88  double ty; ///< slope dy/dz
89  };
90 
91 
92  /**
93  * Acoustic event header.
94  */
95  struct JHead {
96  /**
97  * Default constructor.
98  */
99  JHead() :
100  oid(),
101  UNIXTimeStart(0.0),
102  UNIXTimeStop (0.0),
103  ndf (0),
104  chi2(0.0)
105  {}
106 
107 
108  /**
109  * Constructor.
110  *
111  * \param oid detector identifer
112  * \param t0 UNIX start time
113  * \param t1 UNIX stop time
114  * \param ndf number of degrees of freedom
115  * \param weight total weight of hits
116  * \param chi2 chi2
117  */
118  JHead(const std::string& oid,
119  const double t0,
120  const double t1,
121  const int ndf,
122  const double weight,
123  const double chi2) :
124  oid (oid),
125  UNIXTimeStart(t0),
126  UNIXTimeStop (t1),
127  ndf (ndf),
128  weight(weight),
129  chi2 (chi2)
130  {}
131 
132 
133  /**
134  * Virtual destructor.
135  */
136  virtual ~JHead()
137  {}
138 
139 
140  ClassDef(JHead, 3);
141 
142  std::string oid; ///< detector identifier
143  double UNIXTimeStart; ///< start time
144  double UNIXTimeStop; ///< stop time
145  int ndf; ///< number of degrees of freedom
146  double weight; ///< total weight of hits
147  double chi2; ///< chi2
148  };
149 
150 
151  /**
152  * Less than operator for acoustics event headers.
153  *
154  * The less than operator is applied to the object identifier,
155  * the UNIX start time and the UNIX stop time, respectively.
156  *
157  * \param first first header
158  * \param second second header
159  * \return true if first event header earliear than second; else false
160  */
161  inline bool operator<(const JHead& first, const JHead& second)
162  {
163  if (first.oid == second.oid) {
164 
165  if (first.UNIXTimeStart == second.UNIXTimeStart) {
166 
167  return first.UNIXTimeStop < second.UNIXTimeStop;
168 
169  } else {
170 
171  return first.UNIXTimeStart < second.UNIXTimeStart;
172  }
173 
174  } else {
175 
176  return first.oid < second.oid;
177  }
178  }
179 
180 
181  /**
182  * Acoustic event fit.
183  */
184  struct JEvt :
185  public JHead,
186  public std::vector<JFit>,
187  public TObject
188  {
189  /**
190  * Auxiliary class to determine value of acoustic events.\n
191  * This class can be used with JSUPPORT::JTreeScanner so to read acoustics events in order of start time.
192  */
193  struct JEvaluator {
194  /**
195  * Default constructor.
196  */
198  {}
199 
200 
201  /**
202  * Get value of object.
203  *
204  * \param event event
205  * \return value
206  */
207  inline double operator()(const JEvt& event) const
208  {
209  return event.UNIXTimeStart;
210  }
211  };
212 
213 
214  /**
215  * Default constructor.
216  */
217  JEvt() :
218  JHead()
219  {}
220 
221 
222  /**
223  * Constructor.
224  *
225  * \param header header
226  */
227  JEvt(const JHead& header) :
228  JHead(header)
229  {}
230 
231 
232  /**
233  * Virtual destructor.
234  */
235  virtual ~JEvt()
236  {}
237 
238 
239  /**
240  * Write event to output.
241  *
242  * \param out output stream
243  * \param event event
244  * \return output stream
245  */
246  friend inline std::ostream& operator<<(std::ostream& out, const JEvt& event)
247  {
248  using namespace std;
249 
250  out << event.oid << endl
251  << FIXED(20,5) << event.UNIXTimeStart << endl
252  << FIXED(20,5) << event.UNIXTimeStop << endl
253  << setw(5) << event.ndf << endl
254  << FIXED(12,3) << event.chi2 << endl;
255 
256  for (JEvt::const_iterator fit = event.begin(); fit != event.end(); ++fit) {
257  out << *fit << endl;
258  }
259 
260  return out;
261  }
262 
263 
264  ClassDef(JEvt, 3);
265  };
266 }
267 
268 #endif
JHead(const std::string &oid, const double t0, const double t1, const int ndf, const double weight, const double chi2)
Constructor.
int id
string identifier
JEvaluator()
Default constructor.
std::string oid
detector identifier
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1678
friend std::ostream & operator<<(std::ostream &out, const JFit &fit)
Write fit to output.
Definition: JRoot.hh:19
int ndf
number of degrees of freedom
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
double ty
slope dy/dz
Acoustic single fit.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
virtual ~JFit()
Virtual destructor.
Auxiliary class to determine value of acoustic events.
friend std::ostream & operator<<(std::ostream &out, const JEvt &event)
Write event to output.
double UNIXTimeStop
stop time
double operator()(const JEvt &event) const
Get value of object.
double tx
slope dx/dz
Acoustic event header.
Acoustic event fit.
JEvt(const JHead &header)
Constructor.
virtual ~JEvt()
Virtual destructor.
double weight
total weight of hits
JHead()
Default constructor.
I/O manipulators.
double UNIXTimeStart
start time
virtual ~JHead()
Virtual destructor.
JFit(const int id, const double tx, const double ty)
Constructor.
JEvt()
Default constructor.
std::vector< double > weight
Definition: JAlgorithm.hh:417
JFit()
Default constructor.