//////////////////////////////////////////////////////////////////////// /// \class RAT::ChanSWStatusCalib /// /// \brief Apply the cut values to channels in order to label them /// /// \author Evelina Arushanova -- contact person /// /// REVISION HISTORY:\n /// 2014-12-18 : E Arushanova - first revision /// 2016-04-09 : E Arushanova - second revision - added ECA/PCA/CHS checks. /// excluded all offline channels from every check. /// Changed the output format. /// 2017-01-31 : J Wilson - fixing memory inefficient maps to filling histograms straight off for QHS,QHL,QLX,TAC /// /// \details /// The Processor applies the cut values calculated by ChanSWStatusProc. /// 1. Applying the High Occupancy Cut. For each channel the same ratio /// as in ChanSWStatusProc is calculated, i.e. the total number of hits /// for each channel for PGT events over the total number of hits for /// all events per run. The channel with the ratio larger than the cut /// value calculated by ChanSWStatusProc and stored in CSS_CUTS.ratdb /// doesn't pass the High Occupancy Check. /// /// 2. Applying the Low Occupancy Cut. For each channel the same ratios /// as in ChanSWStatusProc are calculated, i.e. number of hits for every /// channel over the total number of hits of all channels in every time /// block of 30 minutes. If the following ratio of a channel in any /// time block is smaller than the cut value calculated by /// ChanSWStatusProc and stored in CSS_CUTS.ratdb, then the whole channel /// doesn't pass the Low Occupancy Check. /// /// 3. Applying the Charge Time Cuts. For each channel the distributions /// of QHS,QHL,QLX, TAC are studied. For each channel it is counted the /// number of the events where its QHS/QHL/QLX/TAC values are either /// smaller than the low cut value or larger than the high cut value, /// which were calculated by ChanSWSProc. If more than half events fail /// the check than this channel doesn't pass the QHS/QHL/QLX/TAC cut. /// /// 4. ECA / PCA. For each channel the difference between the ratios of /// number of failed events and the total number of events of the current /// run and the standard run should be within 10%. If the channel was not /// hit during either run it is considered as passed. If the channel /// during either run has more than 90% failures is considered to fail. /// /// 5. Channel Hardware Status. All channels that are offline during the /// current run and the standard run are consifered to fail every check. /// The CHS check outputs which channels failed chs check /// into the ratdb table and the bit mask. /// /// Status logic: /// Has a channel failed the check? - Yes, TRUE, it did. Bit = 1 /// Has a channel failed the check? - No, FALSE, it passed it. Bit = 0 /// /// All checks need to be verified using the data. ///////////////////////////////////////////////////////////////////////////// #ifndef __RAT_ChanSWStatusCalib_hh__ #define __RAT_ChanSWStatusCalib_hh__ #include #include #include #include #include #include namespace RAT { class DBTable; namespace DS { class Run; class Entry; class EV; } class ChanSWStatusCalib : public Processor { public: typedef std::map LCNCountMap; ///< the type of object that is the map indexed by integers containing integers. This type was implemented in order to simplify the fHighOccMap typedef std::map IntervalLCNCountMap; ///< the type of object that is the map indexed by integers containing maps. This type was implemented in order to simplify the fLowOccMap typedef std::map StatusCountMap; ///< the type of object that is the map indexed by strings containing integers. This type was implemented in order to simplify the fECAMap and fPCAMap typedef std::map CalibLCNCountMap; ///< the type of object that is the map indexed by integers containing maps. This type was implemented in order to simplify the fECAMap and fPCAMap ///Calls the base class constructor ChanSWStatusCalib() : Processor( "ChanSWStatusCalib" ) {} ///The data collections are initialised for each run /// /// @param[in] run data structure void BeginOfRun( DS::Run& run ); ///Extracting the information, such as QHS, QHL, QLX, TAC, ///occupancy per event /// /// @param[in] run information /// @param[in] ds information Processor::Result DSEvent( DS::Run& run, DS::Entry& ds ); ///Extracting the information, such as QHS, QHL, QLX, TAC, ///occupancy per event /// /// @param[in] run information /// @param[in] ds information Processor::Result Event( DS::Entry& ds, DS::EV& ev ); ///Applies the cut values, output the information into ///RATDB format file, saves the histograms /// /// @param[in] run information void EndOfRun( DS::Run& run ); private: int chargeBins; int chargeMin; int chargeMax; LCNCountMap fHighOccMap; ///< the map indexed by lcn counting the number of hits for each PMT for PGT events unsigned int fHighOccEvents; ///< number of PGT events IntervalLCNCountMap fLowOccMap; ///< the map indexed by time interval and contain a map (indexed by lcn counting the number hits) std::vector fLowOccEvents; ///< number of events in each interval. // JW - replace vectors with histograms to be filled directly std::map hQHS; /// A map of histograms of QHS values for all chs online channels. std::map hQLX; /// A map of histograms of QLX values for all chs online channels. std::map hQHL; /// A map of histograms of QHL values for all chs online channels. std::map hTAC; /// A map of histograms of TAC values for all chs online channels. std::map hGainRatio; /// A map of histograms of GainRatios QHL/QLX values for all chs online channels. CalibLCNCountMap fECAMap; //< the map indexed by lcn and contain a map of ECA information (indexed by status word counting its number hits) CalibLCNCountMap fPCAMap; //< the map indexed by lcn and contain a map of PCA information (indexed by status word counting its number hits) std::vector fCHSVectorStandardRun; ///< the vector containing the status (pass/failed) of Channel Hardware Status of PMTs obtained in the standard run std::vector fCHSVector; ///< the vector containing the status (pass/failed) of Channel Hardware Status of PMTs DS::UniversalTime fStartRun; ///< the time of the beginning of the run double fTimeInterval; ///< the time interval which is chosen to be used in the calculations of the Low Occupancy Cut i.e. a cut for normal events bool fInitialised; ///< the indicator that the first event in the run has happened. int fRunID; ///< the run number size_t fAllLCNs; ///< the total number of LCNs RAT::DU::ChanSWStatus fCSSBits; std::vector fChannelWords; //< vector containing CSS channel words. /// Applies CHS to this run and concludes whether a channel has passed /// the check /// void ApplyCHSCut(); /// Applies the cut value for high occupancy channels calculated by /// ChanSWStatusProc.cc /// void ApplyHighOccCut(); /// Applies the cut value for all channels calculated by /// ChanSWStatusProc.cc /// void ApplyECACut(); /// Applies the cut value for normal channels calculated by /// ChanSWStatusProc.cc /// void ApplyPCACut(); /// Applies the cut value for low occupancy channels calculated by /// ChanSWStatusProc.cc /// void ApplyLowOccCut(); /// Applies the cut values based on the QHS, QHL, QLX, TAC distributions /// calculated by ChanSWStatusProc.cc. The charge time cut checks are following the /// same logic, therefore function is generic for QHS, QHL, QLX, TAC, that could be /// specifed. The data is the map indexed by lcn with vector recording QHS/QHL/QLX/TAC /// for each event. /// /// @param[in] data which is vectors with QHS/QHL/QLX/TAC of every event for every lcn /// @param[in] type which specifies which check to do, i.e. QHS/QHL/QLX/TAC void ApplyChargeTimeCut( const std::map& histos, const std::string& type ); /// Connects to the database and gets the start time of the run and sets the variable fStartRun. void GetStartTime(); }; } #endif