//////////////////////////////////////////////////////////////////// /// \class RAT::clock /// /// \brief Simulate a clock on the digital master trigger card /// /// \author Josh Klein /// /// REVISION HISTORY:\n /// 28 Apr 2010 : Josh Klein --- First version. \n /// 01 May 2010 : Josh Klein --- Fixed bug in clock bit division which /// causes crashes on some platforms. \n /// 03 May 2010 : Gabriel Orebi Gann - replace `double' with `long /// double' to avoid loss of precision. \n /// 03 May 2010 : Gabriel Orebi Gann - set fPeriod in SetFrequency function /// and bug fix in clock bit division. \n /// 07 May 2010 : Gabriel Orebi Gann - remove use of `long doubles' \n /// 07 May 2010 : Gabriel Orebi Gann - add function to get clock time \n /// 12 May 2010 : Gabriel Orebi Gann - inc precision in clock time function \n /// /// /// \details The clock object is a generic clock that can be either the 50 MHz /// or 10 MHz clock that sits on the MTC/D. After setup of the frequency and /// number of bits of each clock, functions allow the MTC/D object to /// determine the time of the next clock tick, which can then be used to latch /// the global trigger. The count on the clock can also be returned for /// inclusion in the trigger words. /// ////////////////////////////////////////////////////////////////////// #ifndef __RAT_clock__ #define __RAT_clock__ #include #include #include namespace RAT { class clock{ public: clock(); virtual ~clock(); void SetFrequency(double freq); void SetNbits(UInt_t nbits){fNbits=nbits;}; double GetNextTickTime(double time); UInt_t GetNbits(){return fNbits;}; virtual ULong64_t GetCount(){return fCount;}; virtual ULong64_t GetCount(EventTime date); double GetFrequency(){return fFrequency;}; EventTime GetUTime(); virtual void SetRolloverInterval(); private: double fFrequency; //in Hz double fPeriod; ULong64_t fCount; UInt_t fNbits; double fNsecsRollover; UInt_t fRolloverDays; UInt_t fRolloverSecs; double fRolloverNsecs; }; } // namespace RAT #endif