source: tags/Mars-V1.2/mpedestal/MExtractPedestal.h

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