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