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