]>
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 | |
15 | # include <TObject.h> | |
16 | #endif | |
17 | ||
18 | class TTree; | |
19 | class TProfile2D; | |
20 | class TGraphErrors; | |
21 | class TObjArray; | |
22 | class TH1I; | |
23 | class TH1; | |
24 | class TH1F; | |
25 | class TH2I; | |
26 | class TH2F; | |
27 | class TF1; | |
28 | ||
29 | class AliLog; | |
f162af62 | 30 | |
55a288e5 | 31 | class AliTRDCalibraMode; |
32 | class AliTRDCalibraVector; | |
33 | class AliTRDCalDet; | |
f162af62 | 34 | class AliTRDgeometry; |
55a288e5 | 35 | |
36 | class AliTRDCalibraFit : public TObject { | |
37 | ||
38 | public: | |
39 | ||
40 | // Instance | |
41 | static AliTRDCalibraFit *Instance(); | |
42 | static void Terminate(); | |
43 | static void Destroy(); | |
44 | ||
45 | AliTRDCalibraFit(const AliTRDCalibraFit &c); | |
46 | AliTRDCalibraFit &operator=(const AliTRDCalibraFit &) { return *this; } | |
47 | ||
48 | // Functions fit online | |
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); | |
58 | ||
59 | // Pad Calibration | |
60 | Bool_t SetModeCalibrationFromTObject(TObject *object, Int_t i); | |
61 | ||
62 | // Fill the database | |
63 | TObject *CreatePadObjectTree(TTree *tree); | |
64 | TObject *CreatePadObjectTree(TTree *tree, Int_t i, AliTRDCalDet *detobject); | |
65 | AliTRDCalDet *CreateDetObjectTree(TTree *tree, Int_t i); | |
66 | ||
67 | // Correct the error | |
68 | TH1F *CorrectTheError(TGraphErrors *hist); | |
69 | ||
70 | // | |
71 | // Set or Get the variables | |
72 | // | |
73 | ||
74 | // Write | |
75 | void SetWriteCoef(Int_t i) { fWriteCoef[i] = kTRUE; } | |
76 | void SetWriteNameCoef(TString writeNameCoef) { fWriteNameCoef = writeNameCoef; } | |
77 | ||
78 | Bool_t GetWriteCoef(Int_t i) const { return fWriteCoef[i]; } | |
79 | TString GetWriteNameCoef() const { return fWriteNameCoef; } | |
80 | ||
81 | // Fit | |
82 | void SetFitPHOn() { fFitPHOn = kTRUE; } | |
83 | void SetFitPol2On() { fFitPol2On = kTRUE; } | |
84 | void SetFitLagrPolOn() { fFitLagrPolOn = kTRUE; } | |
85 | void SetTakeTheMaxPH() { fTakeTheMaxPH = kTRUE; } | |
86 | void SetPeriodeFitPH(Int_t periodeFitPH); | |
87 | void SetFitPHNDB(Int_t fitPHNDB); | |
88 | void SetBeginFitCharge(Float_t beginFitCharge); | |
89 | void SetT0Shift(Float_t t0Shift); | |
90 | void SetRangeFitPRF(Float_t rangeFitPRF); | |
91 | void SetFitPRFOn() { fFitPRFOn = kTRUE; } | |
92 | void SetRMSPRFOn() { fRMSPRFOn = kTRUE; } | |
93 | void SetFitPRFNDB(Int_t fitPRFNDB); | |
94 | void SetMeanChargeOn() { fMeanChargeOn = kTRUE; } | |
95 | void SetFitChargeBisOn() { fFitChargeBisOn = kTRUE; } | |
96 | void SetFitChargeOn() { fFitChargeOn = kTRUE; } | |
97 | void SetFitMeanWOn() { fFitMeanWOn = kTRUE; } | |
98 | void SetFitChargeNDB(Int_t fitChargeNDB); | |
99 | void SetAccCDB() { fAccCDB = kTRUE; } | |
100 | void SetMinEntries(Int_t minEntries) { fMinEntries = minEntries; } | |
101 | void SetRebin(Short_t rebin); | |
102 | ||
103 | Bool_t GetFitPHOn() const { return fFitPHOn; } | |
104 | Bool_t GetFitPol2On() const { return fFitPol2On; } | |
105 | Bool_t GetFitLagrPolOn() const { return fFitLagrPolOn; } | |
106 | Bool_t GetTakeTheMaxPH() const { return fTakeTheMaxPH; } | |
107 | Int_t GetPeriodeFitPH() const { return fFitPHPeriode; } | |
108 | Int_t GetFitPHNDB() const { return fFitPHNDB; } | |
109 | Float_t GetBeginFitCharge() const { return fBeginFitCharge; } | |
110 | Float_t GetT0Shift() const { return fT0Shift; } | |
111 | Float_t GetRangeFitPRF() const { return fRangeFitPRF; } | |
112 | Bool_t GetFitPRFOn() const { return fFitPRFOn; } | |
113 | Bool_t GetRMSPRFOn() const { return fRMSPRFOn; } | |
114 | Int_t GetFitPRFNDB() const { return fFitPRFNDB; } | |
115 | Bool_t GetMeanChargeOn() const { return fMeanChargeOn; } | |
116 | Bool_t GetFitChargeBisOn() const { return fFitChargeBisOn; } | |
117 | Bool_t GetFitChargeOn() const { return fFitChargeOn; } | |
118 | Bool_t GetFitMeanWOn() const { return fFitMeanWOn; } | |
119 | Int_t GetFitChargeNDB() const { return fFitChargeNDB; } | |
120 | Bool_t GetAccCDB() const { return fAccCDB; } | |
121 | Int_t GetMinEntries() const { return fMinEntries; } | |
122 | Short_t GetRebin() const { return fRebin; } | |
123 | ||
124 | // Statistics | |
125 | Int_t GetNumberFit() const { return fNumberFit; } | |
126 | Int_t GetNumberFitSuccess() const { return fNumberFitSuccess; } | |
127 | Int_t GetNumberEnt() const { return fNumberEnt; } | |
128 | Double_t GetStatisticMean() const { return fStatisticMean; } | |
129 | ||
130 | ||
131 | // Debug | |
132 | void SetDebug(Short_t debug) { fDebug = debug; } | |
133 | void SetDet(Int_t iPlane, Int_t iChamb, Int_t iSect) { fDet[0] = iPlane; | |
134 | fDet[1] = iChamb; | |
135 | fDet[2] = iSect; } | |
136 | void SetFitVoir(Int_t fitVoir) { fFitVoir = fitVoir; } | |
137 | ||
138 | Short_t GetDebug() const { return fDebug; } | |
139 | Int_t GetDet(Int_t i) const { return fDet[i]; } | |
140 | Int_t GetFitVoir() const { return fFitVoir; } | |
141 | ||
142 | // calibration mode | |
143 | void SetCalibraMode(AliTRDCalibraMode *calibramode) { fCalibraMode = calibramode; } | |
144 | AliTRDCalibraMode *GetCalibraMode() const { return fCalibraMode; } | |
145 | ||
146 | ||
147 | // Getter for the coefficient trees | |
148 | TTree *GetPRF() const { return fPRF; } | |
149 | TTree *GetGain() const { return fGain; } | |
150 | TTree *GetT0() const { return fT0; } | |
151 | TTree *GetVdrift() const { return fVdrift; } | |
152 | ||
153 | // Vector method | |
154 | void SetCalibraVector(AliTRDCalibraVector *calibraVector) { fCalibraVector = calibraVector; } | |
155 | AliTRDCalibraVector *GetCalibraVector() const { return fCalibraVector; } | |
156 | ||
157 | ||
158 | private: | |
159 | ||
160 | static Double_t PH(Double_t *x, Double_t *par); | |
161 | static Double_t AsymmGauss(Double_t *x, Double_t *par); | |
162 | static Double_t FuncLandauGaus(Double_t *x, Double_t *par); | |
163 | static Double_t LanGauFun(Double_t *x, Double_t *par); | |
164 | TF1 *LanGauFit(TH1 *his, Double_t *fitrange, Double_t *startvalues | |
165 | , Double_t *parlimitslo, Double_t *parlimitshi, Double_t *fitparams | |
166 | , Double_t *fiterrors, Double_t *chiSqr, Int_t *ndf); | |
167 | Int_t LanGauPro(Double_t *params, Double_t &maxx, Double_t &fwhm); | |
168 | Double_t *CalculPolynomeLagrange2(Double_t *x, Double_t *y); | |
169 | Double_t *CalculPolynomeLagrange3(Double_t *x, Double_t *y); | |
170 | Double_t *CalculPolynomeLagrange4(Double_t *x, Double_t *y); | |
171 | static Double_t GausConstant(Double_t *x, Double_t *par); | |
172 | ||
173 | // This is a singleton, contructor is private! | |
174 | AliTRDCalibraFit(); | |
175 | virtual ~AliTRDCalibraFit(); | |
176 | ||
177 | protected: | |
178 | ||
f162af62 | 179 | // Geometry |
180 | AliTRDgeometry *fGeo; //! The TRD geometry | |
181 | ||
55a288e5 | 182 | // Write |
183 | Bool_t fWriteCoef[3]; // Do you want to write the result in a file? | |
184 | TString fWriteNameCoef; // Where the coef Det are written | |
185 | ||
186 | // Fit | |
187 | Bool_t fFitPHOn; // The fit PH On (0) | |
188 | Bool_t fFitPol2On; // The fit Pol2 On (1) | |
189 | Bool_t fFitLagrPolOn; // The fit LagrPol On (3) | |
190 | Bool_t fTakeTheMaxPH; // Take the Max for the T0 determination | |
191 | Int_t fFitPHPeriode; // Periode of the fit PH | |
192 | Int_t fFitPHNDB; // To choose which method will be used to fill the database for the PH | |
193 | Float_t fBeginFitCharge; // The fit begins at mean/fBeginFitCharge for the gain calibration | |
194 | Float_t fT0Shift; // T0 Shift with the actual method | |
195 | Float_t fRangeFitPRF; // The fit range for the PRF is -fRangeFitPRF +fRangeFitPRF | |
196 | Bool_t fFitPRFOn; // The fit PRF Gaussian On (0) | |
197 | Bool_t fRMSPRFOn; // The RMS PRF On (2) | |
198 | Int_t fFitPRFNDB; // To choose which method will be used to fill the database for the PRF | |
199 | Bool_t fMeanChargeOn; // Mean Charge on (1) | |
200 | Bool_t fFitChargeBisOn; // For an other fit function (convolution, more time consuming)(2) | |
201 | Bool_t fFitChargeOn; // For the first fit function (sum of Gaus and Landau) (0) | |
202 | Bool_t fFitMeanWOn; // For the Marian Mean W method (4) | |
203 | Int_t fFitChargeNDB; // To choose which method will be used to fill the database for the CH | |
204 | Bool_t fAccCDB; // If there is a calibration database to be compared with.... | |
205 | Int_t fMinEntries; // Min Entries to fit the histo | |
206 | Short_t fRebin; // If you want to rebin the histo for the gain calibration | |
207 | ||
208 | // Statistics | |
209 | Int_t fNumberFit; // To know how many pad groups have been fitted | |
210 | Int_t fNumberFitSuccess; // To know how many pad groups have been fitted successfully | |
211 | Int_t fNumberEnt; // To know how many pad groups have entries in the histo | |
212 | Double_t fStatisticMean; // To know the mean statistic of the histos | |
213 | ||
214 | // Debug Mode | |
215 | Short_t fDebug; // For debugging 0 rien, 1 errors, 2 one fit alone, 3 one detector, 4 one detector with errors | |
216 | Int_t fDet[3]; // Detector visualised (plane,chamb,sect) si debugging == 3 or 4 | |
217 | Int_t fFitVoir; // Fit visualised si debugging == 2 | |
218 | ||
219 | // Calibration mode | |
220 | ||
221 | AliTRDCalibraMode *fCalibraMode; // The calibration mode | |
222 | ||
223 | // The coefficients trees | |
224 | ||
225 | TTree *fPRF; // Tree of the sigma of PRD | |
226 | TTree *fGain; // Tree of the gain factor | |
227 | TTree *fT0; // Tree of the time0 | |
228 | TTree *fVdrift; // Tree of the drift velocity | |
229 | ||
230 | // "Pointer" of the branch of the tree | |
231 | Int_t fVdriftDetector; // Branch of Vdrift | |
232 | Float_t *fVdriftPad; // Branch of Vdrift | |
233 | Int_t fT0Detector; // Branch of t0 | |
234 | Float_t *fT0Pad; // Branch of t0 | |
235 | Int_t fPRFDetector; // Branch of PRF | |
236 | Float_t *fPRFPad; // Branch of PRF | |
237 | Float_t *fCoefCH; // Branch relative gain | |
238 | ||
239 | // | |
240 | // For debugging | |
241 | // | |
242 | ||
243 | // To build the graph with the errors of the fits | |
244 | Double_t *fCoefCharge[5]; // Coefs resulting from the fit for the gain | |
245 | Double_t *fCoefChargeE[4]; // Error of the found coefs for the gain | |
246 | Double_t *fCoefVdrift[4]; // Coefs resulting from the fit for the drift velocity | |
247 | Double_t *fCoefVdriftE[3]; // Error of the found coefs for the drift velocity | |
248 | Double_t *fCoefT0[4]; // Coefs resulting from the fit for the drift velocity | |
249 | Double_t *fCoefT0E[3]; // Error of the found coefs for the drift velocity | |
250 | Double_t *fCoefPRF[3]; // Coefs resulting from the fit for the PRF | |
251 | Double_t *fCoefPRFE[2]; // Error of the found coefs for the PRF | |
252 | TH2F *fCoefChargeDB[4]; // Visualisation of the coef of the detecteur fDet for the gain | |
253 | TH2F *fCoefVdriftDB[3]; // Visualisation of the coef of the detecteur fDet for the drift velocity | |
254 | TH2F *fCoefT0DB[3]; // Visualisation of the coef of the detecteur fDet for time 0 | |
255 | TH2F *fCoefPRFDB[2]; // Visualisation of the coef of the detecteur fDet for the pad response function | |
256 | ||
257 | // Variables in the loop for the coef or more general | |
258 | Float_t fChargeCoef[5]; // 4 Marian Mean W, 3 database value, 0 fit, 1 mean, 2 fit time consuming | |
259 | Float_t fVdriftCoef[4]; // 3 lagrangepoly, 2 database value, 1 slope method, 0 fit | |
260 | Float_t fPRFCoef[3]; // 2 Rms, 1 database, 0 fit | |
261 | Float_t fT0Coef[4]; // 3 lagrangepoly, 2 database, 1 slope method, 0 fit | |
262 | Float_t fPhd[3]; // Begin AR and DR | |
263 | Int_t fDect1[3]; // First calibration group that will be called to be maybe fitted | |
264 | Int_t fDect2[3]; // Last calibration group that will be called to be maybe fitted | |
265 | Double_t fScaleFitFactor; // Scale factor of the fit results for the gain | |
266 | Int_t fEntriesCurrent; // Entries in the current histo | |
267 | Int_t fCountDet[3]; // Current detector | |
268 | Int_t fCount[3]; // When the next detector comes | |
269 | ||
270 | // Vector method | |
271 | ||
272 | AliTRDCalibraVector *fCalibraVector; // The vector object | |
273 | ||
274 | class AliTRDFitCHInfo : public TObject { | |
275 | ||
276 | public: | |
277 | ||
278 | AliTRDFitCHInfo() | |
279 | :TObject() | |
280 | ,fCoef(0x0) | |
281 | ,fDetector(-1) { } | |
282 | AliTRDFitCHInfo(const AliTRDFitCHInfo &i) | |
283 | :TObject(i) | |
284 | ,fCoef(0x0) | |
285 | ,fDetector(-1) { } | |
286 | AliTRDFitCHInfo &operator=(const AliTRDFitCHInfo&) { return *this; } | |
287 | virtual ~AliTRDFitCHInfo() { } | |
288 | ||
289 | void SetCoef(Float_t *coef) { fCoef = coef; } | |
290 | void SetDetector(Int_t detector) { fDetector = detector; } | |
291 | ||
292 | Float_t *GetCoef() const { return fCoef; } | |
293 | Int_t GetDetector() const { return fDetector; } | |
294 | ||
295 | protected: | |
296 | ||
297 | Float_t *fCoef; // Relative gain coefficient for each group of the detector | |
298 | Int_t fDetector; // Detector number | |
299 | ||
300 | }; | |
301 | ||
302 | TObjArray *fVectorFitCH; // Vectors to fit | |
303 | ||
304 | // | |
305 | // A lot of internal functions...... | |
306 | // | |
307 | ||
308 | // Init AliTRDCalibraFit | |
309 | void Init(); | |
310 | ||
311 | // | |
312 | // Fit | |
313 | // | |
314 | ||
315 | // Create histos if fDebug == 1 or fDebug >=3 | |
316 | void CreateFitHistoPHDB(Int_t rowMax, Int_t colMax); | |
317 | void CreateFitHistoT0DB(Int_t rowMax, Int_t colMax); | |
318 | void CreateFitHistoCHDB(Int_t rowMax, Int_t colMax); | |
319 | void CreateFitHistoPRFDB(Int_t rowMax, Int_t colMax); | |
320 | void InitArrayFitCH(); | |
321 | void InitArrayFitPH(); | |
322 | void InitArrayFitT0(); | |
323 | void InitArrayFitPRF(); | |
324 | ||
325 | // CHFit functions | |
326 | Bool_t FillVectorFitCH(Int_t countdet); | |
327 | Bool_t InitFit(Int_t nbins, Int_t i); | |
328 | void InitfCountDetAndfCount(Int_t i); | |
329 | void UpdatefCountDetAndfCount(Int_t idect, Int_t i); | |
330 | void ReconstructFitRowMinRowMax(Int_t idect, Int_t i); | |
331 | Bool_t NotEnoughStatistic(Int_t idect, Int_t i); | |
332 | Bool_t FillInfosFit(Int_t idect, Int_t i); | |
333 | Bool_t WriteFitInfos(Int_t i); | |
334 | void NormierungCharge(); | |
335 | ||
336 | // Fill histos DB from the Coef histos | |
337 | void FillCoefChargeDB(); | |
338 | void FillCoefVdriftDB(); | |
339 | void FillCoefT0DB(); | |
340 | void FillCoefPRFDB(); | |
341 | ||
342 | // Plot histos CoefPRF Coef.... | |
343 | void PlotWritePH(); | |
344 | void PlotWriteT0(); | |
345 | void PlotWriteCH(); | |
346 | void PlotWritePRF(); | |
347 | ||
348 | // Plot histos DB | |
349 | void PlotPHDB(); | |
350 | void PlotT0DB(); | |
351 | void PlotCHDB(); | |
352 | void PlotPRFDB(); | |
353 | ||
354 | // Write the DB histos | |
355 | void WritePHDB(TFile *fout); | |
356 | void WriteT0DB(TFile *fout); | |
357 | void WriteCHDB(TFile *fout); | |
358 | void WritePRFDB(TFile *fout); | |
359 | ||
360 | // Calculate the mean coefs from the database | |
361 | Bool_t CalculVdriftCoefMean(Int_t fect, Int_t idect); | |
362 | Bool_t CalculChargeCoefMean(Int_t fect, Int_t idect, Bool_t vrai); | |
363 | Bool_t CalculPRFCoefMean(Int_t fect, Int_t idect); | |
364 | Bool_t CalculT0CoefMean(Int_t fect, Int_t idect); | |
365 | Float_t GetPRFDefault(Int_t plane) const; | |
366 | ||
367 | // Fit methods | |
368 | void FitBisCH(TH1 *projch, Int_t idect); | |
369 | void FitCH(TH1 *projch, Int_t idect); | |
370 | void FitMeanW(TH1 *projch, Int_t idect); | |
371 | void FitMean(TH1 *projch, Int_t idect, Double_t nentries); | |
372 | void FitPH(TH1 *projPH, Int_t idect); | |
373 | void FitPRF(TH1 *projPRF, Int_t idect); | |
374 | void RmsPRF(TH1 *projPRF, Int_t idect); | |
375 | void FitPente(TH1 *projPH, Int_t idect); | |
376 | void FitLagrangePoly(TH1* projPH, Int_t idect); | |
377 | TH1I *ReBin(TH1I *hist) const; | |
378 | TH1F *ReBin(TH1F *hist) const; | |
379 | ||
380 | // Clear | |
381 | void ClearTree(); | |
382 | ||
383 | // Some basic geometry function | |
384 | virtual Int_t GetPlane(Int_t d) const; | |
385 | virtual Int_t GetChamber(Int_t d) const; | |
386 | virtual Int_t GetSector(Int_t d) const; | |
387 | ||
388 | // Init, Fill and Reset the variables to default value tree Gain, PRF, Vdrift and T0 | |
389 | void InitTreePH(); | |
390 | void FillTreeVdrift(Int_t countdet); | |
391 | void InitTreeT0(); | |
392 | void FillTreeT0(Int_t countdet); | |
393 | void InitTreePRF(); | |
394 | void FillTreePRF(Int_t countdet); | |
395 | void ConvertVectorFitCHTree(); | |
396 | ||
397 | // Instance of this class and so on | |
398 | static AliTRDCalibraFit *fgInstance; // Instance | |
399 | static Bool_t fgTerminated; // If terminated | |
400 | ||
f162af62 | 401 | ClassDef(AliTRDCalibraFit,2) // TRD Calibration class |
55a288e5 | 402 | |
403 | }; | |
404 | ||
405 | #endif | |
406 | ||
407 |