| 1 | #ifndef MARS_MExtractPedestal
|
|---|
| 2 | #define MARS_MExtractPedestal
|
|---|
| 3 |
|
|---|
| 4 | #ifndef MARS_MTask
|
|---|
| 5 | #include "MTask.h"
|
|---|
| 6 | #endif
|
|---|
| 7 |
|
|---|
| 8 | #ifndef MARS_MArrayD
|
|---|
| 9 | #include <MArrayD.h>
|
|---|
| 10 | #endif
|
|---|
| 11 |
|
|---|
| 12 | #ifndef MARS_MArrayI
|
|---|
| 13 | #include <MArrayI.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | class MGeomCam;
|
|---|
| 17 | class MExtractor;
|
|---|
| 18 | class MPedestalCam;
|
|---|
| 19 | class MRawEvtData;
|
|---|
| 20 | class MRawRunHeader;
|
|---|
| 21 | class MRawEvtHeader;
|
|---|
| 22 | class MExtractTimeAndCharge;
|
|---|
| 23 | class MPedestalSubtractedEvt;
|
|---|
| 24 | class MRawEvtPixelIter;
|
|---|
| 25 |
|
|---|
| 26 | //typedef UShort_t USample_t;
|
|---|
| 27 | typedef Byte_t USample_t;
|
|---|
| 28 |
|
|---|
| 29 | class MExtractPedestal : public MTask
|
|---|
| 30 | {
|
|---|
| 31 | private:
|
|---|
| 32 | static const TString fgNamePedestalCam; //! "MPedestalCam"
|
|---|
| 33 | static const TString fgNameRawEvtData; //! "MRawEvtData"
|
|---|
| 34 |
|
|---|
| 35 | static const UShort_t fgCheckWinFirst; //! First FADC slice to check for signal (currently set to: 0)
|
|---|
| 36 | static const UShort_t fgCheckWinLast; //! Last FADC slice to check for signal (currently set to: 29)
|
|---|
| 37 | static const UShort_t fgMaxSignalVar; //! The maximum difference between the highest and lowest slice
|
|---|
| 38 | static const UShort_t fgMaxSignalAbs; //! The maximum absolte slice
|
|---|
| 39 |
|
|---|
| 40 | TString fNamePedestalCamOut; // Name of the outgoing 'MPedestalCam' container
|
|---|
| 41 | TString fNamePedestalCamInter; // Name of the intermediate 'MPedestalCam' container
|
|---|
| 42 | TString fNameRawEvtData; // Name of MRawEvtData
|
|---|
| 43 |
|
|---|
| 44 | Bool_t fRandomCalculation; // Is pedestalextraction by extractor random?
|
|---|
| 45 |
|
|---|
| 46 | // Helper functions
|
|---|
| 47 | void CalcAreaResults(const UInt_t aidx);
|
|---|
| 48 | void CalcSectorResults(const UInt_t sector);
|
|---|
| 49 |
|
|---|
| 50 | protected:
|
|---|
| 51 |
|
|---|
| 52 | Bool_t fIntermediateStorage; // Is pedestal stored every event?
|
|---|
| 53 |
|
|---|
| 54 | MGeomCam *fGeom; //! Camera geometry
|
|---|
| 55 | MPedestalCam *fPedestalsInter; //! Pedestals of all pixels in the camera (intermediate)
|
|---|
| 56 | MPedestalCam *fPedestalsOut; //! Pedestals of all pixels in the camera (outgoing)
|
|---|
| 57 | MRawEvtData *fRawEvt; //! Raw event data (time slices)
|
|---|
| 58 | MRawRunHeader *fRunHeader; //! RunHeader information
|
|---|
| 59 | MExtractTimeAndCharge *fExtractor; // Possible Extractor
|
|---|
| 60 | MPedestalSubtractedEvt *fSignal; //!
|
|---|
| 61 |
|
|---|
| 62 | UShort_t fExtractWinFirst; // First FADC slice to extract pedestal from
|
|---|
| 63 | UShort_t fExtractWinSize; // Number of slices to calculate the pedestal from
|
|---|
| 64 | UShort_t fExtractWinLast; // Last FADC slice to extract pedestal from
|
|---|
| 65 |
|
|---|
| 66 | UShort_t fCheckWinFirst;
|
|---|
| 67 | UShort_t fCheckWinLast;
|
|---|
| 68 |
|
|---|
| 69 | UShort_t fMaxSignalVar;
|
|---|
| 70 | UShort_t fMaxSignalAbs;
|
|---|
| 71 |
|
|---|
| 72 | Bool_t fUseSpecialPixels; // Flag if the special pixels shall be treated
|
|---|
| 73 |
|
|---|
| 74 | MArrayD fSumx; // sum of values
|
|---|
| 75 | MArrayD fSumx2; // sum of squared values
|
|---|
| 76 | MArrayD fSumAB0; // sum of ABFlag=0 slices
|
|---|
| 77 | MArrayD fSumAB1; // sum of ABFlag=1 slices
|
|---|
| 78 | MArrayD fAreaSumx; // averaged sum of values per area idx
|
|---|
| 79 | MArrayD fAreaSumx2; // averaged sum of squared values per area idx
|
|---|
| 80 | MArrayD fAreaSumAB0; // averaged sum of ABFlag=0 slices per area idx
|
|---|
| 81 | MArrayD fAreaSumAB1; // averaged sum of ABFlag=1 slices per area idx
|
|---|
| 82 | MArrayI fAreaFilled; // number of valid entries with area idx
|
|---|
| 83 | MArrayI fAreaValid; // number of valid pixels within area idx
|
|---|
| 84 | MArrayD fSectorSumx; // averaged sum of values per sector
|
|---|
| 85 | MArrayD fSectorSumx2; // averaged sum of squared values per sector
|
|---|
| 86 | MArrayD fSectorSumAB0; // averaged sum of ABFlag=0 slices per sector
|
|---|
| 87 | MArrayD fSectorSumAB1; // averaged sum of ABFlag=1 slices per sector
|
|---|
| 88 | MArrayI fSectorFilled; // number of valid entries with sector idx
|
|---|
| 89 | MArrayI fSectorValid; // number of valid pixels within sector idx
|
|---|
| 90 |
|
|---|
| 91 | MArrayI fNumEventsUsed; // Number of events used for pedestal calc for each pixel
|
|---|
| 92 |
|
|---|
| 93 | // MTask virtual functions
|
|---|
| 94 | Int_t PreProcess(MParList *pList);
|
|---|
| 95 | Int_t Process();
|
|---|
| 96 | Int_t PostProcess();
|
|---|
| 97 | Bool_t ReInit(MParList *pList);
|
|---|
| 98 | Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
|
|---|
| 99 |
|
|---|
| 100 | // Interface to be overwritten by a new class
|
|---|
| 101 | virtual void ResetArrays();
|
|---|
| 102 | virtual Int_t Calc() = 0;
|
|---|
| 103 |
|
|---|
| 104 | // Helper functions
|
|---|
| 105 | void CalcPixResults(const UInt_t pixid);
|
|---|
| 106 |
|
|---|
| 107 | void CalcPixResult();
|
|---|
| 108 | void CalcSectorResult();
|
|---|
| 109 | void CalcAreaResult();
|
|---|
| 110 |
|
|---|
| 111 | Bool_t CalcPixel(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t usespecialpixels=kFALSE);
|
|---|
| 112 | Float_t CalcExtractor(const MRawEvtPixelIter &pixel, Int_t offset) const;
|
|---|
| 113 | UInt_t CalcSums(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t &ab0, UInt_t &ab1) const;
|
|---|
| 114 | Bool_t CheckVariation(UInt_t idx) const;
|
|---|
| 115 |
|
|---|
| 116 | void CheckExtractionWindow(UInt_t offset=0);
|
|---|
| 117 |
|
|---|
| 118 | Bool_t SetRangeFromExtractor(const MExtractor &ext, Bool_t logain);
|
|---|
| 119 |
|
|---|
| 120 | public:
|
|---|
| 121 | MExtractPedestal(const char *name=NULL, const char *title=NULL);
|
|---|
| 122 |
|
|---|
| 123 | void Clear(const Option_t *o="");
|
|---|
| 124 | void Print(const Option_t *o="") const;
|
|---|
| 125 |
|
|---|
| 126 | // Setters
|
|---|
| 127 | Bool_t SetExtractWindow(UShort_t first, UShort_t size);
|
|---|
| 128 | Bool_t SetCheckRange(UShort_t checkfirst=fgCheckWinFirst, UShort_t checklast=fgCheckWinLast);
|
|---|
| 129 |
|
|---|
| 130 | virtual Bool_t SetRangeFromExtractor(const MExtractor &ext) = 0;
|
|---|
| 131 |
|
|---|
| 132 | void SetMaxSignalVar(UShort_t maxvar=40) { fMaxSignalVar = maxvar; }
|
|---|
| 133 | void SetMaxSignalAbs(UShort_t maxabs=250) { fMaxSignalAbs = maxabs; }
|
|---|
| 134 |
|
|---|
| 135 | // names
|
|---|
| 136 | void SetNamePedestalCamInter(const char *name=fgNamePedestalCam) { fNamePedestalCamInter = name; }
|
|---|
| 137 | void SetNamePedestalCamOut (const char *name=fgNamePedestalCam) { fNamePedestalCamOut = name; }
|
|---|
| 138 | void SetNameRawEvtData (const char *name=fgNameRawEvtData) { fNameRawEvtData = name; }
|
|---|
| 139 |
|
|---|
| 140 | // pointers
|
|---|
| 141 | void SetExtractor ( MExtractTimeAndCharge *e) { fExtractor = e; }
|
|---|
| 142 | void SetPedestalsInter( MPedestalCam *pedcam ) { fPedestalsInter = pedcam; }
|
|---|
| 143 | void SetPedestalsOut ( MPedestalCam *pedcam ) { fPedestalsOut = pedcam; }
|
|---|
| 144 |
|
|---|
| 145 | // flags
|
|---|
| 146 | void SetIntermediateStorage (Bool_t b=kTRUE) { fIntermediateStorage = b; }
|
|---|
| 147 | void SetUseSpecialPixels (Bool_t b=kTRUE) { fUseSpecialPixels = b; }
|
|---|
| 148 | void SetRandomCalculation (Bool_t b=kTRUE) { fRandomCalculation = b; }
|
|---|
| 149 |
|
|---|
| 150 | ClassDef(MExtractPedestal, 0) // Base class for pedestal extractors
|
|---|
| 151 | };
|
|---|
| 152 |
|
|---|
| 153 | #endif
|
|---|