source: branches/AddingGoogleTestEnvironment/mpedestal/MExtractPedestal.h@ 18264

Last change on this file since 18264 was 9157, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 6.0 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
26typedef UShort_t USample_t;
27
28class MExtractPedestal : public MTask
29{
30private:
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
49protected:
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 UInt_t fCounter; // Counter for events processed
93
94 // MTask virtual functions
95 Int_t PreProcess(MParList *pList);
96 Int_t Process();
97 Int_t PostProcess();
98 Bool_t ReInit(MParList *pList);
99 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
100
101 // Interface to be overwritten by a new class
102 virtual void ResetArrays();
103 virtual void Calc() = 0;
104
105 // Helper functions
106 void CalcPixResults(const UInt_t pixid);
107
108 void CalcPixResult();
109 void CalcSectorResult();
110 void CalcAreaResult();
111
112 Bool_t CalcPixel(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t usespecialpixels=kFALSE);
113 Float_t CalcExtractor(const MRawEvtPixelIter &pixel, Int_t offset) const;
114 UInt_t CalcSums(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t &ab0, UInt_t &ab1) const;
115 Bool_t CheckVariation(UInt_t idx) const;
116
117 void CheckExtractionWindow(UInt_t offset=0);
118
119 Bool_t SetRangeFromExtractor(const MExtractor &ext, Bool_t logain);
120
121public:
122 MExtractPedestal(const char *name=NULL, const char *title=NULL);
123
124 void Clear(const Option_t *o="");
125 void Print(const Option_t *o="") const;
126
127 // Setters
128 Bool_t SetExtractWindow(UShort_t first, UShort_t size);
129 Bool_t SetCheckRange(UShort_t checkfirst=fgCheckWinFirst, UShort_t checklast=fgCheckWinLast);
130
131 virtual Bool_t SetRangeFromExtractor(const MExtractor &ext) = 0;
132
133 void SetMaxSignalVar(UShort_t maxvar=40) { fMaxSignalVar = maxvar; }
134 void SetMaxSignalAbs(UShort_t maxabs=250) { fMaxSignalAbs = maxabs; }
135
136 // names
137 void SetNamePedestalCamInter(const char *name=fgNamePedestalCam) { fNamePedestalCamInter = name; }
138 void SetNamePedestalCamOut (const char *name=fgNamePedestalCam) { fNamePedestalCamOut = name; }
139 void SetNameRawEvtData (const char *name=fgNameRawEvtData) { fNameRawEvtData = name; }
140
141 // pointers
142 void SetExtractor ( MExtractTimeAndCharge *e) { fExtractor = e; }
143 void SetPedestalsInter( MPedestalCam *pedcam ) { fPedestalsInter = pedcam; }
144 void SetPedestalsOut ( MPedestalCam *pedcam ) { fPedestalsOut = pedcam; }
145
146 // flags
147 void SetIntermediateStorage (Bool_t b=kTRUE) { fIntermediateStorage = b; }
148 void SetUseSpecialPixels (Bool_t b=kTRUE) { fUseSpecialPixels = b; }
149 void SetRandomCalculation (Bool_t b=kTRUE) { fRandomCalculation = b; }
150
151 ClassDef(MExtractPedestal, 0) // Base class for pedestal extractors
152};
153
154#endif
Note: See TracBrowser for help on using the repository browser.