]>
Commit | Line | Data |
---|---|---|
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 | |
36dc3337 | 15 | # include <TObject.h> |
6bbdc11a | 16 | #endif |
17 | #ifndef ROOT_TVectorD | |
18 | # include <TVectorD.h> | |
36dc3337 | 19 | #endif |
55a288e5 | 20 | |
4c865c34 | 21 | class TString; |
55a288e5 | 22 | class TTree; |
23 | class TProfile2D; | |
24 | class TGraphErrors; | |
25 | class TObjArray; | |
26 | class TH1I; | |
27 | class TH1; | |
28 | class TH1F; | |
29 | class TH2I; | |
30 | class TH2F; | |
31 | class TF1; | |
3a0f6479 | 32 | class TTreeSRedirector; |
55a288e5 | 33 | |
daa7dc79 | 34 | |
55a288e5 | 35 | class AliLog; |
f162af62 | 36 | |
55a288e5 | 37 | class AliTRDCalibraMode; |
38 | class AliTRDCalibraVector; | |
3a0f6479 | 39 | class AliTRDCalibraVdriftLinearFit; |
a0bb5615 | 40 | class AliTRDCalibraExbAltFit; |
55a288e5 | 41 | class AliTRDCalDet; |
3a0f6479 | 42 | class AliTRDCalROC; |
f162af62 | 43 | class AliTRDgeometry; |
55a288e5 | 44 | |
45 | class AliTRDCalibraFit : public TObject { | |
46 | ||
47 | public: | |
48 | ||
49 | // Instance | |
50 | static AliTRDCalibraFit *Instance(); | |
51 | static void Terminate(); | |
52 | static void Destroy(); | |
64942b85 | 53 | void DestroyDebugStreamer(); |
55a288e5 | 54 | |
55 | AliTRDCalibraFit(const AliTRDCalibraFit &c); | |
56 | AliTRDCalibraFit &operator=(const AliTRDCalibraFit &) { return *this; } | |
57 | ||
840ec79d | 58 | // ExB calibration |
59 | void SetCalDetVdriftExB(AliTRDCalDet *calDetVdriftUsed,AliTRDCalDet *calDetExBUsed) {fCalDetVdriftUsed = calDetVdriftUsed; fCalDetExBUsed = calDetExBUsed;}; | |
55a288e5 | 60 | |
6aafa7ea | 61 | // Functions fit for CH |
62 | Bool_t AnalyseCH(const TH2I *ch); | |
63 | Bool_t AnalyseCH(AliTRDCalibraVector *calvect); | |
54f2ff1c | 64 | Double_t AnalyseCHAllTogether(const TH2I *ch); |
6aafa7ea | 65 | |
66 | // Functions fit for PH | |
67 | Bool_t AnalysePH(const TProfile2D *ph); | |
68 | Bool_t AnalysePH(AliTRDCalibraVector *calvect); | |
b88b6bcc | 69 | Double_t AnalysePHAllTogether(const TProfile2D *ph); |
6aafa7ea | 70 | |
71 | // Functions fit for PRF | |
72 | Bool_t AnalysePRF(const TProfile2D *prf); | |
73 | Bool_t AnalysePRF(AliTRDCalibraVector *calvect); | |
74 | ||
75 | Bool_t AnalysePRFMarianFit(const TProfile2D *prf); | |
76 | Bool_t AnalysePRFMarianFit(AliTRDCalibraVector *calvect); | |
77 | ||
78 | // Functions fit for vdrift/lorentzangle | |
79 | Bool_t AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *calivdli); | |
840ec79d | 80 | void AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLinearFit *calivdli, Double_t &vdriftoverall, Double_t &exboverall); |
a0bb5615 | 81 | Bool_t AnalyseExbAltFit(AliTRDCalibraExbAltFit *calivdli); |
6aafa7ea | 82 | |
83 | // Pad Calibration | |
4c865c34 | 84 | Bool_t SetModeCalibration(TString name, Int_t i); |
6aafa7ea | 85 | |
86 | //Reset Function | |
87 | void ResetVectorFit(); | |
88 | ||
89 | // Some functions | |
3b0c1edc | 90 | void CalculPolynomeLagrange2(const Double_t *x, const Double_t *y, Double_t &c0, Double_t &c1, Double_t &c2, Double_t &c3, Double_t &c4) const; |
91 | void CalculPolynomeLagrange3(const Double_t *x, const Double_t *y, Double_t &c0, Double_t &c1, Double_t &c2, Double_t &c3, Double_t &c4) const; | |
92 | void CalculPolynomeLagrange4(const Double_t *x, const Double_t *y, Double_t &c0, Double_t &c1, Double_t &c2, Double_t &c3, Double_t &c4) const; | |
6aafa7ea | 93 | |
94 | // Fill the database | |
95 | void RemoveOutliers(Int_t type, Bool_t perdetector = kFALSE); | |
96 | void RemoveOutliers2(Bool_t perdetector = kFALSE); | |
97 | void PutMeanValueOtherVectorFit(Int_t ofwhat = 1, Bool_t perdetector = kFALSE); | |
98 | void PutMeanValueOtherVectorFit2(Int_t ofwhat = 1, Bool_t perdetector = kFALSE); | |
99 | AliTRDCalDet *CreateDetObjectVdrift(const TObjArray *vectorFit, Bool_t perdetector = kFALSE); | |
100 | AliTRDCalDet *CreateDetObjectGain(const TObjArray *vectorFit, Bool_t meanOtherBefore=kTRUE, Double_t scaleFitFactor = 0.02431, Bool_t perdetector = kTRUE); | |
101 | AliTRDCalDet *CreateDetObjectT0(const TObjArray *vectorFit, Bool_t perdetector = kFALSE); | |
102 | AliTRDCalDet *CreateDetObjectLorentzAngle(const TObjArray *vectorFit); | |
a0bb5615 | 103 | AliTRDCalDet *CreateDetObjectExbAlt(const TObjArray *vectorFit); |
6aafa7ea | 104 | |
105 | TObject *CreatePadObjectGain(const TObjArray *vectorFit = 0, Double_t scaleFitFactor = 1.0, const AliTRDCalDet *detobject = 0); | |
106 | TObject *CreatePadObjectVdrift(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0); | |
107 | TObject *CreatePadObjectT0(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0); | |
108 | TObject *CreatePadObjectPRF(const TObjArray *vectorFit); | |
109 | ||
110 | // Outliers stats | |
111 | AliTRDCalDet *MakeOutliersStatDet(const TObjArray *vectorFit, const char *name, Double_t &mean); | |
112 | TObject *MakeOutliersStatPad(const TObjArray *vectorFit, const char *name, Double_t &mean); | |
413153cb | 113 | |
6aafa7ea | 114 | // |
115 | // Set or Get the variables | |
116 | // | |
117 | ||
118 | // Fit | |
119 | void ChooseMethod(Short_t method) { fMethod = method; } | |
120 | void SetBeginFitCharge(Float_t beginFitCharge); | |
595cfc12 | 121 | void SetFitOutliersChargeLow(Float_t fitOutliersChargeLow) { fOutliersFitChargeLow = fitOutliersChargeLow; } |
122 | void SetFitOutliersChargeHigh(Float_t fitOutliersChargeHigh) { fOutliersFitChargeHigh = fitOutliersChargeHigh; } | |
6aafa7ea | 123 | void SetPeriodeFitPH(Int_t periodeFitPH); |
124 | void SetTakeTheMaxPH() { fTakeTheMaxPH = kTRUE; } | |
125 | void SetT0Shift0(Float_t t0Shift0); | |
126 | void SetT0Shift1(Float_t t0Shift1); | |
127 | void SetRangeFitPRF(Float_t rangeFitPRF); | |
128 | void SetAccCDB() { fAccCDB = kTRUE; } | |
129 | void SetMinEntries(Int_t minEntries); | |
130 | void SetRebin(Short_t rebin); | |
131 | ||
132 | Int_t GetPeriodeFitPH() const { return fFitPHPeriode; } | |
595cfc12 | 133 | Float_t GetFitOutliersChargeLow() const { return fOutliersFitChargeLow; } |
134 | Float_t GetFitOutliersChargeHigh() const { return fOutliersFitChargeHigh; } | |
6aafa7ea | 135 | Bool_t GetTakeTheMaxPH() const { return fTakeTheMaxPH; } |
136 | Float_t GetT0Shift0() const { return fT0Shift0; } | |
137 | Float_t GetT0Shift1() const { return fT0Shift1; } | |
138 | Float_t GetRangeFitPRF() const { return fRangeFitPRF; } | |
139 | Bool_t GetAccCDB() const { return fAccCDB; } | |
140 | Int_t GetMinEntries() const { return fMinEntries; } | |
141 | Short_t GetRebin() const { return fRebin; } | |
54f2ff1c | 142 | Float_t GetScaleFactorGain() const { return fScaleGain; } |
6aafa7ea | 143 | |
144 | // Statistics | |
145 | Int_t GetNumberFit() const { return fNumberFit; } | |
146 | Int_t GetNumberFitSuccess() const { return fNumberFitSuccess; } | |
147 | Int_t GetNumberEnt() const { return fNumberEnt; } | |
148 | Double_t GetStatisticMean() const { return fStatisticMean; } | |
149 | ||
413153cb | 150 | |
6aafa7ea | 151 | // Debug |
152 | void SetDebugLevel(Short_t level) { fDebugLevel = level; } | |
153 | void SetDet(Int_t iLayer, Int_t iStack, Int_t iSector) { fDet[0] = iLayer; | |
053767a4 | 154 | fDet[1] = iStack; |
155 | fDet[2] = iSector; } | |
413153cb | 156 | void SetFitVoir(Int_t fitVoir) { fFitVoir = fitVoir; } |
157 | // Magnetic field | |
158 | void SetMagneticField(Float_t magneticfield) { fMagneticField = magneticfield; } | |
159 | ||
160 | // Get the scale factor | |
053767a4 | 161 | Double_t GetScaleFitFactor() const { return fScaleFitFactor; } |
413153cb | 162 | |
163 | // Vector Fit getter | |
164 | TObjArray GetVectorFit() const { return fVectorFit; } | |
165 | TObjArray GetVectorFit2() const { return fVectorFit2; } | |
166 | ||
167 | // AliTRDCalibraMode | |
979b168f | 168 | AliTRDCalibraMode *GetCalibraMode() const { return fCalibraMode; } |
413153cb | 169 | |
e526983e | 170 | class AliTRDFitInfo : public TObject { |
171 | ||
172 | public: | |
173 | ||
174 | AliTRDFitInfo() | |
175 | :TObject() | |
176 | ,fCoef(0x0) | |
177 | ,fDetector(-1) { } | |
178 | AliTRDFitInfo(const AliTRDFitInfo &i) | |
179 | :TObject(i) | |
180 | ,fCoef(0x0) | |
181 | ,fDetector(-1) { } | |
182 | AliTRDFitInfo &operator=(const AliTRDFitInfo&) { return *this; } | |
183 | virtual ~AliTRDFitInfo() { if(fCoef) { delete [] fCoef;} } | |
184 | ||
daa7dc79 | 185 | void SetCoef(Float_t *coef) { fCoef = coef; } |
e526983e | 186 | void SetDetector(Int_t detector) { fDetector = detector; } |
187 | ||
188 | Float_t *GetCoef() const { return fCoef; } | |
189 | Int_t GetDetector() const { return fDetector; } | |
190 | ||
191 | protected: | |
192 | ||
193 | Float_t *fCoef; // Relative coefficient for each group of the detector | |
194 | Int_t fDetector; // Detector number | |
195 | ||
196 | }; | |
197 | ||
6aafa7ea | 198 | // Fit function |
199 | void FitLagrangePoly(TH1* projPH); | |
e526983e | 200 | |
55a288e5 | 201 | protected: |
413153cb | 202 | |
203 | // Geometry | |
64942b85 | 204 | AliTRDgeometry *fGeo; //! The TRD geometry |
413153cb | 205 | |
206 | ||
207 | Int_t fNumberOfBinsExpected; // Number of bins expected | |
208 | ||
209 | // Fit | |
210 | Short_t fMethod; // Method | |
211 | Float_t fBeginFitCharge; // The fit begins at mean/fBeginFitCharge for the gain calibration | |
595cfc12 | 212 | Float_t fOutliersFitChargeLow; // The fit ends at fOutliersFitCharge procent number of entries |
213 | Float_t fOutliersFitChargeHigh; // The fit ends at fOutliersFitCharge procent number of entries | |
413153cb | 214 | Int_t fFitPHPeriode; // Periode of the fit PH |
215 | Bool_t fTakeTheMaxPH; // Take the Max for the T0 determination | |
216 | Float_t fT0Shift0; // T0 Shift with the maximum positive slope | |
217 | Float_t fT0Shift1; // T0 Shift with the maximum of the amplification region | |
218 | Float_t fRangeFitPRF; // The fit range for the PRF is -fRangeFitPRF +fRangeFitPRF | |
219 | Bool_t fAccCDB; // If there is a calibration database to be compared with.... | |
220 | Int_t fMinEntries; // Min Entries to fit the histo | |
221 | Short_t fRebin; // If you want to rebin the histo for the gain calibration | |
54f2ff1c | 222 | Float_t fScaleGain; // Scale Factor used to scale the gain |
413153cb | 223 | |
224 | // Statistics | |
225 | Int_t fNumberFit; // To know how many pad groups have been fitted | |
226 | Int_t fNumberFitSuccess; // To know how many pad groups have been fitted successfully | |
227 | Int_t fNumberEnt; // To know how many pad groups have entries in the histo | |
228 | Double_t fStatisticMean; // To know the mean statistic of the histos | |
229 | ||
230 | ||
231 | // Debug Modes | |
232 | TTreeSRedirector *fDebugStreamer; //!Debug streamer | |
233 | Short_t fDebugLevel; // Flag for debugging | |
053767a4 | 234 | Int_t fDet[3]; // Detector visualised (layer,stack,sector) si debugging == 3 or 4 |
413153cb | 235 | Int_t fFitVoir; // Fit visualised si debugging == 2 |
236 | ||
237 | // Magnetic field lorentz angle | |
238 | Float_t fMagneticField; // Magnetic field lorentz angle | |
239 | ||
240 | // Calibra objects | |
241 | ||
242 | AliTRDCalibraMode *fCalibraMode; // The calibration mode | |
243 | ||
244 | // Current values of the coefficients found and ect... | |
245 | Float_t fCurrentCoef[2]; // Current coefs | |
246 | Float_t fCurrentCoefE; // Current coefs error | |
247 | Float_t fCurrentCoef2[2]; // Current coefs | |
248 | Float_t fCurrentCoefE2; // Current coefs error | |
249 | Float_t fPhd[3]; // Begin AR and DR | |
250 | Int_t fDect1; // First calibration group that will be called to be maybe fitted | |
251 | Int_t fDect2; // Last calibration group that will be called to be maybe fitted | |
252 | Double_t fScaleFitFactor; // Scale factor of the fit results for the gain | |
253 | Int_t fEntriesCurrent; // Entries in the current histo | |
64942b85 | 254 | Int_t fCountDet; // Current detector (or first in the group) |
413153cb | 255 | Int_t fCount; // When the next detector comes |
64942b85 | 256 | Int_t fNbDet; // Number of detector in the group |
413153cb | 257 | |
258 | // Current calib object | |
259 | AliTRDCalDet *fCalDet; // Current calib object | |
260 | AliTRDCalROC *fCalROC; // Current calib object | |
261 | AliTRDCalDet *fCalDet2; // Current calib object | |
262 | AliTRDCalROC *fCalROC2; // Current calib object | |
840ec79d | 263 | |
264 | AliTRDCalDet *fCalDetVdriftUsed; // ExB calibration | |
265 | AliTRDCalDet *fCalDetExBUsed; // ExB calibration | |
413153cb | 266 | |
267 | // Current values detector | |
268 | ||
269 | Float_t *fCurrentCoefDetector; // Current values for the detector | |
270 | Float_t *fCurrentCoefDetector2; // Current values for the detector | |
271 | ||
413153cb | 272 | TObjArray fVectorFit; // Vectors to fit |
273 | TObjArray fVectorFit2; // Vectors to fit | |
274 | ||
275 | // | |
276 | // A lot of internal functions...... | |
277 | // | |
278 | ||
279 | // Init AliTRDCalibraFit | |
280 | Bool_t InitFit(Int_t nbins, Int_t i); | |
281 | Bool_t InitFitCH(); | |
282 | Bool_t InitFitPH(); | |
283 | Bool_t InitFitPRF(); | |
284 | Bool_t InitFitLinearFitter(); | |
a0bb5615 | 285 | Bool_t InitFitExbAlt(); |
413153cb | 286 | |
287 | // Not enough Statistics | |
288 | Bool_t NotEnoughStatisticCH(Int_t idect); | |
64942b85 | 289 | Bool_t NotEnoughStatisticPH(Int_t idect,Double_t nentries); |
413153cb | 290 | Bool_t NotEnoughStatisticPRF(Int_t idect); |
291 | Bool_t NotEnoughStatisticLinearFitter(); | |
a0bb5615 | 292 | Bool_t NotEnoughStatisticExbAlt(); |
413153cb | 293 | |
294 | // Fill Infos Fit | |
295 | Bool_t FillInfosFitCH(Int_t idect); | |
64942b85 | 296 | Bool_t FillInfosFitPH(Int_t idect,Double_t nentries); |
413153cb | 297 | Bool_t FillInfosFitPRF(Int_t idect); |
298 | Bool_t FillInfosFitLinearFitter(); | |
a0bb5615 | 299 | Bool_t FillInfosFitExbAlt(); |
413153cb | 300 | |
301 | void FillFillCH(Int_t idect); | |
64942b85 | 302 | void FillFillPH(Int_t idect,Double_t nentries); |
413153cb | 303 | void FillFillPRF(Int_t idect); |
304 | void FillFillLinearFitter(); | |
a0bb5615 | 305 | void FillFillExbAlt(); |
413153cb | 306 | |
307 | Bool_t FillVectorFit(); | |
308 | Bool_t FillVectorFit2(); | |
309 | ||
310 | // Functions... | |
311 | void InitfCountDetAndfCount(Int_t i); | |
312 | void CalculNumberOfBinsExpected(Int_t i); | |
313 | void CalculDect1Dect2(Int_t i); | |
314 | void UpdatefCountDetAndfCount(Int_t idect, Int_t i); | |
315 | void ReconstructFitRowMinRowMax(Int_t idect, Int_t i); | |
316 | Bool_t CheckFitVoir(); | |
317 | void NormierungCharge(); | |
4c865c34 | 318 | Bool_t SetNrphiFromTObject(TString name, Int_t i); |
319 | Bool_t SetNzFromTObject(TString name, Int_t i); | |
320 | Int_t GetNumberOfGroupsPRF(TString nametitle); | |
413153cb | 321 | |
322 | // Calculate the mean coefs from the database | |
323 | Bool_t CalculVdriftCoefMean(); | |
324 | Bool_t CalculChargeCoefMean(Bool_t vrai); | |
325 | Bool_t CalculPRFCoefMean(); | |
326 | Bool_t CalculT0CoefMean(); | |
327 | Bool_t CalculVdriftLorentzCoef(); | |
053767a4 | 328 | Float_t GetPRFDefault(Int_t layer) const; |
413153cb | 329 | void SetCalROC(Int_t i); |
330 | ||
331 | // Fit methods | |
595cfc12 | 332 | void FitBisCHEx(TH1 *projch, Double_t mean, Double_t nentries); |
333 | void FitBisCH(TH1 *projch, Double_t mean, Double_t nentries); | |
334 | void FitCH(TH1 *projch, Double_t mean, Double_t nentries); | |
335 | void FitLandau(TH1 *projch, Double_t mean, Double_t nentries); | |
413153cb | 336 | void FitMeanW(TH1 *projch, Double_t nentries); |
337 | void FitMeanWSm(TH1 *projch, Float_t sumAll); | |
338 | void FitMean(TH1 *projch, Double_t nentries, Double_t mean); | |
339 | void FitPH(TH1 *projPH, Int_t idect); | |
340 | void FitPRF(TH1 *projPRF); | |
341 | void RmsPRF(TH1 *projPRF); | |
342 | Bool_t FitPRFGausMI(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nBins,Float_t xMin,Float_t xMax); | |
343 | 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); | |
344 | void FitPente(TH1 *projPH); | |
413153cb | 345 | void FitTnpRange(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nbg,Int_t nybins); |
979b168f | 346 | TH1I *ReBin(const TH1I *hist) const; |
347 | TH1F *ReBin(const TH1F *hist) const; | |
413153cb | 348 | |
349 | // Some basic geometry function | |
053767a4 | 350 | virtual Int_t GetLayer(Int_t d) const; |
351 | virtual Int_t GetStack(Int_t d) const; | |
413153cb | 352 | virtual Int_t GetSector(Int_t d) const; |
353 | ||
354 | // Instance of this class and so on | |
355 | static AliTRDCalibraFit *fgInstance; // Instance | |
356 | static Bool_t fgTerminated; // If terminated | |
357 | ||
358 | ||
359 | private: | |
360 | ||
979b168f | 361 | static Double_t PH(const Double_t *x, const Double_t *par); |
362 | static Double_t AsymmGauss(const Double_t *x, const Double_t *par); | |
363 | static Double_t FuncLandauGaus(const Double_t *x, const Double_t *par); | |
364 | static Double_t LanGauFun(const Double_t *x, const Double_t *par); | |
595cfc12 | 365 | static Double_t LanGauFunEx(const Double_t *x, const Double_t *par); |
979b168f | 366 | TF1 *LanGauFit(TH1 *his, const Double_t *fitrange, const Double_t *startvalues |
367 | , const Double_t *parlimitslo, const Double_t *parlimitshi, Double_t *fitparams | |
413153cb | 368 | , Double_t *fiterrors, Double_t *chiSqr, Int_t *ndf) const; |
595cfc12 | 369 | TF1 *LanGauFitEx(TH1 *his, const Double_t *fitrange, const Double_t *startvalues |
370 | , const Double_t *parlimitslo, const Double_t *parlimitshi | |
371 | , Double_t *fitparams, Double_t *fiterrors | |
372 | , Double_t *chiSqr, Int_t *ndf) const; | |
373 | ||
413153cb | 374 | |
375 | // This is a singleton, contructor is private! | |
376 | AliTRDCalibraFit(); | |
377 | virtual ~AliTRDCalibraFit(); | |
378 | ||
379 | ||
54f2ff1c | 380 | ClassDef(AliTRDCalibraFit,3) // TRD Calibration class |
413153cb | 381 | |
55a288e5 | 382 | }; |
383 | ||
384 | #endif | |
4c865c34 | 385 | |
3b0c1edc | 386 | |
387 |