//////////////////////////////////////////////////////////////////// /// \class RAT::TriggerProc /// /// \brief Simulate the trigger /// /// \author Josh Klein /// /// REVISION HISTORY:\n /// 05 Mar 2010 : Gabriel Orebi Gann - Include a test on DQXX word for /// each PMT to determine whether the trigger is functional /// i.e. whether to allow the hit to contribute to the /// TrigSum. /// NB for now we assume it is the 100ns trigger \n /// 28 Apr 2010: Josh Klein --- almost complete re-write to include /// different analog trigger sums, and to fill the /// various trigger word information. Changed above DQXX /// status so that is correctly applies to 100 ns, 20 /// ns, and ESUM signals independently. \n /// 03 May 2010 : Gabriel Orebi Gann - Init event counter to zero, plus /// bug fix in trigger word \n /// 07 May 2010 : Gabriel Orebi Gann - Handle retriggers \n /// 07 May 2010 : Gabriel Orebi Gann - Set EV UT by 10MHz clock, /// and set time of GT latch on 50MHz clock, in MC time \n /// 12 May 2010 : G Orebi Gann - simulate the skipping of certain eventIDs /// as seen in the hardware \n /// 19 May 2010 : G Orebi Gann - simulate rawTrig->FECD channel \n /// 03 Nov 2010 : G Orebi Gann - fix check on trig enable /// - include new trigger logic /// - include bitwise crate mask for each MTCA (results in /// new functions to check trig status of channel) \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 - include max frequency for pulseGT \n /// 13 Oct 2014 : J.R. Klein- Added logging of trigger settings /// 02 April 2015 - GD Orebi Gann - read run-level DAQ from DAQ_RUN_LEVEL /// (& make DB pointers local, and move all DB access to BeginofRun) /// 22 Oct 2016 : N Barros - Added check that there there is a MC branch to apply the /// processor, otherwise the processor would silently crash. /// 10 June 2016 - Eric Marzec - Add different gain paths for MTCAs when /// digitized. Also apply TUBii analog transform to the digitized signals. /// 10 Nov 2016 : N Barros - Added calls for BeginOfRun of helper classes. Moved DB access to /// BeginOfRun, to ensure proper database access. /// 2 Dec 2017 : T Kaptanoglu - Put full trigger word in mcev /// 9 Jan 2018 : T Kaptanoglu - Option for perfect trigger efficiency /// 23 Apr 2018 : T Kaptanoglu - Add realistic dropout model /// 29 Sep 2021 : T Kroupova - Add gain path specific auto re-triggers, /// remove GTPrime and setting trig word to stored one at lockout /// 06 Feb 2022 : T Kroupova - Add DGT /// - New function to determine when to stop looping through time /// - Add DGT delay, TUBii/MTCD lockout flag, re-trigger delay /// 26 Feb 2022 : T Kroupova - Add re-trigger delay and TUBii lockout /// 4 Jul 2022 : T Kroupova - Add baseline changes after a long time in an event /// /// \details Initialise detector construction /// ////////////////////////////////////////////////////////////////////// #ifndef __RAT_TriggerProc__ #define __RAT_TriggerProc__ #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace RAT { class TriggerProc : public Processor { public: TriggerProc(); virtual ~TriggerProc(); virtual void BeginOfRun(DS::Run& run); virtual void EndOfRun(DS::Run& run) {(void)run;}; virtual Processor::Result DSEvent(DS::Run& run, DS::Entry& ds); protected: UInt_t fEvCount; BitManip *fBits; double fTrigLockoutDB ; // MTCD lockout length, i.e.when it cannot emit another GT double fLockoutStarDB; // when MTCA gets lockout, only used for re-triggers double fTrigSteppingTimeDB ; unsigned int fTriggerEnableDB; double fLatchDelayDB; double fRawTrigWidth; int fFullTrigWord; ///< Whether or not to store full trigger word in mcev // Enabled triggers bool fIsN100L; bool fIsN100M; bool fIsN100H; bool fIsN20; bool fIsN20LB; bool fIsEL; bool fIsEH; bool fIsON; bool fIsOEL; bool fIsOEH; bool fIsPGT; bool fIsPre; bool fIsPed; bool fIsPong; bool fIsSync; bool fIsEXTASY; bool fIsExt2; bool fIsExt3; bool fIsExt4; bool fIsExt5; bool fIsExt6; bool fIsExt7; bool fIsExt8; bool fIsSRaw; bool fIsNCD; bool fIsSGT; bool fIsMiss; bool fIsAnalogue, fIsN100t, fIsN20t; double fTimeJumpDB; int fApplyCutOff; double fCutOffTime; // Turn on/off perfect trigger efficiency bool fDoPerfectTrigger; // Turn on/off a realistic trigger model bool fDoRealisticTrigger; //External trigger information double ExtAsyTimeDB; unsigned int EXTASYWord; // Dropout information bool fFoundDropoutDB; double fN100Dropout; double fN20Dropout; //Trigger pulse information double fN100PulseWidthDB; double fN20PulseWidthDB; double fESUMPulseWidthDB; double fN100RisetimeDB; double fN20RisetimeDB; double fLowGainFact; //attenuation of low gain ESUM relative to ESUMHI float fmVperPE; //pe to mV conversion for ESUMs float fADCperPE;//ADC to pe conversion for charges //Trigger sum information float fNhitNoiseDB; float fBaselineDriftDB; float fDropoutDB; float fTriggerFECDelay; float fGTDelay; std::vector fN100Amplitude; std::vector fN20Amplitude; float fESumNoise; //MTC/A objects for each analog trigger type MTCA *fN100; MTCA *fN20; MTCA *fEHI; MTCA *fELO; //One MTC/D object MTCD *fMasterTrigger; // One FECD object FECD fFECD; // One CAEN board CAEN *fCAEN; TUBII *fTUBii; double fDGTDelay; int fDigTrigSum; std::vector fDigTrigSums; double fGTCaenDelay; short fChannelMask; ///< CAEN input mask bool KeepSteppingInTime(double TimeOfLastPulse, double T, double lastGTTime); void CreateAnalogSums(TriggerSum &perfectSum, TriggerSum* n100Sum, TriggerSum* n20Sum, TriggerSum* ehiSum, TriggerSum* eloSum); void SetBaselines(TriggerSum* n100Sum, TriggerSum* n20Sum, TriggerSum* ehiSum, TriggerSum* eloSum); bool RetrigsRemain(){return (fN100->DoRetrigsRemain() || fN20->DoRetrigsRemain() || fEHI->DoRetrigsRemain() || fELO->DoRetrigsRemain() );}; }; } // namespace RAT #endif