Jpp  15.0.2
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  * Acoustic event fit.
153  */
154  struct JEvt :
155  public JHead,
156  public std::vector<JFit>,
157  public TObject
158  {
159  /**
160  * Auxiliary class to determine value of acoustic events.\n
161  * This class can be used with JSUPPORT::JTreeScanner so to read acoustics events in order of start time.
162  */
163  struct JEvaluator {
164  /**
165  * Default constructor.
166  */
168  {}
169 
170 
171  /**
172  * Get value of object.
173  *
174  * \param event event
175  * \return value
176  */
177  inline double operator()(const JEvt& event) const
178  {
179  return event.UNIXTimeStart;
180  }
181  };
182 
183 
184  /**
185  * Default constructor.
186  */
187  JEvt() :
188  JHead()
189  {}
190 
191 
192  /**
193  * Constructor.
194  *
195  * \param header header
196  */
197  JEvt(const JHead& header) :
198  JHead(header)
199  {}
200 
201 
202  /**
203  * Virtual destructor.
204  */
205  virtual ~JEvt()
206  {}
207 
208 
209  /**
210  * Write event to output.
211  *
212  * \param out output stream
213  * \param event event
214  * \return output stream
215  */
216  friend inline std::ostream& operator<<(std::ostream& out, const JEvt& event)
217  {
218  using namespace std;
219 
220  out << event.oid << endl
221  << FIXED(20,5) << event.UNIXTimeStart << endl
222  << FIXED(20,5) << event.UNIXTimeStop << endl
223  << setw(5) << event.ndf << endl
224  << FIXED(12,3) << event.chi2 << endl;
225 
226  for (JEvt::const_iterator fit = event.begin(); fit != event.end(); ++fit) {
227  out << *fit << endl;
228  }
229 
230  return out;
231  }
232 
233 
234  ClassDef(JEvt, 3);
235  };
236 }
237 
238 #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
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.
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.