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