// $Id: Pedestal_SigmaCut.hh,v 1.8 2002/07/23 23:21:23 kamland0 Exp $ #ifndef __PEDESTAL_SIGMACUT_HH__ #define __PEDESTAL_SIGMACUT_HH__ #include "KamPedestal.hh" #include #include class TKLSinglePedestalSigmaCut; class TKLPedestalSigmaCut : public TKLVirtualPedestal { public: TKLPedestalSigmaCut(Int_t verbosity = 1, Int_t nparams = 0, Float_t *params = 0); virtual ~TKLPedestalSigmaCut(); // basic functions for using fPedestals void LoadPedestalWaveform(Int_t CableNumber, Int_t Gain, Bool_t AorB, Short_t *PedestalWaveform); void SubtractPedestal(Int_t CableNumber, Int_t Gain, Bool_t AorB, Float_t *Waveform); void GetPedestal(Int_t CableNumber, Int_t Gain, Bool_t AorB, Float_t *Waveform); Bool_t IsReady(Int_t CableNumber, Int_t Gain, Bool_t AorB); protected: void CreateSinglePedestalsPointerArray(); enum { // NumPMTs*6 + NumATWDGainChannels*2 + NumATWDAorBChannels kMaxPedestalIndex = 12800 }; TKLSinglePedestalSigmaCut** fSinglePedestals; //! will create kMaxPedestalIndex of these ClassDef(TKLPedestalSigmaCut, 1) // TKLPedestalSigmaCut }; class TKLSinglePedestalSigmaCut : public TKLVirtualWaveformTools { public: TKLSinglePedestalSigmaCut(Int_t verbosity = 0, Int_t nparams = 0, Float_t *params = 0); virtual ~TKLSinglePedestalSigmaCut(); // basic functions for using fPedestals void LoadPedestalWaveform(Short_t *PedestalWaveform) throw(string); void SubtractPedestal(Float_t *Waveform) throw(string); void GetPedestal(Float_t *Waveform) throw(string); Bool_t IsReady(); protected: void CalculateAverage() throw(string); protected: enum { kThrowoutSigma = 4, // Don't use fPedestals with bins this many standard deviations away from the sample mean kMinimumDepth = 5, // Spit out an error message if there are less than this many useable fPedestals kDepth = 50, // Average at most this many fPedestals, and push the oldest off the list (FIFO principle) kNumberOfSamples = 128, kSingleWaveformChiSquaredCut = 20000 // Waveforms with ChiSquared greater than this may shift the average enough to throw out all fPedestals: // sqrt(DeltaChiSquared(=contribution of a single anomolous sample)) ~= kThrowoutSigma * DigitalNoiseRMS * kDepth // Assumes an RMS of digitals noise of ~1 or 2 ADC counts. // I also divided by 2 as a safety factor, but the cut is still comfortably large. // For reference, a "good" pedestal typically has a ChiSquared of about 2000-5000. }; Short_t** fPedestals; //! Float_t* fAverage; //! Float_t* fStandardDev; //! Float_t* fSinglePedestalMeans; //! Bool_t* fUsable; //! Int_t fPutPosition; Bool_t fFull; Bool_t fReady; ClassDef(TKLSinglePedestalSigmaCut, 1) // TKLSinglePedestalSigmaCut }; #endif