Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JCompass/JEvt.hh
Go to the documentation of this file.
1#ifndef __JCOMPASS__JEVT__
2#define __JCOMPASS__JEVT__
3
4#include <ostream>
5#include <iomanip>
6#include <vector>
7
8#include <TROOT.h>
9#include <TObject.h>
10
11#include "JLang/JManip.hh"
12
13
14/**
15 * \file
16 *
17 * Compass event data types.
18 * \author mdejong
19 */
20namespace JCOMPASS {}
21namespace JPP { using namespace JCOMPASS; }
22
23namespace JCOMPASS {
24
25 /**
26 * Quaternion.
27 */
28 struct JQuaternion {
29 /**
30 * Default constructor.
31 */
33 a(0.0),
34 b(0.0),
35 c(0.0),
36 d(0.0)
37 {}
38
39
40 /**
41 * Constructor.
42 *
43 * \param a a component
44 * \param b b component
45 * \param c c component
46 * \param d d component
47 */
48 JQuaternion(const double a,
49 const double b,
50 const double c,
51 const double d) :
52 a(a),
53 b(b),
54 c(c),
55 d(d)
56 {}
57
58
59 /**
60 * Write quaternion to output.
61 *
62 * \param out output stream
63 * \param quaternion quaternion
64 * \return output stream
65 */
66 friend inline std::ostream& operator<<(std::ostream& out, const JQuaternion& quaternion)
67 {
68 using namespace std;
69
70 out << FIXED(9,6) << quaternion.a << ' '
71 << FIXED(9,6) << quaternion.b << ' '
72 << FIXED(9,6) << quaternion.c << ' '
73 << FIXED(9,6) << quaternion.d;
74
75 return out;
76 }
77
78
80
81 double a;
82 double b;
83 double c;
84 double d;
85 };
86
87
88 /**
89 * Orientation of module.
90 */
91 struct JOrientation :
92 public JQuaternion,
93 public TObject
94 {
95 /**
96 * Default constructor.
97 */
100 id(-1),
101 t (0),
102 ns(0),
103 policy(false)
104 {}
105
106
107 /**
108 * Constructor.
109 *
110 * \param id module identifier
111 * \param ts time [s]
112 * \param Q orientation
113 * \param ns number of points
114 * \param policy policy
115 */
116 JOrientation(const int id,
117 const double ts,
118 const JQuaternion& Q,
119 const size_t ns,
120 const bool policy) :
121 JQuaternion(Q),
122 id(id),
123 t (ts),
124 ns(ns),
126 {}
127
128
129 /**
130 * Write orientation to output.
131 *
132 * \param out output stream
133 * \param object orientation
134 * \return output stream
135 */
136 friend inline std::ostream& operator<<(std::ostream& out, const JOrientation& object)
137 {
138 using namespace std;
139
140 out << setw(10) << object.id << ' '
141 << FIXED(20,0) << object.t << ' '
142 << static_cast<const JQuaternion&>(object) << ' '
143 << setw(3) << object.ns << ' '
144 << setw(1) << object.policy << endl;
145
146 return out;
147 }
148
149
151
152 int id; ///< module identifier
153 double t; ///< time [s]
154 size_t ns; ///< number of points
155 bool policy; ///< policy
156 };
157
158
159 /**
160 * Compass event header.
161 */
162 struct JHead :
163 public TObject
164 {
165 /**
166 * Default constructor.
167 */
169 UNIXTimeStart(0.0),
170 UNIXTimeStop (0.0),
171 id (-1),
172 ndf (0),
173 chi2(0.0)
174 {}
175
176
177 /**
178 * Constructor.
179 *
180 * \param t0 UNIX start time
181 * \param t1 UNIX stop time
182 * \param id string identifier
183 * \param ndf number of degrees of freedom
184 * \param chi2 chi2
185 */
186 JHead(const double t0,
187 const double t1,
188 const int id,
189 const int ndf,
190 const double chi2) :
191 UNIXTimeStart(t0),
192 UNIXTimeStop (t1),
193 id (id),
194 ndf (ndf),
195 chi2(chi2)
196 {}
197
198
199 /**
200 * Virtual destructor.
201 */
202 virtual ~JHead()
203 {}
204
205
207
208 double UNIXTimeStart; ///< start time
209 double UNIXTimeStop; ///< stop time
210 int id; ///< string identifier
211 int ndf; ///< number of degrees of freedom
212 double chi2; ///< chi2
213 };
214
215
216 /**
217 * Compass single fit.
218 */
219 struct JEvt :
220 public JHead,
221 public std::vector<JQuaternion>
222 {
223 /**
224 * Default constructor.
225 */
227 {}
228
229
230 /**
231 * Constructor.
232 *
233 * \param header header
234 */
235 JEvt(const JHead& header) :
236 JHead(header)
237 {}
238
239
240 /**
241 * Write event to output.
242 *
243 * \param out output stream
244 * \param evt event
245 * \return output stream
246 */
247 friend inline std::ostream& operator<<(std::ostream& out, const JEvt& evt)
248 {
249 using namespace std;
250
251 out << FIXED(20,5) << evt.UNIXTimeStart << endl
252 << FIXED(20,5) << evt.UNIXTimeStop << endl
253 << setw(4) << evt.id << endl
254 << setw(5) << evt.ndf << endl
255 << FIXED(12,3) << evt.chi2 << endl;
256
257 for (JEvt::const_iterator i = evt.begin(); i != evt.end(); ++i) {
258 out << *i << endl;
259 }
260
261 return out;
262 }
263
264
266 };
267}
268
269#endif
I/O manipulators.
Auxiliary classes and methods for orientation calibration based on compasses.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Compass single fit.
ClassDef(JEvt, 1)
JEvt()
Default constructor.
friend std::ostream & operator<<(std::ostream &out, const JEvt &evt)
Write event to output.
JEvt(const JHead &header)
Constructor.
Compass event header.
int id
string identifier
int ndf
number of degrees of freedom
JHead()
Default constructor.
ClassDef(JHead, 1)
virtual ~JHead()
Virtual destructor.
double UNIXTimeStop
stop time
double UNIXTimeStart
start time
JHead(const double t0, const double t1, const int id, const int ndf, const double chi2)
Constructor.
Orientation of module.
friend std::ostream & operator<<(std::ostream &out, const JOrientation &object)
Write orientation to output.
int id
module identifier
JOrientation(const int id, const double ts, const JQuaternion &Q, const size_t ns, const bool policy)
Constructor.
size_t ns
number of points
JOrientation()
Default constructor.
ClassDefNV(JOrientation, 2)
ClassDefNV(JQuaternion, 1)
JQuaternion()
Default constructor.
friend std::ostream & operator<<(std::ostream &out, const JQuaternion &quaternion)
Write quaternion to output.
JQuaternion(const double a, const double b, const double c, const double d)
Constructor.