//////////////////////////////////////////////////////////////////// /// \class RAT::DU::PMTCalStatus /// /// \brief Hit status regarding CHS, PMTCal and XTalk /// /// \author Javier Caravaca /// /// REVISION HISTORY:\n /// 7 Aug 2017 : Javier Caravaca - Creation \n /// 22 Oct 2017 : T Kaptanoglu - Add channel flags /// /// \details This class outputs whether a hit is good to be included /// in the analysis or not, regarding CHS, PMTCal status, cross-talk, /// out-of-sync, or missing hits /// //////////////////////////////////////////////////////////////////// #ifndef __RAT_DU_PMTCalStatus__ #define __RAT_DU_PMTCalStatus__ #include #include #include #include namespace RAT { namespace DU { class PMTCalStatus : public TObject { public: PMTCalStatus() : TObject() { } /// Initialize with current DB values at the start of a new run. void BeginOfRun(); /// Get hit status flag /// /// @param[in] CalPMT object /// @return a bit mask indicating which test failed: /// CHS, ECA, PCA, XTalk, CSS template unsigned int GetHitStatus(const T) const; enum {kCHSBit, kECABit, kPCABit, kXTalkBit, kFlagBit, kCSSBit}; unsigned int GetCellStatus(int) const; double GetChannelStatus(int lcn) const; std::vector FlagHits(); void FillFlag(std::vector flags); ClassDefNV( PMTCalStatus, 0 ); private: int fPdstMask; /// Cell-level mask applied to ECA_PDST[pdst_status] int fTslpMask; /// Cell-level mask applied to ECA_TSLP[tslp_status] int fTWMask; /// Channel-level mask applied to PCA_TW[PCATW_status] int fECAHitMask; /// Hit-level mask applied to PMT->fStatus (first 32bits) int fPCAHitMask; /// Hit-level mask applied to PMT->fStatus (last 32bits) std::vector fPdstStatus; /// Pedestal calibration status per cell std::vector fTslpStatus; /// TSlope calibration status per cell std::vector fTWStatus; /// Time walk calibration status per channel std::vector fPdstBoardID; /// Board ID used for pedestal calibration std::vector fTslpBoardID; /// Board ID used for tslope calibration /// Used to grab channels flagged at out-of-sync or missing counts std::vector fFlag; std::vector flagHits; std::vector fChannelFlags; static const RAT::DU::ChanHWStatus& GetChanHWStatus(); static const RAT::DU::ChanSWStatus& GetChanSWStatus(); }; template unsigned int PMTCalStatus::GetHitStatus(const T pmthit) const { const RAT::DU::ChanHWStatus& chs = RAT::DU::PMTCalStatus::GetChanHWStatus(); const RAT::DU::ChanSWStatus& css = RAT::DU::PMTCalStatus::GetChanSWStatus(); int status = 0; /* Test CHS */ if( !chs.IsTubeOnline( pmthit.GetID() ) ) status |= (1<