#ifndef __JDB_JTOASHORT__ #define __JDB_JTOASHORT__ #include #include #include #include /** * \author mdejong */ namespace JDATABASE {} namespace JPP { using namespace JDATABASE; } namespace JDATABASE { struct JToAshort : public TObject { static const char* const getName() { return "toashort"; } //!< Table name std::string DETID; ///< constraint int RUN; /// int RUNNUMBER; /// double UNIXTIMEBASE; ///< [s] int DOMID; /// int EMITTERID; ///< waveform identifier double TOA_S; ///< [s] int QUALITYFACTOR; /// int QUALITYNORMALISATION = 0; /// static constexpr int64_t NANOSECONDS_IN_ONE_SECOND = 1000000000; static constexpr int64_t ONE_TICK_NS = 16; /** return the absolute Time Of Arrival, in nanoseconds * (since Unix epoch 1 January 1970 00:00:00 UTC) */ int64_t getAbsoluteToA_ns() const { return llrint((TOA_S + UNIXTIMEBASE) * NANOSECONDS_IN_ONE_SECOND); } /** get the number of nanoseconds (since Unix epoch) of the DAQ Frame start time */ int64_t getDAQFrameNanoseconds() const { return llrint(UNIXTIMEBASE * NANOSECONDS_IN_ONE_SECOND); } /** get the number of seconds (since Unix epoch) of the DAQ Frame start time */ uint32_t getDAQFrameSeconds() const { return getDAQFrameNanoseconds() / NANOSECONDS_IN_ONE_SECOND; } /** get the number of ticks (16 ns) of the DAQ Frame start time */ uint32_t getDAQFrameTicks() const { return (getDAQFrameNanoseconds() % NANOSECONDS_IN_ONE_SECOND) / ONE_TICK_NS; } ClassDef(JToAshort, 1); }; } // namespace JDATABASE #endif