Add the first version of the TRD preprocessor
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibra.h
CommitLineData
77566f2a 1#ifndef ALITRDCALIBRA_H
2#define ALITRDCALIBRA_H
8ec526a4 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
77566f2a 5
8ec526a4 6/* $Id$ */
7
8///////////////////////////////////////////////////////////////////////////////
9// //
10// TRD calibration class for the HLT parameters //
11// //
12///////////////////////////////////////////////////////////////////////////////
13
14#ifndef ROOT_TObject
15# include <TObject.h>
16#endif
17
18class TTree;
19class TProfile2D;
20class TGraphErrors;
21class TObjArray;
22class TH1I;
23class TH1;
24class TH1F;
25class TH2I;
26class TH2F;
27class TF1;
28
29class AliLog;
e5c60cc7 30
8ec526a4 31class AliTRDcluster;
32class AliTRDtrack;
33class AliTRDmcmTracklet;
34class AliTRDCalDet;
77566f2a 35
36class AliTRDCalibra : public TObject {
8ec526a4 37
77566f2a 38 public:
39
8ec526a4 40 // Instance
41 static AliTRDCalibra *Instance();
77566f2a 42 static void Terminate();
43 static void Destroy();
44
45 AliTRDCalibra(const AliTRDCalibra &c);
46 AliTRDCalibra &operator=(const AliTRDCalibra &) { return *this; }
47
77566f2a 48 // Functions fit online
8ec526a4 49 Bool_t FitCHOnline(TH2I *ch);
50 Bool_t FitCHOnline();
51 Bool_t FitCHOnline(TTree *tree);
52 Bool_t FitPHOnline(TProfile2D *ph);
53 Bool_t FitPHOnline();
54 Bool_t FitPHOnline(TTree *tree);
55 Bool_t FitPRFOnline(TProfile2D *prf);
56 Bool_t FitPRFOnline();
57 Bool_t FitPRFOnline(TTree *tree);
77566f2a 58
59 // Functions for initialising the AliTRDCalibra in the code
8ec526a4 60 Bool_t Init2Dhistos();
61
77566f2a 62 // Functions for filling the histos in the code
8ec526a4 63 Bool_t ResetTrack();
64 Bool_t UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t);
65 Bool_t UpdateHistogramcm(AliTRDmcmTracklet *trk);
77566f2a 66
77566f2a 67 // Is Pad on
8ec526a4 68 Bool_t IsPadOn(Int_t detector, Int_t col, Int_t row) const;
77566f2a 69
70 // Functions for plotting the 2D
8ec526a4 71 void Plot2d();
77566f2a 72
73 // Functions for writting the 2D
8ec526a4 74 Bool_t Write2d();
77566f2a 75
76 // Function fill 2D for the moment out of the code
8ec526a4 77 Bool_t Create2DDiSimOnline(Int_t iev1, Int_t iev2);
78 Bool_t Create2DRaDaOnline(Int_t iev1, Int_t iev2);
77566f2a 79
8ec526a4 80 // Pad Calibration
81 Bool_t ModePadFragmentation(Int_t iPlane,Int_t iChamb, Int_t iSect, Int_t i);
82 void ModePadCalibration(Int_t iChamb, Int_t i);
83 Bool_t SetModeCalibrationFromTObject(TObject *object, Int_t i);
77566f2a 84
85 // Fill the database
8ec526a4 86 TObject *CreatePadObjectTree(TTree *tree);
87 TObject *CreatePadObjectTree(TTree *tree, Int_t i, AliTRDCalDet *detobject);
88 AliTRDCalDet *CreateDetObjectTree(TTree *tree, Int_t i);
77566f2a 89
90 // Correct the error
8ec526a4 91 TH1F *CorrectTheError(TGraphErrors *hist);
92 TGraphErrors *AddProfiles(TGraphErrors *hist1, TGraphErrors *hist2) const ;
77566f2a 93
94 // Add two trees
8ec526a4 95 TTree *Sum2Trees(const Char_t *filename1, const Char_t *filename2, const Char_t *variablecali);
77566f2a 96
8ec526a4 97 //
98 // Set of Get the variables
99 //
77566f2a 100
101 // Choice to fill or not the 2D
8ec526a4 102 void SetMITracking(Bool_t mitracking = kTRUE) { fMITracking = mitracking; }
e5c60cc7 103 void SetMcmTracking(Bool_t mcmtracking = kTRUE) { fMcmTracking = mcmtracking; }
104 void SetMcmCorrectAngle() { fMcmCorrectAngle = kTRUE; }
105 void SetPH2dOn() { fPH2dOn = kTRUE; }
106 void SetCH2dOn() { fCH2dOn = kTRUE; }
107 void SetPRF2dOn() { fPRF2dOn = kTRUE; }
108 void SetHisto2d() { fHisto2d = kTRUE; }
109 void SetVector2d() { fVector2d = kTRUE; }
8ec526a4 110
e5c60cc7 111 Bool_t GetMITracking() const { return fMITracking; }
112 Bool_t GetMcmTracking() const { return fMcmTracking; }
113 Bool_t GetMcmCorrectAngle() const { return fMcmCorrectAngle; }
114 Bool_t GetPH2dOn() const { return fPH2dOn; }
115 Bool_t GetCH2dOn() const { return fCH2dOn; }
116 Bool_t GetPRF2dOn() const { return fPRF2dOn; }
117 Bool_t GetHisto2d() const { return fHisto2d; }
118 Bool_t GetVector2d() const { return fVector2d; }
119 TH2I *GetCH2d() const { return fCH2d; }
120 TProfile2D *GetPH2d() const { return fPH2d; }
121 TProfile2D *GetPRF2d() const { return fPRF2d; }
77566f2a 122
123 // How to fill the 2D
e5c60cc7 124 void SetRelativeScaleAuto() { fRelativeScaleAuto = kTRUE; }
8ec526a4 125 void SetRelativeScale(Float_t relativeScale);
e5c60cc7 126 void SetThresholdDigit(Int_t digitthreshold) { fThresholdDigit = digitthreshold; }
127 void SetThresholdClusterPRF1(Float_t thresholdClusterPRF1) { fThresholdClusterPRF1 = thresholdClusterPRF1; }
128 void SetThresholdClusterPRF2(Float_t thresholdClusterPRF2) { fThresholdClusterPRF2 = thresholdClusterPRF2; }
129 void SetCenterOfflineCluster() { fCenterOfflineCluster = kTRUE; }
130 void SetTraMaxPad() { fTraMaxPad = kTRUE; }
8ec526a4 131 void SetNz(Int_t i, Short_t nz);
132 void SetNrphi(Int_t i, Short_t nrphi);
e5c60cc7 133 void SetProcent(Float_t procent) { fProcent = procent; }
134 void SetDifference(Short_t difference) { fDifference = difference; }
135 void SetNumberClusters(Short_t numberClusters) { fNumberClusters = numberClusters; }
136 void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; }
137 void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; }
8ec526a4 138
e5c60cc7 139 Float_t GetRelativeScale() const { return fRelativeScale; }
140 Bool_t GetRelativeScaleAuto() const { return fRelativeScaleAuto; }
141 Int_t GetThresholdDigit() const { return fThresholdDigit; }
142 Float_t GetThresholdClusterPRF1() const { return fThresholdClusterPRF1; }
143 Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; }
144 Bool_t GetTraMaxPad()const { return fTraMaxPad; }
145 Short_t GetNz(Int_t i) const { return fNz[i]; }
146 Short_t GetNrphi(Int_t i) const { return fNrphi[i]; }
147 Float_t GetProcent() const { return fProcent; }
148 Short_t GetDifference() const { return fDifference; }
149 Short_t GetNumberClusters() const { return fNumberClusters; }
150 Short_t GetNumberBinCharge() const { return fNumberBinCharge; }
151 Short_t GetNumberBinPRF() const { return fNumberBinPRF; }
77566f2a 152
153 // Write
8ec526a4 154 void SetWriteCoef(Int_t i) { fWriteCoef[i] = kTRUE; }
155 void SetWriteNameCoef(TString writeNameCoef) { fWriteNameCoef = writeNameCoef; }
156 void SetWrite(Int_t i) { fWrite[i] = kTRUE; }
157 void SetWriteName(TString writeName) { fWriteName = writeName; }
77566f2a 158
8ec526a4 159 Bool_t GetWriteCoef(Int_t i) const { return fWriteCoef[i]; }
160 TString GetWriteNameCoef() const { return fWriteNameCoef; }
161 Bool_t GetWrite(Int_t i) const { return fWrite[i]; }
162 TString GetWriteName() const { return fWriteName; }
77566f2a 163
164 // Fit
e5c60cc7 165 void SetFitPHOn() { fFitPHOn = kTRUE; }
8ec526a4 166 void SetPeriodeFitPH(Int_t periodeFitPH);
167 void SetBeginFitCharge(Float_t beginFitCharge);
168 void SetT0Shift(Float_t t0Shift);
169 void SetRangeFitPRF(Float_t rangeFitPRF);
e5c60cc7 170 void SetMeanChargeOn() { fMeanChargeOn = kTRUE; }
171 void SetAccCDB() { fAccCDB = kTRUE; }
172 void SetFitChargeBisOn() { fFitChargeBisOn = kTRUE; }
173 void SetMinEntries(Int_t minEntries) { fMinEntries = minEntries; }
8ec526a4 174
e5c60cc7 175 Bool_t GetFitPHOn() const { return fFitPHOn; }
176 Int_t GetPeriodeFitPH() const { return fFitPHPeriode; }
177 Float_t GetBeginFitCharge() const { return fBeginFitCharge; }
178 Float_t GetT0Shift() const { return fT0Shift; }
179 Float_t GetRangeFitPRF() const { return fRangeFitPRF; }
180 Bool_t GetMeanChargeOn() const { return fMeanChargeOn; }
181 Bool_t GetAccCDB() const { return fAccCDB; }
182 Bool_t GetFitChargeBisOn() const { return fFitChargeBisOn; }
183 Int_t GetMinEntries() const { return fMinEntries; }
184 Int_t GetNumberFit() const { return fNumberFit; }
185 Int_t GetNumberEnt() const { return fNumberEnt; }
186 Double_t GetStatisticMean() const { return fStatisticMean; }
8ec526a4 187
188 // Debug
e5c60cc7 189 void SetDebug(Short_t debug) { fDebug = debug; }
8ec526a4 190 void SetDet(Int_t iPlane, Int_t iChamb, Int_t iSect) { fDet[0] = iPlane;
191 fDet[1] = iChamb;
e5c60cc7 192 fDet[2] = iSect; }
193 void SetFitVoir(Int_t fitVoir) { fFitVoir = fitVoir; }
8ec526a4 194
e5c60cc7 195 Short_t GetDebug() const { return fDebug; }
196 Int_t GetDet(Int_t i) const { return fDet[i]; }
197 Int_t GetFitVoir() const { return fFitVoir; }
8ec526a4 198
199 //
200 // Internal variables to be sure!
201 //
77566f2a 202
203 // Pad calibration
e5c60cc7 204 Short_t GetNnz(Int_t i) const { return fNnZ[i]; }
205 Short_t GetNnrphi(Int_t i) const { return fNnRphi[i]; }
206 Short_t GetNfragz(Int_t i) const { return fNfragZ[i]; }
207 Short_t GetNfragrphi(Int_t i) const { return fNfragRphi[i]; }
208 Short_t GetDetChamb0(Int_t i) const { return fDetChamb0[i]; }
209 Short_t GetDetChamb2(Int_t i) const { return fDetChamb2[i]; }
8ec526a4 210
211 void SetRebin(Short_t rebin);
e5c60cc7 212 Short_t GetRebin() const { return fRebin; }
8ec526a4 213
214 // Getter for the coefficient trees
e5c60cc7 215 TTree *GetPRF() const { return fPRF; }
216 TTree *GetGain() const { return fGain; }
217 TTree *GetT0() const { return fT0; }
218 TTree *GetVdrift() const { return fVdrift; }
8ec526a4 219
220 private:
221
222 static Double_t PH(Double_t *x, Double_t *par);
223 static Double_t AsymmGauss(Double_t *x, Double_t *par);
224 static Double_t FuncLandauGaus(Double_t *x, Double_t *par);
225 static Double_t LanGauFun(Double_t *x, Double_t *par);
226 TF1 *LanGauFit(TH1 *his, Double_t *fitrange, Double_t *startvalues
227 , Double_t *parlimitslo, Double_t *parlimitshi, Double_t *fitparams
228 , Double_t *fiterrors, Double_t *chiSqr, Int_t *ndf);
229 Int_t LanGauPro(Double_t *params, Double_t &maxx, Double_t &fwhm);
77566f2a 230
8ec526a4 231 // This is a singleton, contructor is private!
232 AliTRDCalibra();
233 virtual ~AliTRDCalibra();
77566f2a 234
8ec526a4 235 protected:
77566f2a 236
77566f2a 237 // Choice to fill or not the 2D
8ec526a4 238 Bool_t fMITracking; // Chose to fill the 2D histos or vectors during the offline MI tracking
239 Bool_t fMcmTracking; // Chose to fill the 2D histos or vectors during the tracking with tracklets
240 Bool_t fMcmCorrectAngle; // Apply correction due to the mcmtrackletangle in the z direction (only) assuming from vertex
241 Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration
242 Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0
243 Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration
244 Bool_t fHisto2d; // Chose to fill the 2D histos
245 Bool_t fVector2d; // Chose to fill vectors
77566f2a 246
247 // How to fill the 2D
8ec526a4 248 Float_t fRelativeScale; // Scale of the deposited charge
249 Int_t fCountRelativeScale; // fCountRelativeScale first data used for the scaling
250 Bool_t fRelativeScaleAuto; // Scaling with the first fCountRelativeScale objects
251 Int_t fThresholdDigit; // Threshold on RawData
252 Float_t fThresholdClusterPRF1; // Threshold on cluster pad signals for PRF peripherique
253 Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals for PRF peripherique
254 Bool_t fCenterOfflineCluster; // Choose to use the offline determination of the center of the cluster
255 Bool_t fTraMaxPad; // Take the Max Pad for the gain calibration and PH
256 Short_t fNz[3]; // Mode of calibration
257 Short_t fNrphi[3]; // Mode of calibration
258 Int_t fNtotal[3]; // Total number of Xbins
77566f2a 259
77566f2a 260 // Write
8ec526a4 261 Bool_t fWriteCoef[3]; // Do you want to write the result in a file?
262 TString fWriteNameCoef; // Where the coef Det are written
263 Bool_t fWrite[3]; // Do you want to write the 2D histo or vectors converted in a tree
264 TString fWriteName; // Where the 2D or trees are written
77566f2a 265
266 // Fit
8ec526a4 267 Bool_t fFitPHOn; // The fit PH On
268 Int_t fFitPHPeriode; // Periode of the fit PH
269 Float_t fBeginFitCharge; // The fit begins at mean/fBeginFitCharge for the gain calibration
270 Float_t fRangeFitPRF; // The fit range for the PRF is -fRangeFitPRF +fRangeFitPRF
271 Bool_t fMeanChargeOn; // Mean Charge on
272 Bool_t fFitChargeBisOn; // For an other fit function (convolution and not sum, more time consuming)
273 Float_t fT0Shift; // T0 Shift with the actual method
274 Bool_t fAccCDB; // If there is a calibration database to be compared with....
275 Int_t fNumberFit; // To know how many pad groups have been fitted
e5c60cc7 276 Int_t fNumberEnt; // To know how many pad groups have entries in the histo
8ec526a4 277 Double_t fStatisticMean; // To know the mean statistic of the histos
278
77566f2a 279 // Debug Mode
8ec526a4 280 Short_t fDebug; // For debugging 0 rien, 1 errors, 2 one fit alone, 3 one detector, 4 one detector with errors
281 Int_t fDet[3]; // Detector visualised (plane,chamb,sect) si debugging == 3 or 4
282 Int_t fFitVoir; // Fit visualised si debugging == 2
77566f2a 283
8ec526a4 284 //
285 // Internal variables
286 //
287
77566f2a 288 // Storage of coef
8ec526a4 289 TTree *fPRF; // Tree of the sigma of PRD
290 TTree *fGain; // Tree of the gain factor
291 TTree *fT0; // Tree of the time0
292 TTree *fVdrift; // Tree of the drift velocity
77566f2a 293
294 // "Pointer" of the branch of the tree
8ec526a4 295 Int_t fVdriftDetector; // Branch of Vdrift
296 Float_t *fVdriftPad; // Branch of Vdrift
297 Int_t fT0Detector; // Branch of t0
298 Float_t *fT0Pad; // Branch of t0
299 Int_t fPRFDetector; // Branch of PRF
300 Float_t *fPRFPad; // Branch of PRF
301 Float_t *fCoefCH; // Branch relative gain
77566f2a 302
303 // Fill the 2D histos in the offline tracking
8ec526a4 304 Bool_t fDetectorAliTRDtrack; // Change of track
305 Int_t fChamberAliTRDtrack; // Change of chamber
306 Int_t fDetectorPreviousTrack; // Change of detector
307 Bool_t fGoodTrack; // If goes through a kaputt pad
308 Float_t *fAmpTotal; // Energy deposited in the calibration group by the track
309 Short_t *fPHPlace; // Calibration group of PH
310 Float_t *fPHValue; // PH
311 Short_t fNumberClusters; // Minimum number of clusters in the tracklets
312 Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
313 Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
314 Int_t fNumberTrack; // How many tracks could be used (Debug for the moment)
315 Int_t fNumberUsedCh[2]; // How many tracks have been really used for the gain (0, strict; 1 with fProcent)
316 Int_t fNumberUsedPh[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fDifference)
317
318 //
77566f2a 319 // For debugging
8ec526a4 320 //
77566f2a 321
322 // Histograms to store the coef
8ec526a4 323 TH1F *fCoefCharge[4]; // Replica des 2D but in coefs resulting from the fit for the gain
324 TH1F *fCoefVdrift[3]; // Replica des 2D but in coefs resulting from the fit for the drift velocity
325 TH1F *fCoefPRF[2]; // Replica des 2D but in coefs resulting from the fit for the pad response function
326 TH1F *fCoefT0[3]; // Replica des 2D but in coefs resulting from the fit for time 0
327 TH1F *fDeltaCharge[3]; // Replica des 2D but in errors for each detector resulting from the fit for the gain
328 TH1F *fDeltaVdrift[2]; // Replica des 2D but in errors for each detector resulting from the fit for the drift velocity
329 TH1F *fDeltaT0[2]; // Replica des 2D but in errors for each detector resulting from the fit for time 0
330 TH1F *fDeltaPRF; // Replica des 2D but in errors for each detector resulting from the fit for the pad response function
331 TH1I *fErrorCharge[3]; // Replica des 2D but in errors resulting from the fit for the gain
332 TH1I *fErrorVdrift[2]; // Replica des 2D but in errors resulting from the fit for the drift velocity
333 TH1I *fErrorT0[2]; // Replica des 2D but in errors resulting from the fit for time 0
334 TH1I *fErrorPRF; // Replica des 2D but in errors resulting from the fit for the pad response function
335 TH2F *fCoefChargeDB[3]; // Visualisation of the coef of the detecteur fDet for the gain
336 TH2F *fCoefVdriftDB[2]; // Visualisation of the coef of the detecteur fDet for the drift velocity
337 TH2F *fCoefT0DB[2]; // Visualisation of the coef of the detecteur fDet for time 0
338 TH2F *fCoefPRFDB; // Visualisation of the coef of the detecteur fDet for the pad response function
77566f2a 339
340 // Variables in the loop for the coef or more general
8ec526a4 341 Float_t fChargeCoef[4]; // 3 database value, 0 fit, 1 mean, 2 fit time consuming
342 Float_t fVdriftCoef[3]; // 2 database value, 1 slope method, 0 fit
343 Float_t fPRFCoef[2]; // 1 database, 0 fit
344 Float_t fT0Coef[3]; // 3 database, 1 slope method, 0 fit
345 Float_t fPhd[3]; // Begin AR and DR
346 Int_t fTimeMax; // Number of time bins
347 Float_t fSf; // Sampling frequence
348 Int_t fDect1[3]; // First calibration group that will be called to be maybe fitted
349 Int_t fDect2[3]; // Last calibration group that will be called to be maybe fitted
350 Double_t fScaleFitFactor; // Scale factor of the fit results for the gain
351 Int_t fMinEntries; // Min Entries to fit the histo
352 Int_t fEntriesCurrent; // Entries in the current histo
353 Int_t fCountDet[3]; // Current detector
354 Int_t fCount[3]; // When the next detector comes
355 Float_t fL3P0; // Parameter to be pass from the default fit of CH histo to the optional one
356 Float_t fL3P2; // Parameter to be pass from the default fit of CH histo to the optional one
357 Float_t fG3P2; // Parameter to be pass from the default fit of CH histo to the optional one
77566f2a 358
77566f2a 359 // Pad Calibration
8ec526a4 360 Short_t fNnZ[3]; // Number of pad rows in a group
361 Short_t fNnRphi[3]; // Number of pad cols in a group
362 Short_t fNfragZ[3]; // Number of pad row group
363 Short_t fNfragRphi[3]; // Number of pad col group
364 Short_t fRowMin[3]; // Limits of the group in pad row
365 Short_t fRowMax[3]; // Limits of the group in pad row
366 Short_t fColMin[3]; // Limits of the group in pad col
367 Short_t fColMax[3]; // Limits of the group in pad col
368 Int_t fXbins[3]; // First Xbins of the detector
369 Short_t fDetChamb0[3]; // Number of XBins for chamber != 2
370 Short_t fDetChamb2[3]; // Number of Xbins fir chamber 2
77566f2a 371
372 // Methode Alexandru store info
8ec526a4 373 class AliTRDPlace : public TObject {
77566f2a 374
8ec526a4 375 public:
376
377 AliTRDPlace()
378 :TObject()
379 ,fPlace(0x0) { }
380 AliTRDPlace(const AliTRDPlace &i)
381 :TObject(i)
382 ,fPlace(0x0) { }
383 AliTRDPlace &operator=(const AliTRDPlace&) { return *this; }
384 virtual ~AliTRDPlace() { }
385
386 void SetPlace(Int_t place) { fPlace = place; }
387 Int_t GetPlace() const { return fPlace; }
388
389 protected:
390
391 Int_t fPlace; // Place of the calibration group
77566f2a 392
8ec526a4 393 };
394
395 class AliTRDCTInfo : public TObject {
77566f2a 396
8ec526a4 397 public:
398
399 AliTRDCTInfo()
400 :TObject()
401 ,fEntries(0x0) { }
402 AliTRDCTInfo(const AliTRDCTInfo &i)
403 :TObject(i)
404 ,fEntries(0x0) { }
405 AliTRDCTInfo &operator=(const AliTRDCTInfo&) { return *this; }
406 virtual ~AliTRDCTInfo() { }
407
408 void SetEntries(UShort_t *entries) { fEntries = entries; }
77566f2a 409
8ec526a4 410 UShort_t *GetEntries() const { return fEntries; }
411
412 protected:
413
414 UShort_t *fEntries; // Current number of entries for each bin of CH
77566f2a 415
416 };
417
8ec526a4 418 class AliTRDFitCHInfo : public TObject {
77566f2a 419
8ec526a4 420 public:
421
422 AliTRDFitCHInfo()
423 :TObject()
424 ,fCoef(0x0)
425 ,fDetector(-1) { }
426 AliTRDFitCHInfo(const AliTRDFitCHInfo &i)
427 :TObject(i)
428 ,fCoef(0x0)
429 ,fDetector(-1) { }
430 AliTRDFitCHInfo &operator=(const AliTRDFitCHInfo&) { return *this; }
431 virtual ~AliTRDFitCHInfo() { }
432
433 void SetCoef(Float_t *coef) { fCoef = coef; }
434 void SetDetector(Int_t detector) { fDetector = detector; }
77566f2a 435
8ec526a4 436 Float_t *GetCoef() const { return fCoef; }
437 Int_t GetDetector() const { return fDetector; }
438
439 protected:
440
441 Float_t *fCoef; // Relative gain coefficient for each group of the detector
442 Int_t fDetector; // Detector number
77566f2a 443
444 };
445
8ec526a4 446 class AliTRDPInfo : public TObject {
77566f2a 447 public:
8ec526a4 448
449 AliTRDPInfo()
450 :TObject()
451 ,fSum(0x0)
452 ,fSumSquare(0x0)
453 ,fEntries(0x0) { }
454 AliTRDPInfo(const AliTRDPInfo &i)
455 :TObject(i)
456 ,fSum(0x0)
457 ,fSumSquare(0x0)
458 ,fEntries(0x0) { }
459 AliTRDPInfo &operator=(const AliTRDPInfo&) { return *this; }
460 virtual ~AliTRDPInfo() { }
461
462 void SetSum(Float_t *sum) { fSum = sum; }
463 void SetSumSquare(Float_t *sumSquare) { fSumSquare = sumSquare; }
464 void SetEntries(UShort_t *entries) { fEntries = entries; }
465
466 Float_t *GetSum() const { return fSum; }
467 Float_t *GetSumSquare() const { return fSumSquare; }
468 UShort_t *GetEntries() const { return fEntries; }
469
470 protected:
77566f2a 471
8ec526a4 472 Float_t *fSum; // Current mean for each bin of the average pulse height
473 Float_t *fSumSquare; // Current mean of square values for each bin of the average pulse height
474 UShort_t *fEntries; // Current number of entries for each bin of the average pulse height
77566f2a 475
476 };
8ec526a4 477
77566f2a 478 // PH
479 // fTimeMax will define the size of fcharge
8ec526a4 480 TObjArray *fVectorPH; // Vectors to fill
481 TObjArray *fPlaPH; // Vectors to fill
77566f2a 482 // CH
8ec526a4 483 Short_t fNumberBinCharge; // Number of bins for the gain factor
484 TObjArray *fVectorCH; // Vectors to fill
485 TObjArray *fPlaCH; // Vectors to fill
77566f2a 486 // FitCH
8ec526a4 487 TObjArray *fVectorFitCH; // Vectors to fit
77566f2a 488 // PRF
8ec526a4 489 Short_t fNumberBinPRF; // Number of bin for the PRF
490 TObjArray *fVectorPRF; // Vectors to fill
491 TObjArray *fPlaPRF; // Vectors to fill
77566f2a 492
77566f2a 493 // Histograms to store the info from the digits, from the tracklets or from the tracks
8ec526a4 494 TProfile2D *fPH2d; // 2D average pulse height
495 TProfile2D *fPRF2d; // 2D PRF
496 TH2I *fCH2d; // 2D deposited charge
497 Short_t fRebin; // If you want to rebin the histo for the gain calibration
77566f2a 498
8ec526a4 499 //
500 // A lot of internal functions......
501 //
77566f2a 502
503 // Init AliTRDCalibra
8ec526a4 504 void Init();
77566f2a 505
506 // Create the 2D histo to be filled Online
8ec526a4 507 void CreateCH2d(Int_t nn);
508 void CreatePH2d(Int_t nn);
509 void CreatePRF2d(Int_t nn);
510
511 // Fill the 2D
512 void FillTheInfoOfTheTrackPH();
513 void FillTheInfoOfTheTrackCH();
514 void ResetfVariables();
515 Bool_t LocalisationDetectorXbins(Int_t detector);
77566f2a 516
517 // Plot the 2D
8ec526a4 518 void PlotCH2d();
519 void PlotPH2d();
520 void PlotPRF2d();
77566f2a 521
8ec526a4 522 //
523 // Fit
524 //
77566f2a 525
77566f2a 526 // Create histos if fDebug == 1 or fDebug >=3
8ec526a4 527 void CreateFitHistoPHDB(Int_t rowMax, Int_t colMax);
528 void CreateFitHistoT0DB(Int_t rowMax, Int_t colMax);
529 void CreateFitHistoCHDB(Int_t rowMax, Int_t colMax);
530 void CreateFitHistoPRFDB(Int_t rowMax, Int_t colMax);
531 void CreateFitHistoCH(Int_t nbins, Double_t low, Double_t high);
532 void CreateFitHistoPH(Int_t nbins, Double_t low, Double_t high);
533 void CreateFitHistoT0(Int_t nbins, Double_t low, Double_t high);
534 void CreateFitHistoPRF(Int_t nbins, Double_t low, Double_t high);
77566f2a 535
536 // CHFit functions
8ec526a4 537 Bool_t FillVectorFitCH(Int_t countdet);
538 Bool_t InitFit(Int_t nbins, Double_t lowedge, Double_t upedge, Int_t i);
539 void InitfCountDetAndfCount(Int_t i);
540 void UpdatefCountDetAndfCount(Int_t idect, Int_t i);
541 void ReconstructFitRowMinRowMax(Int_t idect, Int_t i);
542 Bool_t NotEnoughStatistic(Int_t idect, Int_t i);
543 Bool_t FillInfosFit(Int_t idect, Int_t i);
544 Bool_t WriteFitInfos(Int_t i);
545 void NormierungCharge();
77566f2a 546
547 // Fill histos Errors from the delta histos
8ec526a4 548 void ErrorPH();
549 void ErrorT0();
550 void ErrorCH();
551 void ErrorPRF();
77566f2a 552
553 // Fill histos DB from the Coef histos
8ec526a4 554 void FillCoefChargeDB();
555 void FillCoefVdriftDB();
556 void FillCoefT0DB();
557 void FillCoefPRFDB();
77566f2a 558
77566f2a 559 // Plot histos CoefPRF Coef....
8ec526a4 560 void PlotPH();
561 void PlotT0();
562 void PlotCH();
563 void PlotPRF();
77566f2a 564
77566f2a 565 // Plot histos DB
8ec526a4 566 void PlotPHDB();
567 void PlotT0DB();
568 void PlotCHDB();
569 void PlotPRFDB();
77566f2a 570
571 // Write the Coef, delta and error histos
8ec526a4 572 void WritePH(TFile *fout);
573 void WriteT0(TFile *fout);
574 void WriteCH(TFile *fout);
575 void WritePRF(TFile *fout);
576
577 // Write the DB histos
578 void WritePHDB(TFile *fout);
579 void WriteT0DB(TFile *fout);
580 void WriteCHDB(TFile *fout);
581 void WritePRFDB(TFile *fout);
582
77566f2a 583 // Calculate the mean coefs from the database
8ec526a4 584 Bool_t CalculVdriftCoefMean(Int_t fect, Int_t idect);
585 Bool_t CalculChargeCoefMean(Int_t fect, Int_t idect, Bool_t vrai);
586 Bool_t CalculPRFCoefMean(Int_t fect, Int_t idect);
587 Bool_t CalculT0CoefMean(Int_t fect, Int_t idect);
588 Float_t GetPRFDefault(Int_t plane) const;
77566f2a 589
8ec526a4 590 // Pad group calibration mode
591 void ReconstructionRowPadGroup(Int_t idect, Int_t i);
592 void CalculXBins(Int_t idect, Int_t i);
77566f2a 593
594 // Convertion vector, tree, histos....
8ec526a4 595 Int_t SearchInVector(Int_t group, Int_t i) const;
596 Int_t SearchInTreeVector (TObjArray *vectorplace, Int_t group) const;
597 Int_t SearchBin (Float_t value, Int_t i) const;
598 Bool_t UpdateVectorCH(Int_t group, Float_t value);
599 Bool_t UpdateVectorPRF(Int_t group, Float_t x, Float_t y);
600 Bool_t UpdateVectorPH(Int_t group, Int_t time, Float_t value);
601 Bool_t UpdateVectorT0(Int_t group, Int_t time);
602 TGraphErrors *ConvertVectorPHisto(AliTRDPInfo *pInfo, const Char_t *name) const;
603 TH1F *ConvertVectorCTHisto(AliTRDCTInfo *cTInfo, const Char_t *name) const;
604 TTree *ConvertVectorCTTreeHisto(TObjArray *vVectorCT, TObjArray *pPlaCT, const Char_t *name, const Char_t *nametitle) const;
605 TTree *ConvertVectorPTreeHisto(TObjArray *vVectorP, TObjArray *pPlaP, const Char_t *name, const Char_t *nametitle) const;
606 TObjArray *ConvertTreeVector(TTree *tree) const ;
607 Bool_t MergeVectorCT(TObjArray *vVectorCT2, TObjArray *pPlaCT2);
608 Bool_t MergeVectorP(TObjArray *vVectorP2, TObjArray *pPlaP2, Int_t i);
77566f2a 609
77566f2a 610 // Fit methods
8ec526a4 611 void FitBisCH(TH1 *projch, Int_t idect);
612 void FitCH(TH1 *projch, Int_t idect);
613 void FitPH(TH1 *projPH, Int_t idect);
614 void FitPRF(TH1 *projPRF, Int_t idect);
615 void FitPente(TH1 *projPH, Int_t idect);
616 TH1I *ReBin(TH1I *hist) const;
617 TH1F *ReBin(TH1F *hist) const;
77566f2a 618
619 // Clear
8ec526a4 620 void ClearHistos();
621 void ClearTree();
77566f2a 622
623 // Some basic geometry function
8ec526a4 624 virtual Int_t GetPlane(Int_t d) const;
625 virtual Int_t GetChamber(Int_t d) const;
626 virtual Int_t GetSector(Int_t d) const;
77566f2a 627
628 // Init, Fill and Reset the variables to default value tree Gain, PRF, Vdrift and T0
8ec526a4 629 void InitTreePH();
630 void FillTreeVdrift(Int_t countdet);
631 void InitTreeT0();
632 void FillTreeT0(Int_t countdet);
633 void InitTreePRF();
634 void FillTreePRF(Int_t countdet);
635 void ConvertVectorFitCHTree();
636
637 // Instance of this class and so on
638 static AliTRDCalibra *fgInstance; // Instance
639 static Bool_t fgTerminated; // If terminated
640
77566f2a 641 ClassDef(AliTRDCalibra, 1) // TRD Calibration class
642
643};
644
645#endif
646
647