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 */
6 ////////////////////////////////////////////////////////////////////////////////////////
8 // Implementation of the TPC Central Electrode calibration //
10 ////////////////////////////////////////////////////////////////////////////////////////
13 #include <THnSparse.h>
15 #include "AliTPCCalibRawBase.h"
17 #include "TObjArray.h"
20 class TTreeSRedirector;
26 class AliTPCRawStream;
31 struct eventHeaderStruct;
33 class AliTPCCalibCE : public AliTPCCalibRawBase {
37 AliTPCCalibCE(const AliTPCCalibCE &sig);
38 AliTPCCalibCE(const TMap *config);
39 virtual ~AliTPCCalibCE();
41 AliTPCCalibCE& operator = (const AliTPCCalibCE &source);
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);
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);
48 virtual void Analyse();
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
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
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
68 Float_t GetMeanT0rms() const {return fMeanT0rms;}
69 Float_t GetMeanQrms() const {return fMeanQrms;}
70 Float_t GetMeanRMSrms() const {return fMeanRMSrms;}
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;}
79 TH1S* GetHistoTmean(Int_t sector, Bool_t force=kFALSE); // get refernce histogram
81 //needed here to merge ClibCE objects
82 TObjArray* GetParamArrayPol1(Int_t sector, Bool_t force=kFALSE);
83 TObjArray* GetParamArrayPol2(Int_t sector, Bool_t force=kFALSE);
85 // TObjArray* GetTMeanArrayEvent(){ return &fTMeanArrayEvent; }
86 // TObjArray* GetQMeanArrayEvent(){ return &fQMeanArrayEvent; }
87 TVectorF* GetTMeanEvents(Int_t sector, Bool_t force=kFALSE);
88 TVectorF* GetQMeanEvents(Int_t sector, Bool_t force=kFALSE);
90 const TVectorD* GetEventTimes() const { return &fVEventTime; }
91 const TVectorD* GetEventIds() const { return &fVEventNumber; }
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
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;}
103 void SetEventInfo(UInt_t runNumber,UInt_t timestamp, UInt_t eventId){ fRunNumber=runNumber; fTimeStamp=timestamp; fEventId=eventId;}
105 void SetPedestalDatabase(AliTPCCalPad * const pedestalTPC, AliTPCCalPad * const padNoiseTPC) {fPedestalTPC = pedestalTPC; fPadNoiseTPC = padNoiseTPC;}
106 void SetIsZeroSuppressed(Bool_t zs=kTRUE) { fIsZeroSuppressed=zs; }
107 void SetSecRejectRatio(Float_t ratio) { fSecRejectRatio=ratio; }
109 void SetProcessOld(Bool_t process=kTRUE) {fProcessOld=process;}
110 void SetProcessNew(Bool_t process=kTRUE) {fProcessNew=process; if (process&&!fHnDrift) CreateDVhist(); }
112 Int_t GetNeventsProcessed() const { return fNevents; }
114 Bool_t GetIsZeroSuppressed() const { return fIsZeroSuppressed; }
116 Float_t GetSecRejectRatio() const { return fSecRejectRatio; }
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;}
123 void Merge(AliTPCCalibCE * const ce);
124 virtual Long64_t Merge(TCollection * const list);
126 TGraph *MakeGraphTimeCE(Int_t sector, Int_t xVariable=0, Int_t fitType=0, Int_t fitParameter=0);
129 // New functions using also the laser tracks
131 Bool_t IsEdgePad(Int_t sector, Int_t row, Int_t pad) const;
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);
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;}
141 virtual void DumpToFile(const Char_t *filename, const Char_t *dir="", Bool_t append=kFALSE);
143 static AliTPCCalibCE *ReadFromFile(const Char_t *filename);
146 virtual void EndEvent();
147 virtual void ResetEvent();
150 // reference histogram ranges
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
167 Bool_t fIsZeroSuppressed; // If data is Zero Suppressed -> Don't subtrakt pedestals!
169 Int_t fLastSector; //! Last sector processed
171 Float_t fSecRejectRatio; //! Needed percentage of signals in one chamber. Below it will be rejected
172 // This is neede if we do not process a laser event
174 AliTPCParam *fParam; //! TPC information
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
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
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
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
195 TObjArray fHistoTmean; //! Calibration histograms of the mean CE position for all sectors
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
205 Double_t fEventId; //! Event Id of the current event
206 UInt_t fOldRunNumber; //! Old Run Number
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
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
218 Float_t fPadSignal[1024]; //! signal of current Pad
219 Float_t fPadPedestal; //! Pedestal Value of current pad
220 Float_t fPadNoise; //! Noise Value of current pad
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;
227 Float_t fCurrentCETimeRef; //! Time refernce of the current sector
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...
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
239 UShort_t fPeaks[14]; //! Peak position: 4 laser layers and CE
240 UShort_t fPeakWidths[14]; //! Peak window widths
241 TObjArray *fArrFitGraphs; // Fit resut graphs for each parameter
242 UInt_t fEventInBunch; //! event in current bunch
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 ¶m, 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;
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);
258 AliTPCCalROC* GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) const;
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);
263 TObjArray* GetParamArray(Int_t sector, TObjArray *arr, Bool_t force=kFALSE) const;
268 // new part of the algorithm
271 void FindLaserLayers();
272 Bool_t IsPeakInRange(UShort_t timebin, Int_t roc) const;
274 TObjArray *SetupMeasured();
275 void ResetMeasured(TObjArray * const arr);
277 void AddCEtoIdeal(TObjArray *arr);
279 void CalculateDV(TObjArray * const arrIdeal, TObjArray * const arrMeasured, Int_t burst);
280 Double_t SetBurstHnDrift();
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);
286 ClassDef(AliTPCCalibCE,10) //Implementation of the TPC Central Electrode calibration
290 //_____________________________________________________________________
291 inline Bool_t AliTPCCalibCE::IsPeakInRange(UShort_t timebin, Int_t roc) const
294 // Check whether timebin is in the range of a laser layer
296 Int_t side=(roc/18)%2;
299 if (fPeaks[13]<2) return kTRUE; //not determined yet
300 for (Int_t i=add; i<add+7; ++i){
301 if (TMath::Abs((Short_t)timebin-(Short_t)fPeaks[i])<(Short_t)fPeakWidths[i]) return kTRUE;