Jpp - 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 chi2 chi2
116  */
117  JHead(const std::string& oid,
118  const double t0,
119  const double t1,
120  const int ndf,
121  const double chi2) :
122  oid (oid),
123  UNIXTimeStart(t0),
124  UNIXTimeStop (t1),
125  ndf (ndf),
126  chi2(chi2)
127  {}
128 
129 
130  /**
131  * Virtual destructor.
132  */
133  virtual ~JHead()
134  {}
135 
136 
137  ClassDef(JHead, 2);
138 
139  std::string oid; ///< detector identifier
140  double UNIXTimeStart; ///< start time
141  double UNIXTimeStop; ///< stop time
142  int ndf; ///< number of degrees of freedom
143  double chi2; ///< chi2
144  };
145 
146 
147  /**
148  * Acoustic event fit.
149  */
150  struct JEvt :
151  public JHead,
152  public std::vector<JFit>,
153  public TObject
154  {
155  /**
156  * Auxiliary class to determine value of acoustic events.\n
157  * This class can be used with JSUPPORT::JTreeScanner so to read acoustics events in order of start time.
158  */
159  struct JEvaluator {
160  /**
161  * Default constructor.
162  */
164  {}
165 
166 
167  /**
168  * Get value of object.
169  *
170  * \param event event
171  * \return value
172  */
173  inline double operator()(const JEvt& event) const
174  {
175  return event.UNIXTimeStart;
176  }
177  };
178 
179 
180  /**
181  * Default constructor.
182  */
183  JEvt() :
184  JHead()
185  {}
186 
187 
188  /**
189  * Constructor.
190  *
191  * \param header header
192  */
193  JEvt(const JHead& header) :
194  JHead(header)
195  {}
196 
197 
198  /**
199  * Virtual destructor.
200  */
201  virtual ~JEvt()
202  {}
203 
204 
205  /**
206  * Write event to output.
207  *
208  * \param out output stream
209  * \param event event
210  * \return output stream
211  */
212  friend inline std::ostream& operator<<(std::ostream& out, const JEvt& event)
213  {
214  using namespace std;
215 
216  out << event.oid << endl
217  << FIXED(20,5) << event.UNIXTimeStart << endl
218  << FIXED(20,5) << event.UNIXTimeStop << endl
219  << setw(5) << event.ndf << endl
220  << FIXED(12,3) << event.chi2 << endl;
221 
222  for (JEvt::const_iterator fit = event.begin(); fit != event.end(); ++fit) {
223  out << *fit << endl;
224  }
225 
226  return out;
227  }
228 
229 
230  ClassDef(JEvt, 2);
231  };
232 }
233 
234 #endif
JHead(const std::string &oid, const double t0, const double t1, const int ndf, const double chi2)
Constructor.
int id
string identifier
JEvaluator()
Default constructor.
std::string oid
detector identifier
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.
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.
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.
JFit()
Default constructor.