Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  */
20 namespace JCOMPASS {}
21 namespace JPP { using namespace JCOMPASS; }
22 
23 namespace 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  */
99  JQuaternion(),
100  id(-1),
101  t (0)
102  {}
103 
104 
105  /**
106  * Constructor.
107  *
108  * \param id module identifier
109  * \param ts time [s]
110  * \param Q orientation
111  */
112  JOrientation(const int id,
113  const double ts,
114  const JQuaternion& Q) :
115  JQuaternion(Q),
116  id(id),
117  t (ts)
118  {}
119 
120 
121  /**
122  * Write orientation to output.
123  *
124  * \param out output stream
125  * \param object orientation
126  * \return output stream
127  */
128  friend inline std::ostream& operator<<(std::ostream& out, const JOrientation& object)
129  {
130  using namespace std;
131 
132  out << setw(10) << object.id << ' '
133  << FIXED(20,0) << object.t << ' '
134  << static_cast<const JQuaternion&>(object) << endl;
135 
136  return out;
137  }
138 
139 
141 
142  int id; ///< module identifier
143  double t; ///< time [s]
144  };
145 
146 
147  /**
148  * Compass event header.
149  */
150  struct JHead :
151  public TObject
152  {
153  /**
154  * Default constructor.
155  */
156  JHead() :
157  UNIXTimeStart(0.0),
158  UNIXTimeStop (0.0),
159  id (-1),
160  ndf (0),
161  chi2(0.0)
162  {}
163 
164 
165  /**
166  * Constructor.
167  *
168  * \param t0 UNIX start time
169  * \param t1 UNIX stop time
170  * \param id string identifier
171  * \param ndf number of degrees of freedom
172  * \param chi2 chi2
173  */
174  JHead(const double t0,
175  const double t1,
176  const int id,
177  const int ndf,
178  const double chi2) :
179  UNIXTimeStart(t0),
180  UNIXTimeStop (t1),
181  id (id),
182  ndf (ndf),
183  chi2(chi2)
184  {}
185 
186 
187  /**
188  * Virtual destructor.
189  */
190  virtual ~JHead()
191  {}
192 
193 
194  ClassDef(JHead, 1);
195 
196  double UNIXTimeStart; ///< start time
197  double UNIXTimeStop; ///< stop time
198  int id; ///< string identifier
199  int ndf; ///< number of degrees of freedom
200  double chi2; ///< chi2
201  };
202 
203 
204  /**
205  * Compass single fit.
206  */
207  struct JEvt :
208  public JHead,
209  public std::vector<JQuaternion>
210  {
211  /**
212  * Default constructor.
213  */
214  JEvt()
215  {}
216 
217 
218  /**
219  * Constructor.
220  *
221  * \param header header
222  */
223  JEvt(const JHead& header) :
224  JHead(header)
225  {}
226 
227 
228  /**
229  * Write event to output.
230  *
231  * \param out output stream
232  * \param evt event
233  * \return output stream
234  */
235  friend inline std::ostream& operator<<(std::ostream& out, const JEvt& evt)
236  {
237  using namespace std;
238 
239  out << FIXED(20,5) << evt.UNIXTimeStart << endl
240  << FIXED(20,5) << evt.UNIXTimeStop << endl
241  << setw(4) << evt.id << endl
242  << setw(5) << evt.ndf << endl
243  << FIXED(12,3) << evt.chi2 << endl;
244 
245  for (JEvt::const_iterator i = evt.begin(); i != evt.end(); ++i) {
246  out << *i << endl;
247  }
248 
249  return out;
250  }
251 
252 
253  ClassDef(JEvt, 1);
254  };
255 }
256 
257 #endif
Q(UTCMax_s-UTCMin_s)-livetime_s
JQuaternion()
Default constructor.
int id
module identifier
Compass single fit.
JEvt()
Default constructor.
Definition: JRoot.hh:19
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
int ndf
number of degrees of freedom
friend std::ostream & operator<<(std::ostream &out, const JEvt &evt)
Write event to output.
double UNIXTimeStart
start time
JQuaternion(const double a, const double b, const double c, const double d)
Constructor.
JEvt(const JHead &header)
Constructor.
double chi2
chi2
JHead(const double t0, const double t1, const int id, const int ndf, const double chi2)
Constructor.
JOrientation(const int id, const double ts, const JQuaternion &Q)
Constructor.
friend std::ostream & operator<<(std::ostream &out, const JOrientation &object)
Write orientation to output.
int id
string identifier
double UNIXTimeStop
stop time
I/O manipulators.
#define ClassDef(name, version)
Definition: JRoot.hh:32
JHead()
Default constructor.
friend std::ostream & operator<<(std::ostream &out, const JQuaternion &quaternion)
Write quaternion to output.
ClassDefNV(JQuaternion, 1)
Orientation of module.
Compass event header.
JOrientation()
Default constructor.
virtual ~JHead()
Virtual destructor.