#ifndef __JCOMPASS__JEVT__ #define __JCOMPASS__JEVT__ #include #include #include #include #include #include "JLang/JManip.hh" /** * \file * * Compass event data types. * \author mdejong */ namespace JCOMPASS {} namespace JPP { using namespace JCOMPASS; } namespace JCOMPASS { /** * Quaternion. */ struct JQuaternion { /** * Default constructor. */ JQuaternion() : a(0.0), b(0.0), c(0.0), d(0.0) {} /** * Constructor. * * \param a a component * \param b b component * \param c c component * \param d d component */ JQuaternion(const double a, const double b, const double c, const double d) : a(a), b(b), c(c), d(d) {} /** * Write quaternion to output. * * \param out output stream * \param quaternion quaternion * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JQuaternion& quaternion) { using namespace std; out << FIXED(9,6) << quaternion.a << ' ' << FIXED(9,6) << quaternion.b << ' ' << FIXED(9,6) << quaternion.c << ' ' << FIXED(9,6) << quaternion.d; return out; } ClassDefNV(JQuaternion, 1); double a; double b; double c; double d; }; /** * Orientation of module. */ struct JOrientation : public JQuaternion, public TObject { /** * Default constructor. */ JOrientation() : JQuaternion(), id(-1), t (0) {} /** * Constructor. * * \param id module identifier * \param ts time [s] * \param Q orientation */ JOrientation(const int id, const double ts, const JQuaternion& Q) : JQuaternion(Q), id(id), t (ts) {} /** * Write orientation to output. * * \param out output stream * \param object orientation * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JOrientation& object) { using namespace std; out << setw(10) << object.id << ' ' << FIXED(20,0) << object.t << ' ' << static_cast(object) << endl; return out; } ClassDefNV(JOrientation, 1); int id; ///< module identifier double t; ///< time [s] }; /** * Compass event header. */ struct JHead : public TObject { /** * Default constructor. */ JHead() : UNIXTimeStart(0.0), UNIXTimeStop (0.0), id (-1), ndf (0), chi2(0.0) {} /** * Constructor. * * \param t0 UNIX start time * \param t1 UNIX stop time * \param id string identifier * \param ndf number of degrees of freedom * \param chi2 chi2 */ JHead(const double t0, const double t1, const int id, const int ndf, const double chi2) : UNIXTimeStart(t0), UNIXTimeStop (t1), id (id), ndf (ndf), chi2(chi2) {} /** * Virtual destructor. */ virtual ~JHead() {} ClassDef(JHead, 1); double UNIXTimeStart; ///< start time double UNIXTimeStop; ///< stop time int id; ///< string identifier int ndf; ///< number of degrees of freedom double chi2; ///< chi2 }; /** * Compass single fit. */ struct JEvt : public JHead, public std::vector { /** * Default constructor. */ JEvt() {} /** * Constructor. * * \param header header */ JEvt(const JHead& header) : JHead(header) {} /** * Write event to output. * * \param out output stream * \param evt event * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JEvt& evt) { using namespace std; out << FIXED(20,5) << evt.UNIXTimeStart << endl << FIXED(20,5) << evt.UNIXTimeStop << endl << setw(4) << evt.id << endl << setw(5) << evt.ndf << endl << FIXED(12,3) << evt.chi2 << endl; for (JEvt::const_iterator i = evt.begin(); i != evt.end(); ++i) { out << *i << endl; } return out; } ClassDef(JEvt, 1); }; } #endif