//////////////////////////////////////////////////////////////////// /// \class RAT::PMTCalib /// /// \brief Apply calibrations to PMTUnCal data (/MC) /// /// \author Gabriel D. Orebi Gann /// /// REVISION HISTORY:\n /// 04 May 2010 : Gabriel Orebi Gann - remove badly calibrated hits /// from totalQ sum (since they have Q set to -9999) /// 03 Mar 2011 : G Orebi Gann - Create PMT objects by type (normal, owl etc) /// 17 Oct 2011 : Gabriel Orebi Gann - Move bit funcs to BitManip /// 17 Oct 2011 : Gabriel Orebi Gann - Move bit funcs to BitManip /// 03 Feb 2014 : GDOG - add check on ECA hit status (not currently used) /// 15 Feb 2013: Freija Descamps (fbdescamps@lbl.gov) /// Add PCACal /// 2014-04-04 : P Jones - refactor for new DS and allow for intermediate /// calibrations.\n /// 2017-02-17 : T Kaptanoglu - Put crosstalk flag between ECA and PCA /// /// \details This class applies calibration constants /// to the uncalibrated PMT data (ECA, PCA etc). /// This can be applied either to raw data, /// or to `uncalibrated' MC events. /// /// /// /// //////////////////////////////////////////////////////////////////// #ifndef __RAT_PMTCalib__ #define __RAT_PMTCalib__ #include #include #include #include #include #include namespace RAT { class PMTCalib : public Processor { public: /// The current possible calibration types, note base 10 usage. enum CalibrationTypes { MC = 9, ECA = 1, PCA = 10 }; /// Construct, sets all fDoMC to false and fDoECA=fDoPCA=true PMTCalib(); /// Destruct, nothing virtual ~PMTCalib() { } /// Set the calibration types to perform /// /// @param[in] param name i.e. mc, eca, pca etc... /// @param[in] value value {0, 1} (false or true) or caltype /// @throws ParamUnknown if param is not recognized. /// @throws ParamInvalid if value is not allowed for param. virtual void SetI( const std::string& param, const int value ); /// Called at the beginning of the run, initialises this and the PCA/ECACal instances /// /// @param[in] run information virtual void BeginOfRun( DS::Run& run ); /// Called for every event, calibrates the PMTs in the event /// /// @param[in] run information /// @param[in] ds current event information virtual Processor::Result DSEvent( DS::Run& run, DS::Entry& ds ); protected: typedef enum {CALOBJECT=1,EVENTS=2,PCANOECA=3,IDOOR=4} DieFlagErr; typedef enum {OVERWRITE=1,PMTTRUTH=2} LiveFlagErr; /// Function that checks the flag and sets the booleans accordingly /// ///@param[in] flag status flag ///@param[out] eca boolean to indicate of eca flag is set ///@param[out] pca boolean to indicate of pca flag is set ///@param[out] mc boolean to indicate of mc flag is set void CalibStatus(int flag, bool &eca, bool &pca, bool &mc); /// Function that checks previous and requested calibrations /// ///@param[in] Event current event information void EventChecks(DS::EV& Event); /// Function that prints error messages for fatal errors /// ///@param[in] message message to be parsed ///@param[in] flagErr error flag ///@param[in] info1 additional information if available ///@param[in] info2 additional information if available void Die(std::string message, DieFlagErr flagErr, int info1, int info2); /// Function that prints error messages for fatal errors /// ///@param[in] message the message to be parsed ///@param[in] flagErr error flag ///@param[in] info1 additional information if available ///@param[in] info2 additional information if available void DontDie(std::string message, LiveFlagErr flagErr, int info1, int info2); /// Function that fills the NHitCleaned branch by /// checking the crosstalk/pca/eca status for each hit /// /// @param[in] Event current event information void CleanNHits(DS::EV& ev); DBLinkPtr fHC; ///< Used to grab HITCLEANING cuts std::vector fAddedCuts;///< Keeps track of whether crosstalk cut was added ECACal fECACal; ///< Used to perform the ECA calibration PCACal fPCACal; ///< Used to perform the PCA calibration CrossTalkCut fCrossTalkCut; ///< Used to perform the crosstalk flagging bool fDoECA; ///< True if the ECA calibration is to be performed bool fDoPCA; ///< True if the PCA calibration is to be performed bool fDoMC; ///< True if the MC copy (not really a calibration) is to be perfomed (Not compatible with ECA and PCA) bool fIsMC; ///< True if data is MC data int fEvNo; //< A counter for the event number int fECAMask; //< ECA mask to cut on for clean hits, loaded from db int fPCAMask; //