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