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