]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDCalibraFit.h
Corrected documentation fields
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFit.h
CommitLineData
55a288e5 1#ifndef ALITRDCALIBRAFIT_H
2#define ALITRDCALIBRAFIT_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
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;
3a0f6479 28class TTreeSRedirector;
55a288e5 29
30class AliLog;
f162af62 31
55a288e5 32class AliTRDCalibraMode;
33class AliTRDCalibraVector;
3a0f6479 34class AliTRDCalibraVdriftLinearFit;
55a288e5 35class AliTRDCalDet;
3a0f6479 36class AliTRDCalROC;
f162af62 37class AliTRDgeometry;
55a288e5 38
39class AliTRDCalibraFit : public TObject {
40
41 public:
42
43 // Instance
44 static AliTRDCalibraFit *Instance();
45 static void Terminate();
46 static void Destroy();
47
48 AliTRDCalibraFit(const AliTRDCalibraFit &c);
49 AliTRDCalibraFit &operator=(const AliTRDCalibraFit &) { return *this; }
50
3a0f6479 51 // Functions fit for CH
52 Bool_t AnalyseCH(TH2I *ch);
53 Bool_t AnalyseCH(AliTRDCalibraVector *calvect);
54
55 // Functions fit for PH
56 Bool_t AnalysePH(TProfile2D *ph);
57 Bool_t AnalysePH(AliTRDCalibraVector *calvect);
58
59 // Functions fit for PRF
60 Bool_t AnalysePRF(TProfile2D *prf);
61 Bool_t AnalysePRF(AliTRDCalibraVector *calvect);
62
63 Bool_t AnalysePRFMarianFit(TProfile2D *prf);
64 Bool_t AnalysePRFMarianFit(AliTRDCalibraVector *calvect);
65
66 // Functions fit for vdrift/lorentzangle
67 Bool_t AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *calivdli);
68
55a288e5 69 // Pad Calibration
3a0f6479 70 Bool_t SetModeCalibration(const char *name, Int_t i);
71
72 //Reset Function
73 void ResetVectorFit();
74
75 // Some functions
e6381f8e 76 Double_t *CalculPolynomeLagrange2(Double_t *x, Double_t *y) const;
77 Double_t *CalculPolynomeLagrange3(Double_t *x, Double_t *y) const;
78 Double_t *CalculPolynomeLagrange4(Double_t *x, Double_t *y) const;
55a288e5 79
80 // Fill the database
3a0f6479 81 AliTRDCalDet *CreateDetObjectVdrift(TObjArray *vectorFit, Bool_t perdetector = kFALSE);
82 AliTRDCalDet *CreateDetObjectGain(TObjArray *vectorFit, Double_t scaleFitFactor, Bool_t perdetector = kFALSE);
83 AliTRDCalDet *CreateDetObjectT0(TObjArray *vectorFit, Bool_t perdetector = kFALSE);
84 AliTRDCalDet *CreateDetObjectLorentzAngle(TObjArray *vectorFit);
85
86 TObject *CreatePadObjectGain(TObjArray *vectorFit = 0, Double_t scaleFitFactor = 1.0, AliTRDCalDet *detobject = 0);
87 TObject *CreatePadObjectVdrift(TObjArray *vectorFit = 0, AliTRDCalDet *detobject = 0);
88 TObject *CreatePadObjectT0(TObjArray *vectorFit = 0, AliTRDCalDet *detobject = 0);
89 TObject *CreatePadObjectPRF(TObjArray *vectorFit);
90
91 // Outliers stats
92 AliTRDCalDet *MakeOutliersStatDet(TObjArray *vectorFit, const char *name, Double_t &mean);
93 TObject *MakeOutliersStatPad(TObjArray *vectorFit, const char *name, Double_t &mean);
94
55a288e5 95
96 // Correct the error
97 TH1F *CorrectTheError(TGraphErrors *hist);
98
99 //
100 // Set or Get the variables
101 //
3a0f6479 102
55a288e5 103 // Fit
3a0f6479 104 void ChooseMethod(Short_t method) { fMethod = method; }
105 void SetBeginFitCharge(Float_t beginFitCharge);
106 void SetPeriodeFitPH(Int_t periodeFitPH);
55a288e5 107 void SetTakeTheMaxPH() { fTakeTheMaxPH = kTRUE; }
3a0f6479 108 void SetT0Shift(Float_t t0Shift);
55a288e5 109 void SetRangeFitPRF(Float_t rangeFitPRF);
3a0f6479 110 void SetAccCDB() { fAccCDB = kTRUE; }
111 void SetMinEntries(Int_t minEntries);
55a288e5 112 void SetRebin(Short_t rebin);
113
3a0f6479 114 Int_t GetPeriodeFitPH() const { return fFitPHPeriode; }
55a288e5 115 Bool_t GetTakeTheMaxPH() const { return fTakeTheMaxPH; }
3a0f6479 116 Float_t GetT0Shift() const { return fT0Shift; }
55a288e5 117 Float_t GetRangeFitPRF() const { return fRangeFitPRF; }
55a288e5 118 Bool_t GetAccCDB() const { return fAccCDB; }
119 Int_t GetMinEntries() const { return fMinEntries; }
120 Short_t GetRebin() const { return fRebin; }
121
122 // Statistics
123 Int_t GetNumberFit() const { return fNumberFit; }
124 Int_t GetNumberFitSuccess() const { return fNumberFitSuccess; }
125 Int_t GetNumberEnt() const { return fNumberEnt; }
126 Double_t GetStatisticMean() const { return fStatisticMean; }
127
128
129 // Debug
3a0f6479 130 void SetDebugLevel(Short_t level) { fDebugLevel = level; }
131 void SetDet(Int_t iPlane, Int_t iChamb, Int_t iSect) { fDet[0] = iPlane;
55a288e5 132 fDet[1] = iChamb;
133 fDet[2] = iSect; }
134 void SetFitVoir(Int_t fitVoir) { fFitVoir = fitVoir; }
3a0f6479 135 // Magnetic field
136 void SetMagneticField(Float_t magneticfield) { fMagneticField = magneticfield; }
55a288e5 137
3a0f6479 138 // Get the scale factor
139 Double_t GetScaleFitFactor() const { return fScaleFitFactor; }
55a288e5 140
3a0f6479 141 // Vector Fit getter
e6381f8e 142 TObjArray GetVectorFit() const { return fVectorFit; }
143 TObjArray GetVectorFit2() const { return fVectorFit2; }
3a0f6479 144
145 // AliTRDCalibraMode
146 AliTRDCalibraMode *GetCalibraMode() { return fCalibraMode; }
55a288e5 147
55a288e5 148 protected:
149
f162af62 150 // Geometry
151 AliTRDgeometry *fGeo; //! The TRD geometry
152
3a0f6479 153
154 Int_t fNumberOfBinsExpected; // Number of bins expected
155
156 // Fit
157 Short_t fMethod; // Method
158 Float_t fBeginFitCharge; // The fit begins at mean/fBeginFitCharge for the gain calibration
159 Int_t fFitPHPeriode; // Periode of the fit PH
160 Bool_t fTakeTheMaxPH; // Take the Max for the T0 determination
161 Float_t fT0Shift; // T0 Shift with the actual method
162 Float_t fRangeFitPRF; // The fit range for the PRF is -fRangeFitPRF +fRangeFitPRF
163 Bool_t fAccCDB; // If there is a calibration database to be compared with....
164 Int_t fMinEntries; // Min Entries to fit the histo
165 Short_t fRebin; // If you want to rebin the histo for the gain calibration
55a288e5 166
167 // Statistics
3a0f6479 168 Int_t fNumberFit; // To know how many pad groups have been fitted
169 Int_t fNumberFitSuccess; // To know how many pad groups have been fitted successfully
170 Int_t fNumberEnt; // To know how many pad groups have entries in the histo
171 Double_t fStatisticMean; // To know the mean statistic of the histos
55a288e5 172
55a288e5 173
3a0f6479 174 // Debug Modes
175 TTreeSRedirector *fDebugStreamer; //!Debug streamer
176 Short_t fDebugLevel; // Flag for debugging
177 Int_t fDet[3]; // Detector visualised (plane,chamb,sect) si debugging == 3 or 4
178 Int_t fFitVoir; // Fit visualised si debugging == 2
55a288e5 179
3a0f6479 180 // Magnetic field lorentz angle
181 Float_t fMagneticField; // Magnetic field lorentz angle
182
183 // Calibra objects
184
185 AliTRDCalibraMode *fCalibraMode; // The calibration mode
186
187 // Current values of the coefficients found and ect...
188 Float_t fCurrentCoef[2]; // Current coefs
189 Float_t fCurrentCoefE; // Current coefs error
190 Float_t fCurrentCoef2[2]; // Current coefs
191 Float_t fCurrentCoefE2; // Current coefs error
192 Float_t fPhd[3]; // Begin AR and DR
193 Int_t fDect1; // First calibration group that will be called to be maybe fitted
194 Int_t fDect2; // Last calibration group that will be called to be maybe fitted
55a288e5 195 Double_t fScaleFitFactor; // Scale factor of the fit results for the gain
196 Int_t fEntriesCurrent; // Entries in the current histo
3a0f6479 197 Int_t fCountDet; // Current detector
198 Int_t fCount; // When the next detector comes
199
200 // Current calib object
201 AliTRDCalDet *fCalDet; // Current calib object
202 AliTRDCalROC *fCalROC; // Current calib object
203 AliTRDCalDet *fCalDet2; // Current calib object
204 AliTRDCalROC *fCalROC2; // Current calib object
205
206 // Current values detector
55a288e5 207
3a0f6479 208 Float_t *fCurrentCoefDetector; // Current values for the detector
209 Float_t *fCurrentCoefDetector2; // Current values for the detector
55a288e5 210
3a0f6479 211 class AliTRDFitInfo : public TObject {
55a288e5 212
213 public:
214
3a0f6479 215 AliTRDFitInfo()
55a288e5 216 :TObject()
217 ,fCoef(0x0)
218 ,fDetector(-1) { }
3a0f6479 219 AliTRDFitInfo(const AliTRDFitInfo &i)
55a288e5 220 :TObject(i)
221 ,fCoef(0x0)
222 ,fDetector(-1) { }
3a0f6479 223 AliTRDFitInfo &operator=(const AliTRDFitInfo&) { return *this; }
224 virtual ~AliTRDFitInfo() { }
55a288e5 225
226 void SetCoef(Float_t *coef) { fCoef = coef; }
227 void SetDetector(Int_t detector) { fDetector = detector; }
228
229 Float_t *GetCoef() const { return fCoef; }
230 Int_t GetDetector() const { return fDetector; }
231
232 protected:
233
3a0f6479 234 Float_t *fCoef; // Relative coefficient for each group of the detector
55a288e5 235 Int_t fDetector; // Detector number
236
237 };
238
3a0f6479 239 TObjArray fVectorFit; // Vectors to fit
240 TObjArray fVectorFit2; // Vectors to fit
241
55a288e5 242 //
243 // A lot of internal functions......
244 //
245
246 // Init AliTRDCalibraFit
3a0f6479 247 Bool_t InitFit(Int_t nbins, Int_t i);
248 Bool_t InitFitCH();
249 Bool_t InitFitPH();
250 Bool_t InitFitPRF();
251 Bool_t InitFitLinearFitter();
252
253 // Not enough Statistics
254 Bool_t NotEnoughStatisticCH(Int_t idect);
255 Bool_t NotEnoughStatisticPH(Int_t idect);
256 Bool_t NotEnoughStatisticPRF(Int_t idect);
257 Bool_t NotEnoughStatisticLinearFitter();
258
259 // Fill Infos Fit
260 Bool_t FillInfosFitCH(Int_t idect);
261 Bool_t FillInfosFitPH(Int_t idect);
262 Bool_t FillInfosFitPRF(Int_t idect);
263 Bool_t FillInfosFitLinearFitter();
264
265 void FillFillCH(Int_t idect);
266 void FillFillPH(Int_t idect);
267 void FillFillPRF(Int_t idect);
268 void FillFillLinearFitter();
269
270 Bool_t FillVectorFit();
271 Bool_t FillVectorFit2();
272
273 // Functions...
55a288e5 274 void InitfCountDetAndfCount(Int_t i);
3a0f6479 275 void CalculNumberOfBinsExpected(Int_t i);
276 void CalculDect1Dect2(Int_t i);
55a288e5 277 void UpdatefCountDetAndfCount(Int_t idect, Int_t i);
278 void ReconstructFitRowMinRowMax(Int_t idect, Int_t i);
3a0f6479 279 Bool_t CheckFitVoir();
280 void NormierungCharge();
281 Bool_t SetNrphiFromTObject(const char *name, Int_t i);
282 Bool_t SetNzFromTObject(const char *name, Int_t i);
283 Int_t GetNumberOfGroupsPRF(const char* nametitle);
284
285 // Calculate the mean coefs from the database
286 Bool_t CalculVdriftCoefMean();
287 Bool_t CalculChargeCoefMean(Bool_t vrai);
288 Bool_t CalculPRFCoefMean();
289 Bool_t CalculT0CoefMean();
290 Bool_t CalculVdriftLorentzCoef();
55a288e5 291 Float_t GetPRFDefault(Int_t plane) const;
3a0f6479 292 void SetCalROC(Int_t i);
55a288e5 293
294 // Fit methods
3a0f6479 295 void FitBisCH(TH1 *projch, Double_t mean);
296 void FitCH(TH1 *projch, Double_t mean);
297 void FitMeanW(TH1 *projch, Double_t nentries);
298 void FitMeanWSm(TH1 *projch, Float_t sumAll);
299 void FitMean(TH1 *projch, Double_t nentries, Double_t mean);
55a288e5 300 void FitPH(TH1 *projPH, Int_t idect);
3a0f6479 301 void FitPRF(TH1 *projPRF);
302 void RmsPRF(TH1 *projPRF);
303 Bool_t FitPRFGausMI(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nBins,Float_t xMin,Float_t xMax);
304 Double_t FitGausMI(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nBins, Float_t xMin,Float_t xMax,TVectorD *param, Bool_t kError= kTRUE);
305 void FitPente(TH1 *projPH);
306 void FitLagrangePoly(TH1* projPH);
307 void FitTnpRange(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nbg,Int_t nybins);
55a288e5 308 TH1I *ReBin(TH1I *hist) const;
309 TH1F *ReBin(TH1F *hist) const;
55a288e5 310
3a0f6479 311// Some basic geometry function
55a288e5 312 virtual Int_t GetPlane(Int_t d) const;
313 virtual Int_t GetChamber(Int_t d) const;
314 virtual Int_t GetSector(Int_t d) const;
315
3a0f6479 316 // Instance of this class and so on
317 static AliTRDCalibraFit *fgInstance; // Instance
318 static Bool_t fgTerminated; // If terminated
319
e6381f8e 320
321 private:
322
323 static Double_t PH(Double_t *x, Double_t *par);
324 static Double_t AsymmGauss(Double_t *x, Double_t *par);
325 static Double_t FuncLandauGaus(Double_t *x, Double_t *par);
326 static Double_t LanGauFun(Double_t *x, Double_t *par);
327 TF1 *LanGauFit(TH1 *his, Double_t *fitrange, Double_t *startvalues
328 , Double_t *parlimitslo, Double_t *parlimitshi, Double_t *fitparams
329 , Double_t *fiterrors, Double_t *chiSqr, Int_t *ndf) const;
330 Int_t LanGauPro(Double_t *params, Double_t &maxx, Double_t &fwhm);
331 static Double_t GausConstant(Double_t *x, Double_t *par);
332
333 // This is a singleton, contructor is private!
334 AliTRDCalibraFit();
335 virtual ~AliTRDCalibraFit();
336
337
338
55a288e5 339
f162af62 340 ClassDef(AliTRDCalibraFit,2) // TRD Calibration class
55a288e5 341
342};
343
344#endif
345
346