]>
Commit | Line | Data |
---|---|---|
75d8233f | 1 | #ifndef ALITPCCALIBCE_H |
2 | #define ALITPCCALIBCE_H | |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
3cd27a08 | 6 | //////////////////////////////////////////////////////////////////////////////////////// |
7 | // // | |
8 | // Implementation of the TPC Central Electrode calibration // | |
9 | // // | |
10 | //////////////////////////////////////////////////////////////////////////////////////// | |
11 | ||
75d8233f | 12 | #include <TVectorT.h> |
78f17711 | 13 | #include <THnSparse.h> |
14 | ||
880c3382 | 15 | #include "AliTPCCalibRawBase.h" |
75d8233f | 16 | class TH1S; |
2811495d | 17 | #include "TObjArray.h" |
75d8233f | 18 | class TH2S; |
19 | class TH1F; | |
20 | class TTreeSRedirector; | |
21 | class AliTPCCalPad; | |
22 | class AliTPCROC; | |
23 | class AliTPCCalROC; | |
24 | class AliTPCParam; | |
25 | class AliRawReader; | |
75d8233f | 26 | class TGraph; |
ac940b58 | 27 | class TMap; |
7442bceb | 28 | class TCollection; |
04049c81 | 29 | |
75d8233f | 30 | struct eventHeaderStruct; |
31 | ||
880c3382 | 32 | class AliTPCCalibCE : public AliTPCCalibRawBase { |
33 | ||
75d8233f | 34 | public: |
880c3382 | 35 | AliTPCCalibCE(); |
36 | AliTPCCalibCE(const AliTPCCalibCE &sig); | |
37 | AliTPCCalibCE(const TMap *config); | |
38 | virtual ~AliTPCCalibCE(); | |
39 | ||
40 | AliTPCCalibCE& operator = (const AliTPCCalibCE &source); | |
41 | ||
42 | virtual Int_t Update(const Int_t isector, const Int_t iRow, const Int_t iPad, | |
43 | const Int_t iTimeBin, const Float_t signal); | |
78f17711 | 44 | virtual void ProcessBunch(const Int_t sector, const Int_t row, const Int_t pad, |
45 | const Int_t length, const UInt_t startTimeBin, const UShort_t* signal); | |
46 | ||
880c3382 | 47 | virtual void Analyse(); |
78f17711 | 48 | void AnalyseTrack(); |
880c3382 | 49 | |
75d8233f | 50 | // |
880c3382 | 51 | AliTPCCalROC* GetCalRocT0 (Int_t sector, Bool_t force=kFALSE); // get calibration object - sector |
52 | AliTPCCalROC* GetCalRocT0Err(Int_t sector, Bool_t force=kFALSE); // get calibration object - sector | |
53 | AliTPCCalROC* GetCalRocQ (Int_t sector, Bool_t force=kFALSE); // get calibration object - sector | |
54 | AliTPCCalROC* GetCalRocRMS(Int_t sector, Bool_t force=kFALSE); // get calibration object - sector | |
55 | AliTPCCalROC* GetCalRocOutliers(Int_t sector, Bool_t force=kFALSE); // get calibration object - sector | |
56 | ||
57 | const TObjArray* GetCalPadT0() const { return &fCalRocArrayT0; } // get calibration object | |
58 | const TObjArray* GetCalPadT0Err() const { return &fCalRocArrayT0Err; } // get calibration object | |
59 | const TObjArray* GetCalPadQ() const { return &fCalRocArrayQ; } // get calibration object | |
60 | const TObjArray* GetCalPadRMS() const { return &fCalRocArrayRMS;} // get calibration object | |
61 | const TObjArray* GetCalPadOutliers() const { return &fCalRocArrayOutliers;} // get calibration object | |
62 | ||
63 | TH2S* GetHistoQ (Int_t sector, Bool_t force=kFALSE); // get refernce histogram | |
64 | TH2S* GetHistoT0 (Int_t sector, Bool_t force=kFALSE); // get refernce histogram | |
65 | TH2S* GetHistoRMS(Int_t sector, Bool_t force=kFALSE); // get refernce histogram | |
78f17711 | 66 | |
880c3382 | 67 | Float_t GetMeanT0rms() const {return fMeanT0rms;} |
68 | Float_t GetMeanQrms() const {return fMeanQrms;} | |
69 | Float_t GetMeanRMSrms() const {return fMeanRMSrms;} | |
70 | ||
71 | Int_t GetPeakDetectionMinus() const {return fPeakDetMinus;} | |
72 | Int_t GetPeakDetectionPlus() const {return fPeakDetPlus;} | |
73 | Int_t GetPeakIntRangeMinus() const {return fPeakIntMinus;} | |
74 | Int_t GetPeakIntRangePlus() const {return fPeakIntPlus;} | |
75 | Float_t GetNnoiseThresholdMax() const {return fNoiseThresholdMax;} | |
76 | Float_t GetNnoiseThresholdSum() const {return fNoiseThresholdSum;} | |
77 | ||
78 | TH1S* GetHistoTmean(Int_t sector, Bool_t force=kFALSE); // get refernce histogram | |
79 | ||
7fb602b1 | 80 | //needed here to merge ClibCE objects |
880c3382 | 81 | TObjArray* GetParamArrayPol1(Int_t sector, Bool_t force=kFALSE); |
82 | TObjArray* GetParamArrayPol2(Int_t sector, Bool_t force=kFALSE); | |
83 | ||
7fb602b1 | 84 | // TObjArray* GetTMeanArrayEvent(){ return &fTMeanArrayEvent; } |
85 | // TObjArray* GetQMeanArrayEvent(){ return &fQMeanArrayEvent; } | |
880c3382 | 86 | TVectorF* GetTMeanEvents(Int_t sector, Bool_t force=kFALSE); |
87 | TVectorF* GetQMeanEvents(Int_t sector, Bool_t force=kFALSE); | |
88 | ||
7442bceb | 89 | const TVectorD* GetEventTimes() const { return &fVEventTime; } |
90 | const TVectorD* GetEventIds() const { return &fVEventNumber; } | |
880c3382 | 91 | |
92 | // | |
93 | void SetRangeRefQ (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsQ = nBins; fXminQ = xMin; fXmaxQ = xMax; } //Set range for Q reference histograms | |
94 | void SetRangeRefT0 (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsT0 = nBins; fXminT0 = xMin; fXmaxT0 = xMax; } //Set range for T0 reference histograms | |
95 | void SetRangeRefRMS(Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsRMS = nBins; fXminRMS = xMin; fXmaxRMS = xMax; } //Set range for T0 reference histograms | |
96 | // | |
97 | void SetRangePeakDetection(Int_t minus, Int_t plus) { fPeakDetMinus=minus; fPeakDetPlus=plus;} | |
98 | void SetRangePeakIntegral(Int_t minus, Int_t plus) { fPeakIntMinus=minus; fPeakIntPlus=plus;} | |
99 | void SetNnoiseThresholdMax(Float_t n) {fNoiseThresholdMax=n;} | |
100 | void SetNnoiseThresholdSum(Float_t n) {fNoiseThresholdSum=n;} | |
101 | // | |
c3066940 | 102 | void SetEventInfo(UInt_t runNumber,UInt_t timestamp, UInt_t eventId){ fRunNumber=runNumber; fTimeStamp=timestamp; fEventId=eventId;} |
880c3382 | 103 | // |
7442bceb | 104 | void SetPedestalDatabase(AliTPCCalPad * const pedestalTPC, AliTPCCalPad * const padNoiseTPC) {fPedestalTPC = pedestalTPC; fPadNoiseTPC = padNoiseTPC;} |
880c3382 | 105 | void SetIsZeroSuppressed(Bool_t zs=kTRUE) { fIsZeroSuppressed=zs; } |
106 | void SetSecRejectRatio(Float_t ratio) { fSecRejectRatio=ratio; } | |
78f17711 | 107 | |
108 | void SetProcessOld(Bool_t process=kTRUE) {fProcessOld=process;} | |
109 | void SetProcessNew(Bool_t process=kTRUE) {fProcessNew=process; if (process&&!fHnDrift) CreateDVhist(); } | |
880c3382 | 110 | //Getters |
111 | Int_t GetNeventsProcessed() const { return fNevents; } | |
112 | ||
113 | Bool_t GetIsZeroSuppressed() const { return fIsZeroSuppressed; } | |
114 | ||
115 | Float_t GetSecRejectRatio() const { return fSecRejectRatio; } | |
116 | ||
117 | const TVectorF *GetTime0Side(Int_t side=0) const {return (side==0)?&fVTime0SideA:&fVTime0SideC;} | |
118 | Float_t GetPeakIntegralMinus() const {return fPeakIntMinus;} | |
119 | Float_t GetPeakIntegralPlus() const {return fPeakIntPlus;} | |
120 | ||
121 | ||
7442bceb | 122 | void Merge(AliTPCCalibCE * const ce); |
123 | virtual Long64_t Merge(TCollection * const list); | |
880c3382 | 124 | |
125 | TGraph *MakeGraphTimeCE(Int_t sector, Int_t xVariable=0, Int_t fitType=0, Int_t fitParameter=0); | |
78f17711 | 126 | |
127 | // | |
128 | // New functions using also the laser tracks | |
129 | // | |
130 | Bool_t IsEdgePad(Int_t sector, Int_t row, Int_t pad) const; | |
131 | ||
132 | void FindLocalMaxima(TObjArray * const arrObj, Double_t timestamp, Int_t burst); | |
133 | Int_t FindLaserTrackID(Int_t sector,Int_t row, const Double_t *peakpos,Double_t &mindist, const Double_t *peakposloc, Int_t &itrackMin2); | |
134 | ||
135 | const THnSparseI *GetHnDrift() const {return fHnDrift;} | |
136 | const TObjArray& GetArrHnDrift() const {return fArrHnDrift;} | |
137 | const TVectorD& GetTimeBursts() const {return fTimeBursts;} | |
138 | const TObjArray *GetArrFitGraphs() const {return fArrFitGraphs;} | |
139 | ||
140 | virtual void DumpToFile(const Char_t *filename, const Char_t *dir="", Bool_t append=kFALSE); | |
141 | ||
142 | static AliTPCCalibCE *ReadFromFile(const Char_t *filename); | |
7442bceb | 143 | |
144 | protected: | |
145 | virtual void EndEvent(); | |
146 | virtual void ResetEvent(); | |
147 | ||
bf57d87d | 148 | private: |
75d8233f | 149 | // reference histogram ranges |
880c3382 | 150 | Int_t fNbinsT0; // Number of bins for T0 reference histogram |
151 | Float_t fXminT0; // xmin of T0 reference histogram | |
152 | Float_t fXmaxT0; // xmax of T0 reference histogram | |
153 | Int_t fNbinsQ; // Number of bins for T0 reference histogram | |
154 | Float_t fXminQ; // xmin of T0 reference histogram | |
155 | Float_t fXmaxQ; // xmax of T0 reference histogram | |
156 | Int_t fNbinsRMS; // Number of bins for T0 reference histogram | |
157 | Float_t fXminRMS; // xmin of T0 reference histogram | |
158 | Float_t fXmaxRMS; // xmax of T0 reference histogram | |
159 | Int_t fPeakDetMinus; // Consecutive timebins on rising edge to be regarded as a signal | |
160 | Int_t fPeakDetPlus; // Consecutive timebins on falling edge to be regarded as a signal | |
161 | Int_t fPeakIntMinus; // Peak integral range for COG determination. Bins used before max bin | |
162 | Int_t fPeakIntPlus; // Peak integral range for COG determination. Bins used after max bin | |
163 | Float_t fNoiseThresholdMax; // Analysis Treshold for signal finding: Max>fNoiseThresholdMax*PadNoise | |
164 | Float_t fNoiseThresholdSum; // Analysis Treshold for signal finding: Sum>fNoiseThresholdSum*PadNoise | |
165 | ||
166 | Bool_t fIsZeroSuppressed; // If data is Zero Suppressed -> Don't subtrakt pedestals! | |
167 | ||
168 | Int_t fLastSector; //! Last sector processed | |
169 | ||
170 | Float_t fSecRejectRatio; //! Needed percentage of signals in one chamber. Below it will be rejected | |
930a9868 | 171 | // This is neede if we do not process a laser event |
880c3382 | 172 | |
173 | AliTPCParam *fParam; //! TPC information | |
174 | ||
175 | AliTPCCalPad *fPedestalTPC; //! Pedestal Information whole TPC | |
176 | AliTPCCalPad *fPadNoiseTPC; //! Pad noise Information whole TPC | |
177 | AliTPCCalROC *fPedestalROC; //! Pedestal Information for current ROC | |
178 | AliTPCCalROC *fPadNoiseROC; //! Pad noise Information for current ROC | |
179 | ||
180 | TObjArray fCalRocArrayT0; // Array of AliTPCCalROC class for Time0 calibration | |
181 | TObjArray fCalRocArrayT0Err; // Array of AliTPCCalROC class for the error (rms) of Time0 calibration | |
182 | TObjArray fCalRocArrayQ; // Array of AliTPCCalROC class for Charge calibration | |
183 | TObjArray fCalRocArrayRMS; // Array of AliTPCCalROC class for signal width calibration | |
184 | TObjArray fCalRocArrayOutliers; // Array of AliTPCCalROC class for signal outliers | |
185 | ||
186 | TObjArray fHistoQArray; // Calibration histograms for Charge distribution | |
187 | TObjArray fHistoT0Array; // Calibration histograms for Time0 distribution | |
188 | TObjArray fHistoRMSArray; // Calibration histograms for signal width distribution | |
189 | ||
190 | Float_t fMeanT0rms; // mean of the rms of all pad T0 fits, used as error estimation of T0 results | |
191 | Float_t fMeanQrms; // mean of the rms of all pad Q fits, used as error estimation of Q results | |
192 | Float_t fMeanRMSrms; // mean of the rms of all pad TMS fits, used as error estimation of RMS results | |
193 | ||
194 | TObjArray fHistoTmean; //! Calibration histograms of the mean CE position for all sectors | |
195 | ||
196 | TObjArray fParamArrayEventPol1; // Store mean arrival time parameters for each sector event by event from global plane fit | |
197 | TObjArray fParamArrayEventPol2; // Store mean arrival time parameters for each sector event by event from global parabola fit | |
198 | TObjArray fTMeanArrayEvent; // Store mean arrival time for each sector event by event | |
199 | TObjArray fQMeanArrayEvent; // Store mean arrival Charge for each sector event by event | |
200 | TVectorD fVEventTime; // Timestamps of the events | |
201 | TVectorD fVEventNumber; // Eventnumbers of the events | |
202 | TVectorF fVTime0SideA; // Mean Time0 for side A for all events | |
203 | TVectorF fVTime0SideC; // Mean Time0 for side C for all events | |
880c3382 | 204 | Double_t fEventId; //! Event Id of the current event |
c3066940 | 205 | UInt_t fOldRunNumber; //! Old Run Number |
880c3382 | 206 | |
207 | TObjArray fPadTimesArrayEvent; //! Pad Times for the event, before mean Time0 corrections | |
208 | TObjArray fPadQArrayEvent; //! Charge for the event, only needed for debugging streamer | |
209 | TObjArray fPadRMSArrayEvent; //! Signal width for the event, only needed for debugging streamer | |
210 | TObjArray fPadPedestalArrayEvent; //! Signal width for the event, only needed for debugging streamer | |
211 | ||
212 | Int_t fCurrentChannel; //! current channel processed | |
213 | Int_t fCurrentSector; //! current sector processed | |
214 | Int_t fCurrentRow; //! current row processed | |
215 | Float_t fMaxPadSignal; //! maximum bin of current pad | |
216 | Int_t fMaxTimeBin; //! time bin with maximum value | |
2963bcbf | 217 | Float_t fPadSignal[1024]; //! signal of current Pad |
880c3382 | 218 | Float_t fPadPedestal; //! Pedestal Value of current pad |
219 | Float_t fPadNoise; //! Noise Value of current pad | |
220 | ||
221 | TVectorD fVTime0Offset; //! Time0 Offset for each sector; | |
222 | TVectorD fVTime0OffsetCounter; //! Time0 Offset counter for each sector; | |
223 | TVectorD fVMeanQ; //! Mean Q for each sector; | |
224 | TVectorD fVMeanQCounter; //! Mean Q counter for each sector; | |
225 | ||
226 | Float_t fCurrentCETimeRef; //! Time refernce of the current sector | |
227 | ||
78f17711 | 228 | // new part of the algorithm |
229 | Bool_t fProcessOld; // Whether to use the old algorithm | |
230 | Bool_t fProcessNew; // Whether to use the new algorithm | |
231 | Bool_t fAnalyseNew; //! Whether to analyse the new part of the algorithm. | |
232 | //In the DA this needs to be switched off, in the Preprocessor on... | |
233 | enum {kHnBinsDV=5}; | |
234 | THnSparseI *fHnDrift; //! Histogram digits for each pad and timebin for several timestamps | |
235 | TObjArray fArrHnDrift; // array of sparse histograms for each burst | |
236 | TVectorD fTimeBursts; // time stamps of bursts | |
237 | UInt_t fBinsLastAna[100]; // number of bin in the THnSparse during the last analysis | |
6e6025f4 | 238 | UShort_t fPeaks[14]; //! Peak position: 4 laser layers and CE |
239 | UShort_t fPeakWidths[14]; //! Peak window widths | |
78f17711 | 240 | TObjArray *fArrFitGraphs; // Fit resut graphs for each parameter |
6e6025f4 | 241 | UInt_t fEventInBunch; //! event in current bunch |
78f17711 | 242 | |
243 | ||
244 | // | |
880c3382 | 245 | void FindPedestal(Float_t part=.6); |
246 | void UpdateCETimeRef(); //Get the time reference of the last valid measurement in sector | |
247 | void FindCESignal(TVectorD ¶m, Float_t &qSum, const TVectorF maxima); | |
248 | void FindLocalMaxima(TVectorF &maxima); | |
249 | Bool_t IsPeak(Int_t pos, Int_t tminus, Int_t tplus) const; | |
250 | ||
251 | TH2S* GetHisto(Int_t sector, TObjArray *arr, | |
252 | Int_t nbinsY, Float_t ymin, Float_t ymax, | |
253 | const Char_t *type, Bool_t force); | |
254 | TH1S* GetHisto(Int_t sector, TObjArray *arr, | |
255 | const Char_t *type, Bool_t force); | |
256 | ||
257 | AliTPCCalROC* GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) const; | |
258 | ||
259 | TVectorF* GetVectSector(Int_t sector, TObjArray *arr, UInt_t size, Bool_t force=kFALSE) const; | |
260 | TVectorF* GetPadTimesEvent(Int_t sector, Bool_t force=kFALSE); | |
261 | ||
262 | TObjArray* GetParamArray(Int_t sector, TObjArray *arr, Bool_t force=kFALSE) const; | |
263 | ||
880c3382 | 264 | void ResetPad(); |
265 | void ProcessPad(); | |
78f17711 | 266 | |
267 | // new part of the algorithm | |
268 | void CreateDVhist(); | |
269 | ||
270 | void FindLaserLayers(); | |
6e6025f4 | 271 | Bool_t IsPeakInRange(UShort_t timebin, Int_t roc) const; |
78f17711 | 272 | |
273 | TObjArray *SetupMeasured(); | |
274 | void ResetMeasured(TObjArray * const arr); | |
275 | ||
276 | void AddCEtoIdeal(TObjArray *arr); | |
277 | ||
278 | void CalculateDV(TObjArray * const arrIdeal, TObjArray * const arrMeasured, Int_t burst); | |
279 | Double_t SetBurstHnDrift(); | |
880c3382 | 280 | //debug |
281 | TVectorF* GetPadQEvent(Int_t sector, Bool_t force=kFALSE); | |
282 | TVectorF* GetPadRMSEvent(Int_t sector, Bool_t force=kFALSE); | |
283 | TVectorF* GetPadPedestalEvent(Int_t sector, Bool_t force=kFALSE); | |
284 | ||
6e6025f4 | 285 | ClassDef(AliTPCCalibCE,10) //Implementation of the TPC Central Electrode calibration |
75d8233f | 286 | }; |
287 | ||
78f17711 | 288 | //Inline functions |
289 | //_____________________________________________________________________ | |
6e6025f4 | 290 | inline Bool_t AliTPCCalibCE::IsPeakInRange(UShort_t timebin, Int_t roc) const |
78f17711 | 291 | { |
292 | // | |
293 | // Check whether timebin is in the range of a laser layer | |
294 | // | |
6e6025f4 | 295 | Int_t side=(roc/18)%2; |
296 | Int_t add=7*side; | |
78f17711 | 297 | // return kTRUE; |
6a2742c2 | 298 | if (fPeaks[13]<2) return kTRUE; //not determined yet |
6e6025f4 | 299 | for (Int_t i=add; i<add+7; ++i){ |
78f17711 | 300 | if (TMath::Abs((Short_t)timebin-(Short_t)fPeaks[i])<(Short_t)fPeakWidths[i]) return kTRUE; |
301 | } | |
302 | return kFALSE; | |
303 | } | |
304 | ||
75d8233f | 305 | #endif |