//////////////////////////////////////////////////////////////////// /// \class RAT::MTCD /// /// \brief Simulate the Digital Master Trigger Card /// /// \author Josh Klein /// /// REVISION HISTORY:\n /// 28 Apr 2010 : Josh Klein --- First version. \n /// 07 May 2010 : G Orebi Gann - add function to get clock time \n /// 11 May 2010 : G Orebi Gann - set trigErr bits \n /// 12 May 2010 : G Orebi Gann - check for 16 and 24 bit rollovers, /// and skip event IDs, to mimic the hardware \n /// 19 May 2010 : G Orebi Gann - function to return raw trig time \n /// 11 Nov 2010 : G Orebi Gann - include prescale trigger \n /// 12 Nov 2010 : G Orebi Gann - simulate trig enable (or, more /// accurately, disable) \n /// 19 Nov 2010 : G Orebi Gann - allow option of simulating missed /// triggers \n /// 04 Mar 2011 : G Orebi Gann - impose max frequency for pulseGT \n /// /// /// \details The MTCD object mimics the behavior of the digital master /// trigger card. It takes as input a word containing raw trigger pulses /// from MTCA objects, and compares this word to the trigger mask which /// contains those triggers currently considered to be allowed. The trigger /// mask can be set in DAQ.ratdb. If one or more of the allowed bits is high, /// the MTCD waits for a small delay (LatchDelay) to see if any others also /// go high, and then `latches' those that are high into the trigger word that /// is stored with the event. The global trigger itself is issued on the first /// tick of the 50 MHz clock that follows the initial allowed raw trigger, /// and the count on the 50 MHz clock at the time of this latch is stored. /// The time on the 53-bit 10 MHz clock is also saved at this time. /// The 24-bit GT count is also saved, as are error bits corresponding to /// 16-bit and 24-bit trigger rollovers. In this first version, neither /// PULSE_GT or EXT_ASYNC triggers are simulated. /// ////////////////////////////////////////////////////////////////////// // #ifndef __RAT_MTCD__ #define __RAT_MTCD__ #include #include namespace RAT { class MTCD{ public: MTCD(); virtual ~MTCD(); virtual void SetTriggerMask(unsigned int mask){fTriggerMask=mask;}; virtual void EnablePGT(){fIsPGT = true;}; virtual void EnablePrescale(){fIsPre = true;}; virtual void SetPrescale(int scale){fPrescale=scale;}; virtual void SetPrescaleDelay(float delay){fPrescaleDelay=delay;}; virtual void SetPrescaleWidth(float width){fPrescaleWidth=width;}; virtual void SetPrescaleTime(float time){fPrescaleTime=time;}; virtual void ResetPrescaleBit(){fPrescaleHigh=false;}; virtual void SetPulseGT(double period){fPulseGT=period;}; virtual void SetPulseGTMin(double period){fPulseGTMin=period;}; virtual void SetPulseGTDefault(double period){fPulseGTDefault=period;}; virtual void SetPulseGTWidth(float width){fPGTwidth=width;}; virtual void SetPulseGTFreq(); virtual void SetLatchDelay(double delay){fLatchDelay=delay;}; virtual void SetExtAsyTime(double exttime){fExtAsyTime=exttime;}; virtual void SetGTCount(UInt_t count); virtual void IncrementGTCount(); virtual void SetTrigErrBits(); virtual void SetMCEventTime(double mctime){fMCEventTime=mctime;}; virtual double GetGlobalTriggerTime(){return fGlobalTriggerTime;}; double GetRawTriggerTime(){return fRawTriggerTime;}; bool CheckGlobalTrigger(UInt_t analogword, UInt_t externalword, double T); bool CheckMissedTrigger(UInt_t analogword, UInt_t externalword, double T); virtual Int_t GetGTCount(){return fGTCount;}; virtual UInt_t GetTrigErrBits(){return fErrBits;}; virtual UInt_t GetTriggerWord(){return fTriggerWord;}; virtual ULong64_t GetClockCount50(); virtual ULong64_t GetClockCount50(EventTime GTrigTime); virtual ULong64_t GetClockCount10(EventTime GTrigTime); EventTime GetClockTime10(); virtual bool GetSYNC(){return fSYNC;}; virtual bool GetSYNC24(){return fSYNC24;}; private: Int_t fGTCount; UInt_t fErrBits; unsigned int fTriggerMask; unsigned int fTriggerWord; int fPrescale; int fPrescaleCount; float fPrescaleDelay; float fPrescaleWidth; float fPrescaleTime; bool fPrescaleHigh; bool fLoLow; double fPulseGT; double fPulseGTDefault; double fPulseGTMin; float fPGTwidth; double fPGTtime; ULong64_t fPGTFreq; bool fPulseGTHigh; double fLatchDelay; int fRawTrigger; double fExtAsyTime; int fLatchPending; double fRawTriggerTime; double fGlobalTriggerTime; bool fSYNC; bool fSYNC24; bool fIsPGT; bool fIsPre; double fMCEventTime; clock *fClock50; clock *fClock10; // Trig signal status unsigned int fTrigHigh; }; } // namespace RAT #endif