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