/////////////////////////////////////////////////////////////////////////////// /// \class RAT::TPBurstCut /// /// \brief Tagging Retrigger events, Nhit Burst Events and CAEN Loss Burst Events, /// then store their GTID in ratdb. /// /// \contact Aobo Li /// /// REVISION HISTORY:\n /// 28 Sept. 2017 Aobo Li-First Version /// 7 Dec. 2017 Aobo Li-Adding 3rd pass: CAEN Loss Burst Cut /// set pass parameters in ratdb file to always be -1 /// Adding a new field in ratdb file: cut applied /// (1 if any event is cut, 0 otherwise) /// /// \details This is a Preliminary three pass porcessor for burst events. /// It should only be called by the nearline processing python code. /// It will tag all the retrigger events, nhit burst events and CAEN Loss /// Burst Events Burst Events, and store their GTID in ratdb for further usage. /// Forced trigger and orphans are ignored. /// /// First Pass: tagging all the retrigger events. If one or more event(s) /// happened inside 3 microsecond of its precedent event, they will be /// tagged as retriggers, while the first event will be tagged seperately /// as "first event". /// /// Second Pass: tagging all the nhit burst events. First ignore all retrigger /// events, then if 6 events happened inside 4 second timewindow, all the 6 /// events will be tagged as nhit burst. /// /// Third Pass: tagging all CAEN Loss burst events. First ignore all retrigger /// events, then if 2 CAEN loss events or more happened inside 2ms timewindow, /// the 2 events will be tagged as CAEN loss burst. /// //////////////////////////////////////////////////////////////////////////////////// #ifndef __RAT_TPBurstCut__ #define __RAT_TPBurstCut__ #include #include #include #include namespace RAT { class TPBurstCut : public DataCleaningProc { public: TPBurstCut() : DataCleaningProc("tpburstcut",1){}; virtual ~TPBurstCut(){}; virtual Processor::Result DSEvent(DS::Run& run, DS::Entry& ds); void SetI(const std::string& param, const int value); void BeginOfRun(DS::Run& run); void EndOfRun(DS::Run& run); protected: //The recuesive processor for retrigger and burst cut. virtual Processor::Result BurstProcessor(DS::EV& ev); //Filter out the events that we don't consider in burst cuts, on first pass //PulseGT, Pedestal and extasy(forced trigger), second pass additionally //retrigger events. If needed we can filter out more events other than those. bool EntryFilter(DS::EV& ev); //Push the info of event to buffer. The buffer stores the GTID and Universal Time //for the events. void PushToBuffer(DS::EV& ev); //Check whether the given events is within the time window comparing with the event //at the beginning of the buffer. If true, it means this is a burst events. bool WithinTimeWindow(DS::EV& ev); //Push the Last event of a burst series into fFirstEvent and fLastEvent Array. This Method //also does two sanity check: //1.One-to-one correspondance check: Make sure the event in fFirstEvent and fLastEvent are // paired, in other word, after iteration the two array should have the same size //2.GTID Reset check. If a GTID reset occured during a burst, split the burst into two burst // series. void PushLastEvent(); //buffer std::vector fBufferTime; std::vector fBufferGTID; //Pass1: store the first events(event that triggers retrigger cut) //Pass2: store the first events of each burst std::vector fFirstEvents; //Pass1: store the last events(event that triggers retrigger cut) //Pass2: store the last events of each burst //Pass3: store the last events of each CAEN loss burst std::vector fLastEvents; //Pass1: not in use. //Pass2: store the nhitburst event series. //Pass3: store the CAEN loss event series. std::vector fBurstEvents; //Store all the Retrigger events GTID, used to filter out retriggers for //second pass or later. std::vector fRetriggerReadout; //Burst Window ULong64_t fTwinBurst; //Minimum number of events inside burst window to be characterized as a burst unsigned int fNeventsBurst; //Used to filter out events with nhit lower than certain value. unsigned int fNhitThreshold; }; } // namespace RAT #endif