//////////////////////////////////////////////////////////////////// /// \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 /// /// /// \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.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 namespace RAT { class MTCA { public: MTCA(unsigned NThresholds); virtual ~MTCA() { }; void SetThreshold(float thresh, unsigned ithresh); unsigned int Discriminate(double T, TriggerSum *sum); bool GetGTPrime(){return fGTprime;}; void SetGTPrime(bool GTp){fGTprime = GTp;}; void SendLockoutStar(){fLockoutStar = true;}; void SetNRetrig(int nretrig){fNRetrig = nretrig;}; bool DoRetrigsRemain(){return fNRetrigCount>0;}; void SendEndTrigSum(){fEndTrigSum = true;}; 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; bool fGTprime; bool fLockoutStar; unsigned fNRetrig; // Total number of retriggers unsigned fNRetrigCount; // Number remaining bool fEndTrigSum; 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