//////////////////////////////////////////////////////////////////////// /// \class RAT::ChanSWStatusProc /// /// \brief Find the cut's values in order to label bad channels /// /// \author Nasim Fatemighomi /// \author Evelina Arushanova -- contact person /// /// REVISION HISTORY:\n /// 15 December 2013 : Nasim Fatemighomi - first version /// 2014-12-18 : E Arushanova - second version\n /// 2016-04-09 : E Arushanova - third revision - added ECA/PCA/CHS checks. /// excluded all offline channels from calculating the check /// values of 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 calculates the cut values based on the "standard" run. /// Only normal PMTs are considered. /// 1. The High Occupancy Cut. The total number of hits for each channel /// for Pulse Global Trigger (PGT) events is divided by the total number /// of hits for all PGT events per run. The following ratio is put into /// the histogram from which the cut value is found. It was considered /// that the cut value was obtained as the ( Mean + 3 * RMS ) /// /// 2. The Low Occupancy cut. Each run is devided into block of time. /// Currently it was chosen to be the blocks of 30 minutes. For each /// time block it is calculated the ratio between the number of hits /// for each channel for all events per block and the total number of /// hits from all channels for all events per block. The following ratio /// is put into the histogram from which the cut value is found. It was /// considered that the cut value was obtained as the ( Mean - RMS ) /// /// 3. Charge Time Cuts. The QHS, QHL, QLX, TAC per channel are stored into /// the maps. In order to find the cut values the cumulative sum /// from low to high and from high to low was calculated for each of /// these distributions. The cut range for each distribution is where /// the cumulative sum is < 0.05 /// /// 4. ECA / PCA Cuts. The following information is saved for channels: /// the number of failed ECA/PCA hits, ratios between number of failed /// hits and total number of hits. Checks are preliminar and will be /// will be updated. ECA checks are performed for all channels, /// not just the normal ones. /// /// 5. Channel Hardware Status. This is additional criterion. The channels /// that are offline during the standrd run are excluded from calculations /// of every cut values. Additionally, the chs information of the channels /// pass/fail is output into ratdb table. It will be used in /// ChanSWStatusCalib processor. /// /// All calculations are taking into account only the channels that were hit /// during the run, whilst the output in the ratdb table contains /// the information about every channel. If a PMT was not hit the value of /// -9999.0 is assigned. /// /// All checks need to be verified using the data. ///////////////////////////////////////////////////////////////////////////////// #ifndef __RAT_ChanSWStatusProc_hh__ #define __RAT_ChanSWStatusProc_hh__ #include #include #include #include class TFile; namespace RAT { class DBTable; namespace DS { class Run; class Entry; class EV; } class ChanSWStatusProc : 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 and fLowOccMap 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 ChanSWStatusProc() : Processor( "ChanSWStatusProc" ){} ///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 ); Processor::Result Event( DS::Entry& ds, DS::EV& ev ); ///Calculates 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; int OccBins; int OccMin; int OccMax; 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 std::vector fLowOccEvents; ///< number of events in each interval. IntervalLCNCountMap fLowOccMap; ///< the map indexed by time interval blocks and contain a map (indexed by lcn counting its number hits) // 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) DS::UniversalTime fStartRun; ///< the time of the beginning of the run DS::UniversalTime fEndRun; ///< the time of the end of the run size_t fAllLCNs; ///< the total number of LCNs std::vector fCHSVector;///< the vector containing the status (pass/failed) of Channel Hardware Status of PMTs int fRunID; ///< the run number double fHighOccCut, fLowOccCut; 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. // Connects to the database and gets the start time of the run and sets the variable fStartRun. void GetStartTime(); /// Finds the cut for high occupancy channels /// /// @param[in] outputFile which contains the file with the "standard" run /// @param[in] table which contains the cut values based on the "standard" run void CalculateHighOccCut( TFile& outputFile, DBTable& table ) const; /// Finds the parameters needed for ECA check /// /// @param[in] outputFile which contains the file which contans the "standard" run /// @param[in] table which contains the cut values based on the "standard" run void CalculateECACut( TFile& outputFile, DBTable& table ) const; /// Finds the parameters needed for PCA check /// /// @param[in] outputFile which contains the file which contans the "standard" run /// @param[in] table which contains the cut values based on the "standard" run void CalculatePCACut( TFile& outputFile, DBTable& table ) const; /// Finds the CHS status of all channels in the run /// /// @param[in] outputFile which contains the file which contans the "standard" run /// @param[in] table which contains the cut values based on the "standard" run void CHSCut( TFile& outputFile, DBTable& table ) const; /// Finds the cut for low occupancy channels /// /// @param[in] outputFile which contains the file which contans the "standard" run /// @param[in] table which contains the cut values based on the "standard" run void CalculateLowOccCut( TFile& outputFile, DBTable& table ) const; /// Finds the cuts based on the QHS, QHL, QLX, TAC distributions /// /// @param[in] outputFile which contains the file which contans the "standard" run /// @param[in] table which contains the cut values based on the "standard" run void CalculateChargeTimeCut( TFile& outputFile, DBTable& table ) ; /// Simple helper function to fit the full width half maximum of a histogram. /// /// @param[in] Histogram to act on. double GetFWHM(const TH1D&) const; }; } #endif