//////////////////////////////////////////////////////////////////// /// \class RAT::MTCA /// /// \brief Simulate the SNO Analog Master Trigger Card for any analog trigger /// /// \author Josh Klein /// /// REVISION HISTORY:\n /// 28 Apr 2010 : Josh Klein --- First version. \n /// 03 May 2010 : Gabriel Orebi Gann - reset comparator (avoids mistaken /// retriggers) and use bit manip to set trig word \n /// 07 May 2010 : Gabriel Orebi Gann - new function to handle retriggers \n /// 29 Sep 2021 : Tereza Kroupova - Update re-trigger handling \n /// 06 Feb 2022 : Tereza Kroupova - Add DGT & LO* re-triggering, separate /// lockout action, move around if statements to simplify \n /// /// /// \details The MTCA object mimics the behavior of a SNO analog master trigger /// card. They take as input a trigger sum and discriminate it, deciding /// whether the analog sum is above threshold. Each MTCA can have multiple /// thresholds (like NHIT100LO, NHIT100MED, NHIT100HI. These are set in /// DAQ_RUN_LEVEL.ratdb. When a signal crosses threshold, the MTCA object creates /// a `Raw trigger' which is then sent to the MTCD. The raw trigger pulse /// is just 20 ns long and will time out and go low after that. /// //////////////////////////////////////////////////////////////////// #ifndef __RAT_MTCA__ #define __RAT_MTCA__ #include #include #include namespace RAT { class MTCA { public: MTCA(unsigned NThresholds); virtual ~MTCA() { }; void SetThreshold(float thresh, unsigned ithresh); unsigned int Discriminate(double T, TriggerSum *sum); bool GetDGT(){return fDGT;}; void SetDGT(bool dgt){fDGT = dgt;}; void SendLockoutStar(){fLockoutStar = true;}; void SetNAutoRetrig(std::vector nretrig){fNAutoRetrig = nretrig;}; void SetRetriggerLogic(unsigned int logic){fRetriggerLogic = logic;}; bool DoRetrigsRemain(); void SetRawTrigWidth(float width){fRawTrigPulseWidth = width;}; enum Gain {LO=0,MED=1,HIGH=2}; AnalogSignal* ScaleTrigSum(TriggerSum *sum, Gain scaleVal); double GetGain(Gain gainPath) { return fGains.at(gainPath); } private: unsigned fNThresholds; std::vector fThresholds; std::vector fGains; // The gains for the low/med/high threshold paths std::vector fThreshCrossingTime; unsigned fRawTrigger; std::vector fComparator; float fRawTrigPulseWidth; unsigned int fRetriggerLogic; //0=auto, 1=LO*, 2=DGT retriggering logic bool fDGT; bool fLockoutStar; std::vector fNAutoRetrig; //Number of automatic re-triggers for each gain path std::vector fNAutoRetrigCount; // Number of automatic re-triggers remaining for each gain path std::vector fDGTCrossing; std::vector fWaitingToRetrigger; void DoLockout(double T, unsigned thresh, bool overThreshold, BitManip bits); //Deals with re-triggers at the end of lockout class ScaledSum: public AnalogSignal{ public: ScaledSum(AnalogSignal* _original, double _scaleFactor): original(_original),scaleFactor(_scaleFactor) {} ~ScaledSum(){} double GetHeight(double time); AnalogSignal* original; double scaleFactor; }; }; } // namespace RAT #endif