]>
Commit | Line | Data |
---|---|---|
55a288e5 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | ///////////////////////////////////////////////////////////////////////////////// | |
19 | // | |
20 | // AliTRDCalibraFit | |
21 | // | |
22 | // This class is for the TRD calibration of the relative gain factor, the drift velocity, | |
23 | // the time 0 and the pad response function. It fits the histos. | |
24 | // The 2D histograms or vectors (first converted in 1D histos) will be fitted | |
25 | // if they have enough entries, otherwise the (default) value of the choosen database | |
26 | // will be put. For the relative gain calibration the resulted factors will be globally | |
27 | // normalized to the gain factors of the choosen database. It unables to precise | |
28 | // previous calibration procedure. | |
29 | // The function SetDebug enables the user to see: | |
30 | // _fDebug = 0: nothing, only the values are written in the tree if wanted | |
64942b85 | 31 | // _fDebug = 1: only the fit of the choosen calibration group fFitVoir (SetFitVoir) |
32 | // _fDebug = 2: a comparaison of the coefficients found and the default values | |
55a288e5 | 33 | // in the choosen database. |
34 | // fCoef , histogram of the coefs as function of the calibration group number | |
35 | // fDelta , histogram of the relative difference of the coef with the default | |
36 | // value in the database as function of the calibration group number | |
37 | // fError , dirstribution of this relative difference | |
55a288e5 | 38 | // _fDebug = 3: The coefficients in the choosen detector fDet (SetDet) as function of the |
39 | // pad row and col number | |
40 | // _fDebug = 4; The coeffcicients in the choosen detector fDet (SetDet) like in the 3 but with | |
41 | // also the comparaison histograms of the 1 for this detector | |
42 | // | |
43 | // | |
44 | // Author: | |
45 | // R. Bailhache (R.Bailhache@gsi.de) | |
46 | // | |
47 | ////////////////////////////////////////////////////////////////////////////////////// | |
48 | ||
55a288e5 | 49 | #include <TLine.h> |
50 | #include <TH1I.h> | |
51 | #include <TStyle.h> | |
52 | #include <TProfile2D.h> | |
55a288e5 | 53 | #include <TCanvas.h> |
54 | #include <TGraphErrors.h> | |
55a288e5 | 55 | #include <TObjArray.h> |
56 | #include <TH1.h> | |
57 | #include <TH1F.h> | |
58 | #include <TF1.h> | |
55a288e5 | 59 | #include <TAxis.h> |
55a288e5 | 60 | #include <TMath.h> |
55a288e5 | 61 | #include <TDirectory.h> |
3a0f6479 | 62 | #include <TTreeStream.h> |
63 | #include <TLinearFitter.h> | |
64 | #include <TVectorD.h> | |
daa7dc79 | 65 | #include <TROOT.h> |
4c865c34 | 66 | #include <TString.h> |
55a288e5 | 67 | |
68 | #include "AliLog.h" | |
3a0f6479 | 69 | #include "AliMathBase.h" |
55a288e5 | 70 | |
71 | #include "AliTRDCalibraFit.h" | |
72 | #include "AliTRDCalibraMode.h" | |
73 | #include "AliTRDCalibraVector.h" | |
3a0f6479 | 74 | #include "AliTRDCalibraVdriftLinearFit.h" |
55a288e5 | 75 | #include "AliTRDcalibDB.h" |
76 | #include "AliTRDgeometry.h" | |
3a0f6479 | 77 | #include "AliTRDpadPlane.h" |
78 | #include "AliTRDgeometry.h" | |
a076fc2f | 79 | #include "AliTRDCommonParam.h" |
55a288e5 | 80 | #include "./Cal/AliTRDCalROC.h" |
81 | #include "./Cal/AliTRDCalPad.h" | |
82 | #include "./Cal/AliTRDCalDet.h" | |
83 | ||
84 | ||
85 | ClassImp(AliTRDCalibraFit) | |
86 | ||
87 | AliTRDCalibraFit* AliTRDCalibraFit::fgInstance = 0; | |
88 | Bool_t AliTRDCalibraFit::fgTerminated = kFALSE; | |
89 | ||
90 | //_____________singleton implementation_________________________________________________ | |
91 | AliTRDCalibraFit *AliTRDCalibraFit::Instance() | |
92 | { | |
93 | // | |
94 | // Singleton implementation | |
95 | // | |
96 | ||
97 | if (fgTerminated != kFALSE) { | |
98 | return 0; | |
99 | } | |
100 | ||
101 | if (fgInstance == 0) { | |
102 | fgInstance = new AliTRDCalibraFit(); | |
103 | } | |
104 | ||
105 | return fgInstance; | |
106 | ||
107 | } | |
55a288e5 | 108 | //______________________________________________________________________________________ |
109 | void AliTRDCalibraFit::Terminate() | |
110 | { | |
111 | // | |
112 | // Singleton implementation | |
113 | // Deletes the instance of this class | |
114 | // | |
115 | ||
116 | fgTerminated = kTRUE; | |
117 | ||
118 | if (fgInstance != 0) { | |
119 | delete fgInstance; | |
120 | fgInstance = 0; | |
121 | } | |
122 | ||
123 | } | |
55a288e5 | 124 | //______________________________________________________________________________________ |
125 | AliTRDCalibraFit::AliTRDCalibraFit() | |
126 | :TObject() | |
f162af62 | 127 | ,fGeo(0) |
3a0f6479 | 128 | ,fNumberOfBinsExpected(0) |
129 | ,fMethod(0) | |
130 | ,fBeginFitCharge(3.5) | |
131 | ,fFitPHPeriode(1) | |
413153cb | 132 | ,fTakeTheMaxPH(kTRUE) |
133 | ,fT0Shift0(0.124797) | |
134 | ,fT0Shift1(0.267451) | |
3a0f6479 | 135 | ,fRangeFitPRF(1.0) |
55a288e5 | 136 | ,fAccCDB(kFALSE) |
3a0f6479 | 137 | ,fMinEntries(800) |
138 | ,fRebin(1) | |
54f2ff1c | 139 | ,fScaleGain(0.02431) |
55a288e5 | 140 | ,fNumberFit(0) |
141 | ,fNumberFitSuccess(0) | |
142 | ,fNumberEnt(0) | |
143 | ,fStatisticMean(0.0) | |
3a0f6479 | 144 | ,fDebugStreamer(0x0) |
145 | ,fDebugLevel(0) | |
55a288e5 | 146 | ,fFitVoir(0) |
3a0f6479 | 147 | ,fMagneticField(0.5) |
148 | ,fCalibraMode(new AliTRDCalibraMode()) | |
149 | ,fCurrentCoefE(0.0) | |
150 | ,fCurrentCoefE2(0.0) | |
151 | ,fDect1(0) | |
152 | ,fDect2(0) | |
55a288e5 | 153 | ,fScaleFitFactor(0.0) |
154 | ,fEntriesCurrent(0) | |
3a0f6479 | 155 | ,fCountDet(0) |
156 | ,fCount(0) | |
64942b85 | 157 | ,fNbDet(0) |
3a0f6479 | 158 | ,fCalDet(0x0) |
159 | ,fCalROC(0x0) | |
160 | ,fCalDet2(0x0) | |
161 | ,fCalROC2(0x0) | |
840ec79d | 162 | ,fCalDetVdriftUsed(0x0) |
163 | ,fCalDetExBUsed(0x0) | |
3a0f6479 | 164 | ,fCurrentCoefDetector(0x0) |
165 | ,fCurrentCoefDetector2(0x0) | |
166 | ,fVectorFit(0) | |
167 | ,fVectorFit2(0) | |
55a288e5 | 168 | { |
169 | // | |
170 | // Default constructor | |
171 | // | |
172 | ||
3a0f6479 | 173 | fGeo = new AliTRDgeometry(); |
174 | ||
175 | // Current variables initialised | |
176 | for (Int_t k = 0; k < 2; k++) { | |
177 | fCurrentCoef[k] = 0.0; | |
178 | fCurrentCoef2[k] = 0.0; | |
55a288e5 | 179 | } |
55a288e5 | 180 | for (Int_t i = 0; i < 3; i++) { |
3a0f6479 | 181 | fPhd[i] = 0.0; |
182 | fDet[i] = 0; | |
55a288e5 | 183 | } |
3a0f6479 | 184 | |
55a288e5 | 185 | } |
55a288e5 | 186 | //______________________________________________________________________________________ |
187 | AliTRDCalibraFit::AliTRDCalibraFit(const AliTRDCalibraFit &c) | |
3a0f6479 | 188 | :TObject(c) |
189 | ,fGeo(0) | |
190 | ,fNumberOfBinsExpected(c.fNumberOfBinsExpected) | |
191 | ,fMethod(c.fMethod) | |
192 | ,fBeginFitCharge(c.fBeginFitCharge) | |
193 | ,fFitPHPeriode(c.fFitPHPeriode) | |
194 | ,fTakeTheMaxPH(c.fTakeTheMaxPH) | |
413153cb | 195 | ,fT0Shift0(c.fT0Shift0) |
196 | ,fT0Shift1(c.fT0Shift1) | |
3a0f6479 | 197 | ,fRangeFitPRF(c.fRangeFitPRF) |
198 | ,fAccCDB(c.fAccCDB) | |
199 | ,fMinEntries(c.fMinEntries) | |
200 | ,fRebin(c.fRebin) | |
54f2ff1c | 201 | ,fScaleGain(c.fScaleGain) |
3a0f6479 | 202 | ,fNumberFit(c.fNumberFit) |
203 | ,fNumberFitSuccess(c.fNumberFitSuccess) | |
204 | ,fNumberEnt(c.fNumberEnt) | |
205 | ,fStatisticMean(c.fStatisticMean) | |
206 | ,fDebugStreamer(0x0) | |
207 | ,fDebugLevel(c.fDebugLevel) | |
208 | ,fFitVoir(c.fFitVoir) | |
209 | ,fMagneticField(c.fMagneticField) | |
210 | ,fCalibraMode(0x0) | |
211 | ,fCurrentCoefE(c.fCurrentCoefE) | |
212 | ,fCurrentCoefE2(c.fCurrentCoefE2) | |
213 | ,fDect1(c.fDect1) | |
214 | ,fDect2(c.fDect2) | |
215 | ,fScaleFitFactor(c.fScaleFitFactor) | |
216 | ,fEntriesCurrent(c.fEntriesCurrent) | |
217 | ,fCountDet(c.fCountDet) | |
218 | ,fCount(c.fCount) | |
64942b85 | 219 | ,fNbDet(c.fNbDet) |
3a0f6479 | 220 | ,fCalDet(0x0) |
221 | ,fCalROC(0x0) | |
222 | ,fCalDet2(0x0) | |
223 | ,fCalROC2(0x0) | |
840ec79d | 224 | ,fCalDetVdriftUsed(0x0) |
225 | ,fCalDetExBUsed(0x0) | |
3a0f6479 | 226 | ,fCurrentCoefDetector(0x0) |
227 | ,fCurrentCoefDetector2(0x0) | |
228 | ,fVectorFit(0) | |
229 | ,fVectorFit2(0) | |
55a288e5 | 230 | { |
231 | // | |
232 | // Copy constructor | |
233 | // | |
234 | ||
3a0f6479 | 235 | if(c.fCalibraMode) fCalibraMode = new AliTRDCalibraMode(*c.fCalibraMode); |
236 | ||
237 | //Current variables initialised | |
238 | for (Int_t k = 0; k < 2; k++) { | |
239 | fCurrentCoef[k] = 0.0; | |
240 | fCurrentCoef2[k] = 0.0; | |
241 | } | |
242 | for (Int_t i = 0; i < 3; i++) { | |
243 | fPhd[i] = 0.0; | |
244 | fDet[i] = 0; | |
245 | } | |
246 | if(c.fCalDet) fCalDet = new AliTRDCalDet(*c.fCalDet); | |
247 | if(c.fCalDet2) fCalDet2 = new AliTRDCalDet(*c.fCalDet2); | |
64942b85 | 248 | |
3a0f6479 | 249 | if(c.fCalROC) fCalROC = new AliTRDCalROC(*c.fCalROC); |
250 | if(c.fCalROC2) fCalROC = new AliTRDCalROC(*c.fCalROC2); | |
251 | ||
840ec79d | 252 | if(c.fCalDetVdriftUsed) fCalDetVdriftUsed = new AliTRDCalDet(*c.fCalDetVdriftUsed); |
253 | if(c.fCalDetExBUsed) fCalDetExBUsed = new AliTRDCalDet(*c.fCalDetExBUsed); | |
254 | ||
3a0f6479 | 255 | fVectorFit.SetName(c.fVectorFit.GetName()); |
256 | for(Int_t k = 0; k < c.fVectorFit.GetEntriesFast(); k++){ | |
257 | AliTRDFitInfo *fitInfo = new AliTRDFitInfo(); | |
258 | Int_t detector = ((AliTRDFitInfo *)c.fVectorFit.UncheckedAt(k))->GetDetector(); | |
259 | Int_t ntotal = 1; | |
053767a4 | 260 | if (GetStack(detector) == 2) { |
3a0f6479 | 261 | ntotal = 1728; |
262 | } | |
263 | else { | |
264 | ntotal = 2304; | |
265 | } | |
266 | Float_t *coef = new Float_t[ntotal]; | |
267 | for (Int_t i = 0; i < ntotal; i++) { | |
268 | coef[i] = ((AliTRDFitInfo *)c.fVectorFit.UncheckedAt(k))->GetCoef()[i]; | |
269 | } | |
270 | fitInfo->SetCoef(coef); | |
271 | fitInfo->SetDetector(detector); | |
272 | fVectorFit.Add((TObject *) fitInfo); | |
273 | } | |
274 | fVectorFit.SetName(c.fVectorFit.GetName()); | |
275 | for(Int_t k = 0; k < c.fVectorFit2.GetEntriesFast(); k++){ | |
276 | AliTRDFitInfo *fitInfo = new AliTRDFitInfo(); | |
277 | Int_t detector = ((AliTRDFitInfo *)c.fVectorFit2.UncheckedAt(k))->GetDetector(); | |
278 | Int_t ntotal = 1; | |
053767a4 | 279 | if (GetStack(detector) == 2) { |
3a0f6479 | 280 | ntotal = 1728; |
281 | } | |
282 | else { | |
283 | ntotal = 2304; | |
284 | } | |
285 | Float_t *coef = new Float_t[ntotal]; | |
286 | for (Int_t i = 0; i < ntotal; i++) { | |
287 | coef[i] = ((AliTRDFitInfo *)c.fVectorFit2.UncheckedAt(k))->GetCoef()[i]; | |
288 | } | |
289 | fitInfo->SetCoef(coef); | |
290 | fitInfo->SetDetector(detector); | |
291 | fVectorFit2.Add((TObject *) fitInfo); | |
292 | } | |
293 | if (fGeo) { | |
294 | delete fGeo; | |
295 | } | |
296 | fGeo = new AliTRDgeometry(); | |
55a288e5 | 297 | |
3a0f6479 | 298 | } |
55a288e5 | 299 | //____________________________________________________________________________________ |
300 | AliTRDCalibraFit::~AliTRDCalibraFit() | |
301 | { | |
302 | // | |
303 | // AliTRDCalibraFit destructor | |
304 | // | |
3a0f6479 | 305 | if ( fDebugStreamer ) delete fDebugStreamer; |
306 | if ( fCalDet ) delete fCalDet; | |
307 | if ( fCalDet2 ) delete fCalDet2; | |
308 | if ( fCalROC ) delete fCalROC; | |
1ca79a00 | 309 | if ( fCalROC2 ) delete fCalROC2; |
840ec79d | 310 | if ( fCalDetVdriftUsed) delete fCalDetVdriftUsed; |
311 | if ( fCalDetExBUsed) delete fCalDetExBUsed; | |
1ca79a00 | 312 | if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector; |
313 | if( fCurrentCoefDetector2 ) delete [] fCurrentCoefDetector2; | |
3a0f6479 | 314 | fVectorFit.Delete(); |
315 | fVectorFit2.Delete(); | |
f162af62 | 316 | if (fGeo) { |
317 | delete fGeo; | |
318 | } | |
319 | ||
55a288e5 | 320 | } |
55a288e5 | 321 | //_____________________________________________________________________________ |
322 | void AliTRDCalibraFit::Destroy() | |
323 | { | |
324 | // | |
325 | // Delete instance | |
326 | // | |
327 | ||
328 | if (fgInstance) { | |
329 | delete fgInstance; | |
330 | fgInstance = 0x0; | |
331 | } | |
332 | ||
64942b85 | 333 | } |
334 | //_____________________________________________________________________________ | |
335 | void AliTRDCalibraFit::DestroyDebugStreamer() | |
336 | { | |
337 | // | |
338 | // Delete DebugStreamer | |
339 | // | |
340 | ||
341 | if ( fDebugStreamer ) delete fDebugStreamer; | |
342 | fDebugStreamer = 0x0; | |
343 | ||
413153cb | 344 | } |
345 | //__________________________________________________________________________________ | |
979b168f | 346 | void AliTRDCalibraFit::RangeChargeIntegration(Float_t vdrift, Float_t t0, Int_t &begin, Int_t &peak, Int_t &end) const |
413153cb | 347 | { |
348 | // | |
349 | // From the drift velocity and t0 | |
350 | // return the position of the peak and maximum negative slope | |
351 | // | |
352 | ||
353 | const Float_t kDrWidth = AliTRDgeometry::DrThick(); // drift region | |
354 | Double_t widbins = 0.1; // 0.1 mus | |
355 | ||
356 | //peak and maxnegslope in mus | |
357 | Double_t begind = t0*widbins + fT0Shift0; | |
358 | Double_t peakd = t0*widbins + fT0Shift1; | |
359 | Double_t maxnegslope = (kDrWidth + vdrift*peakd)/vdrift; | |
360 | ||
361 | // peak and maxnegslope in timebin | |
362 | begin = TMath::Nint(begind*widbins); | |
363 | peak = TMath::Nint(peakd*widbins); | |
364 | end = TMath::Nint(maxnegslope*widbins); | |
365 | ||
55a288e5 | 366 | } |
55a288e5 | 367 | //____________Functions fit Online CH2d________________________________________ |
979b168f | 368 | Bool_t AliTRDCalibraFit::AnalyseCH(const TH2I *ch) |
55a288e5 | 369 | { |
370 | // | |
371 | // Fit the 1D histos, projections of the 2D ch on the Xaxis, for each | |
372 | // calibration group normalized the resulted coefficients (to 1 normally) | |
55a288e5 | 373 | // |
374 | ||
3a0f6479 | 375 | // Set the calibration mode |
4c865c34 | 376 | //const char *name = ch->GetTitle(); |
377 | TString name = ch->GetTitle(); | |
64942b85 | 378 | if(!SetModeCalibration(name,0)) return kFALSE; |
3a0f6479 | 379 | |
380 | // Number of Ybins (detectors or groups of pads) | |
381 | Int_t nbins = ch->GetNbinsX();// charge | |
382 | Int_t nybins = ch->GetNbinsY();// groups number | |
383 | if (!InitFit(nybins,0)) { | |
55a288e5 | 384 | return kFALSE; |
385 | } | |
3a0f6479 | 386 | if (!InitFitCH()) { |
55a288e5 | 387 | return kFALSE; |
388 | } | |
389 | fStatisticMean = 0.0; | |
390 | fNumberFit = 0; | |
391 | fNumberFitSuccess = 0; | |
392 | fNumberEnt = 0; | |
55a288e5 | 393 | // Init fCountDet and fCount |
394 | InitfCountDetAndfCount(0); | |
55a288e5 | 395 | // Beginning of the loop betwwen dect1 and dect2 |
3a0f6479 | 396 | for (Int_t idect = fDect1; idect < fDect2; idect++) { |
397 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi... | |
55a288e5 | 398 | UpdatefCountDetAndfCount(idect,0); |
55a288e5 | 399 | ReconstructFitRowMinRowMax(idect, 0); |
3a0f6479 | 400 | // Take the histo |
401 | TH1I *projch = (TH1I *) ch->ProjectionX("projch",idect+1,idect+1,(Option_t *)"e"); | |
402 | projch->SetDirectory(0); | |
55a288e5 | 403 | // Number of entries for this calibration group |
404 | Double_t nentries = 0.0; | |
405 | Double_t mean = 0.0; | |
3a0f6479 | 406 | for (Int_t k = 0; k < nbins; k++) { |
407 | Int_t binnb = (nbins+2)*(idect+1)+(k+1); | |
408 | nentries += ch->GetBinContent(binnb); | |
55a288e5 | 409 | mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1); |
3a0f6479 | 410 | projch->SetBinError(k+1,TMath::Sqrt(projch->GetBinContent(k+1))); |
55a288e5 | 411 | } |
3a0f6479 | 412 | projch->SetEntries(nentries); |
413 | //printf("The number of entries for the group %d is %f\n",idect,nentries); | |
55a288e5 | 414 | if (nentries > 0) { |
415 | fNumberEnt++; | |
416 | mean /= nentries; | |
417 | } | |
55a288e5 | 418 | // Rebin and statistic stuff |
55a288e5 | 419 | if (fRebin > 1) { |
420 | projch = ReBin((TH1I *) projch); | |
421 | } | |
422 | // This detector has not enough statistics or was off | |
3a0f6479 | 423 | if (nentries <= fMinEntries) { |
424 | NotEnoughStatisticCH(idect); | |
425 | if (fDebugLevel != 1) { | |
55a288e5 | 426 | delete projch; |
427 | } | |
428 | continue; | |
429 | } | |
55a288e5 | 430 | // Statistics of the group fitted |
55a288e5 | 431 | fStatisticMean += nentries; |
432 | fNumberFit++; | |
3a0f6479 | 433 | //Method choosen |
434 | switch(fMethod) | |
435 | { | |
436 | case 0: FitMeanW((TH1 *) projch, nentries); break; | |
437 | case 1: FitMean((TH1 *) projch, nentries, mean); break; | |
438 | case 2: FitCH((TH1 *) projch, mean); break; | |
439 | case 3: FitBisCH((TH1 *) projch, mean); break; | |
440 | default: return kFALSE; | |
441 | } | |
55a288e5 | 442 | // Fill Infos Fit |
3a0f6479 | 443 | FillInfosFitCH(idect); |
55a288e5 | 444 | // Memory!!! |
3a0f6479 | 445 | if (fDebugLevel != 1) { |
55a288e5 | 446 | delete projch; |
447 | } | |
55a288e5 | 448 | } // Boucle object |
55a288e5 | 449 | // Normierungcharge |
3a0f6479 | 450 | if (fDebugLevel != 1) { |
55a288e5 | 451 | NormierungCharge(); |
452 | } | |
55a288e5 | 453 | // Mean Statistic |
454 | if (fNumberFit > 0) { | |
3a0f6479 | 455 | AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %d over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Int_t) fStatisticMean/fNumberFit, fNumberFitSuccess)); |
55a288e5 | 456 | fStatisticMean = fStatisticMean / fNumberFit; |
457 | } | |
458 | else { | |
459 | AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt)); | |
460 | } | |
3a0f6479 | 461 | delete fDebugStreamer; |
462 | fDebugStreamer = 0x0; | |
463 | ||
55a288e5 | 464 | return kTRUE; |
55a288e5 | 465 | } |
55a288e5 | 466 | //____________Functions fit Online CH2d________________________________________ |
3a0f6479 | 467 | Bool_t AliTRDCalibraFit::AnalyseCH(AliTRDCalibraVector *calvect) |
55a288e5 | 468 | { |
469 | // | |
470 | // Reconstruct a 1D histo from the vectorCH for each calibration group, | |
471 | // fit the histo, normalized the resulted coefficients (to 1 normally) | |
55a288e5 | 472 | // |
473 | ||
3a0f6479 | 474 | // Set the calibraMode |
4c865c34 | 475 | //const char *name = calvect->GetNameCH(); |
476 | TString name = calvect->GetNameCH(); | |
64942b85 | 477 | if(!SetModeCalibration(name,0)) return kFALSE; |
55a288e5 | 478 | |
3a0f6479 | 479 | // Number of Xbins (detectors or groups of pads) |
480 | if (!InitFit((432*calvect->GetDetCha0(0)+108*calvect->GetDetCha2(0)),0)) { | |
55a288e5 | 481 | return kFALSE; |
482 | } | |
3a0f6479 | 483 | if (!InitFitCH()) { |
55a288e5 | 484 | return kFALSE; |
485 | } | |
486 | fStatisticMean = 0.0; | |
487 | fNumberFit = 0; | |
488 | fNumberFitSuccess = 0; | |
489 | fNumberEnt = 0; | |
55a288e5 | 490 | // Init fCountDet and fCount |
491 | InitfCountDetAndfCount(0); | |
55a288e5 | 492 | // Beginning of the loop between dect1 and dect2 |
3a0f6479 | 493 | for (Int_t idect = fDect1; idect < fDect2; idect++) { |
494 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi........... | |
55a288e5 | 495 | UpdatefCountDetAndfCount(idect,0); |
55a288e5 | 496 | ReconstructFitRowMinRowMax(idect,0); |
3a0f6479 | 497 | // Take the histo |
55a288e5 | 498 | Double_t nentries = 0.0; |
499 | Double_t mean = 0.0; | |
e526983e | 500 | if(!calvect->GetCHEntries(fCountDet)) { |
501 | NotEnoughStatisticCH(idect); | |
502 | continue; | |
503 | } | |
504 | ||
505 | TString tname("CH"); | |
506 | tname += idect; | |
507 | TH1F *projch = calvect->ConvertVectorCHHisto(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0)))),(const char *) tname); | |
508 | projch->SetDirectory(0); | |
509 | for (Int_t k = 0; k < calvect->GetNumberBinCharge(); k++) { | |
510 | nentries += projch->GetBinContent(k+1); | |
511 | mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1); | |
512 | } | |
513 | if (nentries > 0) { | |
514 | fNumberEnt++; | |
515 | mean /= nentries; | |
516 | } | |
517 | //printf("The number of entries for the group %d is %f\n",idect,nentries); | |
518 | // Rebin | |
519 | if (fRebin > 1) { | |
520 | projch = ReBin((TH1F *) projch); | |
55a288e5 | 521 | } |
55a288e5 | 522 | // This detector has not enough statistics or was not found in VectorCH |
3a0f6479 | 523 | if (nentries <= fMinEntries) { |
524 | NotEnoughStatisticCH(idect); | |
55a288e5 | 525 | continue; |
55a288e5 | 526 | } |
55a288e5 | 527 | // Statistic of the histos fitted |
55a288e5 | 528 | fStatisticMean += nentries; |
529 | fNumberFit++; | |
3a0f6479 | 530 | //Method choosen |
531 | switch(fMethod) | |
532 | { | |
533 | case 0: FitMeanW((TH1 *) projch, nentries); break; | |
534 | case 1: FitMean((TH1 *) projch, nentries, mean); break; | |
535 | case 2: FitCH((TH1 *) projch, mean); break; | |
536 | case 3: FitBisCH((TH1 *) projch, mean); break; | |
537 | default: return kFALSE; | |
538 | } | |
55a288e5 | 539 | // Fill Infos Fit |
3a0f6479 | 540 | FillInfosFitCH(idect); |
55a288e5 | 541 | } // Boucle object |
55a288e5 | 542 | // Normierungcharge |
3a0f6479 | 543 | if (fDebugLevel != 1) { |
55a288e5 | 544 | NormierungCharge(); |
545 | } | |
55a288e5 | 546 | // Mean Statistics |
547 | if (fNumberFit > 0) { | |
3a0f6479 | 548 | AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %d over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Int_t) fStatisticMean/fNumberFit, fNumberFitSuccess)); |
55a288e5 | 549 | fStatisticMean = fStatisticMean / fNumberFit; |
550 | } | |
551 | else { | |
552 | AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt)); | |
553 | } | |
3a0f6479 | 554 | delete fDebugStreamer; |
555 | fDebugStreamer = 0x0; | |
55a288e5 | 556 | return kTRUE; |
55a288e5 | 557 | } |
54f2ff1c | 558 | //____________Functions fit Online CH2d________________________________________ |
559 | Double_t AliTRDCalibraFit::AnalyseCHAllTogether(const TH2I *ch) | |
560 | { | |
561 | // | |
562 | // Fit the 1D histos, projections of the 2D ch on the Xaxis, for each | |
563 | // calibration group normalized the resulted coefficients (to 1 normally) | |
564 | // | |
565 | Int_t nbins = ch->GetNbinsX();// charge | |
566 | Int_t nybins = ch->GetNbinsY();// groups number | |
567 | // Take the histo | |
568 | TH1I *projch = (TH1I *) ch->ProjectionX("projch",1,nybins+1,(Option_t *)"e"); | |
569 | projch->SetDirectory(0); | |
570 | // Number of entries for this calibration group | |
571 | Double_t nentries = 0.0; | |
572 | Double_t mean = 0.0; | |
573 | for (Int_t k = 0; k < nbins; k++) { | |
574 | nentries += projch->GetBinContent(k+1); | |
575 | mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1); | |
576 | projch->SetBinError(k+1,TMath::Sqrt(projch->GetBinContent(k+1))); | |
577 | } | |
578 | projch->SetEntries(nentries); | |
579 | //printf("The number of entries for the group %d is %f\n",idect,nentries); | |
580 | if (nentries > 0) { | |
54f2ff1c | 581 | mean /= nentries; |
582 | } | |
583 | // This detector has not enough statistics or was off | |
584 | if (nentries <= fMinEntries) { | |
585 | delete projch; | |
586 | AliInfo(Form("There are %d entries for all together, it is not enough (%d)",(Int_t) nentries, fMinEntries)); | |
587 | return -100.0; | |
588 | } | |
589 | //Method choosen | |
590 | switch(fMethod) | |
591 | { | |
592 | case 0: FitMeanW((TH1 *) projch, nentries); break; | |
593 | case 1: FitMean((TH1 *) projch, nentries, mean); break; | |
594 | case 2: FitCH((TH1 *) projch, mean); break; | |
595 | case 3: FitBisCH((TH1 *) projch, mean); break; | |
b88b6bcc | 596 | default: return -100.0; |
54f2ff1c | 597 | } |
598 | delete fDebugStreamer; | |
599 | fDebugStreamer = 0x0; | |
600 | ||
601 | if(fCurrentCoef[0] > 0.0) return fCurrentCoef[0]; | |
602 | else return -100.0; | |
603 | ||
604 | } | |
3a0f6479 | 605 | //________________functions fit Online PH2d____________________________________ |
b88b6bcc | 606 | Double_t AliTRDCalibraFit::AnalysePHAllTogether(const TProfile2D *ph) |
55a288e5 | 607 | { |
608 | // | |
3a0f6479 | 609 | // Take the 1D profiles (average pulse height), projections of the 2D PH |
610 | // on the Xaxis, for each calibration group | |
611 | // Reconstruct a drift velocity | |
612 | // A first calibration of T0 is also made using the same method | |
55a288e5 | 613 | // |
614 | ||
3a0f6479 | 615 | // Number of Xbins (detectors or groups of pads) |
616 | Int_t nbins = ph->GetNbinsX();// time | |
617 | Int_t nybins = ph->GetNbinsY();// calibration group | |
b88b6bcc | 618 | |
619 | // Take the histo | |
620 | TH1D *projph = (TH1D *) ph->ProjectionX("projph",1,nybins+1,(Option_t *) "e"); | |
621 | projph->SetDirectory(0); | |
622 | // Number of entries for this calibration group | |
623 | Double_t nentries = 0; | |
624 | for(Int_t idect = 0; idect < nybins; idect++){ | |
625 | for (Int_t k = 0; k < nbins; k++) { | |
626 | Int_t binnb = (nbins+2)*(idect+1)+(k+1); | |
627 | nentries += ph->GetBinEntries(binnb); | |
628 | } | |
55a288e5 | 629 | } |
b88b6bcc | 630 | //printf("AnalysePHAllTogether:: the number of entries is %f\n",nentries); |
631 | // This detector has not enough statistics or was off | |
632 | if (nentries <= fMinEntries) { | |
633 | AliInfo(Form("There are %d entries for all together, it is not enough (%d)",(Int_t) nentries, fMinEntries)); | |
634 | if (fDebugLevel != 1) { | |
635 | delete projph; | |
636 | } | |
637 | return -100.0; | |
638 | } | |
639 | //Method choosen | |
640 | //printf("Method\n"); | |
641 | switch(fMethod) | |
642 | { | |
643 | case 0: FitLagrangePoly((TH1 *) projph); break; | |
644 | case 1: FitPente((TH1 *) projph); break; | |
645 | case 2: FitPH((TH1 *) projph,0); break; | |
646 | default: return -100.0; | |
647 | } | |
648 | // Memory!!! | |
649 | if (fDebugLevel != 1) { | |
650 | delete projph; | |
651 | } | |
652 | delete fDebugStreamer; | |
653 | fDebugStreamer = 0x0; | |
654 | ||
655 | if(fCurrentCoef[0] > 0.0) return fCurrentCoef[0]; | |
656 | else return -100.0; | |
657 | ||
658 | } | |
659 | //____________Functions fit Online PH2d________________________________________ | |
660 | Bool_t AliTRDCalibraFit::AnalysePH(AliTRDCalibraVector *calvect) | |
661 | { | |
662 | // | |
663 | // Reconstruct the average pulse height from the vectorPH for each | |
664 | // calibration group | |
665 | // Reconstruct a drift velocity | |
666 | // A first calibration of T0 is also made using the same method (slope method) | |
667 | // | |
6aafa7ea | 668 | |
b88b6bcc | 669 | // Set the calibration mode |
670 | //const char *name = calvect->GetNamePH(); | |
671 | TString name = calvect->GetNamePH(); | |
672 | if(!SetModeCalibration(name,1)) return kFALSE; | |
6aafa7ea | 673 | |
b88b6bcc | 674 | // Number of Xbins (detectors or groups of pads) |
675 | if (!InitFit((432*calvect->GetDetCha0(1)+108*calvect->GetDetCha2(1)),1)) { | |
676 | return kFALSE; | |
677 | } | |
3a0f6479 | 678 | if (!InitFitPH()) { |
55a288e5 | 679 | return kFALSE; |
680 | } | |
681 | fStatisticMean = 0.0; | |
682 | fNumberFit = 0; | |
683 | fNumberFitSuccess = 0; | |
684 | fNumberEnt = 0; | |
55a288e5 | 685 | // Init fCountDet and fCount |
3a0f6479 | 686 | InitfCountDetAndfCount(1); |
687 | // Beginning of the loop | |
688 | for (Int_t idect = fDect1; idect < fDect2; idect++) { | |
b88b6bcc | 689 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi........... |
3a0f6479 | 690 | UpdatefCountDetAndfCount(idect,1); |
691 | ReconstructFitRowMinRowMax(idect,1); | |
692 | // Take the histo | |
b88b6bcc | 693 | fEntriesCurrent = 0; |
694 | if(!calvect->GetPHEntries(fCountDet)) { | |
695 | NotEnoughStatisticPH(idect,fEntriesCurrent); | |
696 | continue; | |
55a288e5 | 697 | } |
b88b6bcc | 698 | TString tname("PH"); |
699 | tname += idect; | |
700 | TH1F *projph = calvect->CorrectTheError((TGraphErrors *) (calvect->ConvertVectorPHTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname)),fEntriesCurrent); | |
701 | projph->SetDirectory(0); | |
702 | if(fEntriesCurrent > 0) fNumberEnt++; | |
703 | //printf("The number of entries for the group %d is %d\n",idect,fEntriesCurrent); | |
3a0f6479 | 704 | // This detector has not enough statistics or was off |
b88b6bcc | 705 | if (fEntriesCurrent <= fMinEntries) { |
706 | //printf("Not enough stat!\n"); | |
707 | NotEnoughStatisticPH(idect,fEntriesCurrent); | |
55a288e5 | 708 | continue; |
55a288e5 | 709 | } |
b88b6bcc | 710 | // Statistic of the histos fitted |
55a288e5 | 711 | fNumberFit++; |
b88b6bcc | 712 | fStatisticMean += fEntriesCurrent; |
3a0f6479 | 713 | // Calcul of "real" coef |
714 | CalculVdriftCoefMean(); | |
715 | CalculT0CoefMean(); | |
716 | //Method choosen | |
717 | switch(fMethod) | |
718 | { | |
719 | case 0: FitLagrangePoly((TH1 *) projph); break; | |
720 | case 1: FitPente((TH1 *) projph); break; | |
721 | case 2: FitPH((TH1 *) projph,(Int_t) (idect - fDect1)); break; | |
722 | default: return kFALSE; | |
723 | } | |
724 | // Fill the tree if end of a detector or only the pointer to the branch!!! | |
b88b6bcc | 725 | FillInfosFitPH(idect,fEntriesCurrent); |
55a288e5 | 726 | } // Boucle object |
b88b6bcc | 727 | |
55a288e5 | 728 | // Mean Statistic |
729 | if (fNumberFit > 0) { | |
3a0f6479 | 730 | AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %d over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess)); |
55a288e5 | 731 | fStatisticMean = fStatisticMean / fNumberFit; |
732 | } | |
733 | else { | |
734 | AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt)); | |
735 | } | |
3a0f6479 | 736 | delete fDebugStreamer; |
737 | fDebugStreamer = 0x0; | |
55a288e5 | 738 | return kTRUE; |
55a288e5 | 739 | } |
b88b6bcc | 740 | //________________functions fit Online PH2d____________________________________ |
741 | Bool_t AliTRDCalibraFit::AnalysePH(const TProfile2D *ph) | |
55a288e5 | 742 | { |
743 | // | |
b88b6bcc | 744 | // Take the 1D profiles (average pulse height), projections of the 2D PH |
745 | // on the Xaxis, for each calibration group | |
3a0f6479 | 746 | // Reconstruct a drift velocity |
b88b6bcc | 747 | // A first calibration of T0 is also made using the same method |
55a288e5 | 748 | // |
749 | ||
3a0f6479 | 750 | // Set the calibration mode |
b88b6bcc | 751 | //const char *name = ph->GetTitle(); |
752 | TString name = ph->GetTitle(); | |
64942b85 | 753 | if(!SetModeCalibration(name,1)) return kFALSE; |
b88b6bcc | 754 | |
755 | //printf("Mode calibration set\n"); | |
3a0f6479 | 756 | |
757 | // Number of Xbins (detectors or groups of pads) | |
b88b6bcc | 758 | Int_t nbins = ph->GetNbinsX();// time |
759 | Int_t nybins = ph->GetNbinsY();// calibration group | |
760 | if (!InitFit(nybins,1)) { | |
55a288e5 | 761 | return kFALSE; |
762 | } | |
b88b6bcc | 763 | |
764 | //printf("Init fit\n"); | |
765 | ||
3a0f6479 | 766 | if (!InitFitPH()) { |
55a288e5 | 767 | return kFALSE; |
768 | } | |
b88b6bcc | 769 | |
770 | //printf("Init fit PH\n"); | |
771 | ||
55a288e5 | 772 | fStatisticMean = 0.0; |
773 | fNumberFit = 0; | |
774 | fNumberFitSuccess = 0; | |
775 | fNumberEnt = 0; | |
55a288e5 | 776 | // Init fCountDet and fCount |
777 | InitfCountDetAndfCount(1); | |
b88b6bcc | 778 | //printf("Init Count Det and fCount %d, %d\n",fDect1,fDect2); |
779 | ||
55a288e5 | 780 | // Beginning of the loop |
3a0f6479 | 781 | for (Int_t idect = fDect1; idect < fDect2; idect++) { |
b88b6bcc | 782 | //printf("idect = %d\n",idect); |
783 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi....... | |
55a288e5 | 784 | UpdatefCountDetAndfCount(idect,1); |
55a288e5 | 785 | ReconstructFitRowMinRowMax(idect,1); |
3a0f6479 | 786 | // Take the histo |
b88b6bcc | 787 | TH1D *projph = (TH1D *) ph->ProjectionX("projph",idect+1,idect+1,(Option_t *) "e"); |
788 | projph->SetDirectory(0); | |
789 | // Number of entries for this calibration group | |
790 | Double_t nentries = 0; | |
791 | for (Int_t k = 0; k < nbins; k++) { | |
792 | Int_t binnb = (nbins+2)*(idect+1)+(k+1); | |
793 | nentries += ph->GetBinEntries(binnb); | |
3a0f6479 | 794 | } |
b88b6bcc | 795 | if (nentries > 0) { |
796 | fNumberEnt++; | |
797 | } | |
798 | //printf("The number of entries for the group %d is %f\n",idect,nentries); | |
55a288e5 | 799 | // This detector has not enough statistics or was off |
b88b6bcc | 800 | if (nentries <= fMinEntries) { |
801 | //printf("Not enough statistic!\n"); | |
802 | NotEnoughStatisticPH(idect,nentries); | |
803 | if (fDebugLevel != 1) { | |
804 | delete projph; | |
805 | } | |
55a288e5 | 806 | continue; |
55a288e5 | 807 | } |
b88b6bcc | 808 | // Statistics of the histos fitted |
55a288e5 | 809 | fNumberFit++; |
b88b6bcc | 810 | fStatisticMean += nentries; |
55a288e5 | 811 | // Calcul of "real" coef |
3a0f6479 | 812 | CalculVdriftCoefMean(); |
813 | CalculT0CoefMean(); | |
814 | //Method choosen | |
b88b6bcc | 815 | //printf("Method\n"); |
3a0f6479 | 816 | switch(fMethod) |
817 | { | |
818 | case 0: FitLagrangePoly((TH1 *) projph); break; | |
819 | case 1: FitPente((TH1 *) projph); break; | |
820 | case 2: FitPH((TH1 *) projph,(Int_t) (idect - fDect1)); break; | |
821 | default: return kFALSE; | |
822 | } | |
55a288e5 | 823 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
b88b6bcc | 824 | FillInfosFitPH(idect,nentries); |
825 | // Memory!!! | |
826 | if (fDebugLevel != 1) { | |
827 | delete projph; | |
828 | } | |
55a288e5 | 829 | } // Boucle object |
55a288e5 | 830 | // Mean Statistic |
831 | if (fNumberFit > 0) { | |
3a0f6479 | 832 | AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %d over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess)); |
55a288e5 | 833 | fStatisticMean = fStatisticMean / fNumberFit; |
834 | } | |
835 | else { | |
836 | AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt)); | |
837 | } | |
3a0f6479 | 838 | delete fDebugStreamer; |
839 | fDebugStreamer = 0x0; | |
55a288e5 | 840 | return kTRUE; |
55a288e5 | 841 | } |
3a0f6479 | 842 | //____________Functions fit Online PRF2d_______________________________________ |
979b168f | 843 | Bool_t AliTRDCalibraFit::AnalysePRF(const TProfile2D *prf) |
55a288e5 | 844 | { |
845 | // | |
3a0f6479 | 846 | // Take the 1D profiles (pad response function), projections of the 2D PRF |
847 | // on the Xaxis, for each calibration group | |
848 | // Fit with a gaussian to reconstruct the sigma of the pad response function | |
55a288e5 | 849 | // |
850 | ||
3a0f6479 | 851 | // Set the calibration mode |
4c865c34 | 852 | //const char *name = prf->GetTitle(); |
853 | TString name = prf->GetTitle(); | |
64942b85 | 854 | if(!SetModeCalibration(name,2)) return kFALSE; |
55a288e5 | 855 | |
3a0f6479 | 856 | // Number of Ybins (detectors or groups of pads) |
857 | Int_t nybins = prf->GetNbinsY();// calibration groups | |
858 | Int_t nbins = prf->GetNbinsX();// bins | |
859 | Int_t nbg = GetNumberOfGroupsPRF((const char *)prf->GetTitle()); | |
860 | if((nbg > 0) || (nbg == -1)) return kFALSE; | |
861 | if (!InitFit(nybins,2)) { | |
55a288e5 | 862 | return kFALSE; |
863 | } | |
3a0f6479 | 864 | if (!InitFitPRF()) { |
55a288e5 | 865 | return kFALSE; |
866 | } | |
867 | fStatisticMean = 0.0; | |
868 | fNumberFit = 0; | |
869 | fNumberFitSuccess = 0; | |
870 | fNumberEnt = 0; | |
55a288e5 | 871 | // Init fCountDet and fCount |
3a0f6479 | 872 | InitfCountDetAndfCount(2); |
55a288e5 | 873 | // Beginning of the loop |
3a0f6479 | 874 | for (Int_t idect = fDect1; idect < fDect2; idect++) { |
875 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi...... | |
876 | UpdatefCountDetAndfCount(idect,2); | |
877 | ReconstructFitRowMinRowMax(idect,2); | |
878 | // Take the histo | |
879 | TH1D *projprf = (TH1D *) prf->ProjectionX("projprf",idect+1,idect+1,(Option_t *) "e"); | |
880 | projprf->SetDirectory(0); | |
881 | // Number of entries for this calibration group | |
882 | Double_t nentries = 0; | |
883 | for (Int_t k = 0; k < nbins; k++) { | |
884 | Int_t binnb = (nbins+2)*(idect+1)+(k+1); | |
885 | nentries += prf->GetBinEntries(binnb); | |
55a288e5 | 886 | } |
3a0f6479 | 887 | if(nentries > 0) fNumberEnt++; |
55a288e5 | 888 | // This detector has not enough statistics or was off |
3a0f6479 | 889 | if (nentries <= fMinEntries) { |
890 | NotEnoughStatisticPRF(idect); | |
891 | if (fDebugLevel != 1) { | |
892 | delete projprf; | |
55a288e5 | 893 | } |
55a288e5 | 894 | continue; |
55a288e5 | 895 | } |
3a0f6479 | 896 | // Statistics of the histos fitted |
55a288e5 | 897 | fNumberFit++; |
3a0f6479 | 898 | fStatisticMean += nentries; |
55a288e5 | 899 | // Calcul of "real" coef |
3a0f6479 | 900 | CalculPRFCoefMean(); |
901 | //Method choosen | |
902 | switch(fMethod) | |
903 | { | |
904 | case 0: FitPRF((TH1 *) projprf); break; | |
905 | case 1: RmsPRF((TH1 *) projprf); break; | |
906 | default: return kFALSE; | |
907 | } | |
55a288e5 | 908 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
3a0f6479 | 909 | FillInfosFitPRF(idect); |
55a288e5 | 910 | // Memory!!! |
3a0f6479 | 911 | if (fDebugLevel != 1) { |
912 | delete projprf; | |
55a288e5 | 913 | } |
55a288e5 | 914 | } // Boucle object |
55a288e5 | 915 | // Mean Statistic |
916 | if (fNumberFit > 0) { | |
917 | AliInfo(Form("There are %d with at least one entries.",fNumberEnt)); | |
918 | AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit)); | |
919 | AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits" | |
920 | ,(Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess)); | |
921 | fStatisticMean = fStatisticMean / fNumberFit; | |
922 | } | |
923 | else { | |
924 | AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt)); | |
925 | } | |
3a0f6479 | 926 | delete fDebugStreamer; |
927 | fDebugStreamer = 0x0; | |
55a288e5 | 928 | return kTRUE; |
55a288e5 | 929 | } |
3a0f6479 | 930 | //____________Functions fit Online PRF2d_______________________________________ |
979b168f | 931 | Bool_t AliTRDCalibraFit::AnalysePRFMarianFit(const TProfile2D *prf) |
55a288e5 | 932 | { |
933 | // | |
3a0f6479 | 934 | // Take the 1D profiles (pad response function), projections of the 2D PRF |
935 | // on the Xaxis, for each calibration group | |
936 | // Fit with a gaussian to reconstruct the sigma of the pad response function | |
55a288e5 | 937 | // |
3a0f6479 | 938 | |
939 | // Set the calibration mode | |
4c865c34 | 940 | //const char *name = prf->GetTitle(); |
941 | TString name = prf->GetTitle(); | |
64942b85 | 942 | if(!SetModeCalibration(name,2)) return kFALSE; |
3a0f6479 | 943 | |
944 | // Number of Ybins (detectors or groups of pads) | |
945 | TAxis *xprf = prf->GetXaxis(); | |
946 | TAxis *yprf = prf->GetYaxis(); | |
947 | Int_t nybins = yprf->GetNbins();// calibration groups | |
948 | Int_t nbins = xprf->GetNbins();// bins | |
949 | Float_t lowedge = (Float_t) xprf->GetBinLowEdge(1);//lowedge in bins | |
950 | Float_t upedge = (Float_t) xprf->GetBinUpEdge(nbins);//upedge in bins | |
951 | Int_t nbg = GetNumberOfGroupsPRF((const char *)name); | |
952 | if(nbg == -1) return kFALSE; | |
953 | if(nbg > 0) fMethod = 1; | |
954 | else fMethod = 0; | |
955 | if (!InitFit(nybins,2)) { | |
55a288e5 | 956 | return kFALSE; |
957 | } | |
3a0f6479 | 958 | if (!InitFitPRF()) { |
55a288e5 | 959 | return kFALSE; |
960 | } | |
961 | fStatisticMean = 0.0; | |
3a0f6479 | 962 | fNumberFit = 0; |
55a288e5 | 963 | fNumberFitSuccess = 0; |
964 | fNumberEnt = 0; | |
55a288e5 | 965 | // Init fCountDet and fCount |
3a0f6479 | 966 | InitfCountDetAndfCount(2); |
55a288e5 | 967 | // Beginning of the loop |
3a0f6479 | 968 | for (Int_t idect = fDect1; idect < fDect2; idect++) { |
969 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi....... | |
970 | UpdatefCountDetAndfCount(idect,2); | |
971 | ReconstructFitRowMinRowMax(idect,2); | |
972 | // Build the array of entries and sum | |
973 | TArrayD arraye = TArrayD(nbins); | |
974 | TArrayD arraym = TArrayD(nbins); | |
975 | TArrayD arrayme = TArrayD(nbins); | |
976 | Double_t nentries = 0; | |
977 | //printf("nbins %d\n",nbins); | |
978 | for (Int_t k = 0; k < nbins; k++) { | |
979 | Int_t binnb = (nbins+2)*(idect+1)+(k+1); | |
980 | Double_t entries = (Double_t)prf->GetBinEntries(binnb); | |
981 | Double_t mean = (Double_t)prf->GetBinContent(binnb); | |
982 | Double_t error = (Double_t)prf->GetBinError(binnb); | |
983 | //printf("for %d we have %f\n",k,entries); | |
984 | nentries += entries; | |
985 | arraye.AddAt(entries,k); | |
986 | arraym.AddAt(mean,k); | |
987 | arrayme.AddAt(error,k); | |
55a288e5 | 988 | } |
3a0f6479 | 989 | if(nentries > 0) fNumberEnt++; |
990 | //printf("The number of entries for the group %d is %f\n",idect,nentries); | |
55a288e5 | 991 | // This detector has not enough statistics or was off |
3a0f6479 | 992 | if (nentries <= fMinEntries) { |
993 | NotEnoughStatisticPRF(idect); | |
55a288e5 | 994 | continue; |
55a288e5 | 995 | } |
55a288e5 | 996 | // Statistics of the histos fitted |
55a288e5 | 997 | fNumberFit++; |
3a0f6479 | 998 | fStatisticMean += nentries; |
55a288e5 | 999 | // Calcul of "real" coef |
3a0f6479 | 1000 | CalculPRFCoefMean(); |
1001 | //Method choosen | |
1002 | switch(fMethod) | |
1003 | { | |
1004 | case 0: FitPRFGausMI( arraye.GetArray(), arraym.GetArray(), arrayme.GetArray(), nbins, lowedge, upedge); break; | |
1005 | case 1: FitTnpRange( arraye.GetArray(), arraym.GetArray(), arrayme.GetArray(), nbg, nbins); break; | |
1006 | default: return kFALSE; | |
1007 | } | |
55a288e5 | 1008 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
3a0f6479 | 1009 | FillInfosFitPRF(idect); |
55a288e5 | 1010 | } // Boucle object |
3a0f6479 | 1011 | // Mean Statistic |
55a288e5 | 1012 | if (fNumberFit > 0) { |
1013 | AliInfo(Form("There are %d with at least one entries.",fNumberEnt)); | |
1014 | AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit)); | |
1015 | AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits" | |
1016 | ,(Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess)); | |
1017 | fStatisticMean = fStatisticMean / fNumberFit; | |
1018 | } | |
1019 | else { | |
1020 | AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt)); | |
1021 | } | |
3a0f6479 | 1022 | delete fDebugStreamer; |
1023 | fDebugStreamer = 0x0; | |
55a288e5 | 1024 | return kTRUE; |
55a288e5 | 1025 | } |
55a288e5 | 1026 | //____________Functions fit Online PRF2d_______________________________________ |
3a0f6479 | 1027 | Bool_t AliTRDCalibraFit::AnalysePRF(AliTRDCalibraVector *calvect) |
55a288e5 | 1028 | { |
1029 | // | |
3a0f6479 | 1030 | // Reconstruct the 1D histo (pad response function) from the vectorPRD for |
1031 | // each calibration group | |
55a288e5 | 1032 | // Fit with a gaussian to reconstruct the sigma of the pad response function |
55a288e5 | 1033 | // |
1034 | ||
3a0f6479 | 1035 | // Set the calibra mode |
4c865c34 | 1036 | //const char *name = calvect->GetNamePRF(); |
1037 | TString name = calvect->GetNamePRF(); | |
64942b85 | 1038 | if(!SetModeCalibration(name,2)) return kFALSE; |
3a0f6479 | 1039 | //printf("test0 %s\n",name); |
55a288e5 | 1040 | |
1041 | // Number of Xbins (detectors or groups of pads) | |
3a0f6479 | 1042 | if (!InitFit((432*calvect->GetDetCha0(2)+108*calvect->GetDetCha2(2)),2)) { |
1043 | //printf("test1\n"); | |
1044 | return kFALSE; | |
1045 | } | |
1046 | if (!InitFitPRF()) { | |
1047 | ///printf("test2\n"); | |
55a288e5 | 1048 | return kFALSE; |
1049 | } | |
1050 | fStatisticMean = 0.0; | |
1051 | fNumberFit = 0; | |
1052 | fNumberFitSuccess = 0; | |
1053 | fNumberEnt = 0; | |
55a288e5 | 1054 | // Init fCountDet and fCount |
1055 | InitfCountDetAndfCount(2); | |
55a288e5 | 1056 | // Beginning of the loop |
3a0f6479 | 1057 | for (Int_t idect = fDect1; idect < fDect2; idect++) { |
1058 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi........ | |
55a288e5 | 1059 | UpdatefCountDetAndfCount(idect,2); |
55a288e5 | 1060 | ReconstructFitRowMinRowMax(idect,2); |
3a0f6479 | 1061 | // Take the histo |
3a0f6479 | 1062 | fEntriesCurrent = 0; |
e526983e | 1063 | if(!calvect->GetPRFEntries(fCountDet)) { |
1064 | NotEnoughStatisticPRF(idect); | |
1065 | continue; | |
3a0f6479 | 1066 | } |
e526983e | 1067 | TString tname("PRF"); |
1068 | tname += idect; | |
1069 | TH1F *projprf = calvect->CorrectTheError((TGraphErrors *) (calvect->ConvertVectorPRFTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname)),fEntriesCurrent); | |
1070 | projprf->SetDirectory(0); | |
1071 | if(fEntriesCurrent > 0) fNumberEnt++; | |
55a288e5 | 1072 | // This detector has not enough statistics or was off |
3a0f6479 | 1073 | if (fEntriesCurrent <= fMinEntries) { |
1074 | NotEnoughStatisticPRF(idect); | |
55a288e5 | 1075 | continue; |
55a288e5 | 1076 | } |
3a0f6479 | 1077 | // Statistic of the histos fitted |
55a288e5 | 1078 | fNumberFit++; |
3a0f6479 | 1079 | fStatisticMean += fEntriesCurrent; |
55a288e5 | 1080 | // Calcul of "real" coef |
3a0f6479 | 1081 | CalculPRFCoefMean(); |
1082 | //Method choosen | |
1083 | switch(fMethod) | |
1084 | { | |
1085 | case 1: FitPRF((TH1 *) projprf); break; | |
1086 | case 2: RmsPRF((TH1 *) projprf); break; | |
1087 | default: return kFALSE; | |
1088 | } | |
55a288e5 | 1089 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
3a0f6479 | 1090 | FillInfosFitPRF(idect); |
55a288e5 | 1091 | } // Boucle object |
3a0f6479 | 1092 | // Mean Statistics |
55a288e5 | 1093 | if (fNumberFit > 0) { |
3a0f6479 | 1094 | AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %d over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess)); |
55a288e5 | 1095 | } |
1096 | else { | |
1097 | AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt)); | |
1098 | } | |
3a0f6479 | 1099 | delete fDebugStreamer; |
1100 | fDebugStreamer = 0x0; | |
55a288e5 | 1101 | return kTRUE; |
55a288e5 | 1102 | } |
55a288e5 | 1103 | //____________Functions fit Online PRF2d_______________________________________ |
3a0f6479 | 1104 | Bool_t AliTRDCalibraFit::AnalysePRFMarianFit(AliTRDCalibraVector *calvect) |
55a288e5 | 1105 | { |
1106 | // | |
1107 | // Reconstruct the 1D histo (pad response function) from the vectorPRD for | |
1108 | // each calibration group | |
1109 | // Fit with a gaussian to reconstruct the sigma of the pad response function | |
55a288e5 | 1110 | // |
1111 | ||
3a0f6479 | 1112 | // Set the calibra mode |
4c865c34 | 1113 | //const char *name = calvect->GetNamePRF(); |
1114 | TString name = calvect->GetNamePRF(); | |
64942b85 | 1115 | if(!SetModeCalibration(name,2)) return kFALSE; |
3a0f6479 | 1116 | //printf("test0 %s\n",name); |
1117 | Int_t nbg = GetNumberOfGroupsPRF((const char *)name); | |
64942b85 | 1118 | //printf("test1 %d\n",nbg); |
3a0f6479 | 1119 | if(nbg == -1) return kFALSE; |
1120 | if(nbg > 0) fMethod = 1; | |
1121 | else fMethod = 0; | |
1122 | // Number of Xbins (detectors or groups of pads) | |
1123 | if (!InitFit((432*calvect->GetDetCha0(2)+108*calvect->GetDetCha2(2)),2)) { | |
1124 | //printf("test2\n"); | |
55a288e5 | 1125 | return kFALSE; |
1126 | } | |
3a0f6479 | 1127 | if (!InitFitPRF()) { |
1128 | //printf("test3\n"); | |
55a288e5 | 1129 | return kFALSE; |
1130 | } | |
1131 | fStatisticMean = 0.0; | |
1132 | fNumberFit = 0; | |
1133 | fNumberFitSuccess = 0; | |
1134 | fNumberEnt = 0; | |
3a0f6479 | 1135 | // Variables |
1136 | Int_t nbins = 0; | |
1137 | Double_t *arrayx = 0; | |
1138 | Double_t *arraye = 0; | |
1139 | Double_t *arraym = 0; | |
1140 | Double_t *arrayme = 0; | |
1141 | Float_t lowedge = 0.0; | |
1142 | Float_t upedge = 0.0; | |
55a288e5 | 1143 | // Init fCountDet and fCount |
1144 | InitfCountDetAndfCount(2); | |
55a288e5 | 1145 | // Beginning of the loop |
3a0f6479 | 1146 | for (Int_t idect = fDect1; idect < fDect2; idect++) { |
1147 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi...... | |
55a288e5 | 1148 | UpdatefCountDetAndfCount(idect,2); |
55a288e5 | 1149 | ReconstructFitRowMinRowMax(idect,2); |
3a0f6479 | 1150 | // Take the histo |
3a0f6479 | 1151 | fEntriesCurrent = 0; |
e526983e | 1152 | if(!calvect->GetPRFEntries(fCountDet)) { |
1153 | NotEnoughStatisticPRF(idect); | |
1154 | continue; | |
3a0f6479 | 1155 | } |
e526983e | 1156 | TString tname("PRF"); |
1157 | tname += idect; | |
1158 | TGraphErrors *projprftree = calvect->ConvertVectorPRFTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname); | |
1159 | nbins = projprftree->GetN(); | |
1160 | arrayx = (Double_t *)projprftree->GetX(); | |
1161 | arraye = (Double_t *)projprftree->GetEX(); | |
1162 | arraym = (Double_t *)projprftree->GetY(); | |
1163 | arrayme = (Double_t *)projprftree->GetEY(); | |
1164 | Float_t step = arrayx[1]-arrayx[0]; | |
1165 | lowedge = arrayx[0] - step/2.0; | |
1166 | upedge = arrayx[(nbins-1)] + step/2.0; | |
1167 | //printf("nbins est %d\n",nbins); | |
1168 | for(Int_t k = 0; k < nbins; k++){ | |
1169 | fEntriesCurrent += (Int_t)arraye[k]; | |
1170 | //printf("for %d we have %f, %f\n",k,arraye[k],((projprftree->GetEX())[k])); | |
1171 | if(arraye[k]>0.0) arrayme[k] = TMath::Sqrt(TMath::Abs(arrayme[k]-arraym[k]*arraym[k])/arraye[k]); | |
1172 | } | |
1173 | if(fEntriesCurrent > 0) fNumberEnt++; | |
3a0f6479 | 1174 | //printf("The number of entries for the group %d is %d\n",idect,fEntriesCurrent); |
1175 | // This detector has not enough statistics or was off | |
1176 | if (fEntriesCurrent <= fMinEntries) { | |
1177 | NotEnoughStatisticPRF(idect); | |
55a288e5 | 1178 | continue; |
55a288e5 | 1179 | } |
55a288e5 | 1180 | // Statistic of the histos fitted |
55a288e5 | 1181 | fNumberFit++; |
1182 | fStatisticMean += fEntriesCurrent; | |
55a288e5 | 1183 | // Calcul of "real" coef |
3a0f6479 | 1184 | CalculPRFCoefMean(); |
1185 | //Method choosen | |
1186 | switch(fMethod) | |
1187 | { | |
1188 | case 0: FitPRFGausMI(arraye,arraym,arrayme,nbins,lowedge,upedge); break; | |
1189 | case 1: FitTnpRange(arraye,arraym,arrayme,nbg,nbins); break; | |
1190 | default: return kFALSE; | |
1191 | } | |
55a288e5 | 1192 | // Fill the tree if end of a detector or only the pointer to the branch!!! |
3a0f6479 | 1193 | FillInfosFitPRF(idect); |
55a288e5 | 1194 | } // Boucle object |
55a288e5 | 1195 | // Mean Statistics |
1196 | if (fNumberFit > 0) { | |
3a0f6479 | 1197 | AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %d over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess)); |
55a288e5 | 1198 | } |
1199 | else { | |
1200 | AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt)); | |
1201 | } | |
3a0f6479 | 1202 | delete fDebugStreamer; |
1203 | fDebugStreamer = 0x0; | |
55a288e5 | 1204 | return kTRUE; |
55a288e5 | 1205 | } |
3a0f6479 | 1206 | //____________Functions fit Online CH2d________________________________________ |
1207 | Bool_t AliTRDCalibraFit::AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *calivdli) | |
55a288e5 | 1208 | { |
1209 | // | |
3a0f6479 | 1210 | // The linear method |
55a288e5 | 1211 | // |
1212 | ||
55a288e5 | 1213 | fStatisticMean = 0.0; |
1214 | fNumberFit = 0; | |
1215 | fNumberFitSuccess = 0; | |
1216 | fNumberEnt = 0; | |
3a0f6479 | 1217 | if(!InitFitLinearFitter()) return kFALSE; |
55a288e5 | 1218 | |
3a0f6479 | 1219 | |
1220 | for(Int_t idet = 0; idet < 540; idet++){ | |
55a288e5 | 1221 | |
55a288e5 | 1222 | |
3a0f6479 | 1223 | //printf("detector number %d\n",idet); |
55a288e5 | 1224 | |
3a0f6479 | 1225 | // Take the result |
1226 | TVectorD param(2); | |
1227 | TVectorD error(3); | |
1228 | fEntriesCurrent = 0; | |
1229 | fCountDet = idet; | |
1230 | Bool_t here = calivdli->GetParam(idet,¶m); | |
1231 | Bool_t heree = calivdli->GetError(idet,&error); | |
1232 | //printf("here %d and heree %d\n",here, heree); | |
1233 | if(heree) { | |
1234 | fEntriesCurrent = (Int_t) error[2]; | |
55a288e5 | 1235 | fNumberEnt++; |
55a288e5 | 1236 | } |
3a0f6479 | 1237 | //printf("Number of entries %d\n",fEntriesCurrent); |
1238 | // Nothing found or not enough statistic | |
1239 | if((!heree) || (!here) || (fEntriesCurrent <= fMinEntries)) { | |
1240 | NotEnoughStatisticLinearFitter(); | |
1241 | continue; | |
1242 | } | |
1243 | //param.Print(); | |
1244 | //error.Print(); | |
1245 | //Statistics | |
1246 | fNumberFit++; | |
1247 | fStatisticMean += fEntriesCurrent; | |
55a288e5 | 1248 | |
3a0f6479 | 1249 | // Check the fit |
1250 | if((-(param[1])) <= 0.0) { | |
1251 | NotEnoughStatisticLinearFitter(); | |
1252 | continue; | |
1253 | } | |
55a288e5 | 1254 | |
3a0f6479 | 1255 | // CalculDatabaseVdriftandTan |
1256 | CalculVdriftLorentzCoef(); | |
840ec79d | 1257 | //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFit detector %d, vdrift %f and %f and exB %f and %f\n",idet,fCalDetVdriftUsed->GetValue(idet),fCurrentCoef[1],fCalDetExBUsed->GetValue(idet),fCurrentCoef2[1]); |
55a288e5 | 1258 | |
3a0f6479 | 1259 | // Statistics |
1260 | fNumberFitSuccess ++; | |
55a288e5 | 1261 | |
3a0f6479 | 1262 | // Put the fCurrentCoef |
1263 | fCurrentCoef[0] = -param[1]; | |
1264 | // here the database must be the one of the reconstruction for the lorentz angle.... | |
1265 | fCurrentCoef2[0] = (param[0]+fCurrentCoef[1]*fCurrentCoef2[1])/fCurrentCoef[0]; | |
1266 | fCurrentCoefE = error[1]; | |
1267 | fCurrentCoefE2 = error[0]; | |
daa7dc79 | 1268 | if((TMath::Abs(fCurrentCoef2[0]) > 0.0000001) && (TMath::Abs(param[0]) > 0.0000001)){ |
3a0f6479 | 1269 | fCurrentCoefE2 = (fCurrentCoefE2/param[0]+fCurrentCoefE/fCurrentCoef[0])*fCurrentCoef2[0]; |
1270 | } | |
55a288e5 | 1271 | |
3a0f6479 | 1272 | // Fill |
1273 | FillInfosFitLinearFitter(); | |
55a288e5 | 1274 | |
55a288e5 | 1275 | |
55a288e5 | 1276 | } |
55a288e5 | 1277 | // Mean Statistics |
1278 | if (fNumberFit > 0) { | |
3a0f6479 | 1279 | AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %d over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess)); |
55a288e5 | 1280 | } |
1281 | else { | |
1282 | AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt)); | |
1283 | } | |
3a0f6479 | 1284 | delete fDebugStreamer; |
1285 | fDebugStreamer = 0x0; | |
55a288e5 | 1286 | return kTRUE; |
1287 | ||
54f2ff1c | 1288 | } |
1289 | //____________Functions fit Online CH2d________________________________________ | |
840ec79d | 1290 | void AliTRDCalibraFit::AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLinearFit *calivdli, Double_t &vdriftoverall, Double_t &exboverall) |
54f2ff1c | 1291 | { |
1292 | // | |
1293 | // The linear method | |
1294 | // | |
1295 | ||
840ec79d | 1296 | // Get the mean vdrift and exb used |
1297 | Double_t meanvdriftused = 0.0; | |
1298 | Double_t meanexbused = 0.0; | |
1299 | Double_t counterdet = 0.0; | |
1300 | if((!fCalDetVdriftUsed) || (!fCalDetExBUsed)) { | |
1301 | vdriftoverall = -100.0; | |
1302 | exboverall = 100.0; | |
1303 | return; | |
1304 | } | |
1305 | ||
54f2ff1c | 1306 | // Add histos |
1307 | ||
1308 | TH2S *linearfitterhisto = 0x0; | |
1309 | ||
1310 | for(Int_t idet = 0; idet < 540; idet++){ | |
1311 | ||
1312 | TH2S * u = calivdli->GetLinearFitterHistoForce(idet); | |
840ec79d | 1313 | Double_t detectorentries = u->Integral(); |
1314 | meanvdriftused += fCalDetVdriftUsed->GetValue(idet)*detectorentries; | |
1315 | meanexbused += fCalDetExBUsed->GetValue(idet)*detectorentries; | |
1316 | counterdet += detectorentries; | |
1317 | ||
1318 | //printf("detectorentries %f\n",detectorentries); | |
1319 | ||
1320 | //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFitsAllTogether detector %d, vdrift %f and exB %f\n",idet,fCalDetVdriftUsed->GetValue(idet),fCalDetExBUsed->GetValue(idet)); | |
1321 | ||
54f2ff1c | 1322 | if(idet == 0) linearfitterhisto = u; |
1323 | else linearfitterhisto->Add(u); | |
1324 | ||
1325 | } | |
840ec79d | 1326 | if(counterdet > 0.0){ |
1327 | meanvdriftused = meanvdriftused/counterdet; | |
1328 | meanexbused = meanexbused/counterdet; | |
1329 | } | |
1330 | else { | |
1331 | vdriftoverall = -100.0; | |
1332 | exboverall = 100.0; | |
1333 | return; | |
1334 | } | |
1335 | ||
1336 | ||
1337 | //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFitsAllTogether MEAN vdrift %f and exB %f\n",meanvdriftused,meanexbused); | |
54f2ff1c | 1338 | |
1339 | // Fit | |
1340 | ||
1341 | Int_t entries = 0; | |
1342 | TAxis *xaxis = linearfitterhisto->GetXaxis(); | |
1343 | TAxis *yaxis = linearfitterhisto->GetYaxis(); | |
1344 | TLinearFitter linearfitter = TLinearFitter(2,"pol1"); | |
1345 | //printf("test\n"); | |
1346 | Double_t integral = linearfitterhisto->Integral(); | |
1347 | //printf("Integral is %f\n",integral); | |
1348 | Bool_t securitybreaking = kFALSE; | |
1349 | if(TMath::Abs(integral-1199) < 0.00001) securitybreaking = kTRUE; | |
1350 | for(Int_t ibinx = 0; ibinx < linearfitterhisto->GetNbinsX(); ibinx++){ | |
1351 | for(Int_t ibiny = 0; ibiny < linearfitterhisto->GetNbinsY(); ibiny++){ | |
1352 | if(linearfitterhisto->GetBinContent(ibinx+1,ibiny+1)>0){ | |
1353 | Double_t x = xaxis->GetBinCenter(ibinx+1); | |
1354 | Double_t y = yaxis->GetBinCenter(ibiny+1); | |
1355 | ||
1356 | for(Int_t k = 0; k < (Int_t)linearfitterhisto->GetBinContent(ibinx+1,ibiny+1); k++){ | |
1357 | if(!securitybreaking){ | |
1358 | linearfitter.AddPoint(&x,y); | |
1359 | entries++; | |
1360 | } | |
1361 | else { | |
1362 | if(entries< 1198){ | |
1363 | linearfitter.AddPoint(&x,y); | |
1364 | entries++; | |
1365 | } | |
1366 | } | |
1367 | } | |
1368 | ||
1369 | } | |
1370 | } | |
1371 | } | |
1372 | ||
b88b6bcc | 1373 | //printf("AnalyseLinearFittersAllTogether::Find %d entries\n",entries); |
1374 | //printf("Minstats %d\n",fMinEntries); | |
54f2ff1c | 1375 | |
840ec79d | 1376 | |
1377 | ||
1378 | // Eval the linear fitter | |
54f2ff1c | 1379 | if(entries > fMinEntries){ |
1380 | TVectorD par = TVectorD(2); | |
1381 | //printf("Fit\n"); | |
1382 | if((linearfitter.EvalRobust(0.8)==0)) { | |
1383 | //printf("Take the param\n"); | |
1384 | linearfitter.GetParameters(par); | |
1385 | //printf("Done\n"); | |
840ec79d | 1386 | //par.Print(); |
54f2ff1c | 1387 | //printf("Finish\n"); |
1388 | // Put the fCurrentCoef | |
1389 | fCurrentCoef[0] = -par[1]; | |
1390 | // here the database must be the one of the reconstruction for the lorentz angle.... | |
840ec79d | 1391 | if(fCurrentCoef[0] > 0.0) fCurrentCoef2[0] = (par[0]+meanvdriftused*meanexbused)/fCurrentCoef[0]; |
1392 | else fCurrentCoef2[0] = 100.0; | |
1393 | ||
1394 | } | |
1395 | else { | |
1396 | ||
1397 | fCurrentCoef[0] = -100.0; | |
1398 | fCurrentCoef2[0] = 100.0; | |
54f2ff1c | 1399 | |
54f2ff1c | 1400 | } |
54f2ff1c | 1401 | |
1402 | ||
1403 | } | |
1404 | else { | |
840ec79d | 1405 | |
1406 | fCurrentCoef[0] = -100.0; | |
1407 | fCurrentCoef2[0] = 100.0; | |
1408 | ||
54f2ff1c | 1409 | } |
1410 | ||
840ec79d | 1411 | vdriftoverall = fCurrentCoef[0]; |
1412 | exboverall = fCurrentCoef2[0]; | |
1413 | ||
1414 | ||
54f2ff1c | 1415 | delete linearfitterhisto; |
1416 | delete fDebugStreamer; | |
1417 | fDebugStreamer = 0x0; | |
1418 | ||
55a288e5 | 1419 | } |
55a288e5 | 1420 | //____________Functions for seeing if the pad is really okey___________________ |
3a0f6479 | 1421 | //_____________________________________________________________________________ |
4c865c34 | 1422 | Int_t AliTRDCalibraFit::GetNumberOfGroupsPRF(TString nametitle) |
3a0f6479 | 1423 | { |
1424 | // | |
1425 | // Get numberofgroupsprf | |
1426 | // | |
1427 | ||
1428 | // Some patterns | |
1429 | const Char_t *pattern0 = "Ngp0"; | |
1430 | const Char_t *pattern1 = "Ngp1"; | |
1431 | const Char_t *pattern2 = "Ngp2"; | |
1432 | const Char_t *pattern3 = "Ngp3"; | |
1433 | const Char_t *pattern4 = "Ngp4"; | |
1434 | const Char_t *pattern5 = "Ngp5"; | |
1435 | const Char_t *pattern6 = "Ngp6"; | |
1436 | ||
1437 | // Nrphi mode | |
4c865c34 | 1438 | if (strstr(nametitle.Data(),pattern0)) { |
3a0f6479 | 1439 | return 0; |
1440 | } | |
4c865c34 | 1441 | if (strstr(nametitle.Data(),pattern1)) { |
3a0f6479 | 1442 | return 1; |
1443 | } | |
4c865c34 | 1444 | if (strstr(nametitle.Data(),pattern2)) { |
3a0f6479 | 1445 | return 2; |
1446 | } | |
4c865c34 | 1447 | if (strstr(nametitle.Data(),pattern3)) { |
3a0f6479 | 1448 | return 3; |
1449 | } | |
4c865c34 | 1450 | if (strstr(nametitle.Data(),pattern4)) { |
3a0f6479 | 1451 | return 4; |
1452 | } | |
4c865c34 | 1453 | if (strstr(nametitle.Data(),pattern5)) { |
3a0f6479 | 1454 | return 5; |
1455 | } | |
4c865c34 | 1456 | if (strstr(nametitle.Data(),pattern6)){ |
3a0f6479 | 1457 | return 6; |
1458 | } | |
1459 | else return -1; | |
1460 | ||
55a288e5 | 1461 | |
3a0f6479 | 1462 | } |
55a288e5 | 1463 | //_____________________________________________________________________________ |
4c865c34 | 1464 | Bool_t AliTRDCalibraFit::SetModeCalibration(TString name, Int_t i) |
55a288e5 | 1465 | { |
1466 | // | |
1467 | // Set fNz[i] and fNrphi[i] of the AliTRDCalibraFit::Instance() | |
3a0f6479 | 1468 | // corresponding to the given name |
55a288e5 | 1469 | // |
1470 | ||
3a0f6479 | 1471 | if(!SetNzFromTObject(name,i)) return kFALSE; |
1472 | if(!SetNrphiFromTObject(name,i)) return kFALSE; | |
1473 | ||
1474 | return kTRUE; | |
55a288e5 | 1475 | |
3a0f6479 | 1476 | } |
1477 | //_____________________________________________________________________________ | |
4c865c34 | 1478 | Bool_t AliTRDCalibraFit::SetNrphiFromTObject(TString name, Int_t i) |
3a0f6479 | 1479 | { |
1480 | // | |
1481 | // Set fNrphi[i] of the AliTRDCalibraFit::Instance() | |
1482 | // corresponding to the given TObject | |
1483 | // | |
1484 | ||
55a288e5 | 1485 | // Some patterns |
55a288e5 | 1486 | const Char_t *patternrphi0 = "Nrphi0"; |
1487 | const Char_t *patternrphi1 = "Nrphi1"; | |
1488 | const Char_t *patternrphi2 = "Nrphi2"; | |
1489 | const Char_t *patternrphi3 = "Nrphi3"; | |
1490 | const Char_t *patternrphi4 = "Nrphi4"; | |
1491 | const Char_t *patternrphi5 = "Nrphi5"; | |
1492 | const Char_t *patternrphi6 = "Nrphi6"; | |
1493 | ||
64942b85 | 1494 | |
1495 | const Char_t *patternrphi10 = "Nrphi10"; | |
1496 | const Char_t *patternrphi100 = "Nrphi100"; | |
1497 | const Char_t *patternz10 = "Nz10"; | |
1498 | const Char_t *patternz100 = "Nz100"; | |
1499 | ||
55a288e5 | 1500 | // Nrphi mode |
4c865c34 | 1501 | if ((strstr(name.Data(),patternrphi100)) && (strstr(name.Data(),patternz100))) { |
64942b85 | 1502 | fCalibraMode->SetAllTogether(i); |
1503 | fNbDet = 540; | |
1504 | if (fDebugLevel > 1) { | |
1505 | AliInfo(Form("fNbDet %d and 100",fNbDet)); | |
1506 | } | |
1507 | return kTRUE; | |
1508 | } | |
4c865c34 | 1509 | if ((strstr(name.Data(),patternrphi10)) && (strstr(name.Data(),patternz10))) { |
64942b85 | 1510 | fCalibraMode->SetPerSuperModule(i); |
1511 | fNbDet = 30; | |
1512 | if (fDebugLevel > 1) { | |
1513 | AliInfo(Form("fNDet %d and 100",fNbDet)); | |
1514 | } | |
1515 | return kTRUE; | |
1516 | } | |
1517 | ||
4c865c34 | 1518 | if (strstr(name.Data(),patternrphi0)) { |
55a288e5 | 1519 | fCalibraMode->SetNrphi(i ,0); |
64942b85 | 1520 | if (fDebugLevel > 1) { |
1521 | AliInfo(Form("fNbDet %d and 0",fNbDet)); | |
1522 | } | |
3a0f6479 | 1523 | return kTRUE; |
55a288e5 | 1524 | } |
4c865c34 | 1525 | if (strstr(name.Data(),patternrphi1)) { |
55a288e5 | 1526 | fCalibraMode->SetNrphi(i, 1); |
64942b85 | 1527 | if (fDebugLevel > 1) { |
1528 | AliInfo(Form("fNbDet %d and 1",fNbDet)); | |
1529 | } | |
3a0f6479 | 1530 | return kTRUE; |
55a288e5 | 1531 | } |
4c865c34 | 1532 | if (strstr(name.Data(),patternrphi2)) { |
55a288e5 | 1533 | fCalibraMode->SetNrphi(i, 2); |
64942b85 | 1534 | if (fDebugLevel > 1) { |
1535 | AliInfo(Form("fNbDet %d and 2",fNbDet)); | |
1536 | } | |
3a0f6479 | 1537 | return kTRUE; |
55a288e5 | 1538 | } |
4c865c34 | 1539 | if (strstr(name.Data(),patternrphi3)) { |
55a288e5 | 1540 | fCalibraMode->SetNrphi(i, 3); |
64942b85 | 1541 | if (fDebugLevel > 1) { |
1542 | AliInfo(Form("fNbDet %d and 3",fNbDet)); | |
1543 | } | |
3a0f6479 | 1544 | return kTRUE; |
55a288e5 | 1545 | } |
4c865c34 | 1546 | if (strstr(name.Data(),patternrphi4)) { |
55a288e5 | 1547 | fCalibraMode->SetNrphi(i, 4); |
64942b85 | 1548 | if (fDebugLevel > 1) { |
1549 | AliInfo(Form("fNbDet %d and 4",fNbDet)); | |
1550 | } | |
3a0f6479 | 1551 | return kTRUE; |
55a288e5 | 1552 | } |
4c865c34 | 1553 | if (strstr(name.Data(),patternrphi5)) { |
55a288e5 | 1554 | fCalibraMode->SetNrphi(i, 5); |
64942b85 | 1555 | if (fDebugLevel > 1) { |
1556 | AliInfo(Form("fNbDet %d and 5",fNbDet)); | |
1557 | } | |
3a0f6479 | 1558 | return kTRUE; |
55a288e5 | 1559 | } |
4c865c34 | 1560 | if (strstr(name.Data(),patternrphi6)) { |
55a288e5 | 1561 | fCalibraMode->SetNrphi(i, 6); |
64942b85 | 1562 | if (fDebugLevel > 1) { |
1563 | AliInfo(Form("fNbDet %d and 6",fNbDet)); | |
1564 | } | |
55a288e5 | 1565 | return kTRUE; |
1566 | } | |
55a288e5 | 1567 | |
64942b85 | 1568 | if (fDebugLevel > 1) { |
1569 | AliInfo(Form("fNbDet %d and rest",fNbDet)); | |
1570 | } | |
3a0f6479 | 1571 | fCalibraMode->SetNrphi(i ,0); |
1572 | return kFALSE; | |
64942b85 | 1573 | |
55a288e5 | 1574 | } |
55a288e5 | 1575 | //_____________________________________________________________________________ |
4c865c34 | 1576 | Bool_t AliTRDCalibraFit::SetNzFromTObject(TString name, Int_t i) |
55a288e5 | 1577 | { |
1578 | // | |
3a0f6479 | 1579 | // Set fNz[i] of the AliTRDCalibraFit::Instance() |
1580 | // corresponding to the given TObject | |
55a288e5 | 1581 | // |
3a0f6479 | 1582 | |
1583 | // Some patterns | |
1584 | const Char_t *patternz0 = "Nz0"; | |
1585 | const Char_t *patternz1 = "Nz1"; | |
1586 | const Char_t *patternz2 = "Nz2"; | |
1587 | const Char_t *patternz3 = "Nz3"; | |
1588 | const Char_t *patternz4 = "Nz4"; | |
64942b85 | 1589 | |
1590 | const Char_t *patternrphi10 = "Nrphi10"; | |
1591 | const Char_t *patternrphi100 = "Nrphi100"; | |
1592 | const Char_t *patternz10 = "Nz10"; | |
1593 | const Char_t *patternz100 = "Nz100"; | |
1594 | ||
4c865c34 | 1595 | if ((strstr(name.Data(),patternrphi100)) && (strstr(name.Data(),patternz100))) { |
64942b85 | 1596 | fCalibraMode->SetAllTogether(i); |
1597 | fNbDet = 540; | |
1598 | if (fDebugLevel > 1) { | |
1599 | AliInfo(Form("fNbDet %d and 100",fNbDet)); | |
1600 | } | |
1601 | return kTRUE; | |
1602 | } | |
4c865c34 | 1603 | if ((strstr(name.Data(),patternrphi10)) && (strstr(name.Data(),patternz10))) { |
64942b85 | 1604 | fCalibraMode->SetPerSuperModule(i); |
1605 | fNbDet = 30; | |
1606 | if (fDebugLevel > 1) { | |
1607 | AliInfo(Form("fNbDet %d and 10",fNbDet)); | |
1608 | } | |
1609 | return kTRUE; | |
1610 | } | |
4c865c34 | 1611 | if (strstr(name.Data(),patternz0)) { |
3a0f6479 | 1612 | fCalibraMode->SetNz(i, 0); |
64942b85 | 1613 | if (fDebugLevel > 1) { |
1614 | AliInfo(Form("fNbDet %d and 0",fNbDet)); | |
1615 | } | |
3a0f6479 | 1616 | return kTRUE; |
55a288e5 | 1617 | } |
4c865c34 | 1618 | if (strstr(name.Data(),patternz1)) { |
3a0f6479 | 1619 | fCalibraMode->SetNz(i ,1); |
64942b85 | 1620 | if (fDebugLevel > 1) { |
1621 | AliInfo(Form("fNbDet %d and 1",fNbDet)); | |
1622 | } | |
3a0f6479 | 1623 | return kTRUE; |
55a288e5 | 1624 | } |
4c865c34 | 1625 | if (strstr(name.Data(),patternz2)) { |
3a0f6479 | 1626 | fCalibraMode->SetNz(i ,2); |
64942b85 | 1627 | if (fDebugLevel > 1) { |
1628 | AliInfo(Form("fNbDet %d and 2",fNbDet)); | |
1629 | } | |
3a0f6479 | 1630 | return kTRUE; |
55a288e5 | 1631 | } |
4c865c34 | 1632 | if (strstr(name.Data(),patternz3)) { |
3a0f6479 | 1633 | fCalibraMode->SetNz(i ,3); |
64942b85 | 1634 | if (fDebugLevel > 1) { |
1635 | AliInfo(Form("fNbDet %d and 3",fNbDet)); | |
1636 | } | |
3a0f6479 | 1637 | return kTRUE; |
55a288e5 | 1638 | } |
4c865c34 | 1639 | if (strstr(name.Data(),patternz4)) { |
3a0f6479 | 1640 | fCalibraMode->SetNz(i ,4); |
64942b85 | 1641 | if (fDebugLevel > 1) { |
1642 | AliInfo(Form("fNbDet %d and 4",fNbDet)); | |
1643 | } | |
3a0f6479 | 1644 | return kTRUE; |
55a288e5 | 1645 | } |
64942b85 | 1646 | |
1647 | if (fDebugLevel > 1) { | |
1648 | AliInfo(Form("fNbDet %d and rest",fNbDet)); | |
1649 | } | |
3a0f6479 | 1650 | fCalibraMode->SetNz(i ,0); |
1651 | return kFALSE; | |
1652 | } | |
64942b85 | 1653 | //______________________________________________________________________ |
6aafa7ea | 1654 | void AliTRDCalibraFit::RemoveOutliers(Int_t type, Bool_t perdetector){ |
1655 | // | |
1656 | // Remove the results too far from the mean value and rms | |
1657 | // type: 0 gain, 1 vdrift | |
1658 | // perdetector | |
1659 | // | |
1660 | ||
1661 | Int_t loop = (Int_t) fVectorFit.GetEntriesFast(); | |
1662 | if(loop != 540) { | |
1663 | AliInfo("The Vector Fit is not complete!"); | |
1664 | return; | |
1665 | } | |
1666 | Int_t detector = -1; | |
1667 | Int_t sector = -1; | |
1668 | Float_t value = 0.0; | |
1669 | ||
1670 | ///////////////////////////////// | |
1671 | // Calculate the mean values | |
1672 | //////////////////////////////// | |
1673 | // Initialisation | |
1674 | //////////////////////// | |
1675 | Double_t meanAll = 0.0; | |
1676 | Double_t rmsAll = 0.0; | |
1677 | Int_t countAll = 0; | |
1678 | //////////// | |
1679 | // compute | |
1680 | //////////// | |
1681 | for (Int_t k = 0; k < loop; k++) { | |
1682 | detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector(); | |
1683 | sector = GetSector(detector); | |
1684 | if(perdetector){ | |
1685 | value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[0]; | |
1686 | if(value > 0.0) { | |
1687 | rmsAll += value*value; | |
1688 | meanAll += value; | |
1689 | countAll++; | |
1690 | } | |
1691 | } | |
1692 | else { | |
1693 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); | |
1694 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
1695 | for (Int_t row = 0; row < rowMax; row++) { | |
1696 | for (Int_t col = 0; col < colMax; col++) { | |
1697 | value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
1698 | if(value > 0.0) { | |
1699 | rmsAll += value*value; | |
1700 | meanAll += value; | |
1701 | countAll++; | |
1702 | } | |
1703 | ||
1704 | } // Col | |
1705 | } // Row | |
1706 | } | |
1707 | } | |
1708 | if(countAll > 0) { | |
1709 | meanAll = meanAll/countAll; | |
1710 | rmsAll = TMath::Sqrt(TMath::Abs(rmsAll/countAll - (meanAll*meanAll))); | |
1711 | } | |
1712 | //printf("RemoveOutliers: meanAll %f and rmsAll %f\n",meanAll,rmsAll); | |
1713 | ///////////////////////////////////////////////// | |
1714 | // Remove outliers | |
1715 | //////////////////////////////////////////////// | |
1716 | Double_t defaultvalue = -1.0; | |
1717 | if(type==1) defaultvalue = -1.5; | |
1718 | for (Int_t k = 0; k < loop; k++) { | |
1719 | detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector(); | |
1720 | sector = GetSector(detector); | |
1721 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); | |
1722 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
1723 | Float_t *coef = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef(); | |
1724 | ||
1725 | // remove the results too far away | |
1726 | for (Int_t row = 0; row < rowMax; row++) { | |
1727 | for (Int_t col = 0; col < colMax; col++) { | |
1728 | value = coef[(Int_t)(col*rowMax+row)]; | |
1729 | if((value > 0.0) && (rmsAll > 0.0) && (TMath::Abs(value-meanAll) > (2*rmsAll))) { | |
1730 | coef[(Int_t)(col*rowMax+row)] = defaultvalue; | |
1731 | } | |
1732 | } // Col | |
1733 | } // Row | |
1734 | } | |
1735 | } | |
1736 | //______________________________________________________________________ | |
1737 | void AliTRDCalibraFit::RemoveOutliers2(Bool_t perdetector){ | |
1738 | // | |
1739 | // Remove the results too far from the mean and rms | |
1740 | // perdetector | |
1741 | // | |
1742 | ||
1743 | Int_t loop = (Int_t) fVectorFit2.GetEntriesFast(); | |
1744 | if(loop != 540) { | |
1745 | AliInfo("The Vector Fit is not complete!"); | |
1746 | return; | |
1747 | } | |
1748 | Int_t detector = -1; | |
1749 | Int_t sector = -1; | |
1750 | Float_t value = 0.0; | |
1751 | ||
1752 | ///////////////////////////////// | |
1753 | // Calculate the mean values | |
1754 | //////////////////////////////// | |
1755 | // Initialisation | |
1756 | //////////////////////// | |
1757 | Double_t meanAll = 0.0; | |
1758 | Double_t rmsAll = 0.0; | |
1759 | Int_t countAll = 0; | |
1760 | ///////////// | |
1761 | // compute | |
1762 | //////////// | |
1763 | for (Int_t k = 0; k < loop; k++) { | |
1764 | detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector(); | |
1765 | sector = GetSector(detector); | |
1766 | if(perdetector){ | |
1767 | value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[0]; | |
1768 | if(value < 70.0) { | |
1769 | meanAll += value; | |
1770 | rmsAll += value*value; | |
1771 | countAll++; | |
1772 | } | |
1773 | } | |
1774 | else { | |
1775 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); | |
1776 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
1777 | for (Int_t row = 0; row < rowMax; row++) { | |
1778 | for (Int_t col = 0; col < colMax; col++) { | |
1779 | value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
1780 | if(value < 70.0) { | |
1781 | rmsAll += value*value; | |
1782 | meanAll += value; | |
1783 | countAll++; | |
1784 | } | |
1785 | } // Col | |
1786 | } // Row | |
1787 | } | |
1788 | } | |
1789 | if(countAll > 0) { | |
1790 | meanAll = meanAll/countAll; | |
1791 | rmsAll = TMath::Sqrt(TMath::Abs(rmsAll/countAll - (meanAll*meanAll))); | |
1792 | } | |
1793 | //printf("Remove outliers 2: meanAll %f, rmsAll %f\n",meanAll,rmsAll); | |
1794 | ///////////////////////////////////////////////// | |
1795 | // Remove outliers | |
1796 | //////////////////////////////////////////////// | |
1797 | for (Int_t k = 0; k < loop; k++) { | |
1798 | detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector(); | |
1799 | sector = GetSector(detector); | |
1800 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); | |
1801 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
1802 | Float_t *coef = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef(); | |
1803 | ||
1804 | // remove the results too far away | |
1805 | for (Int_t row = 0; row < rowMax; row++) { | |
1806 | for (Int_t col = 0; col < colMax; col++) { | |
1807 | value = coef[(Int_t)(col*rowMax+row)]; | |
b88b6bcc | 1808 | if((value < 70.0) && (rmsAll > 0.0) && (TMath::Abs(value-meanAll) > (2.5*rmsAll))) { |
1809 | //printf("value outlier %f\n",value); | |
1810 | coef[(Int_t)(col*rowMax+row)] = 100.0; | |
1811 | } | |
6aafa7ea | 1812 | } // Col |
1813 | } // Row | |
1814 | } | |
1815 | } | |
1816 | //______________________________________________________________________ | |
64942b85 | 1817 | void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetector){ |
1818 | // | |
1819 | // ofwhat is equaled to 0: mean value of all passing detectors | |
1820 | // ofwhat is equaled to 1: mean value of the detector, otherwise supermodule, otherwise all | |
1821 | // | |
1822 | ||
1823 | Int_t loop = (Int_t) fVectorFit.GetEntriesFast(); | |
1824 | if(loop != 540) { | |
1825 | AliInfo("The Vector Fit is not complete!"); | |
1826 | return; | |
1827 | } | |
1828 | Int_t detector = -1; | |
1829 | Int_t sector = -1; | |
1830 | Float_t value = 0.0; | |
1831 | ||
1832 | ///////////////////////////////// | |
1833 | // Calculate the mean values | |
1834 | //////////////////////////////// | |
1835 | // Initialisation | |
1836 | //////////////////////// | |
1837 | Double_t meanAll = 0.0; | |
1838 | Double_t meanSupermodule[18]; | |
1839 | Double_t meanDetector[540]; | |
6aafa7ea | 1840 | Double_t rmsAll = 0.0; |
1841 | Double_t rmsSupermodule[18]; | |
1842 | Double_t rmsDetector[540]; | |
64942b85 | 1843 | Int_t countAll = 0; |
1844 | Int_t countSupermodule[18]; | |
1845 | Int_t countDetector[540]; | |
1846 | for(Int_t sm = 0; sm < 18; sm++){ | |
6aafa7ea | 1847 | rmsSupermodule[sm] = 0.0; |
64942b85 | 1848 | meanSupermodule[sm] = 0.0; |
1849 | countSupermodule[sm] = 0; | |
1850 | } | |
1851 | for(Int_t det = 0; det < 540; det++){ | |
6aafa7ea | 1852 | rmsDetector[det] = 0.0; |
64942b85 | 1853 | meanDetector[det] = 0.0; |
1854 | countDetector[det] = 0; | |
1855 | } | |
6aafa7ea | 1856 | //////////// |
64942b85 | 1857 | // compute |
1858 | //////////// | |
1859 | for (Int_t k = 0; k < loop; k++) { | |
1860 | detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector(); | |
1861 | sector = GetSector(detector); | |
1862 | if(perdetector){ | |
1863 | value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[0]; | |
1864 | if(value > 0.0) { | |
6aafa7ea | 1865 | rmsDetector[detector] += value*value; |
64942b85 | 1866 | meanDetector[detector] += value; |
1867 | countDetector[detector]++; | |
6aafa7ea | 1868 | rmsSupermodule[sector] += value*value; |
64942b85 | 1869 | meanSupermodule[sector] += value; |
1870 | countSupermodule[sector]++; | |
6aafa7ea | 1871 | rmsAll += value*value; |
64942b85 | 1872 | meanAll += value; |
1873 | countAll++; | |
1874 | } | |
1875 | } | |
1876 | else { | |
1877 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); | |
1878 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
1879 | for (Int_t row = 0; row < rowMax; row++) { | |
1880 | for (Int_t col = 0; col < colMax; col++) { | |
1881 | value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
1882 | if(value > 0.0) { | |
6aafa7ea | 1883 | rmsDetector[detector] += value*value; |
64942b85 | 1884 | meanDetector[detector] += value; |
1885 | countDetector[detector]++; | |
6aafa7ea | 1886 | rmsSupermodule[sector] += value*value; |
64942b85 | 1887 | meanSupermodule[sector] += value; |
1888 | countSupermodule[sector]++; | |
6aafa7ea | 1889 | rmsAll += value*value; |
64942b85 | 1890 | meanAll += value; |
1891 | countAll++; | |
1892 | } | |
1893 | ||
1894 | } // Col | |
1895 | } // Row | |
1896 | } | |
1897 | } | |
6aafa7ea | 1898 | if(countAll > 0) { |
1899 | meanAll = meanAll/countAll; | |
1900 | rmsAll = TMath::Abs(rmsAll/countAll - (meanAll*meanAll)); | |
1901 | } | |
64942b85 | 1902 | for(Int_t sm = 0; sm < 18; sm++){ |
6aafa7ea | 1903 | if(countSupermodule[sm] > 0) { |
1904 | meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm]; | |
1905 | rmsSupermodule[sm] = TMath::Abs(rmsSupermodule[sm]/countSupermodule[sm] - (meanSupermodule[sm]*meanSupermodule[sm])); | |
1906 | } | |
64942b85 | 1907 | } |
1908 | for(Int_t det = 0; det < 540; det++){ | |
6aafa7ea | 1909 | if(countDetector[det] > 0) { |
1910 | meanDetector[det] = meanDetector[det]/countDetector[det]; | |
1911 | rmsDetector[det] = TMath::Abs(rmsDetector[det]/countDetector[det] - (meanDetector[det]*meanDetector[det])); | |
1912 | } | |
64942b85 | 1913 | } |
6aafa7ea | 1914 | //printf("Put mean value, meanAll %f, rmsAll %f\n",meanAll,rmsAll); |
1915 | /////////////////////////////////////////////// | |
64942b85 | 1916 | // Put the mean value for the no-fitted |
1917 | ///////////////////////////////////////////// | |
1918 | for (Int_t k = 0; k < loop; k++) { | |
1919 | detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector(); | |
1920 | sector = GetSector(detector); | |
1921 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); | |
1922 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
1923 | Float_t *coef = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef(); | |
1924 | ||
1925 | for (Int_t row = 0; row < rowMax; row++) { | |
1926 | for (Int_t col = 0; col < colMax; col++) { | |
1927 | value = coef[(Int_t)(col*rowMax+row)]; | |
1928 | if(value < 0.0) { | |
6aafa7ea | 1929 | if((ofwhat == 0) && (meanAll > 0.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll); |
64942b85 | 1930 | if(ofwhat == 1){ |
6aafa7ea | 1931 | if((meanDetector[detector] > 0.0) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanDetector[detector]); |
1932 | else if((meanSupermodule[sector] > 0.0) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanSupermodule[sector]); | |
1933 | else if((meanAll > 0.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll); | |
64942b85 | 1934 | } |
1935 | } | |
1936 | // Debug | |
1937 | if(fDebugLevel > 1){ | |
1938 | ||
1939 | if ( !fDebugStreamer ) { | |
1940 | //debug stream | |
1941 | TDirectory *backup = gDirectory; | |
1942 | fDebugStreamer = new TTreeSRedirector("TRDDebugFit.root"); | |
1943 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer | |
1944 | } | |
1945 | ||
1946 | Float_t coefnow = coef[(Int_t)(col*rowMax+row)]; | |
1947 | ||
1948 | (* fDebugStreamer) << "PutMeanValueOtherVectorFit"<< | |
1949 | "detector="<<detector<< | |
1950 | "sector="<<sector<< | |
1951 | "row="<<row<< | |
1952 | "col="<<col<< | |
1953 | "before="<<value<< | |
1954 | "after="<<coefnow<< | |
1955 | "\n"; | |
1956 | } | |
1957 | } // Col | |
1958 | } // Row | |
1959 | } | |
64942b85 | 1960 | } |
1961 | //______________________________________________________________________ | |
1962 | void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetector){ | |
1963 | // | |
1964 | // ofwhat is equaled to 0: mean value of all passing detectors | |
1965 | // ofwhat is equaled to 1: mean value of the detector, otherwise supermodule, otherwise all | |
1966 | // | |
1967 | ||
1968 | Int_t loop = (Int_t) fVectorFit2.GetEntriesFast(); | |
1969 | if(loop != 540) { | |
1970 | AliInfo("The Vector Fit is not complete!"); | |
1971 | return; | |
1972 | } | |
1973 | Int_t detector = -1; | |
1974 | Int_t sector = -1; | |
1975 | Float_t value = 0.0; | |
1976 | ||
1977 | ///////////////////////////////// | |
1978 | // Calculate the mean values | |
1979 | //////////////////////////////// | |
1980 | // Initialisation | |
1981 | //////////////////////// | |
1982 | Double_t meanAll = 0.0; | |
6aafa7ea | 1983 | Double_t rmsAll = 0.0; |
64942b85 | 1984 | Double_t meanSupermodule[18]; |
6aafa7ea | 1985 | Double_t rmsSupermodule[18]; |
64942b85 | 1986 | Double_t meanDetector[540]; |
6aafa7ea | 1987 | Double_t rmsDetector[540]; |
64942b85 | 1988 | Int_t countAll = 0; |
1989 | Int_t countSupermodule[18]; | |
1990 | Int_t countDetector[540]; | |
1991 | for(Int_t sm = 0; sm < 18; sm++){ | |
6aafa7ea | 1992 | rmsSupermodule[sm] = 0.0; |
64942b85 | 1993 | meanSupermodule[sm] = 0.0; |
1994 | countSupermodule[sm] = 0; | |
1995 | } | |
1996 | for(Int_t det = 0; det < 540; det++){ | |
6aafa7ea | 1997 | rmsDetector[det] = 0.0; |
64942b85 | 1998 | meanDetector[det] = 0.0; |
1999 | countDetector[det] = 0; | |
2000 | } | |
2001 | // compute | |
2002 | //////////// | |
2003 | for (Int_t k = 0; k < loop; k++) { | |
2004 | detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector(); | |
2005 | sector = GetSector(detector); | |
2006 | if(perdetector){ | |
2007 | value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[0]; | |
2008 | if(value < 70.0) { | |
6aafa7ea | 2009 | rmsDetector[detector] += value*value; |
64942b85 | 2010 | meanDetector[detector] += value; |
2011 | countDetector[detector]++; | |
6aafa7ea | 2012 | rmsSupermodule[sector] += value*value; |
64942b85 | 2013 | meanSupermodule[sector] += value; |
2014 | countSupermodule[sector]++; | |
2015 | meanAll += value; | |
6aafa7ea | 2016 | rmsAll += value*value; |
64942b85 | 2017 | countAll++; |
2018 | } | |
2019 | } | |
2020 | else { | |
2021 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); | |
2022 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
2023 | for (Int_t row = 0; row < rowMax; row++) { | |
2024 | for (Int_t col = 0; col < colMax; col++) { | |
2025 | value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
2026 | if(value < 70.0) { | |
6aafa7ea | 2027 | rmsDetector[detector] += value*value; |
64942b85 | 2028 | meanDetector[detector] += value; |
2029 | countDetector[detector]++; | |
6aafa7ea | 2030 | rmsSupermodule[sector] += value*value; |
64942b85 | 2031 | meanSupermodule[sector] += value; |
2032 | countSupermodule[sector]++; | |
6aafa7ea | 2033 | rmsAll += value*value; |
64942b85 | 2034 | meanAll += value; |
2035 | countAll++; | |
2036 | } | |
2037 | ||
2038 | } // Col | |
2039 | } // Row | |
2040 | } | |
2041 | } | |
6aafa7ea | 2042 | if(countAll > 0) { |
2043 | meanAll = meanAll/countAll; | |
2044 | rmsAll = TMath::Abs(rmsAll/countAll - (meanAll*meanAll)); | |
2045 | } | |
64942b85 | 2046 | for(Int_t sm = 0; sm < 18; sm++){ |
6aafa7ea | 2047 | if(countSupermodule[sm] > 0) { |
2048 | meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm]; | |
2049 | rmsSupermodule[sm] = TMath::Abs(rmsSupermodule[sm]/countSupermodule[sm] - (meanSupermodule[sm]*meanSupermodule[sm])); | |
2050 | } | |
64942b85 | 2051 | } |
2052 | for(Int_t det = 0; det < 540; det++){ | |
6aafa7ea | 2053 | if(countDetector[det] > 0) { |
2054 | meanDetector[det] = meanDetector[det]/countDetector[det]; | |
2055 | rmsDetector[det] = TMath::Abs(rmsDetector[det]/countDetector[det] - (meanDetector[det]*meanDetector[det])); | |
2056 | } | |
64942b85 | 2057 | } |
6aafa7ea | 2058 | //printf("Put mean value 2: meanAll %f, rmsAll %f\n",meanAll,rmsAll); |
2059 | //////////////////////////////////////////// | |
64942b85 | 2060 | // Put the mean value for the no-fitted |
2061 | ///////////////////////////////////////////// | |
2062 | for (Int_t k = 0; k < loop; k++) { | |
2063 | detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector(); | |
2064 | sector = GetSector(detector); | |
2065 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); | |
2066 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
2067 | Float_t *coef = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef(); | |
2068 | ||
2069 | for (Int_t row = 0; row < rowMax; row++) { | |
2070 | for (Int_t col = 0; col < colMax; col++) { | |
2071 | value = coef[(Int_t)(col*rowMax+row)]; | |
2072 | if(value > 70.0) { | |
840ec79d | 2073 | if((ofwhat == 0) && (meanAll > -3.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0; |
64942b85 | 2074 | if(ofwhat == 1){ |
840ec79d | 2075 | if((meanDetector[detector] > -3.0) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = meanDetector[detector]+100.0; |
2076 | else if((meanSupermodule[sector] > -3.0) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = meanSupermodule[sector]+100.0; | |
2077 | else if((meanAll > -3.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0; | |
64942b85 | 2078 | } |
2079 | } | |
2080 | // Debug | |
2081 | if(fDebugLevel > 1){ | |
2082 | ||
2083 | if ( !fDebugStreamer ) { | |
2084 | //debug stream | |
2085 | TDirectory *backup = gDirectory; | |
2086 | fDebugStreamer = new TTreeSRedirector("TRDDebugFit.root"); | |
2087 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer | |
2088 | } | |
2089 | ||
2090 | Float_t coefnow = coef[(Int_t)(col*rowMax+row)]; | |
2091 | ||
2092 | (* fDebugStreamer) << "PutMeanValueOtherVectorFit2"<< | |
2093 | "detector="<<detector<< | |
2094 | "sector="<<sector<< | |
2095 | "row="<<row<< | |
2096 | "col="<<col<< | |
2097 | "before="<<value<< | |
2098 | "after="<<coefnow<< | |
2099 | "\n"; | |
2100 | } | |
2101 | } // Col | |
2102 | } // Row | |
2103 | } | |
2104 | ||
2105 | } | |
3a0f6479 | 2106 | //_____________________________________________________________________________ |
979b168f | 2107 | AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectVdrift(const TObjArray *vectorFit, Bool_t perdetector) |
3a0f6479 | 2108 | { |
2109 | // | |
2110 | // It creates the AliTRDCalDet object from the AliTRDFitInfo | |
2111 | // It takes the mean value of the coefficients per detector | |
2112 | // This object has to be written in the database | |
2113 | // | |
55a288e5 | 2114 | |
3a0f6479 | 2115 | // Create the DetObject |
2116 | AliTRDCalDet *object = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)"); | |
2117 | ||
2118 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); | |
2119 | if(loop != 540) AliInfo("The Vector Fit is not complete!"); | |
2120 | Int_t detector = -1; | |
2121 | Float_t value = 0.0; | |
64942b85 | 2122 | |
2123 | // | |
3a0f6479 | 2124 | for (Int_t k = 0; k < loop; k++) { |
2125 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2126 | Float_t mean = 0.0; | |
2127 | if(perdetector){ | |
2128 | mean = TMath::Abs(((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0]); | |
55a288e5 | 2129 | } |
2130 | else { | |
3a0f6479 | 2131 | Int_t count = 0; |
053767a4 | 2132 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); |
2133 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
3a0f6479 | 2134 | for (Int_t row = 0; row < rowMax; row++) { |
2135 | for (Int_t col = 0; col < colMax; col++) { | |
2136 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
2137 | mean += TMath::Abs(value); | |
2138 | count++; | |
2139 | } // Col | |
2140 | } // Row | |
2141 | if(count > 0) mean = mean/count; | |
55a288e5 | 2142 | } |
2143 | object->SetValue(detector,mean); | |
2144 | } | |
3a0f6479 | 2145 | |
55a288e5 | 2146 | return object; |
55a288e5 | 2147 | } |
55a288e5 | 2148 | //_____________________________________________________________________________ |
979b168f | 2149 | AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectGain(const TObjArray *vectorFit, Bool_t meanOtherBefore, Double_t scaleFitFactor, Bool_t perdetector) |
55a288e5 | 2150 | { |
2151 | // | |
3a0f6479 | 2152 | // It creates the AliTRDCalDet object from the AliTRDFitInfo |
2153 | // It takes the mean value of the coefficients per detector | |
55a288e5 | 2154 | // This object has to be written in the database |
2155 | // | |
2156 | ||
2157 | // Create the DetObject | |
3a0f6479 | 2158 | AliTRDCalDet *object = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)"); |
55a288e5 | 2159 | |
54f2ff1c | 2160 | fScaleGain = scaleFitFactor; |
3a0f6479 | 2161 | |
2162 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); | |
2163 | if(loop != 540) AliInfo("The Vector Fit is not complete!"); | |
2164 | Int_t detector = -1; | |
2165 | Float_t value = 0.0; | |
2166 | ||
2167 | for (Int_t k = 0; k < loop; k++) { | |
2168 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2169 | Float_t mean = 0.0; | |
2170 | if(perdetector){ | |
2171 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0]; | |
64942b85 | 2172 | if(!meanOtherBefore){ |
2173 | if(value > 0) value = value*scaleFitFactor; | |
2174 | } | |
2175 | else value = value*scaleFitFactor; | |
3a0f6479 | 2176 | mean = TMath::Abs(value); |
2177 | } | |
2178 | else{ | |
2179 | Int_t count = 0; | |
053767a4 | 2180 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); |
2181 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
3a0f6479 | 2182 | for (Int_t row = 0; row < rowMax; row++) { |
2183 | for (Int_t col = 0; col < colMax; col++) { | |
2184 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
64942b85 | 2185 | if(!meanOtherBefore) { |
2186 | if(value > 0) value = value*scaleFitFactor; | |
2187 | } | |
2188 | else value = value*scaleFitFactor; | |
3a0f6479 | 2189 | mean += TMath::Abs(value); |
2190 | count++; | |
2191 | } // Col | |
2192 | } // Row | |
2193 | if(count > 0) mean = mean/count; | |
2194 | } | |
ba1aa7a7 | 2195 | if(mean < 0.1) mean = 0.1; |
3a0f6479 | 2196 | object->SetValue(detector,mean); |
55a288e5 | 2197 | } |
3a0f6479 | 2198 | |
2199 | return object; | |
2200 | } | |
2201 | //_____________________________________________________________________________ | |
979b168f | 2202 | AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectT0(const TObjArray *vectorFit, Bool_t perdetector) |
3a0f6479 | 2203 | { |
2204 | // | |
2205 | // It creates the AliTRDCalDet object from the AliTRDFitInfo2 | |
2206 | // It takes the min value of the coefficients per detector | |
2207 | // This object has to be written in the database | |
2208 | // | |
55a288e5 | 2209 | |
3a0f6479 | 2210 | // Create the DetObject |
2211 | AliTRDCalDet *object = new AliTRDCalDet("ChamberT0","T0 (detector value)"); | |
55a288e5 | 2212 | |
3a0f6479 | 2213 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); |
2214 | if(loop != 540) AliInfo("The Vector Fit is not complete!"); | |
2215 | Int_t detector = -1; | |
2216 | Float_t value = 0.0; | |
2217 | ||
2218 | for (Int_t k = 0; k < loop; k++) { | |
2219 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2220 | Float_t min = 100.0; | |
2221 | if(perdetector){ | |
64942b85 | 2222 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0]; |
b88b6bcc | 2223 | //printf("Create det object %f for %d\n",value,k); |
64942b85 | 2224 | // check successful |
2225 | if(value > 70.0) value = value-100.0; | |
2226 | // | |
2227 | min = value; | |
55a288e5 | 2228 | } |
3a0f6479 | 2229 | else{ |
053767a4 | 2230 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); |
2231 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
3a0f6479 | 2232 | for (Int_t row = 0; row < rowMax; row++) { |
2233 | for (Int_t col = 0; col < colMax; col++) { | |
2234 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
64942b85 | 2235 | // check successful |
2236 | if(value > 70.0) value = value-100.0; | |
2237 | // | |
3a0f6479 | 2238 | if(min > value) min = value; |
2239 | } // Col | |
2240 | } // Row | |
2241 | } | |
2242 | object->SetValue(detector,min); | |
55a288e5 | 2243 | } |
2244 | ||
2245 | return object; | |
2246 | ||
2247 | } | |
55a288e5 | 2248 | //_____________________________________________________________________________ |
979b168f | 2249 | AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectLorentzAngle(const TObjArray *vectorFit) |
55a288e5 | 2250 | { |
2251 | // | |
3a0f6479 | 2252 | // It creates the AliTRDCalDet object from the AliTRDFitInfo2 |
2253 | // It takes the min value of the coefficients per detector | |
55a288e5 | 2254 | // This object has to be written in the database |
2255 | // | |
2256 | ||
2257 | // Create the DetObject | |
3a0f6479 | 2258 | AliTRDCalDet *object = new AliTRDCalDet("tan(lorentzangle)","tan(lorentzangle) (detector value)"); |
2259 | ||
2260 | ||
2261 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); | |
2262 | if(loop != 540) AliInfo("The Vector Fit is not complete!"); | |
2263 | Int_t detector = -1; | |
2264 | Float_t value = 0.0; | |
55a288e5 | 2265 | |
3a0f6479 | 2266 | for (Int_t k = 0; k < loop; k++) { |
2267 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2268 | /* | |
053767a4 | 2269 | Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); |
2270 | Int_t colMax = fGeo->GetColMax(GetLayer(detector)); | |
3a0f6479 | 2271 | Float_t min = 100.0; |
2272 | for (Int_t row = 0; row < rowMax; row++) { | |
2273 | for (Int_t col = 0; col < colMax; col++) { | |
2274 | value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
2275 | mean += -TMath::Abs(value); | |
2276 | count++; | |
55a288e5 | 2277 | } // Col |
3a0f6479 | 2278 | } // Row |
2279 | if(count > 0) mean = mean/count; | |
2280 | */ | |
2281 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0]; | |
840ec79d | 2282 | if(value > 70.0) value = value-100.0; |
2283 | object->SetValue(detector,value); | |
55a288e5 | 2284 | } |
2285 | ||
2286 | return object; | |
3a0f6479 | 2287 | |
55a288e5 | 2288 | } |
55a288e5 | 2289 | //_____________________________________________________________________________ |
979b168f | 2290 | TObject *AliTRDCalibraFit::CreatePadObjectGain(const TObjArray *vectorFit, Double_t scaleFitFactor, const AliTRDCalDet *detobject) |
3a0f6479 | 2291 | { |
55a288e5 | 2292 | // |
3a0f6479 | 2293 | // It Creates the AliTRDCalPad object from AliTRDFitInfo |
2294 | // You need first to create the object for the detectors, | |
2295 | // where the mean value is put. | |
2296 | // This object has to be written in the database | |
55a288e5 | 2297 | // |
3a0f6479 | 2298 | |
2299 | // Create the DetObject | |
2300 | AliTRDCalPad *object = new AliTRDCalPad("GainFactor","GainFactor (local variations)"); | |
2301 | ||
2302 | if(!vectorFit){ | |
2303 | for(Int_t k = 0; k < 540; k++){ | |
2304 | AliTRDCalROC *calROC = object->GetCalROC(k); | |
2305 | Int_t nchannels = calROC->GetNchannels(); | |
2306 | for(Int_t ch = 0; ch < nchannels; ch++){ | |
2307 | calROC->SetValue(ch,1.0); | |
2308 | } | |
2309 | } | |
55a288e5 | 2310 | } |
3a0f6479 | 2311 | else{ |
2312 | ||
2313 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); | |
2314 | if(loop != 540) AliInfo("The Vector Fit is not complete!"); | |
2315 | Int_t detector = -1; | |
2316 | Float_t value = 0.0; | |
2317 | ||
2318 | for (Int_t k = 0; k < loop; k++) { | |
2319 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2320 | AliTRDCalROC *calROC = object->GetCalROC(detector); | |
2321 | Float_t mean = detobject->GetValue(detector); | |
daa7dc79 | 2322 | if(TMath::Abs(mean) <= 0.0000000001) continue; |
3a0f6479 | 2323 | Int_t rowMax = calROC->GetNrows(); |
2324 | Int_t colMax = calROC->GetNcols(); | |
2325 | for (Int_t row = 0; row < rowMax; row++) { | |
2326 | for (Int_t col = 0; col < colMax; col++) { | |
2327 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
2328 | if(value > 0) value = value*scaleFitFactor; | |
2329 | calROC->SetValue(col,row,TMath::Abs(value)/mean); | |
2330 | } // Col | |
2331 | } // Row | |
2332 | } | |
55a288e5 | 2333 | } |
2334 | ||
3a0f6479 | 2335 | return object; |
55a288e5 | 2336 | } |
55a288e5 | 2337 | //_____________________________________________________________________________ |
979b168f | 2338 | TObject *AliTRDCalibraFit::CreatePadObjectVdrift(const TObjArray *vectorFit, const AliTRDCalDet *detobject) |
3a0f6479 | 2339 | { |
55a288e5 | 2340 | // |
3a0f6479 | 2341 | // It Creates the AliTRDCalPad object from AliTRDFitInfo |
2342 | // You need first to create the object for the detectors, | |
2343 | // where the mean value is put. | |
2344 | // This object has to be written in the database | |
55a288e5 | 2345 | // |
2346 | ||
3a0f6479 | 2347 | // Create the DetObject |
2348 | AliTRDCalPad *object = new AliTRDCalPad("LocalVdrift","TRD drift velocities (local variations)"); | |
2349 | ||
2350 | if(!vectorFit){ | |
2351 | for(Int_t k = 0; k < 540; k++){ | |
2352 | AliTRDCalROC *calROC = object->GetCalROC(k); | |
2353 | Int_t nchannels = calROC->GetNchannels(); | |
2354 | for(Int_t ch = 0; ch < nchannels; ch++){ | |
2355 | calROC->SetValue(ch,1.0); | |
2356 | } | |
2357 | } | |
55a288e5 | 2358 | } |
2359 | else { | |
3a0f6479 | 2360 | |
2361 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); | |
2362 | if(loop != 540) AliInfo("The Vector Fit is not complete!"); | |
2363 | Int_t detector = -1; | |
2364 | Float_t value = 0.0; | |
2365 | ||
2366 | for (Int_t k = 0; k < loop; k++) { | |
2367 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2368 | AliTRDCalROC *calROC = object->GetCalROC(detector); | |
2369 | Float_t mean = detobject->GetValue(detector); | |
2370 | if(mean == 0) continue; | |
2371 | Int_t rowMax = calROC->GetNrows(); | |
2372 | Int_t colMax = calROC->GetNcols(); | |
2373 | for (Int_t row = 0; row < rowMax; row++) { | |
2374 | for (Int_t col = 0; col < colMax; col++) { | |
2375 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
2376 | calROC->SetValue(col,row,TMath::Abs(value)/mean); | |
2377 | } // Col | |
2378 | } // Row | |
2379 | } | |
55a288e5 | 2380 | } |
3a0f6479 | 2381 | return object; |
55a288e5 | 2382 | |
2383 | } | |
55a288e5 | 2384 | //_____________________________________________________________________________ |
979b168f | 2385 | TObject *AliTRDCalibraFit::CreatePadObjectT0(const TObjArray *vectorFit, const AliTRDCalDet *detobject) |
3a0f6479 | 2386 | { |
55a288e5 | 2387 | // |
3a0f6479 | 2388 | // It Creates the AliTRDCalPad object from AliTRDFitInfo2 |
2389 | // You need first to create the object for the detectors, | |
2390 | // where the mean value is put. | |
2391 | // This object has to be written in the database | |
55a288e5 | 2392 | // |
3a0f6479 | 2393 | |
2394 | // Create the DetObject | |
2395 | AliTRDCalPad *object = new AliTRDCalPad("LocalT0","T0 (local variations)"); | |
2396 | ||
2397 | if(!vectorFit){ | |
2398 | for(Int_t k = 0; k < 540; k++){ | |
2399 | AliTRDCalROC *calROC = object->GetCalROC(k); | |
2400 | Int_t nchannels = calROC->GetNchannels(); | |
2401 | for(Int_t ch = 0; ch < nchannels; ch++){ | |
2402 | calROC->SetValue(ch,0.0); | |
2403 | } | |
2404 | } | |
55a288e5 | 2405 | } |
2406 | else { | |
3a0f6479 | 2407 | |
2408 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); | |
2409 | if(loop != 540) AliInfo("The Vector Fit is not complete!"); | |
2410 | Int_t detector = -1; | |
2411 | Float_t value = 0.0; | |
2412 | ||
2413 | for (Int_t k = 0; k < loop; k++) { | |
2414 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2415 | AliTRDCalROC *calROC = object->GetCalROC(detector); | |
2416 | Float_t min = detobject->GetValue(detector); | |
2417 | Int_t rowMax = calROC->GetNrows(); | |
2418 | Int_t colMax = calROC->GetNcols(); | |
2419 | for (Int_t row = 0; row < rowMax; row++) { | |
2420 | for (Int_t col = 0; col < colMax; col++) { | |
2421 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
64942b85 | 2422 | // check successful |
2423 | if(value > 70.0) value = value - 100.0; | |
2424 | // | |
3a0f6479 | 2425 | calROC->SetValue(col,row,value-min); |
2426 | } // Col | |
2427 | } // Row | |
2428 | } | |
55a288e5 | 2429 | } |
3a0f6479 | 2430 | return object; |
55a288e5 | 2431 | |
2432 | } | |
3a0f6479 | 2433 | //_____________________________________________________________________________ |
979b168f | 2434 | TObject *AliTRDCalibraFit::CreatePadObjectPRF(const TObjArray *vectorFit) |
3a0f6479 | 2435 | { |
2436 | // | |
2437 | // It Creates the AliTRDCalPad object from AliTRDFitInfo | |
2438 | // This object has to be written in the database | |
2439 | // | |
2440 | ||
2441 | // Create the DetObject | |
2442 | AliTRDCalPad *object = new AliTRDCalPad("PRFWidth","PRFWidth"); | |
2443 | ||
2444 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); | |
2445 | if(loop != 540) AliInfo("The Vector Fit is not complete!"); | |
2446 | Int_t detector = -1; | |
2447 | Float_t value = 0.0; | |
55a288e5 | 2448 | |
3a0f6479 | 2449 | for (Int_t k = 0; k < loop; k++) { |
2450 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2451 | AliTRDCalROC *calROC = object->GetCalROC(detector); | |
2452 | Int_t rowMax = calROC->GetNrows(); | |
2453 | Int_t colMax = calROC->GetNcols(); | |
2454 | for (Int_t row = 0; row < rowMax; row++) { | |
2455 | for (Int_t col = 0; col < colMax; col++) { | |
2456 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; | |
2457 | calROC->SetValue(col,row,TMath::Abs(value)); | |
2458 | } // Col | |
2459 | } // Row | |
2460 | } | |
2461 | ||
2462 | return object; | |
2463 | ||
2464 | } | |
55a288e5 | 2465 | //_____________________________________________________________________________ |
979b168f | 2466 | AliTRDCalDet *AliTRDCalibraFit::MakeOutliersStatDet(const TObjArray *vectorFit, const char *name, Double_t &mean) |
3a0f6479 | 2467 | { |
2468 | // | |
2469 | // It Creates the AliTRDCalDet object from AliTRDFitInfo | |
2470 | // 0 successful fit 1 not successful fit | |
2471 | // mean is the mean value over the successful fit | |
2472 | // do not use it for t0: no meaning | |
2473 | // | |
2474 | ||
2475 | // Create the CalObject | |
2476 | AliTRDCalDet *object = new AliTRDCalDet(name,name); | |
2477 | mean = 0.0; | |
2478 | Int_t count = 0; | |
2479 | ||
2480 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); | |
2481 | if(loop != 540) { | |
2482 | AliInfo("The Vector Fit is not complete! We initialise all outliers"); | |
2483 | for(Int_t k = 0; k < 540; k++){ | |
2484 | object->SetValue(k,1.0); | |
2485 | } | |
2486 | } | |
2487 | Int_t detector = -1; | |
2488 | Float_t value = 0.0; | |
2489 | ||
2490 | for (Int_t k = 0; k < loop; k++) { | |
2491 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2492 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0]; | |
2493 | if(value <= 0) object->SetValue(detector,1.0); | |
2494 | else { | |
2495 | object->SetValue(detector,0.0); | |
2496 | mean += value; | |
2497 | count++; | |
2498 | } | |
2499 | } | |
2500 | if(count > 0) mean /= count; | |
2501 | return object; | |
2502 | } | |
2503 | //_____________________________________________________________________________ | |
979b168f | 2504 | TObject *AliTRDCalibraFit::MakeOutliersStatPad(const TObjArray *vectorFit, const char *name, Double_t &mean) |
3a0f6479 | 2505 | { |
2506 | // | |
2507 | // It Creates the AliTRDCalPad object from AliTRDFitInfo | |
2508 | // 0 not successful fit 1 successful fit | |
2509 | // mean mean value over the successful fit | |
2510 | // | |
2511 | ||
2512 | // Create the CalObject | |
2513 | AliTRDCalPad *object = new AliTRDCalPad(name,name); | |
2514 | mean = 0.0; | |
2515 | Int_t count = 0; | |
2516 | ||
2517 | Int_t loop = (Int_t) vectorFit->GetEntriesFast(); | |
2518 | if(loop != 540) { | |
2519 | AliInfo("The Vector Fit is not complete! We initialise all outliers"); | |
2520 | for(Int_t k = 0; k < 540; k++){ | |
2521 | AliTRDCalROC *calROC = object->GetCalROC(k); | |
2522 | Int_t nchannels = calROC->GetNchannels(); | |
2523 | for(Int_t ch = 0; ch < nchannels; ch++){ | |
2524 | calROC->SetValue(ch,1.0); | |
2525 | } | |
2526 | } | |
2527 | } | |
2528 | Int_t detector = -1; | |
2529 | Float_t value = 0.0; | |
2530 | ||
2531 | for (Int_t k = 0; k < loop; k++) { | |
2532 | detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector(); | |
2533 | AliTRDCalROC *calROC = object->GetCalROC(detector); | |
2534 | Int_t nchannels = calROC->GetNchannels(); | |
2535 | for (Int_t ch = 0; ch < nchannels; ch++) { | |
2536 | value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[ch]; | |
2537 | if(value <= 0) calROC->SetValue(ch,1.0); | |
2538 | else { | |
2539 | calROC->SetValue(ch,0.0); | |
2540 | mean += value; | |
2541 | count++; | |
2542 | } | |
2543 | } // channels | |
2544 | } | |
2545 | if(count > 0) mean /= count; | |
2546 | return object; | |
2547 | } | |
2548 | //_____________________________________________________________________________ | |
2549 | void AliTRDCalibraFit::SetPeriodeFitPH(Int_t periodeFitPH) | |
55a288e5 | 2550 | { |
2551 | // | |
3a0f6479 | 2552 | // Set FitPH if 1 then each detector will be fitted |
55a288e5 | 2553 | // |
2554 | ||
3a0f6479 | 2555 | if (periodeFitPH > 0) { |
2556 | fFitPHPeriode = periodeFitPH; | |
55a288e5 | 2557 | } |
2558 | else { | |
3a0f6479 | 2559 | AliInfo("periodeFitPH must be higher than 0!"); |
55a288e5 | 2560 | } |
2561 | ||
2562 | } | |
55a288e5 | 2563 | //_____________________________________________________________________________ |
2564 | void AliTRDCalibraFit::SetBeginFitCharge(Float_t beginFitCharge) | |
2565 | { | |
2566 | // | |
2567 | // The fit of the deposited charge distribution begins at | |
2568 | // histo->Mean()/beginFitCharge | |
2569 | // You can here set beginFitCharge | |
2570 | // | |
2571 | ||
2572 | if (beginFitCharge > 0) { | |
2573 | fBeginFitCharge = beginFitCharge; | |
2574 | } | |
2575 | else { | |
2576 | AliInfo("beginFitCharge must be strict positif!"); | |
2577 | } | |
2578 | ||
2579 | } | |
2580 | ||
2581 | //_____________________________________________________________________________ | |
413153cb | 2582 | void AliTRDCalibraFit::SetT0Shift0(Float_t t0Shift) |
2583 | { | |
2584 | // | |
2585 | // The t0 calculated with the maximum positif slope is shift from t0Shift0 | |
2586 | // You can here set t0Shift0 | |
2587 | // | |
2588 | ||
2589 | if (t0Shift > 0) { | |
2590 | fT0Shift0 = t0Shift; | |
2591 | } | |
2592 | else { | |
2593 | AliInfo("t0Shift0 must be strict positif!"); | |
2594 | } | |
2595 | ||
2596 | } | |
2597 | ||
2598 | //_____________________________________________________________________________ | |
2599 | void AliTRDCalibraFit::SetT0Shift1(Float_t t0Shift) | |
55a288e5 | 2600 | { |
2601 | // | |
413153cb | 2602 | // The t0 calculated with the maximum of the amplification region is shift from t0Shift1 |
2603 | // You can here set t0Shift1 | |
55a288e5 | 2604 | // |
2605 | ||
2606 | if (t0Shift > 0) { | |
413153cb | 2607 | fT0Shift1 = t0Shift; |
55a288e5 | 2608 | } |
2609 | else { | |
2610 | AliInfo("t0Shift must be strict positif!"); | |
2611 | } | |
2612 | ||
2613 | } | |
2614 | ||
2615 | //_____________________________________________________________________________ | |
2616 | void AliTRDCalibraFit::SetRangeFitPRF(Float_t rangeFitPRF) | |
2617 | { | |
2618 | // | |
2619 | // The fit of the PRF is from -rangeFitPRF to rangeFitPRF | |
2620 | // You can here set rangeFitPRF | |
2621 | // | |
2622 | ||
2623 | if ((rangeFitPRF > 0) && | |
2624 | (rangeFitPRF <= 1.5)) { | |
2625 | fRangeFitPRF = rangeFitPRF; | |
2626 | } | |
2627 | else { | |
2628 | AliInfo("rangeFitPRF must be between 0 and 1.0"); | |
2629 | } | |
2630 | ||
2631 | } | |
2632 | ||
3a0f6479 | 2633 | //_____________________________________________________________________________ |
2634 | void AliTRDCalibraFit::SetMinEntries(Int_t minEntries) | |
2635 | { | |
2636 | // | |
2637 | // Minimum entries for fitting | |
2638 | // | |
2639 | ||
2640 | if (minEntries > 0) { | |
2641 | fMinEntries = minEntries; | |
2642 | } | |
2643 | else { | |
2644 | AliInfo("fMinEntries must be >= 0."); | |
2645 | } | |
2646 | ||
2647 | } | |
2648 | ||
55a288e5 | 2649 | //_____________________________________________________________________________ |
2650 | void AliTRDCalibraFit::SetRebin(Short_t rebin) | |
2651 | { | |
2652 | // | |
2653 | // Rebin with rebin time less bins the Ch histo | |
2654 | // You can set here rebin that should divide the number of bins of CH histo | |
2655 | // | |
2656 | ||
2657 | if (rebin > 0) { | |
2658 | fRebin = rebin; | |
2659 | AliInfo("You have to be sure that fRebin divides fNumberBinCharge used!"); | |
2660 | } | |
2661 | else { | |
2662 | AliInfo("You have to choose a positiv value!"); | |
2663 | } | |
2664 | ||
2665 | } | |
55a288e5 | 2666 | //_____________________________________________________________________________ |
3a0f6479 | 2667 | Bool_t AliTRDCalibraFit::FillVectorFit() |
55a288e5 | 2668 | { |
2669 | // | |
3a0f6479 | 2670 | // For the Fit functions fill the vector Fit |
55a288e5 | 2671 | // |
55a288e5 | 2672 | |
3a0f6479 | 2673 | AliTRDFitInfo *fitInfo = new AliTRDFitInfo(); |
55a288e5 | 2674 | |
3a0f6479 | 2675 | Int_t ntotal = 1; |
053767a4 | 2676 | if (GetStack(fCountDet) == 2) { |
3a0f6479 | 2677 | ntotal = 1728; |
55a288e5 | 2678 | } |
3a0f6479 | 2679 | else { |
2680 | ntotal = 2304; | |
55a288e5 | 2681 | } |
3a0f6479 | 2682 | |
2683 | //printf("For the detector %d , ntotal %d and fCoefCH[0] %f\n",countdet,ntotal,fCoefCH[0]); | |
2684 | Float_t *coef = new Float_t[ntotal]; | |
2685 | for (Int_t i = 0; i < ntotal; i++) { | |
2686 | coef[i] = fCurrentCoefDetector[i]; | |
55a288e5 | 2687 | } |
3a0f6479 | 2688 | |
2689 | Int_t detector = fCountDet; | |
2690 | // Set | |
2691 | fitInfo->SetCoef(coef); | |
2692 | fitInfo->SetDetector(detector); | |
2693 | fVectorFit.Add((TObject *) fitInfo); | |
2694 | ||
2695 | return kTRUE; | |
55a288e5 | 2696 | |
3a0f6479 | 2697 | } |
55a288e5 | 2698 | //_____________________________________________________________________________ |
3a0f6479 | 2699 | Bool_t AliTRDCalibraFit::FillVectorFit2() |
55a288e5 | 2700 | { |
2701 | // | |
3a0f6479 | 2702 | // For the Fit functions fill the vector Fit |
55a288e5 | 2703 | // |
55a288e5 | 2704 | |
3a0f6479 | 2705 | AliTRDFitInfo *fitInfo = new AliTRDFitInfo(); |
55a288e5 | 2706 | |
3a0f6479 | 2707 | Int_t ntotal = 1; |
053767a4 | 2708 | if (GetStack(fCountDet) == 2) { |
3a0f6479 | 2709 | ntotal = 1728; |
55a288e5 | 2710 | } |
3a0f6479 | 2711 | else { |
2712 | ntotal = 2304; | |
55a288e5 | 2713 | } |
3a0f6479 | 2714 | |
2715 | //printf("For the detector %d , ntotal %d and fCoefCH[0] %f\n",countdet,ntotal,fCoefCH[0]); | |
2716 | Float_t *coef = new Float_t[ntotal]; | |
2717 | for (Int_t i = 0; i < ntotal; i++) { | |
2718 | coef[i] = fCurrentCoefDetector2[i]; | |
55a288e5 | 2719 | } |
3a0f6479 | 2720 | |
2721 | Int_t detector = fCountDet; | |
2722 | // Set | |
2723 | fitInfo->SetCoef(coef); | |
2724 | fitInfo->SetDetector(detector); | |
2725 | fVectorFit2.Add((TObject *) fitInfo); | |
55a288e5 | 2726 | |
3a0f6479 | 2727 | return kTRUE; |
55a288e5 | 2728 | |
3a0f6479 | 2729 | } |
2730 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ | |
2731 | Bool_t AliTRDCalibraFit::InitFit(Int_t nbins, Int_t i) | |
55a288e5 | 2732 | { |
2733 | // | |
3a0f6479 | 2734 | // Init the number of expected bins and fDect1[i] fDect2[i] |
55a288e5 | 2735 | // |
2736 | ||
3a0f6479 | 2737 | gStyle->SetPalette(1); |
2738 | gStyle->SetOptStat(1111); | |
2739 | gStyle->SetPadBorderMode(0); | |
2740 | gStyle->SetCanvasColor(10); | |
2741 | gStyle->SetPadLeftMargin(0.13); | |
2742 | gStyle->SetPadRightMargin(0.01); | |
2743 | ||
2744 | // Mode groups of pads: the total number of bins! | |
2745 | CalculNumberOfBinsExpected(i); | |
2746 | ||
2747 | // Quick verification that we have the good pad calibration mode! | |
2748 | if (fNumberOfBinsExpected != nbins) { | |
64942b85 | 2749 | AliInfo(Form("It doesn't correspond to the mode of pad group calibration: expected %d and seen %d!",fNumberOfBinsExpected,nbins)); |
3a0f6479 | 2750 | return kFALSE; |
55a288e5 | 2751 | } |
3a0f6479 | 2752 | |
2753 | // Security for fDebug 3 and 4 | |
2754 | if ((fDebugLevel >= 3) && | |
2755 | ((fDet[0] > 5) || | |
2756 | (fDet[1] > 4) || | |
2757 | (fDet[2] > 17))) { | |
2758 | AliInfo("This detector doesn't exit!"); | |
2759 | return kFALSE; | |
55a288e5 | 2760 | } |
2761 | ||
3a0f6479 | 2762 | // Determine fDet1 and fDet2 and set the fNfragZ and fNfragRphi for debug 3 and 4 |
2763 | CalculDect1Dect2(i); | |
55a288e5 | 2764 | |
3a0f6479 | 2765 | |
2766 | return kTRUE; | |
55a288e5 | 2767 | } |
3a0f6479 | 2768 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
2769 | Bool_t AliTRDCalibraFit::InitFitCH() | |
55a288e5 | 2770 | { |
2771 | // | |
3a0f6479 | 2772 | // Init the fVectorFitCH for normalisation |
2773 | // Init the histo for debugging | |
55a288e5 | 2774 | // |
2775 | ||
3a0f6479 | 2776 | gDirectory = gROOT; |
2777 | ||
2778 | fScaleFitFactor = 0.0; | |
2779 | fCurrentCoefDetector = new Float_t[2304]; | |
2780 | for (Int_t k = 0; k < 2304; k++) { | |
2781 | fCurrentCoefDetector[k] = 0.0; | |
2782 | } | |
2783 | fVectorFit.SetName("gainfactorscoefficients"); | |
55a288e5 | 2784 | |
3a0f6479 | 2785 | // fDebug == 0 nothing |
2786 | // fDebug == 1 and fFitVoir no histo | |
2787 | if (fDebugLevel == 1) { | |
2788 | if(!CheckFitVoir()) return kFALSE; | |
2789 | } | |
2790 | //Get the CalDet object | |
2791 | if(fAccCDB){ | |
2792 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
2793 | if (!cal) { | |
2794 | AliInfo("Could not get calibDB"); | |
2795 | return kFALSE; | |
55a288e5 | 2796 | } |
3a0f6479 | 2797 | if(fCalDet) delete fCalDet; |
2798 | fCalDet = new AliTRDCalDet(*(cal->GetGainFactorDet())); | |
55a288e5 | 2799 | } |
3a0f6479 | 2800 | else{ |
2801 | Float_t devalue = 1.0; | |
2802 | if(fCalDet) delete fCalDet; | |
2803 | fCalDet = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)"); | |
2804 | for(Int_t k = 0; k < 540; k++){ | |
2805 | fCalDet->SetValue(k,devalue); | |
55a288e5 | 2806 | } |
2807 | } | |
3a0f6479 | 2808 | return kTRUE; |
2809 | ||
55a288e5 | 2810 | } |
3a0f6479 | 2811 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
2812 | Bool_t AliTRDCalibraFit::InitFitPH() | |
55a288e5 | 2813 | { |
2814 | // | |
3a0f6479 | 2815 | // Init the arrays of results |
2816 | // Init the histos for debugging | |
55a288e5 | 2817 | // |
55a288e5 | 2818 | |
3a0f6479 | 2819 | gDirectory = gROOT; |
2820 | fVectorFit.SetName("driftvelocitycoefficients"); | |
2821 | fVectorFit2.SetName("t0coefficients"); | |
55a288e5 | 2822 | |
3a0f6479 | 2823 | fCurrentCoefDetector = new Float_t[2304]; |
2824 | for (Int_t k = 0; k < 2304; k++) { | |
2825 | fCurrentCoefDetector[k] = 0.0; | |
2826 | } | |
2827 | ||
2828 | fCurrentCoefDetector2 = new Float_t[2304]; | |
2829 | for (Int_t k = 0; k < 2304; k++) { | |
2830 | fCurrentCoefDetector2[k] = 0.0; | |
55a288e5 | 2831 | } |
2832 | ||
3a0f6479 | 2833 | //fDebug == 0 nothing |
2834 | // fDebug == 1 and fFitVoir no histo | |
2835 | if (fDebugLevel == 1) { | |
2836 | if(!CheckFitVoir()) return kFALSE; | |
2837 | } | |
2838 | //Get the CalDet object | |
2839 | if(fAccCDB){ | |
2840 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
2841 | if (!cal) { | |
2842 | AliInfo("Could not get calibDB"); | |
2843 | return kFALSE; | |
2844 | } | |
2845 | if(fCalDet) delete fCalDet; | |
2846 | if(fCalDet2) delete fCalDet2; | |
2847 | fCalDet = new AliTRDCalDet(*(cal->GetVdriftDet())); | |
2848 | fCalDet2 = new AliTRDCalDet(*(cal->GetT0Det())); | |
2849 | } | |
2850 | else{ | |
2851 | Float_t devalue = 1.5; | |
2852 | Float_t devalue2 = 0.0; | |
2853 | if(fCalDet) delete fCalDet; | |
2854 | if(fCalDet2) delete fCalDet2; | |
2855 | fCalDet = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)"); | |
2856 | fCalDet2 = new AliTRDCalDet("ChamberT0","T0 (detector value)"); | |
2857 | for(Int_t k = 0; k < 540; k++){ | |
2858 | fCalDet->SetValue(k,devalue); | |
2859 | fCalDet2->SetValue(k,devalue2); | |
2860 | } | |
2861 | } | |
2862 | return kTRUE; | |
55a288e5 | 2863 | } |
3a0f6479 | 2864 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
2865 | Bool_t AliTRDCalibraFit::InitFitPRF() | |
55a288e5 | 2866 | { |
2867 | // | |
3a0f6479 | 2868 | // Init the calibration mode (Nz, Nrphi), the histograms for |
2869 | // debugging the fit methods if fDebug > 0, | |
2870 | // | |
2871 | ||
2872 | gDirectory = gROOT; | |
2873 | fVectorFit.SetName("prfwidthcoefficients"); | |
2874 | ||
2875 | fCurrentCoefDetector = new Float_t[2304]; | |
2876 | for (Int_t k = 0; k < 2304; k++) { | |
2877 | fCurrentCoefDetector[k] = 0.0; | |
55a288e5 | 2878 | } |
2879 | ||
3a0f6479 | 2880 | // fDebug == 0 nothing |
2881 | // fDebug == 1 and fFitVoir no histo | |
2882 | if (fDebugLevel == 1) { | |
2883 | if(!CheckFitVoir()) return kFALSE; | |
2884 | } | |
2885 | return kTRUE; | |
55a288e5 | 2886 | } |
3a0f6479 | 2887 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
2888 | Bool_t AliTRDCalibraFit::InitFitLinearFitter() | |
55a288e5 | 2889 | { |
2890 | // | |
3a0f6479 | 2891 | // Init the fCalDet, fVectorFit fCurrentCoefDetector |
55a288e5 | 2892 | // |
3a0f6479 | 2893 | |
2894 | gDirectory = gROOT; | |
2895 | ||
2896 | fCurrentCoefDetector = new Float_t[2304]; | |
2897 | fCurrentCoefDetector2 = new Float_t[2304]; | |
2898 | for (Int_t k = 0; k < 2304; k++) { | |
2899 | fCurrentCoefDetector[k] = 0.0; | |
2900 | fCurrentCoefDetector2[k] = 0.0; | |
55a288e5 | 2901 | } |
2902 | ||
840ec79d | 2903 | if((!fCalDetVdriftUsed) || (!fCalDetExBUsed)) return kFALSE; |
2904 | ||
55a288e5 | 2905 | return kTRUE; |
55a288e5 | 2906 | } |
55a288e5 | 2907 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
3a0f6479 | 2908 | void AliTRDCalibraFit::InitfCountDetAndfCount(Int_t i) |
55a288e5 | 2909 | { |
2910 | // | |
3a0f6479 | 2911 | // Init the current detector where we are fCountDet and the |
2912 | // next fCount for the functions Fit... | |
55a288e5 | 2913 | // |
2914 | ||
3a0f6479 | 2915 | // Loop on the Xbins of ch!! |
2916 | fCountDet = -1; // Current detector | |
2917 | fCount = 0; // To find the next detector | |
2918 | ||
2919 | // If fDebug >= 3 | |
2920 | if (fDebugLevel >= 3) { | |
2921 | // Set countdet to the detector | |
2922 | fCountDet = AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]); | |
2923 | // Set counter to write at the end of the detector | |
2924 | fCount = fDect2; | |
2925 | // Get the right calib objects | |
2926 | SetCalROC(i); | |
2927 | } | |
2928 | if(fDebugLevel == 1) { | |
2929 | fCountDet = 0; | |
2930 | fCalibraMode->CalculXBins(fCountDet,i); | |
6aafa7ea | 2931 | if((fCalibraMode->GetNz(i)!=100) && (fCalibraMode->GetNrphi(i)!=100)){ |
2932 | while(fCalibraMode->GetXbins(i) <=fFitVoir){ | |
2933 | fCountDet++; | |
2934 | fCalibraMode->CalculXBins(fCountDet,i); | |
2935 | //printf("GetXBins %d\n",fCalibraMode->GetXbins(i)); | |
2936 | } | |
2937 | } | |
2938 | else { | |
3a0f6479 | 2939 | fCountDet++; |
6aafa7ea | 2940 | } |
3a0f6479 | 2941 | fCount = fCalibraMode->GetXbins(i); |
2942 | fCountDet--; | |
2943 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
053767a4 | 2944 | fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),i); |
2945 | fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet) | |
2946 | ,(Int_t) GetStack(fCountDet) | |
2947 | ,(Int_t) GetSector(fCountDet),i); | |
3a0f6479 | 2948 | } |
2949 | } | |
2950 | //_______________________________________________________________________________ | |
2951 | void AliTRDCalibraFit::CalculNumberOfBinsExpected(Int_t i) | |
2952 | { | |
2953 | // | |
2954 | // Calculate the number of bins expected (calibration groups) | |
2955 | // | |
2956 | ||
2957 | fNumberOfBinsExpected = 0; | |
64942b85 | 2958 | // All |
2959 | if((fCalibraMode->GetNz(i) == 100) && (fCalibraMode->GetNrphi(i) == 100)){ | |
2960 | fNumberOfBinsExpected = 1; | |
2961 | return; | |
2962 | } | |
2963 | // Per supermodule | |
2964 | if((fCalibraMode->GetNz(i) == 10) && (fCalibraMode->GetNrphi(i) == 10)){ | |
2965 | fNumberOfBinsExpected = 18; | |
2966 | return; | |
2967 | } | |
2968 | // More | |
55a288e5 | 2969 | fCalibraMode->ModePadCalibration(2,i); |
2970 | fCalibraMode->ModePadFragmentation(0,2,0,i); | |
2971 | fCalibraMode->SetDetChamb2(i); | |
3a0f6479 | 2972 | if (fDebugLevel > 1) { |
55a288e5 | 2973 | AliInfo(Form("For the chamber 2: %d",fCalibraMode->GetDetChamb2(i))); |
2974 | } | |
3a0f6479 | 2975 | fNumberOfBinsExpected += 6 * 18 * fCalibraMode->GetDetChamb2(i); |
55a288e5 | 2976 | fCalibraMode->ModePadCalibration(0,i); |
2977 | fCalibraMode->ModePadFragmentation(0,0,0,i); | |
2978 | fCalibraMode->SetDetChamb0(i); | |
3a0f6479 | 2979 | if (fDebugLevel > 1) { |
55a288e5 | 2980 | AliInfo(Form("For the other chamber 0: %d",fCalibraMode->GetDetChamb0(i))); |
2981 | } | |
3a0f6479 | 2982 | fNumberOfBinsExpected += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(i); |
2983 | ||
2984 | } | |
2985 | //_______________________________________________________________________________ | |
2986 | void AliTRDCalibraFit::CalculDect1Dect2(Int_t i) | |
2987 | { | |
2988 | // | |
2989 | // Calculate the range of fits | |
2990 | // | |
55a288e5 | 2991 | |
3a0f6479 | 2992 | fDect1 = -1; |
2993 | fDect2 = -1; | |
2994 | if (fDebugLevel == 1) { | |
2995 | fDect1 = fFitVoir; | |
2996 | fDect2 = fDect1 +1; | |
55a288e5 | 2997 | } |
3a0f6479 | 2998 | if ((fDebugLevel == 2) || (fDebugLevel == 0)) { |
2999 | fDect1 = 0; | |
3000 | fDect2 = fNumberOfBinsExpected; | |
55a288e5 | 3001 | } |
3a0f6479 | 3002 | if (fDebugLevel >= 3) { |
3003 | fCountDet = AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]); | |
3004 | fCalibraMode->CalculXBins(fCountDet,i); | |
3005 | fDect1 = fCalibraMode->GetXbins(i); | |
3006 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
053767a4 | 3007 | fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),i); |
3008 | fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet) | |
3009 | ,(Int_t) GetStack(fCountDet) | |
3010 | ,(Int_t) GetSector(fCountDet),i); | |
3a0f6479 | 3011 | // Set for the next detector |
3012 | fDect2 = fDect1 + fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i); | |
55a288e5 | 3013 | } |
55a288e5 | 3014 | } |
3a0f6479 | 3015 | //_______________________________________________________________________________ |
3016 | Bool_t AliTRDCalibraFit::CheckFitVoir() | |
55a288e5 | 3017 | { |
3018 | // | |
3a0f6479 | 3019 | // Check if fFitVoir is in the range |
55a288e5 | 3020 | // |
3021 | ||
3a0f6479 | 3022 | if (fFitVoir < fNumberOfBinsExpected) { |
3023 | AliInfo(Form("We will see the fit of the object %d",fFitVoir)); | |
55a288e5 | 3024 | } |
3a0f6479 | 3025 | else { |
3026 | AliInfo("fFitVoir is out of range of the histo!"); | |
3027 | return kFALSE; | |
3028 | } | |
3029 | return kTRUE; | |
55a288e5 | 3030 | } |
55a288e5 | 3031 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
3032 | void AliTRDCalibraFit::UpdatefCountDetAndfCount(Int_t idect, Int_t i) | |
3033 | { | |
3034 | // | |
3035 | // See if we are in a new detector and update the | |
3036 | // variables fNfragZ and fNfragRphi if yes | |
3a0f6479 | 3037 | // Will never happen for only one detector (3 and 4) |
3038 | // Doesn't matter for 2 | |
3039 | // | |
3040 | if (fCount == idect) { | |
64942b85 | 3041 | // On en est au detector (or first detector in the group) |
3042 | fCountDet += 1; | |
3043 | AliDebug(2,Form("We are at the detector %d\n",fCountDet)); | |
3044 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
3045 | fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),i); | |
3046 | fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet) | |
053767a4 | 3047 | ,(Int_t) GetStack(fCountDet) |
3048 | ,(Int_t) GetSector(fCountDet),i); | |
64942b85 | 3049 | // Set for the next detector |
3050 | fCount += fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i); | |
3051 | // calib objects | |
3052 | SetCalROC(i); | |
3053 | } | |
55a288e5 | 3054 | } |
55a288e5 | 3055 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
3056 | void AliTRDCalibraFit::ReconstructFitRowMinRowMax(Int_t idect, Int_t i) | |
3057 | { | |
3058 | // | |
3059 | // Reconstruct the min pad row, max pad row, min pad col and | |
3060 | // max pad col of the calibration group for the Fit functions | |
64942b85 | 3061 | // idect is the calibration group inside the detector |
55a288e5 | 3062 | // |
3a0f6479 | 3063 | if (fDebugLevel != 1) { |
3064 | fCalibraMode->ReconstructionRowPadGroup((Int_t) (idect-(fCount-(fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i)))),i); | |
55a288e5 | 3065 | } |
64942b85 | 3066 | AliDebug(2,Form("AliTRDCalibraFit::ReconstructFitRowMinRowMax: the local calibration group is %d",idect-(fCount-(fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i))))); |
3067 | AliDebug(2,Form("AliTRDCalibraFit::ReconstructFitRowMinRowMax: the number of group per detector is %d",fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i))); | |
55a288e5 | 3068 | } |
55a288e5 | 3069 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
3a0f6479 | 3070 | Bool_t AliTRDCalibraFit::NotEnoughStatisticCH(Int_t idect) |
55a288e5 | 3071 | { |
3072 | // | |
3073 | // For the case where there are not enough entries in the histograms | |
3a0f6479 | 3074 | // of the calibration group, the value present in the choosen database |
3075 | // will be put. A negativ sign enables to know that a fit was not possible. | |
3076 | // | |
3077 | ||
3078 | if (fDebugLevel == 1) { | |
3079 | AliInfo("The element has not enough statistic to be fitted"); | |
55a288e5 | 3080 | } |
64942b85 | 3081 | else if (fNbDet > 0){ |
3082 | Int_t firstdetector = fCountDet; | |
3083 | Int_t lastdetector = fCountDet+fNbDet; | |
840ec79d | 3084 | //AliInfo(Form("The element %d containing the detectors %d to %d has not enough statistic to be fitted",idect,firstdetector,lastdetector)); |
64942b85 | 3085 | // loop over detectors |
3086 | for(Int_t det = firstdetector; det < lastdetector; det++){ | |
3087 | ||
3088 | //Set the calibration object again | |
3089 | fCountDet = det; | |
3090 | SetCalROC(0); | |
3091 | ||
3092 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
3093 | // Put them at 1 | |
3094 | fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),0); | |
3095 | fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet) | |
3096 | ,(Int_t) GetStack(fCountDet) | |
3097 | ,(Int_t) GetSector(fCountDet),0); | |
3098 | // Reconstruct row min row max | |
3099 | ReconstructFitRowMinRowMax(idect,0); | |
3100 | ||
3101 | // Calcul the coef from the database choosen for the detector | |
3102 | CalculChargeCoefMean(kFALSE); | |
3103 | ||
3104 | //stack 2, not stack 2 | |
3105 | Int_t factor = 0; | |
3106 | if(GetStack(fCountDet) == 2) factor = 12; | |
3107 | else factor = 16; | |
3108 | ||
3109 | // Fill the fCurrentCoefDetector with negative value to say: not fitted | |
3110 | for (Int_t k = fCalibraMode->GetRowMin(0); k < fCalibraMode->GetRowMax(0); k++) { | |
3111 | for (Int_t j = fCalibraMode->GetColMin(0); j < fCalibraMode->GetColMax(0); j++) { | |
3112 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = -TMath::Abs(fCurrentCoef[1]); | |
3113 | } | |
3114 | } | |
3115 | ||
3116 | //Put default value negative | |
3117 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
3118 | fCurrentCoefE = 0.0; | |
3119 | ||
3120 | // Fill the stuff | |
3121 | FillVectorFit(); | |
3122 | // Debug | |
3123 | if(fDebugLevel > 1){ | |
3124 | ||
3125 | if ( !fDebugStreamer ) { | |
3126 | //debug stream | |
3127 | TDirectory *backup = gDirectory; | |
3128 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitCH.root"); | |
3129 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer | |
3130 | } | |
3131 | ||
3132 | Int_t detector = fCountDet; | |
3133 | Int_t caligroup = idect; | |
3134 | Short_t rowmin = fCalibraMode->GetRowMin(0); | |
3135 | Short_t rowmax = fCalibraMode->GetRowMax(0); | |
3136 | Short_t colmin = fCalibraMode->GetColMin(0); | |
3137 | Short_t colmax = fCalibraMode->GetColMax(0); | |
3138 | Float_t gf = fCurrentCoef[0]; | |
3139 | Float_t gfs = fCurrentCoef[1]; | |
3140 | Float_t gfE = fCurrentCoefE; | |
3141 | ||
3142 | (*fDebugStreamer) << "FillFillCH" << | |
3143 | "detector=" << detector << | |
3144 | "caligroup=" << caligroup << | |
3145 | "rowmin=" << rowmin << | |
3146 | "rowmax=" << rowmax << | |
3147 | "colmin=" << colmin << | |
3148 | "colmax=" << colmax << | |
3149 | "gf=" << gf << | |
3150 | "gfs=" << gfs << | |
3151 | "gfE=" << gfE << | |
3152 | "\n"; | |
3153 | ||
3154 | } | |
3155 | // Reset | |
3156 | for (Int_t k = 0; k < 2304; k++) { | |
3157 | fCurrentCoefDetector[k] = 0.0; | |
3158 | } | |
3159 | ||
3160 | }// loop detector | |
3161 | AliDebug(2,Form("Check the count now: fCountDet %d",fCountDet)); | |
3162 | } | |
3a0f6479 | 3163 | else { |
55a288e5 | 3164 | |
840ec79d | 3165 | //AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted",idect-(fCount-(fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0))),fCountDet)); |
3a0f6479 | 3166 | |
3167 | // Calcul the coef from the database choosen | |
3168 | CalculChargeCoefMean(kFALSE); | |
55a288e5 | 3169 | |
053767a4 | 3170 | //stack 2, not stack 2 |
3a0f6479 | 3171 | Int_t factor = 0; |
053767a4 | 3172 | if(GetStack(fCountDet) == 2) factor = 12; |
3a0f6479 | 3173 | else factor = 16; |
55a288e5 | 3174 | |
3a0f6479 | 3175 | // Fill the fCurrentCoefDetector with negative value to say: not fitted |
3176 | for (Int_t k = fCalibraMode->GetRowMin(0); k < fCalibraMode->GetRowMax(0); k++) { | |
3177 | for (Int_t j = fCalibraMode->GetColMin(0); j < fCalibraMode->GetColMax(0); j++) { | |
3178 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = -TMath::Abs(fCurrentCoef[1]); | |
55a288e5 | 3179 | } |
3180 | } | |
3a0f6479 | 3181 | |
3182 | //Put default value negative | |
3183 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
3184 | fCurrentCoefE = 0.0; | |
3185 | ||
3186 | FillFillCH(idect); | |
3187 | } | |
3188 | ||
3189 | return kTRUE; | |
55a288e5 | 3190 | } |
3191 | ||
3a0f6479 | 3192 | |
3193 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ | |
64942b85 | 3194 | Bool_t AliTRDCalibraFit::NotEnoughStatisticPH(Int_t idect,Double_t nentries) |
55a288e5 | 3195 | { |
3196 | // | |
3a0f6479 | 3197 | // For the case where there are not enough entries in the histograms |
3198 | // of the calibration group, the value present in the choosen database | |
3199 | // will be put. A negativ sign enables to know that a fit was not possible. | |
55a288e5 | 3200 | // |
3a0f6479 | 3201 | if (fDebugLevel == 1) { |
3202 | AliInfo("The element has not enough statistic to be fitted"); | |
3203 | } | |
64942b85 | 3204 | else if (fNbDet > 0) { |
3205 | ||
3206 | Int_t firstdetector = fCountDet; | |
3207 | Int_t lastdetector = fCountDet+fNbDet; | |
840ec79d | 3208 | //AliInfo(Form("The element %d containing the detectors %d to %d has not enough statistic to be fitted",idect,firstdetector,lastdetector)); |
64942b85 | 3209 | // loop over detectors |
3210 | for(Int_t det = firstdetector; det < lastdetector; det++){ | |
3211 | ||
3212 | //Set the calibration object again | |
3213 | fCountDet = det; | |
3214 | SetCalROC(1); | |
3215 | ||
3216 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
3217 | // Put them at 1 | |
3218 | fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),1); | |
3219 | fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet) | |
3220 | ,(Int_t) GetStack(fCountDet) | |
3221 | ,(Int_t) GetSector(fCountDet),1); | |
3222 | // Reconstruct row min row max | |
3223 | ReconstructFitRowMinRowMax(idect,1); | |
3224 | ||
3225 | // Calcul the coef from the database choosen for the detector | |
3226 | CalculVdriftCoefMean(); | |
3227 | CalculT0CoefMean(); | |
3228 | ||
3229 | //stack 2, not stack 2 | |
3230 | Int_t factor = 0; | |
3231 | if(GetStack(fCountDet) == 2) factor = 12; | |
3232 | else factor = 16; | |
3233 | ||
3234 | // Fill the fCurrentCoefDetector with negative value to say: not fitted | |
3235 | for (Int_t k = fCalibraMode->GetRowMin(1); k < fCalibraMode->GetRowMax(1); k++) { | |
3236 | for (Int_t j = fCalibraMode->GetColMin(1); j < fCalibraMode->GetColMax(1); j++) { | |
3237 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = -TMath::Abs(fCurrentCoef[1]); | |
3238 | fCurrentCoefDetector2[(Int_t)(j*factor+k)] = fCurrentCoef2[1] + 100.0; | |
3239 | } | |
3240 | } | |
3241 | ||
3242 | //Put default value negative | |
3243 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
3244 | fCurrentCoefE = 0.0; | |
3245 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; | |
3246 | fCurrentCoefE2 = 0.0; | |
3247 | ||
3248 | // Fill the stuff | |
3249 | FillVectorFit(); | |
3250 | FillVectorFit2(); | |
3251 | // Debug | |
3252 | if(fDebugLevel > 1){ | |
3253 | ||
3254 | if ( !fDebugStreamer ) { | |
3255 | //debug stream | |
3256 | TDirectory *backup = gDirectory; | |
3257 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPH.root"); | |
3258 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer | |
3259 | } | |
3260 | ||
3261 | ||
3262 | Int_t detector = fCountDet; | |
3263 | Int_t caligroup = idect; | |
3264 | Short_t rowmin = fCalibraMode->GetRowMin(1); | |
3265 | Short_t rowmax = fCalibraMode->GetRowMax(1); | |
3266 | Short_t colmin = fCalibraMode->GetColMin(1); | |
3267 | Short_t colmax = fCalibraMode->GetColMax(1); | |
3268 | Float_t vf = fCurrentCoef[0]; | |
3269 | Float_t vs = fCurrentCoef[1]; | |
3270 | Float_t vfE = fCurrentCoefE; | |
3271 | Float_t t0f = fCurrentCoef2[0]; | |
3272 | Float_t t0s = fCurrentCoef2[1]; | |
3273 | Float_t t0E = fCurrentCoefE2; | |
3274 | ||
3275 | ||
3276 | ||
3277 | (* fDebugStreamer) << "FillFillPH"<< | |
3278 | "detector="<<detector<< | |
3279 | "nentries="<<nentries<< | |
3280 | "caligroup="<<caligroup<< | |
3281 | "rowmin="<<rowmin<< | |
3282 | "rowmax="<<rowmax<< | |
3283 | "colmin="<<colmin<< | |
3284 | "colmax="<<colmax<< | |
3285 | "vf="<<vf<< | |
3286 | "vs="<<vs<< | |
3287 | "vfE="<<vfE<< | |
3288 | "t0f="<<t0f<< | |
3289 | "t0s="<<t0s<< | |
3290 | "t0E="<<t0E<< | |
3291 | "\n"; | |
3292 | } | |
3293 | // Reset | |
3294 | for (Int_t k = 0; k < 2304; k++) { | |
3295 | fCurrentCoefDetector[k] = 0.0; | |
3296 | fCurrentCoefDetector2[k] = 0.0; | |
3297 | } | |
3298 | ||
3299 | }// loop detector | |
3300 | AliDebug(2,Form("Check the count now: fCountDet %d",fCountDet)); | |
3301 | } | |
3a0f6479 | 3302 | else { |
55a288e5 | 3303 | |
840ec79d | 3304 | //AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted",idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1))),fCountDet)); |
55a288e5 | 3305 | |
3a0f6479 | 3306 | CalculVdriftCoefMean(); |
3307 | CalculT0CoefMean(); | |
55a288e5 | 3308 | |
053767a4 | 3309 | //stack 2 and not stack 2 |
3a0f6479 | 3310 | Int_t factor = 0; |
053767a4 | 3311 | if(GetStack(fCountDet) == 2) factor = 12; |
3a0f6479 | 3312 | else factor = 16; |
55a288e5 | 3313 | |
55a288e5 | 3314 | |
3a0f6479 | 3315 | // Fill the fCurrentCoefDetector 2 |
3316 | for (Int_t k = fCalibraMode->GetRowMin(1); k < fCalibraMode->GetRowMax(1); k++) { | |
3317 | for (Int_t j = fCalibraMode->GetColMin(1); j < fCalibraMode->GetColMax(1); j++) { | |
3318 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = -TMath::Abs(fCurrentCoef[1]); | |
64942b85 | 3319 | fCurrentCoefDetector2[(Int_t)(j*factor+k)] = fCurrentCoef2[1] + 100.0; |
55a288e5 | 3320 | } |
3321 | } | |
55a288e5 | 3322 | |
3a0f6479 | 3323 | // Put the default value |
3324 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
3325 | fCurrentCoefE = 0.0; | |
64942b85 | 3326 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
3a0f6479 | 3327 | fCurrentCoefE2 = 0.0; |
3328 | ||
64942b85 | 3329 | FillFillPH(idect,nentries); |
3a0f6479 | 3330 | |
3331 | } | |
55a288e5 | 3332 | |
3a0f6479 | 3333 | return kTRUE; |
64942b85 | 3334 | |
3a0f6479 | 3335 | } |
3336 | ||
3337 | ||
3338 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ | |
3339 | Bool_t AliTRDCalibraFit::NotEnoughStatisticPRF(Int_t idect) | |
3340 | { | |
3341 | // | |
3342 | // For the case where there are not enough entries in the histograms | |
3343 | // of the calibration group, the value present in the choosen database | |
3344 | // will be put. A negativ sign enables to know that a fit was not possible. | |
3345 | // | |
55a288e5 | 3346 | |
3a0f6479 | 3347 | if (fDebugLevel == 1) { |
3348 | AliInfo("The element has not enough statistic to be fitted"); | |
55a288e5 | 3349 | } |
64942b85 | 3350 | else if (fNbDet > 0){ |
3351 | ||
3352 | Int_t firstdetector = fCountDet; | |
3353 | Int_t lastdetector = fCountDet+fNbDet; | |
840ec79d | 3354 | // AliInfo(Form("The element %d containing the detectors %d to %d has not enough statistic to be fitted",idect,firstdetector,lastdetector)); |
64942b85 | 3355 | |
3356 | // loop over detectors | |
3357 | for(Int_t det = firstdetector; det < lastdetector; det++){ | |
3358 | ||
3359 | //Set the calibration object again | |
3360 | fCountDet = det; | |
3361 | SetCalROC(2); | |
3362 | ||
3363 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
3364 | // Put them at 1 | |
3365 | fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),2); | |
3366 | fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet) | |
3367 | ,(Int_t) GetStack(fCountDet) | |
3368 | ,(Int_t) GetSector(fCountDet),2); | |
3369 | // Reconstruct row min row max | |
3370 | ReconstructFitRowMinRowMax(idect,2); | |
3371 | ||
3372 | // Calcul the coef from the database choosen for the detector | |
3373 | CalculPRFCoefMean(); | |
3374 | ||
3375 | //stack 2, not stack 2 | |
3376 | Int_t factor = 0; | |
3377 | if(GetStack(fCountDet) == 2) factor = 12; | |
3378 | else factor = 16; | |
3379 | ||
3380 | // Fill the fCurrentCoefDetector with negative value to say: not fitted | |
3381 | for (Int_t k = fCalibraMode->GetRowMin(2); k < fCalibraMode->GetRowMax(2); k++) { | |
3382 | for (Int_t j = fCalibraMode->GetColMin(2); j < fCalibraMode->GetColMax(2); j++) { | |
3383 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = -TMath::Abs(fCurrentCoef[1]); | |
3384 | } | |
3385 | } | |
3386 | ||
3387 | //Put default value negative | |
3388 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
3389 | fCurrentCoefE = 0.0; | |
3390 | ||
3391 | // Fill the stuff | |
3392 | FillVectorFit(); | |
3393 | // Debug | |
3394 | if(fDebugLevel > 1){ | |
3395 | ||
3396 | if ( !fDebugStreamer ) { | |
3397 | //debug stream | |
3398 | TDirectory *backup = gDirectory; | |
3399 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPRF.root"); | |
3400 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer | |
3401 | } | |
3402 | ||
3403 | Int_t detector = fCountDet; | |
3404 | Int_t layer = GetLayer(fCountDet); | |
3405 | Int_t caligroup = idect; | |
3406 | Short_t rowmin = fCalibraMode->GetRowMin(2); | |
3407 | Short_t rowmax = fCalibraMode->GetRowMax(2); | |
3408 | Short_t colmin = fCalibraMode->GetColMin(2); | |
3409 | Short_t colmax = fCalibraMode->GetColMax(2); | |
3410 | Float_t widf = fCurrentCoef[0]; | |
3411 | Float_t wids = fCurrentCoef[1]; | |
3412 | Float_t widfE = fCurrentCoefE; | |
3413 | ||
3414 | (* fDebugStreamer) << "FillFillPRF"<< | |
3415 | "detector="<<detector<< | |
3416 | "layer="<<layer<< | |
3417 | "caligroup="<<caligroup<< | |
3418 | "rowmin="<<rowmin<< | |
3419 | "rowmax="<<rowmax<< | |
3420 | "colmin="<<colmin<< | |
3421 | "colmax="<<colmax<< | |
3422 | "widf="<<widf<< | |
3423 | "wids="<<wids<< | |
3424 | "widfE="<<widfE<< | |
3425 | "\n"; | |
3426 | } | |
3427 | // Reset | |
3428 | for (Int_t k = 0; k < 2304; k++) { | |
3429 | fCurrentCoefDetector[k] = 0.0; | |
3430 | } | |
3431 | ||
3432 | }// loop detector | |
3433 | AliDebug(2,Form("Check the count now: fCountDet %d",fCountDet)); | |
3434 | } | |
3a0f6479 | 3435 | else { |
3436 | ||
840ec79d | 3437 | // AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted",idect-(fCount-(fCalibraMode->GetNfragZ(2)*fCalibraMode->GetNfragRphi(2))),fCountDet)); |
3a0f6479 | 3438 | |
3439 | CalculPRFCoefMean(); | |
3440 | ||
053767a4 | 3441 | // stack 2 and not stack 2 |
3a0f6479 | 3442 | Int_t factor = 0; |
053767a4 | 3443 | if(GetStack(fCountDet) == 2) factor = 12; |
3a0f6479 | 3444 | else factor = 16; |
55a288e5 | 3445 | |
55a288e5 | 3446 | |
3a0f6479 | 3447 | // Fill the fCurrentCoefDetector |
3448 | for (Int_t k = fCalibraMode->GetRowMin(2); k < fCalibraMode->GetRowMax(2); k++) { | |
3449 | for (Int_t j = fCalibraMode->GetColMin(2); j < fCalibraMode->GetColMax(2); j++) { | |
64942b85 | 3450 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = -TMath::Abs(fCurrentCoef[1]); |
55a288e5 | 3451 | } |
3452 | } | |
55a288e5 | 3453 | |
3a0f6479 | 3454 | // Put the default value |
64942b85 | 3455 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); |
3a0f6479 | 3456 | fCurrentCoefE = 0.0; |
3457 | ||
3458 | FillFillPRF(idect); | |
3459 | } | |
3460 | ||
3461 | return kTRUE; | |
55a288e5 | 3462 | |
3a0f6479 | 3463 | } |
3464 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ | |
3465 | Bool_t AliTRDCalibraFit::NotEnoughStatisticLinearFitter() | |
55a288e5 | 3466 | { |
3467 | // | |
3a0f6479 | 3468 | // For the case where there are not enough entries in the histograms |
3469 | // of the calibration group, the value present in the choosen database | |
3470 | // will be put. A negativ sign enables to know that a fit was not possible. | |
3471 | // | |
3472 | ||
3473 | // Calcul the coef from the database choosen | |
3474 | CalculVdriftLorentzCoef(); | |
3475 | ||
3476 | Int_t factor = 0; | |
053767a4 | 3477 | if(GetStack(fCountDet) == 2) factor = 1728; |
3a0f6479 | 3478 | else factor = 2304; |
3479 | ||
3480 | ||
3481 | // Fill the fCurrentCoefDetector | |
3482 | for (Int_t k = 0; k < factor; k++) { | |
3483 | fCurrentCoefDetector[k] = -TMath::Abs(fCurrentCoef[1]); | |
3484 | // should be negative | |
840ec79d | 3485 | fCurrentCoefDetector2[k] = fCurrentCoef2[1]+100.0; |
55a288e5 | 3486 | } |
3a0f6479 | 3487 | |
3488 | ||
840ec79d | 3489 | //Put default opposite sign only for vdrift |
3a0f6479 | 3490 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); |
3491 | fCurrentCoefE = 0.0; | |
840ec79d | 3492 | fCurrentCoef2[0] = fCurrentCoef2[1]+100.0; |
3a0f6479 | 3493 | fCurrentCoefE2 = 0.0; |
3494 | ||
3495 | FillFillLinearFitter(); | |
3496 | ||
3497 | return kTRUE; | |
55a288e5 | 3498 | } |
3499 | ||
3a0f6479 | 3500 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
3501 | Bool_t AliTRDCalibraFit::FillInfosFitCH(Int_t idect) | |
55a288e5 | 3502 | { |
3503 | // | |
3a0f6479 | 3504 | // Fill the coefficients found with the fits or other |
3505 | // methods from the Fit functions | |
3506 | // | |
3507 | ||
3508 | if (fDebugLevel != 1) { | |
64942b85 | 3509 | if (fNbDet > 0){ |
3510 | Int_t firstdetector = fCountDet; | |
3511 | Int_t lastdetector = fCountDet+fNbDet; | |
840ec79d | 3512 | // AliInfo(Form("The element %d containing the detectors %d to %d has been fitted",idect,firstdetector,lastdetector)); |
64942b85 | 3513 | // loop over detectors |
3514 | for(Int_t det = firstdetector; det < lastdetector; det++){ | |
3515 | ||
3516 | //Set the calibration object again | |
3517 | fCountDet = det; | |
3518 | SetCalROC(0); | |
3519 | ||
3520 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
3521 | // Put them at 1 | |
3522 | fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),0); | |
3523 | fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet) | |
3524 | ,(Int_t) GetStack(fCountDet) | |
3525 | ,(Int_t) GetSector(fCountDet),0); | |
3526 | // Reconstruct row min row max | |
3527 | ReconstructFitRowMinRowMax(idect,0); | |
3528 | ||
3529 | // Calcul the coef from the database choosen for the detector | |
3530 | if(fCurrentCoef[0] < 0.0) CalculChargeCoefMean(kFALSE); | |
3531 | else CalculChargeCoefMean(kTRUE); | |
3532 | ||
3533 | //stack 2, not stack 2 | |
3534 | Int_t factor = 0; | |
3535 | if(GetStack(fCountDet) == 2) factor = 12; | |
3536 | else factor = 16; | |
3537 | ||
3538 | // Fill the fCurrentCoefDetector with negative value to say: not fitted | |
3539 | Double_t coeftoput = 1.0; | |
3540 | if(fCurrentCoef[0] < 0.0) coeftoput = - TMath::Abs(fCurrentCoef[1]); | |
3541 | else coeftoput = fCurrentCoef[0]; | |
3542 | for (Int_t k = fCalibraMode->GetRowMin(0); k < fCalibraMode->GetRowMax(0); k++) { | |
3543 | for (Int_t j = fCalibraMode->GetColMin(0); j < fCalibraMode->GetColMax(0); j++) { | |
3544 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = coeftoput; | |
3545 | } | |
3546 | } | |
3547 | ||
3548 | // Fill the stuff | |
3549 | FillVectorFit(); | |
3550 | // Debug | |
3551 | if(fDebugLevel > 1){ | |
3552 | ||
3553 | if ( !fDebugStreamer ) { | |
3554 | //debug stream | |
3555 | TDirectory *backup = gDirectory; | |
3556 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitCH.root"); | |
3557 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer | |
3558 | } | |
3559 | ||
3560 | Int_t detector = fCountDet; | |
3561 | Int_t caligroup = idect; | |
3562 | Short_t rowmin = fCalibraMode->GetRowMin(0); | |
3563 | Short_t rowmax = fCalibraMode->GetRowMax(0); | |
3564 | Short_t colmin = fCalibraMode->GetColMin(0); | |
3565 | Short_t colmax = fCalibraMode->GetColMax(0); | |
3566 | Float_t gf = fCurrentCoef[0]; | |
3567 | Float_t gfs = fCurrentCoef[1]; | |
3568 | Float_t gfE = fCurrentCoefE; | |
3569 | ||
3570 | (*fDebugStreamer) << "FillFillCH" << | |
3571 | "detector=" << detector << | |
3572 | "caligroup=" << caligroup << | |
3573 | "rowmin=" << rowmin << | |
3574 | "rowmax=" << rowmax << | |
3575 | "colmin=" << colmin << | |
3576 | "colmax=" << colmax << | |
3577 | "gf=" << gf << | |
3578 | "gfs=" << gfs << | |
3579 | "gfE=" << gfE << | |
3580 | "\n"; | |
3581 | ||
3582 | } | |
3583 | // Reset | |
3584 | for (Int_t k = 0; k < 2304; k++) { | |
3585 | fCurrentCoefDetector[k] = 0.0; | |
3586 | } | |
3587 | ||
3588 | }// loop detector | |
3589 | //printf("Check the count now: fCountDet %d\n",fCountDet); | |
3590 | } | |
3591 | else{ | |
3592 | ||
3593 | Int_t factor = 0; | |
3594 | if(GetStack(fCountDet) == 2) factor = 12; | |
3595 | else factor = 16; | |
3596 | ||
3597 | for (Int_t k = fCalibraMode->GetRowMin(0); k < fCalibraMode->GetRowMax(0); k++) { | |
3598 | for (Int_t j = fCalibraMode->GetColMin(0); j < fCalibraMode->GetColMax(0); j++) { | |
3599 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = fCurrentCoef[0]; | |
3600 | } | |
3a0f6479 | 3601 | } |
64942b85 | 3602 | |
3603 | FillFillCH(idect); | |
55a288e5 | 3604 | } |
3605 | } | |
55a288e5 | 3606 | |
3a0f6479 | 3607 | return kTRUE; |
3608 | ||
3609 | } | |
3610 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ | |
64942b85 | 3611 | Bool_t AliTRDCalibraFit::FillInfosFitPH(Int_t idect,Double_t nentries) |
55a288e5 | 3612 | { |
3613 | // | |
3a0f6479 | 3614 | // Fill the coefficients found with the fits or other |
3615 | // methods from the Fit functions | |
3616 | // | |
3617 | ||
3618 | if (fDebugLevel != 1) { | |
64942b85 | 3619 | if (fNbDet > 0){ |
3620 | ||
3621 | Int_t firstdetector = fCountDet; | |
3622 | Int_t lastdetector = fCountDet+fNbDet; | |
840ec79d | 3623 | // AliInfo(Form("The element %d containing the detectors %d to %d has been fitted",idect,firstdetector,lastdetector)); |
64942b85 | 3624 | |
3625 | // loop over detectors | |
3626 | for(Int_t det = firstdetector; det < lastdetector; det++){ | |
3627 | ||
3628 | //Set the calibration object again | |
3629 | fCountDet = det; | |
3630 | SetCalROC(1); | |
3631 | ||
3632 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
3633 | // Put them at 1 | |
3634 | fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),1); | |
3635 | fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet) | |
3636 | ,(Int_t) GetStack(fCountDet) | |
3637 | ,(Int_t) GetSector(fCountDet),1); | |
3638 | // Reconstruct row min row max | |
3639 | ReconstructFitRowMinRowMax(idect,1); | |
3640 | ||
3641 | // Calcul the coef from the database choosen for the detector | |
3642 | CalculVdriftCoefMean(); | |
3643 | CalculT0CoefMean(); | |
3644 | ||
3645 | //stack 2, not stack 2 | |
3646 | Int_t factor = 0; | |
3647 | if(GetStack(fCountDet) == 2) factor = 12; | |
3648 | else factor = 16; | |
3649 | ||
3650 | // Fill the fCurrentCoefDetector with negative value to say: not fitted | |
3651 | Double_t coeftoput = 1.5; | |
3652 | Double_t coeftoput2 = 0.0; | |
3653 | ||
3654 | if(fCurrentCoef[0] < 0.0) coeftoput = - TMath::Abs(fCurrentCoef[1]); | |
3655 | else coeftoput = fCurrentCoef[0]; | |
3656 | ||
3657 | if(fCurrentCoef2[0] > 70.0) coeftoput2 = fCurrentCoef2[1] + 100.0; | |
3658 | else coeftoput2 = fCurrentCoef2[0]; | |
3659 | ||
3660 | for (Int_t k = fCalibraMode->GetRowMin(1); k < fCalibraMode->GetRowMax(1); k++) { | |
3661 | for (Int_t j = fCalibraMode->GetColMin(1); j < fCalibraMode->GetColMax(1); j++) { | |
3662 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = coeftoput; | |
3663 | fCurrentCoefDetector2[(Int_t)(j*factor+k)] = coeftoput2; | |
3664 | } | |
3665 | } | |
3666 | ||
3667 | // Fill the stuff | |
3668 | FillVectorFit(); | |
3669 | FillVectorFit2(); | |
3670 | // Debug | |
3671 | if(fDebugLevel > 1){ | |
3672 | ||
3673 | if ( !fDebugStreamer ) { | |
3674 | //debug stream | |
3675 | TDirectory *backup = gDirectory; | |
3676 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPH.root"); | |
3677 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer | |
3678 | } | |
3679 | ||
3680 | ||
3681 | Int_t detector = fCountDet; | |
3682 | Int_t caligroup = idect; | |
3683 | Short_t rowmin = fCalibraMode->GetRowMin(1); | |
3684 | Short_t rowmax = fCalibraMode->GetRowMax(1); | |
3685 | Short_t colmin = fCalibraMode->GetColMin(1); | |
3686 | Short_t colmax = fCalibraMode->GetColMax(1); | |
3687 | Float_t vf = fCurrentCoef[0]; | |
3688 | Float_t vs = fCurrentCoef[1]; | |
3689 | Float_t vfE = fCurrentCoefE; | |
3690 | Float_t t0f = fCurrentCoef2[0]; | |
3691 | Float_t t0s = fCurrentCoef2[1]; | |
3692 | Float_t t0E = fCurrentCoefE2; | |
3693 | ||
3694 | ||
3695 | ||
3696 | (* fDebugStreamer) << "FillFillPH"<< | |
3697 | "detector="<<detector<< | |
3698 | "nentries="<<nentries<< | |
3699 | "caligroup="<<caligroup<< | |
3700 | "rowmin="<<rowmin<< | |
3701 | "rowmax="<<rowmax<< | |
3702 | "colmin="<<colmin<< | |
3703 | "colmax="<<colmax<< | |
3704 | "vf="<<vf<< | |
3705 | "vs="<<vs<< | |
3706 | "vfE="<<vfE<< | |
3707 | "t0f="<<t0f<< | |
3708 | "t0s="<<t0s<< | |
3709 | "t0E="<<t0E<< | |
3710 | "\n"; | |
3711 | } | |
3712 | // Reset | |
3713 | for (Int_t k = 0; k < 2304; k++) { | |
3714 | fCurrentCoefDetector[k] = 0.0; | |
3715 | fCurrentCoefDetector2[k] = 0.0; | |
3716 | } | |
3717 | ||
3718 | }// loop detector | |
3719 | //printf("Check the count now: fCountDet %d\n",fCountDet); | |
3720 | } | |
3721 | else { | |
3722 | ||
3723 | Int_t factor = 0; | |
3724 | if(GetStack(fCountDet) == 2) factor = 12; | |
3725 | else factor = 16; | |
3726 | ||
3727 | for (Int_t k = fCalibraMode->GetRowMin(1); k < fCalibraMode->GetRowMax(1); k++) { | |
3728 | for (Int_t j = fCalibraMode->GetColMin(1); j < fCalibraMode->GetColMax(1); j++) { | |
3729 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = fCurrentCoef[0]; | |
3730 | fCurrentCoefDetector2[(Int_t)(j*factor+k)] = fCurrentCoef2[0]; | |
3731 | } | |
3732 | } | |
3733 | ||
3734 | FillFillPH(idect,nentries); | |
3735 | } | |
55a288e5 | 3736 | } |
3a0f6479 | 3737 | return kTRUE; |
55a288e5 | 3738 | } |
3a0f6479 | 3739 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ |
3740 | Bool_t AliTRDCalibraFit::FillInfosFitPRF(Int_t idect) | |
55a288e5 | 3741 | { |
3742 | // | |
3a0f6479 | 3743 | // Fill the coefficients found with the fits or other |
3744 | // methods from the Fit functions | |
55a288e5 | 3745 | // |
3a0f6479 | 3746 | |
3747 | if (fDebugLevel != 1) { | |
64942b85 | 3748 | if (fNbDet > 0){ |
3a0f6479 | 3749 | |
64942b85 | 3750 | Int_t firstdetector = fCountDet; |
3751 | Int_t lastdetector = fCountDet+fNbDet; | |
840ec79d | 3752 | // AliInfo(Form("The element %d containing the detectors %d to %d has been fitted",idect,firstdetector,lastdetector)); |
64942b85 | 3753 | |
3754 | // loop over detectors | |
3755 | for(Int_t det = firstdetector; det < lastdetector; det++){ | |
3756 | ||
3757 | //Set the calibration object again | |
3758 | fCountDet = det; | |
3759 | SetCalROC(2); | |
3760 | ||
3761 | // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi | |
3762 | // Put them at 1 | |
3763 | fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),2); | |
3764 | fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet) | |
3765 | ,(Int_t) GetStack(fCountDet) | |
3766 | ,(Int_t) GetSector(fCountDet),2); | |
3767 | // Reconstruct row min row max | |
3768 | ReconstructFitRowMinRowMax(idect,2); | |
3769 | ||
3770 | // Calcul the coef from the database choosen for the detector | |
3771 | CalculPRFCoefMean(); | |
3772 | ||
3773 | //stack 2, not stack 2 | |
3774 | Int_t factor = 0; | |
3775 | if(GetStack(fCountDet) == 2) factor = 12; | |
3776 | else factor = 16; | |
3777 | ||
3778 | // Fill the fCurrentCoefDetector with negative value to say: not fitted | |
3779 | Double_t coeftoput = 1.0; | |
3780 | if(fCurrentCoef[0] < 0.0) coeftoput = - TMath::Abs(fCurrentCoef[1]); | |
3781 | else coeftoput = fCurrentCoef[0]; | |
3782 | for (Int_t k = fCalibraMode->GetRowMin(2); k < fCalibraMode->GetRowMax(2); k++) { | |
3783 | for (Int_t j = fCalibraMode->GetColMin(2); j < fCalibraMode->GetColMax(2); j++) { | |
3784 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = coeftoput; | |
3785 | } | |
3786 | } | |
3787 | ||
3788 | // Fill the stuff | |
3789 | FillVectorFit(); | |
3790 | // Debug | |
3791 | if(fDebugLevel > 1){ | |
3792 | ||
3793 | if ( !fDebugStreamer ) { | |
3794 | //debug stream | |
3795 | TDirectory *backup = gDirectory; | |
3796 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPRF.root"); | |
3797 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer | |
3798 | } | |
3799 | ||
3800 | Int_t detector = fCountDet; | |
3801 | Int_t layer = GetLayer(fCountDet); | |
3802 | Int_t caligroup = idect; | |
3803 | Short_t rowmin = fCalibraMode->GetRowMin(2); | |
3804 | Short_t rowmax = fCalibraMode->GetRowMax(2); | |
3805 | Short_t colmin = fCalibraMode->GetColMin(2); | |
3806 | Short_t colmax = fCalibraMode->GetColMax(2); | |
3807 | Float_t widf = fCurrentCoef[0]; | |
3808 | Float_t wids = fCurrentCoef[1]; | |
3809 | Float_t widfE = fCurrentCoefE; | |
3810 | ||
3811 | (* fDebugStreamer) << "FillFillPRF"<< | |
3812 | "detector="<<detector<< | |
3813 | "layer="<<layer<< | |
3814 | "caligroup="<<caligroup<< | |
3815 | "rowmin="<<rowmin<< | |
3816 | "rowmax="<<rowmax<< | |
3817 | "colmin="<<colmin<< | |
3818 | "colmax="<<colmax<< | |
3819 | "widf="<<widf<< | |
3820 | "wids="<<wids<< | |
3821 | "widfE="<<widfE<< | |
3822 | "\n"; | |
3823 | } | |
3824 | // Reset | |
3825 | for (Int_t k = 0; k < 2304; k++) { | |
3826 | fCurrentCoefDetector[k] = 0.0; | |
3827 | } | |
3828 | ||
3829 | }// loop detector | |
3830 | //printf("Check the count now: fCountDet %d\n",fCountDet); | |
3831 | } | |
3832 | else { | |
3833 | ||
3834 | Int_t factor = 0; | |
3835 | if(GetStack(fCountDet) == 2) factor = 12; | |
3836 | else factor = 16; | |
3837 | ||
3838 | // Pointer to the branch | |
3839 | for (Int_t k = fCalibraMode->GetRowMin(2); k < fCalibraMode->GetRowMax(2); k++) { | |
3840 | for (Int_t j = fCalibraMode->GetColMin(2); j < fCalibraMode->GetColMax(2); j++) { | |
3841 | fCurrentCoefDetector[(Int_t)(j*factor+k)] = fCurrentCoef[0]; | |
3842 | } | |
3a0f6479 | 3843 | } |
64942b85 | 3844 | FillFillPRF(idect); |
55a288e5 | 3845 | } |
3846 | } | |
64942b85 | 3847 | |
3a0f6479 | 3848 | return kTRUE; |
55a288e5 | 3849 | |
3a0f6479 | 3850 | } |
3851 | //____________Functions for initialising the AliTRDCalibraFit in the code_________ | |
3852 | Bool_t AliTRDCalibraFit::FillInfosFitLinearFitter() | |
55a288e5 | 3853 | { |
3854 | // | |
3a0f6479 | 3855 | // Fill the coefficients found with the fits or other |
3856 | // methods from the Fit functions | |
55a288e5 | 3857 | // |
3a0f6479 | 3858 | |
3859 | Int_t factor = 0; | |
053767a4 | 3860 | if(GetStack(fCountDet) == 2) factor = 1728; |
3a0f6479 | 3861 | else factor = 2304; |
3862 | ||
3863 | // Pointer to the branch | |
3864 | for (Int_t k = 0; k < factor; k++) { | |
3865 | fCurrentCoefDetector[k] = fCurrentCoef[0]; | |
3866 | fCurrentCoefDetector2[k] = fCurrentCoef2[0]; | |
55a288e5 | 3867 | } |
3a0f6479 | 3868 | |
3869 | FillFillLinearFitter(); | |
3870 | ||
3871 | return kTRUE; | |
55a288e5 | 3872 | |
3873 | } | |
3a0f6479 | 3874 | //________________________________________________________________________________ |
3875 | void AliTRDCalibraFit::FillFillCH(Int_t idect) | |
55a288e5 | 3876 | { |
3877 | // | |
3a0f6479 | 3878 | // DebugStream and fVectorFit |
55a288e5 | 3879 | // |
3880 | ||
3a0f6479 | 3881 | // End of one detector |
3882 | if ((idect == (fCount-1))) { | |
3883 | FillVectorFit(); | |
3884 | // Reset | |
3885 | for (Int_t k = 0; k < 2304; k++) { | |
3886 | fCurrentCoefDetector[k] = 0.0; | |
3887 | } | |
55a288e5 | 3888 | } |
3889 | ||
3a0f6479 | 3890 | if(fDebugLevel > 1){ |
55a288e5 | 3891 | |
3a0f6479 | 3892 | if ( !fDebugStreamer ) { |
3893 | //debug stream | |
3894 | TDirectory *backup = gDirectory; | |
4aad967c | 3895 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitCH.root"); |
3a0f6479 | 3896 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer |
3897 | } | |
3898 | ||
3899 | Int_t detector = fCountDet; | |
3900 | Int_t caligroup = idect; | |
3901 | Short_t rowmin = fCalibraMode->GetRowMin(0); | |
3902 | Short_t rowmax = fCalibraMode->GetRowMax(0); | |
3903 | Short_t colmin = fCalibraMode->GetColMin(0); | |
3904 | Short_t colmax = fCalibraMode->GetColMax(0); | |
3905 | Float_t gf = fCurrentCoef[0]; | |
3906 | Float_t gfs = fCurrentCoef[1]; | |
3907 | Float_t gfE = fCurrentCoefE; | |
3908 | ||
413153cb | 3909 | (*fDebugStreamer) << "FillFillCH" << |
3a0f6479 | 3910 | "detector=" << detector << |
3911 | "caligroup=" << caligroup << | |
3912 | "rowmin=" << rowmin << | |
3913 | "rowmax=" << rowmax << | |
3914 | "colmin=" << colmin << | |
3915 | "colmax=" << colmax << | |
3916 | "gf=" << gf << | |
3917 | "gfs=" << gfs << | |
3918 | "gfE=" << gfE << | |
3919 | "\n"; | |
3920 | ||
3921 | } | |
3922 | } | |
3923 | //________________________________________________________________________________ | |
64942b85 | 3924 | void AliTRDCalibraFit::FillFillPH(Int_t idect,Double_t nentries) |
55a288e5 | 3925 | { |
3926 | // | |
3a0f6479 | 3927 | // DebugStream and fVectorFit and fVectorFit2 |
55a288e5 | 3928 | // |
3a0f6479 | 3929 | |
3930 | // End of one detector | |
3931 | if ((idect == (fCount-1))) { | |
3932 | FillVectorFit(); | |
3933 | FillVectorFit2(); | |
3934 | // Reset | |
3935 | for (Int_t k = 0; k < 2304; k++) { | |
3936 | fCurrentCoefDetector[k] = 0.0; | |
3937 | fCurrentCoefDetector2[k] = 0.0; | |
3938 | } | |
3939 | } | |
3940 | ||
3941 | if(fDebugLevel > 1){ | |
3942 | ||
3943 | if ( !fDebugStreamer ) { | |
3944 | //debug stream | |
3945 | TDirectory *backup = gDirectory; | |
4aad967c | 3946 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPH.root"); |
3a0f6479 | 3947 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer |
3948 | } | |
3949 | ||
3950 | ||
3951 | Int_t detector = fCountDet; | |
3952 | Int_t caligroup = idect; | |
3953 | Short_t rowmin = fCalibraMode->GetRowMin(1); | |
3954 | Short_t rowmax = fCalibraMode->GetRowMax(1); | |
3955 | Short_t colmin = fCalibraMode->GetColMin(1); | |
3956 | Short_t colmax = fCalibraMode->GetColMax(1); | |
3957 | Float_t vf = fCurrentCoef[0]; | |
3958 | Float_t vs = fCurrentCoef[1]; | |
3959 | Float_t vfE = fCurrentCoefE; | |
3960 | Float_t t0f = fCurrentCoef2[0]; | |
3961 | Float_t t0s = fCurrentCoef2[1]; | |
3962 | Float_t t0E = fCurrentCoefE2; | |
3963 | ||
55a288e5 | 3964 | |
3a0f6479 | 3965 | |
413153cb | 3966 | (* fDebugStreamer) << "FillFillPH"<< |
3a0f6479 | 3967 | "detector="<<detector<< |
64942b85 | 3968 | "nentries="<<nentries<< |
3a0f6479 | 3969 | "caligroup="<<caligroup<< |
3970 | "rowmin="<<rowmin<< | |
3971 | "rowmax="<<rowmax<< | |
3972 | "colmin="<<colmin<< | |
3973 | "colmax="<<colmax<< | |
3974 | "vf="<<vf<< | |
3975 | "vs="<<vs<< | |
3976 | "vfE="<<vfE<< | |
3977 | "t0f="<<t0f<< | |
3978 | "t0s="<<t0s<< | |
3979 | "t0E="<<t0E<< | |
3980 | "\n"; | |
3981 | } | |
55a288e5 | 3982 | |
3983 | } | |
3a0f6479 | 3984 | //________________________________________________________________________________ |
3985 | void AliTRDCalibraFit::FillFillPRF(Int_t idect) | |
3986 | { | |
3987 | // | |
3988 | // DebugStream and fVectorFit | |
3989 | // | |
55a288e5 | 3990 | |
3a0f6479 | 3991 | // End of one detector |
3992 | if ((idect == (fCount-1))) { | |
3993 | FillVectorFit(); | |
3994 | // Reset | |
3995 | for (Int_t k = 0; k < 2304; k++) { | |
3996 | fCurrentCoefDetector[k] = 0.0; | |
3997 | } | |
3998 | } | |
3999 | ||
4000 | ||
4001 | if(fDebugLevel > 1){ | |
4002 | ||
4003 | if ( !fDebugStreamer ) { | |
4004 | //debug stream | |
4005 | TDirectory *backup = gDirectory; | |
4aad967c | 4006 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPRF.root"); |
3a0f6479 | 4007 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer |
4008 | } | |
4009 | ||
4010 | Int_t detector = fCountDet; | |
053767a4 | 4011 | Int_t layer = GetLayer(fCountDet); |
3a0f6479 | 4012 | Int_t caligroup = idect; |
4013 | Short_t rowmin = fCalibraMode->GetRowMin(2); | |
4014 | Short_t rowmax = fCalibraMode->GetRowMax(2); | |
4015 | Short_t colmin = fCalibraMode->GetColMin(2); | |
4016 | Short_t colmax = fCalibraMode->GetColMax(2); | |
4017 | Float_t widf = fCurrentCoef[0]; | |
4018 | Float_t wids = fCurrentCoef[1]; | |
4019 | Float_t widfE = fCurrentCoefE; | |
4020 | ||
413153cb | 4021 | (* fDebugStreamer) << "FillFillPRF"<< |
3a0f6479 | 4022 | "detector="<<detector<< |
053767a4 | 4023 | "layer="<<layer<< |
3a0f6479 | 4024 | "caligroup="<<caligroup<< |
4025 | "rowmin="<<rowmin<< | |
4026 | "rowmax="<<rowmax<< | |
4027 | "colmin="<<colmin<< | |
4028 | "colmax="<<colmax<< | |
4029 | "widf="<<widf<< | |
4030 | "wids="<<wids<< | |
4031 | "widfE="<<widfE<< | |
4032 | "\n"; | |
4033 | } | |
4034 | ||
4035 | } | |
4036 | //________________________________________________________________________________ | |
4037 | void AliTRDCalibraFit::FillFillLinearFitter() | |
55a288e5 | 4038 | { |
4039 | // | |
3a0f6479 | 4040 | // DebugStream and fVectorFit |
55a288e5 | 4041 | // |
3a0f6479 | 4042 | |
4043 | // End of one detector | |
4044 | FillVectorFit(); | |
4045 | FillVectorFit2(); | |
4046 | ||
4047 | ||
4048 | // Reset | |
4049 | for (Int_t k = 0; k < 2304; k++) { | |
4050 | fCurrentCoefDetector[k] = 0.0; | |
4051 | fCurrentCoefDetector2[k] = 0.0; | |
55a288e5 | 4052 | } |
3a0f6479 | 4053 | |
55a288e5 | 4054 | |
3a0f6479 | 4055 | if(fDebugLevel > 1){ |
55a288e5 | 4056 | |
3a0f6479 | 4057 | if ( !fDebugStreamer ) { |
4058 | //debug stream | |
4059 | TDirectory *backup = gDirectory; | |
4aad967c | 4060 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitLinearFitter.root"); |
3a0f6479 | 4061 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer |
4062 | } | |
4063 | ||
4064 | //Debug: comparaison of the different methods (okey for first time but not for iterative procedure) | |
053767a4 | 4065 | AliTRDpadPlane *padplane = fGeo->GetPadPlane(GetLayer(fCountDet),GetStack(fCountDet)); |
3a0f6479 | 4066 | Float_t rowmd = (padplane->GetRow0()+padplane->GetRowEnd())/2.; |
053767a4 | 4067 | Float_t r = AliTRDgeometry::GetTime0(GetLayer(fCountDet)); |
3a0f6479 | 4068 | Float_t tiltangle = padplane->GetTiltingAngle(); |
4069 | Int_t detector = fCountDet; | |
053767a4 | 4070 | Int_t stack = GetStack(fCountDet); |
4071 | Int_t layer = GetLayer(fCountDet); | |
3a0f6479 | 4072 | Float_t vf = fCurrentCoef[0]; |
4073 | Float_t vs = fCurrentCoef[1]; | |
4074 | Float_t vfE = fCurrentCoefE; | |
4075 | Float_t lorentzangler = fCurrentCoef2[0]; | |
e6381f8e | 4076 | Float_t elorentzangler = fCurrentCoefE2; |
3a0f6479 | 4077 | Float_t lorentzangles = fCurrentCoef2[1]; |
4078 | ||
413153cb | 4079 | (* fDebugStreamer) << "FillFillLinearFitter"<< |
3a0f6479 | 4080 | "detector="<<detector<< |
053767a4 | 4081 | "stack="<<stack<< |
4082 | "layer="<<layer<< | |
3a0f6479 | 4083 | "rowmd="<<rowmd<< |
4084 | "r="<<r<< | |
4085 | "tiltangle="<<tiltangle<< | |
4086 | "vf="<<vf<< | |
4087 | "vs="<<vs<< | |
4088 | "vfE="<<vfE<< | |
4089 | "lorentzangler="<<lorentzangler<< | |
e6381f8e | 4090 | "Elorentzangler="<<elorentzangler<< |
3a0f6479 | 4091 | "lorentzangles="<<lorentzangles<< |
4092 | "\n"; | |
4093 | } | |
4094 | ||
4095 | } | |
55a288e5 | 4096 | // |
4097 | //____________Calcul Coef Mean_________________________________________________ | |
4098 | // | |
55a288e5 | 4099 | //_____________________________________________________________________________ |
3a0f6479 | 4100 | Bool_t AliTRDCalibraFit::CalculT0CoefMean() |
55a288e5 | 4101 | { |
4102 | // | |
4103 | // For the detector Dect calcul the mean time 0 | |
4104 | // for the calibration group idect from the choosen database | |
4105 | // | |
4106 | ||
3a0f6479 | 4107 | fCurrentCoef2[1] = 0.0; |
4108 | if(fDebugLevel != 1){ | |
64942b85 | 4109 | if(((fCalibraMode->GetNz(1) > 0) || |
4110 | (fCalibraMode->GetNrphi(1) > 0)) && ((fCalibraMode->GetNz(1) != 10) && (fCalibraMode->GetNz(1) != 100))) { | |
4111 | ||
3a0f6479 | 4112 | for (Int_t row = fCalibraMode->GetRowMin(1); row < fCalibraMode->GetRowMax(1); row++) { |
4113 | for (Int_t col = fCalibraMode->GetColMin(1); col < fCalibraMode->GetColMax(1); col++) { | |
4114 | fCurrentCoef2[1] += (Float_t) (fCalROC2->GetValue(col,row)+fCalDet2->GetValue(fCountDet)); | |
55a288e5 | 4115 | } |
3a0f6479 | 4116 | } |
64942b85 | 4117 | |
3a0f6479 | 4118 | fCurrentCoef2[1] = fCurrentCoef2[1] / ((fCalibraMode->GetColMax(1)-fCalibraMode->GetColMin(1))*(fCalibraMode->GetRowMax(1)-fCalibraMode->GetRowMin(1))); |
64942b85 | 4119 | |
3a0f6479 | 4120 | } |
4121 | else { | |
64942b85 | 4122 | |
3a0f6479 | 4123 | if(!fAccCDB){ |
4124 | fCurrentCoef2[1] = fCalDet2->GetValue(fCountDet); | |
4125 | } | |
4126 | else{ | |
64942b85 | 4127 | |
053767a4 | 4128 | for(Int_t row = 0; row < fGeo->GetRowMax(GetLayer(fCountDet),GetStack(fCountDet),GetSector(fCountDet)); row++){ |
4129 | for(Int_t col = 0; col < fGeo->GetColMax(GetLayer(fCountDet)); col++){ | |
3a0f6479 | 4130 | fCurrentCoef2[1] += (Float_t) (fCalROC2->GetValue(col,row)+fCalDet2->GetValue(fCountDet)); |
4131 | } | |
55a288e5 | 4132 | } |
053767a4 | 4133 | fCurrentCoef2[1] = fCurrentCoef2[1] / ((fGeo->GetRowMax(GetLayer(fCountDet),GetStack(fCountDet),GetSector(fCountDet)))*(fGeo->GetColMax(GetLayer(fCountDet)))); |
64942b85 | 4134 | |
55a288e5 | 4135 | } |
4136 | } | |
55a288e5 | 4137 | } |
55a288e5 | 4138 | return kTRUE; |
55a288e5 | 4139 | } |
4140 | ||
4141 | //_____________________________________________________________________________ | |
3a0f6479 | 4142 | Bool_t AliTRDCalibraFit::CalculChargeCoefMean(Bool_t vrai) |
55a288e5 | 4143 | { |
4144 | // | |
4145 | // For the detector Dect calcul the mean gain factor | |
4146 | // for the calibration group idect from the choosen database | |
4147 | // | |
4148 | ||
3a0f6479 | 4149 | fCurrentCoef[1] = 0.0; |
4150 | if(fDebugLevel != 1){ | |
64942b85 | 4151 | if (((fCalibraMode->GetNz(0) > 0) || |
4152 | (fCalibraMode->GetNrphi(0) > 0)) && ((fCalibraMode->GetNz(0) != 10) && (fCalibraMode->GetNz(0) != 100))) { | |
3a0f6479 | 4153 | for (Int_t row = fCalibraMode->GetRowMin(0); row < fCalibraMode->GetRowMax(0); row++) { |
4154 | for (Int_t col = fCalibraMode->GetColMin(0); col < fCalibraMode->GetColMax(0); col++) { | |
4155 | fCurrentCoef[1] += (Float_t) (fCalROC->GetValue(col,row)*fCalDet->GetValue(fCountDet)); | |
4156 | if (vrai) fScaleFitFactor += (Float_t) (fCalROC->GetValue(col,row)*fCalDet->GetValue(fCountDet)); | |
55a288e5 | 4157 | } |
4158 | } | |
3a0f6479 | 4159 | fCurrentCoef[1] = fCurrentCoef[1] / ((fCalibraMode->GetColMax(0)-fCalibraMode->GetColMin(0))*(fCalibraMode->GetRowMax(0)-fCalibraMode->GetRowMin(0))); |
55a288e5 | 4160 | } |
3a0f6479 | 4161 | else { |
4162 | //Per detectors | |
4163 | fCurrentCoef[1] = (Float_t) fCalDet->GetValue(fCountDet); | |
4164 | if (vrai) fScaleFitFactor += ((Float_t) fCalDet->GetValue(fCountDet))*(fCalibraMode->GetColMax(0)-fCalibraMode->GetColMin(0))*(fCalibraMode->GetRowMax(0)-fCalibraMode->GetRowMin(0)); | |
4165 | } | |
55a288e5 | 4166 | } |
55a288e5 | 4167 | return kTRUE; |
55a288e5 | 4168 | } |
55a288e5 | 4169 | //_____________________________________________________________________________ |
3a0f6479 | 4170 | Bool_t AliTRDCalibraFit::CalculPRFCoefMean() |
55a288e5 | 4171 | { |
4172 | // | |
4173 | // For the detector Dect calcul the mean sigma of pad response | |
4174 | // function for the calibration group idect from the choosen database | |
4175 | // | |
3a0f6479 | 4176 | |
4177 | fCurrentCoef[1] = 0.0; | |
4178 | if(fDebugLevel != 1){ | |
55a288e5 | 4179 | for (Int_t row = fCalibraMode->GetRowMin(2); row < fCalibraMode->GetRowMax(2); row++) { |
4180 | for (Int_t col = fCalibraMode->GetColMin(2); col < fCalibraMode->GetColMax(2); col++) { | |
3a0f6479 | 4181 | fCurrentCoef[1] += (Float_t) fCalROC->GetValue(col,row); |
55a288e5 | 4182 | } |
4183 | } | |
3a0f6479 | 4184 | fCurrentCoef[1] = fCurrentCoef[1] / ((fCalibraMode->GetColMax(2)-fCalibraMode->GetColMin(2))*(fCalibraMode->GetRowMax(2)-fCalibraMode->GetRowMin(2))); |
55a288e5 | 4185 | } |
55a288e5 | 4186 | return kTRUE; |
55a288e5 | 4187 | } |
55a288e5 | 4188 | //_____________________________________________________________________________ |
3a0f6479 | 4189 | Bool_t AliTRDCalibraFit::CalculVdriftCoefMean() |
55a288e5 | 4190 | { |
4191 | // | |
4192 | // For the detector dect calcul the mean drift velocity for the | |
4193 | // calibration group idect from the choosen database | |
4194 | // | |
4195 | ||
3a0f6479 | 4196 | fCurrentCoef[1] = 0.0; |
4197 | if(fDebugLevel != 1){ | |
64942b85 | 4198 | if (((fCalibraMode->GetNz(1) > 0) || |
4199 | (fCalibraMode->GetNrphi(1) > 0)) && ((fCalibraMode->GetNz(1) != 10) && (fCalibraMode->GetNz(1) != 100))) { | |
4200 | ||
3a0f6479 | 4201 | for (Int_t row = fCalibraMode->GetRowMin(1); row < fCalibraMode->GetRowMax(1); row++) { |
4202 | for (Int_t col = fCalibraMode->GetColMin(1); col < fCalibraMode->GetColMax(1); col++) { | |
4203 | fCurrentCoef[1] += (Float_t) (fCalROC->GetValue(col,row)*fCalDet->GetValue(fCountDet)); | |
55a288e5 | 4204 | } |
4205 | } | |
64942b85 | 4206 | |
3a0f6479 | 4207 | fCurrentCoef[1] = fCurrentCoef[1] / ((fCalibraMode->GetColMax(1)-fCalibraMode->GetColMin(1))*(fCalibraMode->GetRowMax(1)-fCalibraMode->GetRowMin(1))); |
64942b85 | 4208 | |
55a288e5 | 4209 | } |
3a0f6479 | 4210 | else { |
4211 | //per detectors | |
4212 | fCurrentCoef[1] = (Float_t) fCalDet->GetValue(fCountDet); | |
4213 | } | |
55a288e5 | 4214 | } |
55a288e5 | 4215 | return kTRUE; |
55a288e5 | 4216 | } |
3a0f6479 | 4217 | //_____________________________________________________________________________ |
4218 | Bool_t AliTRDCalibraFit::CalculVdriftLorentzCoef() | |
4219 | { | |
4220 | // | |
4221 | // For the detector fCountDet, mean drift velocity and tan lorentzangle | |
4222 | // | |
4223 | ||
840ec79d | 4224 | fCurrentCoef[1] = fCalDetVdriftUsed->GetValue(fCountDet); |
4225 | fCurrentCoef2[1] = fCalDetExBUsed->GetValue(fCountDet); | |
55a288e5 | 4226 | |
3a0f6479 | 4227 | return kTRUE; |
4228 | } | |
55a288e5 | 4229 | //_____________________________________________________________________________ |
053767a4 | 4230 | Float_t AliTRDCalibraFit::GetPRFDefault(Int_t layer) const |
55a288e5 | 4231 | { |
4232 | // | |
4233 | // Default width of the PRF if there is no database as reference | |
4234 | // | |
053767a4 | 4235 | switch(layer) |
3a0f6479 | 4236 | { |
4237 | // default database | |
4238 | //case 0: return 0.515; | |
4239 | //case 1: return 0.502; | |
4240 | //case 2: return 0.491; | |
4241 | //case 3: return 0.481; | |
4242 | //case 4: return 0.471; | |
4243 | //case 5: return 0.463; | |
4244 | //default: return 0.0; | |
4245 | ||
4246 | // fit database | |
4247 | case 0: return 0.538429; | |
4248 | case 1: return 0.524302; | |
4249 | case 2: return 0.511591; | |
4250 | case 3: return 0.500140; | |
4251 | case 4: return 0.489821; | |
4252 | case 5: return 0.480524; | |
4253 | default: return 0.0; | |
55a288e5 | 4254 | } |
3a0f6479 | 4255 | } |
4256 | //________________________________________________________________________________ | |
4257 | void AliTRDCalibraFit::SetCalROC(Int_t i) | |
4258 | { | |
4259 | // | |
4260 | // Set the calib object for fCountDet | |
4261 | // | |
4262 | ||
4263 | Float_t value = 0.0; | |
4264 | ||
4265 | //Get the CalDet object | |
4266 | if(fAccCDB){ | |
4267 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
4268 | if (!cal) { | |
4269 | AliInfo("Could not get calibDB"); | |
4270 | return; | |
4271 | } | |
4272 | switch (i) | |
4273 | { | |
4274 | case 0: | |
64942b85 | 4275 | if( fCalROC ){ |
4276 | fCalROC->~AliTRDCalROC(); | |
4277 | new(fCalROC) AliTRDCalROC(*(cal->GetGainFactorROC(fCountDet))); | |
4278 | }else fCalROC = new AliTRDCalROC(*(cal->GetGainFactorROC(fCountDet))); | |
3a0f6479 | 4279 | break; |
4280 | case 1: | |
64942b85 | 4281 | if( fCalROC ){ |
4282 | fCalROC->~AliTRDCalROC(); | |
4283 | new(fCalROC) AliTRDCalROC(*(cal->GetVdriftROC(fCountDet))); | |
4284 | }else fCalROC = new AliTRDCalROC(*(cal->GetVdriftROC(fCountDet))); | |
4285 | if( fCalROC2 ){ | |
4286 | fCalROC2->~AliTRDCalROC(); | |
4287 | new(fCalROC2) AliTRDCalROC(*(cal->GetT0ROC(fCountDet))); | |
4288 | }else fCalROC2 = new AliTRDCalROC(*(cal->GetT0ROC(fCountDet))); | |
3a0f6479 | 4289 | break; |
4290 | case 2: | |
64942b85 | 4291 | if( fCalROC ){ |
4292 | fCalROC->~AliTRDCalROC(); | |
4293 | new(fCalROC) AliTRDCalROC(*(cal->GetPRFROC(fCountDet))); | |
4294 | }else fCalROC = new AliTRDCalROC(*(cal->GetPRFROC(fCountDet))); | |
4295 | break; | |
3a0f6479 | 4296 | default: return; |
4297 | } | |
55a288e5 | 4298 | } |
3a0f6479 | 4299 | else{ |
4300 | switch (i) | |
4301 | { | |
4302 | case 0: | |
4303 | if(fCalROC) delete fCalROC; | |
053767a4 | 4304 | fCalROC = new AliTRDCalROC(GetLayer(fCountDet),GetStack(fCountDet)); |
3a0f6479 | 4305 | for(Int_t k = 0; k < fCalROC->GetNchannels(); k++){ |
4306 | fCalROC->SetValue(k,1.0); | |
4307 | } | |
4308 | break; | |
4309 | case 1: | |
4310 | if(fCalROC) delete fCalROC; | |
4311 | if(fCalROC2) delete fCalROC2; | |
053767a4 | 4312 | fCalROC = new AliTRDCalROC(GetLayer(fCountDet),GetStack(fCountDet)); |
4313 | fCalROC2 = new AliTRDCalROC(GetLayer(fCountDet),GetStack(fCountDet)); | |
3a0f6479 | 4314 | for(Int_t k = 0; k < fCalROC->GetNchannels(); k++){ |
4315 | fCalROC->SetValue(k,1.0); | |
4316 | fCalROC2->SetValue(k,0.0); | |
4317 | } | |
4318 | break; | |
4319 | case 2: | |
4320 | if(fCalROC) delete fCalROC; | |
053767a4 | 4321 | value = GetPRFDefault(GetLayer(fCountDet)); |
4322 | fCalROC = new AliTRDCalROC(GetLayer(fCountDet),GetStack(fCountDet)); | |
3a0f6479 | 4323 | for(Int_t k = 0; k < fCalROC->GetNchannels(); k++){ |
4324 | fCalROC->SetValue(k,value); | |
4325 | } | |
4326 | break; | |
4327 | default: return; | |
4328 | } | |
55a288e5 | 4329 | } |
4330 | ||
4331 | } | |
55a288e5 | 4332 | //____________Fit Methods______________________________________________________ |
4333 | ||
4334 | //_____________________________________________________________________________ | |
3a0f6479 | 4335 | void AliTRDCalibraFit::FitPente(TH1* projPH) |
55a288e5 | 4336 | { |
4337 | // | |
4338 | // Slope methode for the drift velocity | |
4339 | // | |
4340 | ||
4341 | // Constants | |
4342 | const Float_t kDrWidth = AliTRDgeometry::DrThick(); | |
3a0f6479 | 4343 | Int_t binmax = 0; |
4344 | Int_t binmin = 0; | |
4345 | fPhd[0] = 0.0; | |
4346 | fPhd[1] = 0.0; | |
4347 | fPhd[2] = 0.0; | |
4348 | Int_t ju = 0; | |
4349 | fCurrentCoefE = 0.0; | |
4350 | fCurrentCoefE2 = 0.0; | |
4351 | fCurrentCoef[0] = 0.0; | |
4352 | fCurrentCoef2[0] = 0.0; | |
4353 | TLine *line = new TLine(); | |
55a288e5 | 4354 | |
4355 | // Some variables | |
4356 | TAxis *xpph = projPH->GetXaxis(); | |
4357 | Int_t nbins = xpph->GetNbins(); | |
4358 | Double_t lowedge = xpph->GetBinLowEdge(1); | |
4359 | Double_t upedge = xpph->GetBinUpEdge(xpph->GetNbins()); | |
4360 | Double_t widbins = (upedge - lowedge) / nbins; | |
4361 | Double_t limit = upedge + 0.5 * widbins; | |
4362 | Bool_t put = kTRUE; | |
4363 | ||
4364 | // Beginning of the signal | |
4365 | TH1D *pentea = new TH1D("pentea","pentea",projPH->GetNbinsX(),0,(Float_t) limit); | |
4366 | for (Int_t k = 1; k < projPH->GetNbinsX(); k++) { | |
4367 | pentea->SetBinContent(k,(Double_t) (projPH->GetBinContent(k+1) - projPH->GetBinContent(k))); | |
4368 | } | |
55a288e5 | 4369 | binmax = (Int_t) pentea->GetMaximumBin(); |
55a288e5 | 4370 | if (binmax <= 1) { |
4371 | binmax = 2; | |
4372 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
4373 | } | |
4374 | if (binmax >= nbins) { | |
4375 | binmax = nbins-1; | |
4376 | put = kFALSE; | |
4377 | AliInfo("Put the binmax from nbins-1 to nbins-2 to enable the fit"); | |
4378 | } | |
4379 | pentea->Fit("pol2","0MR","",TMath::Max(pentea->GetBinCenter(binmax-1),0.0),pentea->GetBinCenter(binmax+1)); | |
4380 | Float_t l3P1am = pentea->GetFunction("pol2")->GetParameter(1); | |
4381 | Float_t l3P2am = pentea->GetFunction("pol2")->GetParameter(2); | |
4382 | Float_t l3P1amE = pentea->GetFunction("pol2")->GetParError(1); | |
4383 | Float_t l3P2amE = pentea->GetFunction("pol2")->GetParError(2); | |
daa7dc79 | 4384 | if (TMath::Abs(l3P2am) > 0.00000001) { |
55a288e5 | 4385 | fPhd[0] = -(l3P1am / (2 * l3P2am)); |
4386 | } | |
4387 | if(!fTakeTheMaxPH){ | |
daa7dc79 | 4388 | if((TMath::Abs(l3P1am) > 0.0000000001) && (TMath::Abs(l3P2am) > 0.00000000001)){ |
3a0f6479 | 4389 | fCurrentCoefE2 = (l3P1amE/l3P1am + l3P2amE/l3P2am)*fPhd[0]; |
55a288e5 | 4390 | } |
4391 | } | |
55a288e5 | 4392 | // Amplification region |
4393 | binmax = 0; | |
4394 | ju = 0; | |
4395 | for (Int_t kbin = 1; kbin < projPH->GetNbinsX(); kbin ++) { | |
3a0f6479 | 4396 | if (((projPH->GetBinContent(kbin+1) - projPH->GetBinContent(kbin)) <= 0.0) && (ju == 0) && (kbin > (fPhd[0]/widbins))) { |
55a288e5 | 4397 | binmax = kbin; |
4398 | ju = 1; | |
4399 | } | |
4400 | } | |
55a288e5 | 4401 | if (binmax <= 1) { |
4402 | binmax = 2; | |
4403 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
4404 | } | |
4405 | if (binmax >= nbins) { | |
4406 | binmax = nbins-1; | |
4407 | put = kFALSE; | |
4408 | AliInfo("Put the binmax from nbins-1 to nbins-2 to enable the fit"); | |
4409 | } | |
4410 | projPH->Fit("pol2","0MR","",TMath::Max(projPH->GetBinCenter(binmax-1),0.0),projPH->GetBinCenter(binmax+1)); | |
4411 | Float_t l3P1amf = projPH->GetFunction("pol2")->GetParameter(1); | |
4412 | Float_t l3P2amf = projPH->GetFunction("pol2")->GetParameter(2); | |
4413 | Float_t l3P1amfE = projPH->GetFunction("pol2")->GetParError(1); | |
4414 | Float_t l3P2amfE = projPH->GetFunction("pol2")->GetParError(2); | |
daa7dc79 | 4415 | if (TMath::Abs(l3P2amf) > 0.00000000001) { |
55a288e5 | 4416 | fPhd[1] = -(l3P1amf / (2 * l3P2amf)); |
4417 | } | |
daa7dc79 | 4418 | if((TMath::Abs(l3P1amf) > 0.0000000001) && (TMath::Abs(l3P2amf) > 0.000000001)){ |
3a0f6479 | 4419 | fCurrentCoefE = (l3P1amfE/l3P1amf + l3P2amfE/l3P2amf)*fPhd[1]; |
55a288e5 | 4420 | } |
4421 | if(fTakeTheMaxPH){ | |
3a0f6479 | 4422 | fCurrentCoefE2 = fCurrentCoefE; |
55a288e5 | 4423 | } |
55a288e5 | 4424 | // Drift region |
4425 | TH1D *pente = new TH1D("pente","pente",projPH->GetNbinsX(),0,(Float_t) limit); | |
4426 | for (Int_t k = TMath::Min(binmax+4,projPH->GetNbinsX()); k < projPH->GetNbinsX(); k++) { | |
4427 | pente->SetBinContent(k,(Double_t) (projPH->GetBinContent(k+1) - projPH->GetBinContent(k))); | |
4428 | } | |
4429 | binmin = 0; | |
4430 | if(pente->GetEntries() > 0) binmin = (Int_t) pente->GetMinimumBin(); | |
4431 | if (binmin <= 1) { | |
4432 | binmin = 2; | |
4433 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
4434 | } | |
4435 | if (binmin >= nbins) { | |
4436 | binmin = nbins-1; | |
4437 | put = kFALSE; | |
4438 | AliInfo("Put the binmax from nbins-1 to nbins-2 to enable the fit"); | |
4439 | } | |
55a288e5 | 4440 | pente->Fit("pol2" |
4441 | ,"0MR" | |
4442 | ,"" | |
4443 | ,TMath::Max(pente->GetBinCenter(binmin-1), 0.0) | |
4444 | ,TMath::Min(pente->GetBinCenter(binmin+1),(Double_t) limit)); | |
4445 | Float_t l3P1dr = pente->GetFunction("pol2")->GetParameter(1); | |
4446 | Float_t l3P2dr = pente->GetFunction("pol2")->GetParameter(2); | |
4447 | Float_t l3P1drE = pente->GetFunction("pol2")->GetParError(1); | |
4448 | Float_t l3P2drE = pente->GetFunction("pol2")->GetParError(2); | |
daa7dc79 | 4449 | if (TMath::Abs(l3P2dr) > 0.00000001) { |
55a288e5 | 4450 | fPhd[2] = -(l3P1dr / (2 * l3P2dr)); |
4451 | } | |
daa7dc79 | 4452 | if((TMath::Abs(l3P1dr) > 0.0000000001) && (TMath::Abs(l3P2dr) > 0.00000000001)){ |
3a0f6479 | 4453 | fCurrentCoefE += (l3P1drE/l3P1dr + l3P2drE/l3P2dr)*fPhd[2]; |
55a288e5 | 4454 | } |
413153cb | 4455 | Float_t fPhdt0 = 0.0; |
4456 | Float_t t0Shift = 0.0; | |
4457 | if(fTakeTheMaxPH) { | |
4458 | fPhdt0 = fPhd[1]; | |
4459 | t0Shift = fT0Shift1; | |
4460 | } | |
4461 | else { | |
4462 | fPhdt0 = fPhd[0]; | |
4463 | t0Shift = fT0Shift0; | |
4464 | } | |
55a288e5 | 4465 | |
4466 | if ((fPhd[2] > fPhd[0]) && | |
4467 | (fPhd[2] > fPhd[1]) && | |
4468 | (fPhd[1] > fPhd[0]) && | |
4469 | (put)) { | |
3a0f6479 | 4470 | fCurrentCoef[0] = (kDrWidth) / (fPhd[2]-fPhd[1]); |
4471 | fNumberFitSuccess++; | |
4472 | ||
55a288e5 | 4473 | if (fPhdt0 >= 0.0) { |
413153cb | 4474 | fCurrentCoef2[0] = (fPhdt0 - t0Shift) / widbins; |
b88b6bcc | 4475 | if (fCurrentCoef2[0] < -3.0) { |
64942b85 | 4476 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
55a288e5 | 4477 | } |
4478 | } | |
4479 | else { | |
64942b85 | 4480 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
55a288e5 | 4481 | } |
3a0f6479 | 4482 | |
55a288e5 | 4483 | } |
4484 | else { | |
3a0f6479 | 4485 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); |
64942b85 | 4486 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
55a288e5 | 4487 | } |
4488 | ||
3a0f6479 | 4489 | if (fDebugLevel == 1) { |
55a288e5 | 4490 | TCanvas *cpentei = new TCanvas("cpentei","cpentei",50,50,600,800); |
4491 | cpentei->cd(); | |
4492 | projPH->Draw(); | |
4493 | line->SetLineColor(2); | |
4494 | line->DrawLine(fPhd[0],0,fPhd[0],projPH->GetMaximum()); | |
4495 | line->DrawLine(fPhd[1],0,fPhd[1],projPH->GetMaximum()); | |
4496 | line->DrawLine(fPhd[2],0,fPhd[2],projPH->GetMaximum()); | |
4497 | AliInfo(Form("fPhd[0] (beginning of the signal): %f" ,(Float_t) fPhd[0])); | |
4498 | AliInfo(Form("fPhd[1] (end of the amplification region): %f" ,(Float_t) fPhd[1])); | |
4499 | AliInfo(Form("fPhd[2] (end of the drift region): %f" ,(Float_t) fPhd[2])); | |
3a0f6479 | 4500 | AliInfo(Form("fVriftCoef[1] (with only the drift region(default)): %f",(Float_t) fCurrentCoef[0])); |
55a288e5 | 4501 | TCanvas *cpentei2 = new TCanvas("cpentei2","cpentei2",50,50,600,800); |
4502 | cpentei2->cd(); | |
4503 | pentea->Draw(); | |
4504 | TCanvas *cpentei3 = new TCanvas("cpentei3","cpentei3",50,50,600,800); | |
4505 | cpentei3->cd(); | |
4506 | pente->Draw(); | |
4507 | } | |
3a0f6479 | 4508 | else { |
55a288e5 | 4509 | delete pentea; |
55a288e5 | 4510 | delete pente; |
4511 | } | |
55a288e5 | 4512 | } |
55a288e5 | 4513 | //_____________________________________________________________________________ |
3a0f6479 | 4514 | void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH) |
55a288e5 | 4515 | { |
4516 | // | |
4517 | // Slope methode but with polynomes de Lagrange | |
4518 | // | |
6aafa7ea | 4519 | |
55a288e5 | 4520 | // Constants |
4521 | const Float_t kDrWidth = AliTRDgeometry::DrThick(); | |
3a0f6479 | 4522 | Int_t binmax = 0; |
4523 | Int_t binmin = 0; | |
fdc15553 | 4524 | //Double_t *x = new Double_t[5]; |
4525 | //Double_t *y = new Double_t[5]; | |
4526 | Double_t x[5]; | |
4527 | Double_t y[5]; | |
3a0f6479 | 4528 | x[0] = 0.0; |
4529 | x[1] = 0.0; | |
4530 | x[2] = 0.0; | |
4531 | x[3] = 0.0; | |
4532 | x[4] = 0.0; | |
4533 | y[0] = 0.0; | |
4534 | y[1] = 0.0; | |
4535 | y[2] = 0.0; | |
4536 | y[3] = 0.0; | |
4537 | y[4] = 0.0; | |
4538 | fPhd[0] = 0.0; | |
4539 | fPhd[1] = 0.0; | |
4540 | fPhd[2] = 0.0; | |
4541 | Int_t ju = 0; | |
4542 | fCurrentCoefE = 0.0; | |
4543 | fCurrentCoefE2 = 1.0; | |
4544 | fCurrentCoef[0] = 0.0; | |
4545 | fCurrentCoef2[0] = 0.0; | |
55a288e5 | 4546 | TLine *line = new TLine(); |
4547 | TF1 * polynome = 0x0; | |
4548 | TF1 * polynomea = 0x0; | |
4549 | TF1 * polynomeb = 0x0; | |
3b0c1edc | 4550 | Double_t c0 = 0.0; |
4551 | Double_t c1 = 0.0; | |
4552 | Double_t c2 = 0.0; | |
4553 | Double_t c3 = 0.0; | |
4554 | Double_t c4 = 0.0; | |
55a288e5 | 4555 | |
4556 | // Some variables | |
4557 | TAxis *xpph = projPH->GetXaxis(); | |
4558 | Int_t nbins = xpph->GetNbins(); | |
4559 | Double_t lowedge = xpph->GetBinLowEdge(1); | |
4560 | Double_t upedge = xpph->GetBinUpEdge(xpph->GetNbins()); | |
4561 | Double_t widbins = (upedge - lowedge) / nbins; | |
4562 | Double_t limit = upedge + 0.5 * widbins; | |
4563 | ||
4564 | ||
4565 | Bool_t put = kTRUE; | |
4566 | ||
4567 | // Beginning of the signal | |
4568 | TH1D *pentea = new TH1D("pentea","pentea",projPH->GetNbinsX(),0,(Float_t) limit); | |
4569 | for (Int_t k = 1; k < projPH->GetNbinsX(); k++) { | |
4570 | pentea->SetBinContent(k,(Double_t) (projPH->GetBinContent(k+1) - projPH->GetBinContent(k))); | |
4571 | } | |
4572 | ||
4573 | binmax = (Int_t) pentea->GetMaximumBin(); | |
55a288e5 | 4574 | |
4575 | Double_t minnn = 0.0; | |
4576 | Double_t maxxx = 0.0; | |
4577 | ||
3a0f6479 | 4578 | Int_t kase = nbins-binmax; |
4579 | ||
4580 | switch(kase) | |
4581 | { | |
4582 | case 0: | |
4583 | put = kFALSE; | |
4584 | break; | |
4585 | case 1: | |
4586 | minnn = pentea->GetBinCenter(binmax-2); | |
4587 | maxxx = pentea->GetBinCenter(binmax); | |
4588 | x[0] = pentea->GetBinCenter(binmax-2); | |
4589 | x[1] = pentea->GetBinCenter(binmax-1); | |
4590 | x[2] = pentea->GetBinCenter(binmax); | |
4591 | y[0] = pentea->GetBinContent(binmax-2); | |
4592 | y[1] = pentea->GetBinContent(binmax-1); | |
4593 | y[2] = pentea->GetBinContent(binmax); | |
3b0c1edc | 4594 | CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4595 | AliInfo("At the limit for beginning!"); |
4596 | break; | |
4597 | case 2: | |
4598 | minnn = pentea->GetBinCenter(binmax-2); | |
4599 | maxxx = pentea->GetBinCenter(binmax+1); | |
4600 | x[0] = pentea->GetBinCenter(binmax-2); | |
4601 | x[1] = pentea->GetBinCenter(binmax-1); | |
4602 | x[2] = pentea->GetBinCenter(binmax); | |
4603 | x[3] = pentea->GetBinCenter(binmax+1); | |
4604 | y[0] = pentea->GetBinContent(binmax-2); | |
4605 | y[1] = pentea->GetBinContent(binmax-1); | |
4606 | y[2] = pentea->GetBinContent(binmax); | |
4607 | y[3] = pentea->GetBinContent(binmax+1); | |
3b0c1edc | 4608 | CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4609 | break; |
4610 | default: | |
4611 | switch(binmax){ | |
4612 | case 0: | |
4613 | put = kFALSE; | |
4614 | break; | |
4615 | case 1: | |
4616 | minnn = pentea->GetBinCenter(binmax); | |
4617 | maxxx = pentea->GetBinCenter(binmax+2); | |
4618 | x[0] = pentea->GetBinCenter(binmax); | |
4619 | x[1] = pentea->GetBinCenter(binmax+1); | |
4620 | x[2] = pentea->GetBinCenter(binmax+2); | |
4621 | y[0] = pentea->GetBinContent(binmax); | |
4622 | y[1] = pentea->GetBinContent(binmax+1); | |
4623 | y[2] = pentea->GetBinContent(binmax+2); | |
3b0c1edc | 4624 | CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4625 | break; |
4626 | case 2: | |
4627 | minnn = pentea->GetBinCenter(binmax-1); | |
4628 | maxxx = pentea->GetBinCenter(binmax+2); | |
4629 | x[0] = pentea->GetBinCenter(binmax-1); | |
4630 | x[1] = pentea->GetBinCenter(binmax); | |
4631 | x[2] = pentea->GetBinCenter(binmax+1); | |
4632 | x[3] = pentea->GetBinCenter(binmax+2); | |
4633 | y[0] = pentea->GetBinContent(binmax-1); | |
4634 | y[1] = pentea->GetBinContent(binmax); | |
4635 | y[2] = pentea->GetBinContent(binmax+1); | |
4636 | y[3] = pentea->GetBinContent(binmax+2); | |
3b0c1edc | 4637 | CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4638 | break; |
4639 | default: | |
4640 | minnn = pentea->GetBinCenter(binmax-2); | |
4641 | maxxx = pentea->GetBinCenter(binmax+2); | |
4642 | x[0] = pentea->GetBinCenter(binmax-2); | |
4643 | x[1] = pentea->GetBinCenter(binmax-1); | |
4644 | x[2] = pentea->GetBinCenter(binmax); | |
4645 | x[3] = pentea->GetBinCenter(binmax+1); | |
4646 | x[4] = pentea->GetBinCenter(binmax+2); | |
4647 | y[0] = pentea->GetBinContent(binmax-2); | |
4648 | y[1] = pentea->GetBinContent(binmax-1); | |
4649 | y[2] = pentea->GetBinContent(binmax); | |
4650 | y[3] = pentea->GetBinContent(binmax+1); | |
4651 | y[4] = pentea->GetBinContent(binmax+2); | |
3b0c1edc | 4652 | CalculPolynomeLagrange4(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4653 | break; |
4654 | } | |
4655 | break; | |
55a288e5 | 4656 | } |
3a0f6479 | 4657 | |
4658 | ||
55a288e5 | 4659 | if(put) { |
4660 | polynomeb = new TF1("polb","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",minnn,maxxx); | |
3b0c1edc | 4661 | polynomeb->SetParameters(c0,c1,c2,c3,c4); |
3a0f6479 | 4662 | |
55a288e5 | 4663 | Double_t step = (maxxx-minnn)/10000; |
4664 | Double_t l = minnn; | |
4665 | Double_t maxvalue = 0.0; | |
4666 | Double_t placemaximum = minnn; | |
4667 | for(Int_t o = 0; o < 10000; o++){ | |
4668 | if(o == 0) maxvalue = polynomeb->Eval(l); | |
4669 | if(maxvalue < (polynomeb->Eval(l))){ | |
4670 | maxvalue = polynomeb->Eval(l); | |
4671 | placemaximum = l; | |
4672 | } | |
4673 | l += step; | |
4674 | } | |
4675 | fPhd[0] = placemaximum; | |
4676 | } | |
55a288e5 | 4677 | |
4678 | // Amplification region | |
4679 | binmax = 0; | |
4680 | ju = 0; | |
4681 | for (Int_t kbin = 1; kbin < projPH->GetNbinsX(); kbin ++) { | |
3a0f6479 | 4682 | if (((projPH->GetBinContent(kbin+1) - projPH->GetBinContent(kbin)) <= 0.0) && (ju == 0) && (kbin > (fPhd[0]/widbins))) { |
55a288e5 | 4683 | binmax = kbin; |
4684 | ju = 1; | |
4685 | } | |
4686 | } | |
3a0f6479 | 4687 | |
55a288e5 | 4688 | Double_t minn = 0.0; |
4689 | Double_t maxx = 0.0; | |
3a0f6479 | 4690 | x[0] = 0.0; |
4691 | x[1] = 0.0; | |
4692 | x[2] = 0.0; | |
4693 | x[3] = 0.0; | |
4694 | x[4] = 0.0; | |
4695 | y[0] = 0.0; | |
4696 | y[1] = 0.0; | |
4697 | y[2] = 0.0; | |
4698 | y[3] = 0.0; | |
4699 | y[4] = 0.0; | |
4700 | ||
4701 | Int_t kase1 = nbins - binmax; | |
55a288e5 | 4702 | |
4703 | //Determination of minn and maxx | |
4704 | //case binmax = nbins | |
4705 | //pol2 | |
3a0f6479 | 4706 | switch(kase1) |
4707 | { | |
4708 | case 0: | |
4709 | minn = projPH->GetBinCenter(binmax-2); | |
4710 | maxx = projPH->GetBinCenter(binmax); | |
4711 | x[0] = projPH->GetBinCenter(binmax-2); | |
4712 | x[1] = projPH->GetBinCenter(binmax-1); | |
4713 | x[2] = projPH->GetBinCenter(binmax); | |
4714 | y[0] = projPH->GetBinContent(binmax-2); | |
4715 | y[1] = projPH->GetBinContent(binmax-1); | |
4716 | y[2] = projPH->GetBinContent(binmax); | |
3b0c1edc | 4717 | CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4718 | //AliInfo("At the limit for the drift!"); |
4719 | break; | |
4720 | case 1: | |
4721 | minn = projPH->GetBinCenter(binmax-2); | |
4722 | maxx = projPH->GetBinCenter(binmax+1); | |
4723 | x[0] = projPH->GetBinCenter(binmax-2); | |
4724 | x[1] = projPH->GetBinCenter(binmax-1); | |
4725 | x[2] = projPH->GetBinCenter(binmax); | |
4726 | x[3] = projPH->GetBinCenter(binmax+1); | |
4727 | y[0] = projPH->GetBinContent(binmax-2); | |
4728 | y[1] = projPH->GetBinContent(binmax-1); | |
4729 | y[2] = projPH->GetBinContent(binmax); | |
4730 | y[3] = projPH->GetBinContent(binmax+1); | |
3b0c1edc | 4731 | CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4732 | break; |
4733 | default: | |
4734 | switch(binmax) | |
4735 | { | |
4736 | case 0: | |
4737 | put = kFALSE; | |
4738 | break; | |
4739 | case 1: | |
4740 | minn = projPH->GetBinCenter(binmax); | |
4741 | maxx = projPH->GetBinCenter(binmax+2); | |
4742 | x[0] = projPH->GetBinCenter(binmax); | |
4743 | x[1] = projPH->GetBinCenter(binmax+1); | |
4744 | x[2] = projPH->GetBinCenter(binmax+2); | |
4745 | y[0] = projPH->GetBinContent(binmax); | |
4746 | y[1] = projPH->GetBinContent(binmax+1); | |
4747 | y[2] = projPH->GetBinContent(binmax+2); | |
3b0c1edc | 4748 | CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4749 | break; |
4750 | case 2: | |
4751 | minn = projPH->GetBinCenter(binmax-1); | |
4752 | maxx = projPH->GetBinCenter(binmax+2); | |
4753 | x[0] = projPH->GetBinCenter(binmax-1); | |
4754 | x[1] = projPH->GetBinCenter(binmax); | |
4755 | x[2] = projPH->GetBinCenter(binmax+1); | |
4756 | x[3] = projPH->GetBinCenter(binmax+2); | |
4757 | y[0] = projPH->GetBinContent(binmax-1); | |
4758 | y[1] = projPH->GetBinContent(binmax); | |
4759 | y[2] = projPH->GetBinContent(binmax+1); | |
4760 | y[3] = projPH->GetBinContent(binmax+2); | |
3b0c1edc | 4761 | CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4762 | break; |
4763 | default: | |
4764 | minn = projPH->GetBinCenter(binmax-2); | |
4765 | maxx = projPH->GetBinCenter(binmax+2); | |
4766 | x[0] = projPH->GetBinCenter(binmax-2); | |
4767 | x[1] = projPH->GetBinCenter(binmax-1); | |
4768 | x[2] = projPH->GetBinCenter(binmax); | |
4769 | x[3] = projPH->GetBinCenter(binmax+1); | |
4770 | x[4] = projPH->GetBinCenter(binmax+2); | |
4771 | y[0] = projPH->GetBinContent(binmax-2); | |
4772 | y[1] = projPH->GetBinContent(binmax-1); | |
4773 | y[2] = projPH->GetBinContent(binmax); | |
4774 | y[3] = projPH->GetBinContent(binmax+1); | |
4775 | y[4] = projPH->GetBinContent(binmax+2); | |
3b0c1edc | 4776 | CalculPolynomeLagrange4(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4777 | break; |
4778 | } | |
4779 | break; | |
55a288e5 | 4780 | } |
3a0f6479 | 4781 | |
55a288e5 | 4782 | if(put) { |
4783 | polynomea = new TF1("pola","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",minn,maxx); | |
3b0c1edc | 4784 | polynomea->SetParameters(c0,c1,c2,c3,c4); |
3a0f6479 | 4785 | |
55a288e5 | 4786 | Double_t step = (maxx-minn)/1000; |
4787 | Double_t l = minn; | |
4788 | Double_t maxvalue = 0.0; | |
4789 | Double_t placemaximum = minn; | |
4790 | for(Int_t o = 0; o < 1000; o++){ | |
4791 | if(o == 0) maxvalue = polynomea->Eval(l); | |
4792 | if(maxvalue < (polynomea->Eval(l))){ | |
4793 | maxvalue = polynomea->Eval(l); | |
4794 | placemaximum = l; | |
4795 | } | |
4796 | l += step; | |
4797 | } | |
4798 | fPhd[1] = placemaximum; | |
4799 | } | |
4800 | ||
55a288e5 | 4801 | // Drift region |
4802 | TH1D *pente = new TH1D("pente","pente", projPH->GetNbinsX(),0,(Float_t) limit); | |
4803 | for (Int_t k = TMath::Min(binmax+4, projPH->GetNbinsX()); k < projPH->GetNbinsX(); k++) { | |
4804 | pente->SetBinContent(k,(Double_t) (projPH->GetBinContent(k+1) - projPH->GetBinContent(k))); | |
4805 | } | |
4806 | binmin = 0; | |
4807 | if(pente->GetEntries() > 0) binmin = (Int_t) pente->GetMinimumBin(); | |
4808 | ||
4809 | //should not happen | |
4810 | if (binmin <= 1) { | |
4811 | binmin = 2; | |
4812 | put = 1; | |
4813 | AliInfo("Put the binmax from 1 to 2 to enable the fit"); | |
4814 | } | |
4815 | ||
4816 | //check | |
64942b85 | 4817 | if((projPH->GetBinContent(binmin)-projPH->GetBinError(binmin)) < (projPH->GetBinContent(binmin+1))) { |
4818 | AliInfo("Too many fluctuations at the end!"); | |
4819 | put = kFALSE; | |
4820 | } | |
4821 | if((projPH->GetBinContent(binmin)+projPH->GetBinError(binmin)) > (projPH->GetBinContent(binmin-1))) { | |
4822 | AliInfo("Too many fluctuations at the end!"); | |
4823 | put = kFALSE; | |
4824 | } | |
daa7dc79 | 4825 | if(TMath::Abs(pente->GetBinContent(binmin+1)) <= 0.0000000000001){ |
64942b85 | 4826 | AliInfo("No entries for the next bin!"); |
4827 | pente->SetBinContent(binmin,0); | |
4828 | if(pente->GetEntries() > 0) binmin = (Int_t) pente->GetMinimumBin(); | |
4829 | } | |
4830 | ||
3a0f6479 | 4831 | |
4832 | x[0] = 0.0; | |
4833 | x[1] = 0.0; | |
4834 | x[2] = 0.0; | |
4835 | x[3] = 0.0; | |
4836 | x[4] = 0.0; | |
4837 | y[0] = 0.0; | |
4838 | y[1] = 0.0; | |
4839 | y[2] = 0.0; | |
4840 | y[3] = 0.0; | |
4841 | y[4] = 0.0; | |
55a288e5 | 4842 | Double_t min = 0.0; |
4843 | Double_t max = 0.0; | |
4844 | Bool_t case1 = kFALSE; | |
4845 | Bool_t case2 = kFALSE; | |
4846 | Bool_t case4 = kFALSE; | |
4847 | ||
4848 | //Determination of min and max | |
4849 | //case binmin <= nbins-3 | |
4850 | //pol4 case 3 | |
4851 | if((binmin <= (nbins-3)) && ((binmin-2) >= TMath::Min(binmax+4, projPH->GetNbinsX()))){ | |
4852 | min = pente->GetBinCenter(binmin-2); | |
4853 | max = pente->GetBinCenter(binmin+2); | |
4854 | x[0] = pente->GetBinCenter(binmin-2); | |
4855 | x[1] = pente->GetBinCenter(binmin-1); | |
4856 | x[2] = pente->GetBinCenter(binmin); | |
4857 | x[3] = pente->GetBinCenter(binmin+1); | |
4858 | x[4] = pente->GetBinCenter(binmin+2); | |
4859 | y[0] = pente->GetBinContent(binmin-2); | |
4860 | y[1] = pente->GetBinContent(binmin-1); | |
4861 | y[2] = pente->GetBinContent(binmin); | |
4862 | y[3] = pente->GetBinContent(binmin+1); | |
4863 | y[4] = pente->GetBinContent(binmin+2); | |
4864 | //Calcul the polynome de Lagrange | |
3b0c1edc | 4865 | CalculPolynomeLagrange4(x,y,c0,c1,c2,c3,c4); |
55a288e5 | 4866 | //richtung +/- |
4867 | if((pente->GetBinContent(binmin+2) <= pente->GetBinContent(binmin+1)) && | |
64942b85 | 4868 | (pente->GetBinContent(binmin-2) <= pente->GetBinContent(binmin-1))) { |
4869 | //AliInfo("polynome 4 false 1"); | |
4870 | put = kFALSE; | |
4871 | } | |
55a288e5 | 4872 | if(((binmin+3) <= (nbins-1)) && |
4873 | (pente->GetBinContent(binmin+3) <= pente->GetBinContent(binmin+2)) && | |
4874 | ((binmin-3) >= TMath::Min(binmax+4, projPH->GetNbinsX())) && | |
64942b85 | 4875 | (pente->GetBinContent(binmin-3) <= pente->GetBinContent(binmin-2))) { |
4876 | AliInfo("polynome 4 false 2"); | |
4877 | put = kFALSE; | |
4878 | } | |
4879 | // poly 3 | |
55a288e5 | 4880 | if((pente->GetBinContent(binmin+2) <= pente->GetBinContent(binmin+1)) && |
64942b85 | 4881 | (pente->GetBinContent(binmin-2) > pente->GetBinContent(binmin-1))) { |
4882 | //AliInfo("polynome 4 case 1"); | |
4883 | case1 = kTRUE; | |
4884 | } | |
55a288e5 | 4885 | if((pente->GetBinContent(binmin+2) > pente->GetBinContent(binmin+1)) && |
64942b85 | 4886 | (pente->GetBinContent(binmin-2) <= pente->GetBinContent(binmin-1))) { |
4887 | //AliInfo("polynome 4 case 4"); | |
4888 | case4 = kTRUE; | |
4889 | } | |
4890 | ||
55a288e5 | 4891 | } |
4892 | //case binmin = nbins-2 | |
4893 | //pol3 case 1 | |
4894 | if(((binmin == (nbins-2)) && ((binmin-2) >= TMath::Min(binmax+4, projPH->GetNbinsX()))) || | |
4895 | (case1)){ | |
4896 | min = pente->GetBinCenter(binmin-2); | |
4897 | max = pente->GetBinCenter(binmin+1); | |
4898 | x[0] = pente->GetBinCenter(binmin-2); | |
4899 | x[1] = pente->GetBinCenter(binmin-1); | |
4900 | x[2] = pente->GetBinCenter(binmin); | |
4901 | x[3] = pente->GetBinCenter(binmin+1); | |
4902 | y[0] = pente->GetBinContent(binmin-2); | |
4903 | y[1] = pente->GetBinContent(binmin-1); | |
4904 | y[2] = pente->GetBinContent(binmin); | |
4905 | y[3] = pente->GetBinContent(binmin+1); | |
4906 | //Calcul the polynome de Lagrange | |
3b0c1edc | 4907 | CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4); |
55a288e5 | 4908 | //richtung +: nothing |
4909 | //richtung - | |
64942b85 | 4910 | if((pente->GetBinContent(binmin-2) <= pente->GetBinContent(binmin-1))) { |
4911 | //AliInfo("polynome 3- case 2"); | |
4912 | case2 = kTRUE; | |
4913 | } | |
55a288e5 | 4914 | } |
4915 | //pol3 case 4 | |
4916 | if(((binmin <= (nbins-3)) && ((binmin-1) == TMath::Min(binmax+4, projPH->GetNbinsX()))) || | |
4917 | (case4)){ | |
4918 | min = pente->GetBinCenter(binmin-1); | |
4919 | max = pente->GetBinCenter(binmin+2); | |
4920 | x[0] = pente->GetBinCenter(binmin-1); | |
4921 | x[1] = pente->GetBinCenter(binmin); | |
4922 | x[2] = pente->GetBinCenter(binmin+1); | |
4923 | x[3] = pente->GetBinCenter(binmin+2); | |
4924 | y[0] = pente->GetBinContent(binmin-1); | |
4925 | y[1] = pente->GetBinContent(binmin); | |
4926 | y[2] = pente->GetBinContent(binmin+1); | |
4927 | y[3] = pente->GetBinContent(binmin+2); | |
4928 | //Calcul the polynome de Lagrange | |
3b0c1edc | 4929 | CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4); |
55a288e5 | 4930 | //richtung + |
64942b85 | 4931 | if((pente->GetBinContent(binmin+2) <= pente->GetBinContent(binmin+1))) { |
4932 | //AliInfo("polynome 3+ case 2"); | |
4933 | case2 = kTRUE; | |
4934 | } | |
55a288e5 | 4935 | } |
4936 | //pol2 case 5 | |
4937 | if((binmin <= (nbins-3)) && (binmin == TMath::Min(binmax+4, projPH->GetNbinsX()))){ | |
4938 | min = pente->GetBinCenter(binmin); | |
4939 | max = pente->GetBinCenter(binmin+2); | |
4940 | x[0] = pente->GetBinCenter(binmin); | |
4941 | x[1] = pente->GetBinCenter(binmin+1); | |
4942 | x[2] = pente->GetBinCenter(binmin+2); | |
4943 | y[0] = pente->GetBinContent(binmin); | |
4944 | y[1] = pente->GetBinContent(binmin+1); | |
4945 | y[2] = pente->GetBinContent(binmin+2); | |
4946 | //Calcul the polynome de Lagrange | |
3b0c1edc | 4947 | CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4); |
55a288e5 | 4948 | //richtung + |
64942b85 | 4949 | if((pente->GetBinContent(binmin+2) <= pente->GetBinContent(binmin+1))) { |
4950 | //AliInfo("polynome 2+ false"); | |
4951 | put = kFALSE; | |
4952 | } | |
55a288e5 | 4953 | } |
4954 | //pol2 case 2 | |
4955 | if(((binmin == (nbins-2)) && ((binmin-1) == TMath::Min(binmax+4, projPH->GetNbinsX()))) || | |
4956 | (case2)){ | |
4957 | min = pente->GetBinCenter(binmin-1); | |
4958 | max = pente->GetBinCenter(binmin+1); | |
4959 | x[0] = pente->GetBinCenter(binmin-1); | |
4960 | x[1] = pente->GetBinCenter(binmin); | |
4961 | x[2] = pente->GetBinCenter(binmin+1); | |
4962 | y[0] = pente->GetBinContent(binmin-1); | |
4963 | y[1] = pente->GetBinContent(binmin); | |
4964 | y[2] = pente->GetBinContent(binmin+1); | |
4965 | //Calcul the polynome de Lagrange | |
3b0c1edc | 4966 | CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4); |
55a288e5 | 4967 | //richtung +: nothing |
4968 | //richtung -: nothing | |
4969 | } | |
4970 | //case binmin = nbins-1 | |
4971 | //pol2 case 0 | |
4972 | if((binmin == (nbins-1)) && ((binmin-2) >= TMath::Min(binmax+4, projPH->GetNbinsX()))){ | |
4973 | min = pente->GetBinCenter(binmin-2); | |
4974 | max = pente->GetBinCenter(binmin); | |
4975 | x[0] = pente->GetBinCenter(binmin-2); | |
4976 | x[1] = pente->GetBinCenter(binmin-1); | |
4977 | x[2] = pente->GetBinCenter(binmin); | |
4978 | y[0] = pente->GetBinContent(binmin-2); | |
4979 | y[1] = pente->GetBinContent(binmin-1); | |
4980 | y[2] = pente->GetBinContent(binmin); | |
4981 | //Calcul the polynome de Lagrange | |
3b0c1edc | 4982 | CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4); |
3a0f6479 | 4983 | //AliInfo("At the limit for the drift!"); |
55a288e5 | 4984 | //fluctuation too big! |
4985 | //richtung +: nothing | |
4986 | //richtung - | |
64942b85 | 4987 | if((pente->GetBinContent(binmin-2) <= pente->GetBinContent(binmin-1))) { |
4988 | //AliInfo("polynome 2- false "); | |
4989 | put = kFALSE; | |
4990 | } | |
55a288e5 | 4991 | } |
4992 | if((binmin == (nbins-1)) && ((binmin-2) < TMath::Min(binmax+4, projPH->GetNbinsX()))) { | |
4993 | put = kFALSE; | |
4994 | AliInfo("At the limit for the drift and not usable!"); | |
4995 | } | |
4996 | ||
4997 | //pass | |
4998 | if((binmin == (nbins-2)) && ((binmin-1) < TMath::Min(binmax+4, projPH->GetNbinsX()))){ | |
4999 | put = kFALSE; | |
5000 | AliInfo("For the drift...problem!"); | |
5001 | } | |
55a288e5 | 5002 | //pass but should not happen |
64942b85 | 5003 | if((binmin <= (nbins-3)) && (binmin < TMath::Min(binmax+6, projPH->GetNbinsX()))){ |
55a288e5 | 5004 | put = kFALSE; |
5005 | AliInfo("For the drift...problem!"); | |
5006 | } | |
3a0f6479 | 5007 | |
55a288e5 | 5008 | if(put) { |
5009 | polynome = new TF1("pol","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",min,max); | |
3b0c1edc | 5010 | polynome->SetParameters(c0,c1,c2,c3,c4); |
55a288e5 | 5011 | //AliInfo(Form("GetMinimum of the function %f",polynome->GetMinimumX())); |
5012 | Double_t step = (max-min)/1000; | |
5013 | Double_t l = min; | |
5014 | Double_t minvalue = 0.0; | |
5015 | Double_t placeminimum = min; | |
5016 | for(Int_t o = 0; o < 1000; o++){ | |
5017 | if(o == 0) minvalue = polynome->Eval(l); | |
5018 | if(minvalue > (polynome->Eval(l))){ | |
5019 | minvalue = polynome->Eval(l); | |
5020 | placeminimum = l; | |
5021 | } | |
5022 | l += step; | |
5023 | } | |
5024 | fPhd[2] = placeminimum; | |
5025 | } | |
64942b85 | 5026 | //printf("La fin %d\n",((Int_t)(fPhd[2]*10.0))+2); |
5027 | if((((Int_t)(fPhd[2]*10.0))+2) >= projPH->GetNbinsX()) fPhd[2] = 0.0; | |
5028 | if(((((Int_t)(fPhd[2]*10.0))+2) < projPH->GetNbinsX()) && (projPH->GetBinContent(((Int_t)(fPhd[2]*10.0))+2)==0)) fPhd[2] = 0.0; | |
3a0f6479 | 5029 | |
413153cb | 5030 | Float_t fPhdt0 = 0.0; |
5031 | Float_t t0Shift = 0.0; | |
5032 | if(fTakeTheMaxPH) { | |
5033 | fPhdt0 = fPhd[1]; | |
5034 | t0Shift = fT0Shift1; | |
5035 | } | |
5036 | else { | |
5037 | fPhdt0 = fPhd[0]; | |
5038 | t0Shift = fT0Shift0; | |
5039 | } | |
55a288e5 | 5040 | |
5041 | if ((fPhd[2] > fPhd[0]) && | |
5042 | (fPhd[2] > fPhd[1]) && | |
5043 | (fPhd[1] > fPhd[0]) && | |
5044 | (put)) { | |
3a0f6479 | 5045 | fCurrentCoef[0] = (kDrWidth) / (fPhd[2]-fPhd[1]); |
6210514c | 5046 | if(fCurrentCoef[0] > 2.5) fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); |
6aafa7ea | 5047 | else fNumberFitSuccess++; |
55a288e5 | 5048 | if (fPhdt0 >= 0.0) { |
413153cb | 5049 | fCurrentCoef2[0] = (fPhdt0 - t0Shift) / widbins; |
b88b6bcc | 5050 | //printf("Value of timeoffset %f\n",fCurrentCoef2[0]); |
5051 | if (fCurrentCoef2[0] < -3.0) { | |
64942b85 | 5052 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
55a288e5 | 5053 | } |
5054 | } | |
5055 | else { | |
64942b85 | 5056 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
55a288e5 | 5057 | } |
5058 | } | |
5059 | else { | |
b88b6bcc | 5060 | ////printf("Put default %f\n",-TMath::Abs(fCurrentCoef[1])); |
6210514c | 5061 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); |
5062 | ||
64942b85 | 5063 | if((fPhd[1] > fPhd[0]) && |
5064 | (put)) { | |
5065 | if (fPhdt0 >= 0.0) { | |
5066 | fCurrentCoef2[0] = (fPhdt0 - t0Shift) / widbins; | |
b88b6bcc | 5067 | if (fCurrentCoef2[0] < -3.0) { |
64942b85 | 5068 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
5069 | } | |
5070 | } | |
5071 | else { | |
5072 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; | |
5073 | } | |
5074 | } | |
5075 | else{ | |
64942b85 | 5076 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
5077 | //printf("Fit failed!\n"); | |
5078 | } | |
55a288e5 | 5079 | } |
5080 | ||
3a0f6479 | 5081 | if (fDebugLevel == 1) { |
55a288e5 | 5082 | TCanvas *cpentei = new TCanvas("cpentei","cpentei",50,50,600,800); |
5083 | cpentei->cd(); | |
5084 | projPH->Draw(); | |
5085 | line->SetLineColor(2); | |
5086 | line->DrawLine(fPhd[0],0,fPhd[0],projPH->GetMaximum()); | |
5087 | line->DrawLine(fPhd[1],0,fPhd[1],projPH->GetMaximum()); | |
5088 | line->DrawLine(fPhd[2],0,fPhd[2],projPH->GetMaximum()); | |
5089 | AliInfo(Form("fPhd[0] (beginning of the signal): %f" ,(Float_t) fPhd[0])); | |
5090 | AliInfo(Form("fPhd[1] (end of the amplification region): %f" ,(Float_t) fPhd[1])); | |
5091 | AliInfo(Form("fPhd[2] (end of the drift region): %f" ,(Float_t) fPhd[2])); | |
3a0f6479 | 5092 | AliInfo(Form("fVriftCoef[3] (with only the drift region(default)): %f",(Float_t) fCurrentCoef[0])); |
55a288e5 | 5093 | TCanvas *cpentei2 = new TCanvas("cpentei2","cpentei2",50,50,600,800); |
5094 | cpentei2->cd(); | |
5095 | pentea->Draw(); | |
5096 | TCanvas *cpentei3 = new TCanvas("cpentei3","cpentei3",50,50,600,800); | |
5097 | cpentei3->cd(); | |
5098 | pente->Draw(); | |
5099 | } | |
3a0f6479 | 5100 | else { |
a987273c | 5101 | delete pentea; |
5102 | delete pente; | |
1ca79a00 | 5103 | if(polynome) delete polynome; |
5104 | if(polynomea) delete polynomea; | |
5105 | if(polynomeb) delete polynomeb; | |
fdc15553 | 5106 | //if(x) delete [] x; |
5107 | //if(y) delete [] y; | |
1ca79a00 | 5108 | if(line) delete line; |
5109 | ||
55a288e5 | 5110 | } |
64942b85 | 5111 | |
5112 | //Provisoire | |
5113 | //if(fCurrentCoef[0] > 1.7) fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
5114 | //if((fCurrentCoef2[0] > 2.6) || (fCurrentCoef2[0] < 2.1)) fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; | |
b88b6bcc | 5115 | //printf("Value of timeoffset final %f\n",fCurrentCoef2[0]); |
55a288e5 | 5116 | projPH->SetDirectory(0); |
5117 | ||
5118 | } | |
5119 | ||
5120 | //_____________________________________________________________________________ | |
5121 | void AliTRDCalibraFit::FitPH(TH1* projPH, Int_t idect) | |
5122 | { | |
5123 | // | |
5124 | // Fit methode for the drift velocity | |
5125 | // | |
5126 | ||
5127 | // Constants | |
5128 | const Float_t kDrWidth = AliTRDgeometry::DrThick(); | |
5129 | ||
5130 | // Some variables | |
5131 | TAxis *xpph = projPH->GetXaxis(); | |
5132 | Double_t upedge = xpph->GetBinUpEdge(xpph->GetNbins()); | |
5133 | ||
5134 | TF1 *fPH = new TF1("fPH",AliTRDCalibraFit::PH,-0.05,3.2,6); | |
5135 | fPH->SetParameter(0,0.469); // Scaling | |
5136 | fPH->SetParameter(1,0.18); // Start | |
5137 | fPH->SetParameter(2,0.0857325); // AR | |
5138 | fPH->SetParameter(3,1.89); // DR | |
5139 | fPH->SetParameter(4,0.08); // QA/QD | |
5140 | fPH->SetParameter(5,0.0); // Baseline | |
5141 | ||
5142 | TLine *line = new TLine(); | |
5143 | ||
3a0f6479 | 5144 | fCurrentCoef[0] = 0.0; |
5145 | fCurrentCoef2[0] = 0.0; | |
5146 | fCurrentCoefE = 0.0; | |
5147 | fCurrentCoefE2 = 0.0; | |
55a288e5 | 5148 | |
5149 | if (idect%fFitPHPeriode == 0) { | |
5150 | ||
3a0f6479 | 5151 | AliInfo(Form("The detector %d will be fitted",idect)); |
55a288e5 | 5152 | fPH->SetParameter(0,(projPH->Integral()-(projPH->GetBinContent(1)*projPH->GetNbinsX())) * 0.00028); // Scaling |
5153 | fPH->SetParameter(1,fPhd[0] - 0.1); // Start | |
5154 | fPH->SetParameter(2,fPhd[1] - fPhd[0]); // AR | |
5155 | fPH->SetParameter(3,fPhd[2] - fPhd[1]); // DR | |
5156 | fPH->SetParameter(4,0.225); // QA/QD | |
5157 | fPH->SetParameter(5,(Float_t) projPH->GetBinContent(1)); | |
5158 | ||
3a0f6479 | 5159 | if (fDebugLevel != 1) { |
55a288e5 | 5160 | projPH->Fit(fPH,"0M","",0.0,upedge); |
5161 | } | |
3a0f6479 | 5162 | else { |
55a288e5 | 5163 | TCanvas *cpente = new TCanvas("cpente","cpente",50,50,600,800); |
5164 | cpente->cd(); | |
5165 | projPH->Fit(fPH,"M+","",0.0,upedge); | |
5166 | projPH->Draw("E0"); | |
5167 | line->SetLineColor(4); | |
5168 | line->DrawLine(fPH->GetParameter(1) | |
5169 | ,0 | |
5170 | ,fPH->GetParameter(1) | |
5171 | ,projPH->GetMaximum()); | |
5172 | line->DrawLine(fPH->GetParameter(1)+fPH->GetParameter(2) | |
5173 | ,0 | |
5174 | ,fPH->GetParameter(1)+fPH->GetParameter(2) | |
5175 | ,projPH->GetMaximum()); | |
5176 | line->DrawLine(fPH->GetParameter(1)+fPH->GetParameter(2)+fPH->GetParameter(3) | |
5177 | ,0 | |
5178 | ,fPH->GetParameter(1)+fPH->GetParameter(2)+fPH->GetParameter(3) | |
5179 | ,projPH->GetMaximum()); | |
5180 | } | |
5181 | ||
5182 | if (fPH->GetParameter(3) != 0) { | |
3a0f6479 | 5183 | fNumberFitSuccess++; |
5184 | fCurrentCoef[0] = kDrWidth / (fPH->GetParameter(3)); | |
5185 | fCurrentCoefE = (fPH->GetParError(3)/fPH->GetParameter(3))*fCurrentCoef[0]; | |
5186 | fCurrentCoef2[0] = fPH->GetParameter(1); | |
5187 | fCurrentCoefE2 = fPH->GetParError(1); | |
55a288e5 | 5188 | } |
5189 | else { | |
3a0f6479 | 5190 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); |
64942b85 | 5191 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
55a288e5 | 5192 | } |
3a0f6479 | 5193 | |
55a288e5 | 5194 | } |
55a288e5 | 5195 | else { |
5196 | ||
3a0f6479 | 5197 | // Put the default value |
5198 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
64942b85 | 5199 | fCurrentCoef2[0] = fCurrentCoef2[1] + 100.0; |
55a288e5 | 5200 | } |
5201 | ||
3a0f6479 | 5202 | if (fDebugLevel != 1) { |
55a288e5 | 5203 | delete fPH; |
5204 | } | |
5205 | ||
5206 | } | |
55a288e5 | 5207 | //_____________________________________________________________________________ |
3a0f6479 | 5208 | Bool_t AliTRDCalibraFit::FitPRFGausMI(Double_t *arraye, Double_t *arraym, Double_t *arrayme, Int_t nBins, Float_t xMin, Float_t xMax) |
55a288e5 | 5209 | { |
5210 | // | |
5211 | // Fit methode for the sigma of the pad response function | |
5212 | // | |
3a0f6479 | 5213 | |
5214 | TVectorD param(3); | |
55a288e5 | 5215 | |
3a0f6479 | 5216 | fCurrentCoef[0] = 0.0; |
5217 | fCurrentCoefE = 0.0; | |
5218 | ||
5219 | Double_t ret = FitGausMI(arraye, arraym, arrayme, nBins, xMin, xMax,¶m); | |
5220 | ||
daa7dc79 | 5221 | if(TMath::Abs(ret+4) <= 0.000000001){ |
3a0f6479 | 5222 | fCurrentCoef[0] = -fCurrentCoef[1]; |
5223 | return kFALSE; | |
5224 | } | |
5225 | else { | |
5226 | fNumberFitSuccess++; | |
5227 | fCurrentCoef[0] = param[2]; | |
5228 | fCurrentCoefE = ret; | |
5229 | return kTRUE; | |
5230 | } | |
5231 | } | |
5232 | //_____________________________________________________________________________ | |
7bce990c | 5233 | Double_t AliTRDCalibraFit::FitGausMI(Double_t *arraye, Double_t *arraym, Double_t *arrayme, Int_t nBins, Float_t xMin, Float_t xMax, TVectorD *param, Bool_t bError) |
3a0f6479 | 5234 | { |
5235 | // | |
5236 | // Fit methode for the sigma of the pad response function | |
5237 | // | |
5238 | ||
5239 | //We should have at least 3 points | |
5240 | if(nBins <=3) return -4.0; | |
5241 | ||
5242 | TLinearFitter fitter(3,"pol2"); | |
5243 | fitter.StoreData(kFALSE); | |
5244 | fitter.ClearPoints(); | |
5245 | TVectorD par(3); | |
5246 | Float_t binWidth = (xMax-xMin)/(Float_t)nBins; | |
5247 | Float_t entries = 0; | |
5248 | Int_t nbbinwithentries = 0; | |
5249 | for (Int_t i=0; i<nBins; i++){ | |
5250 | entries+=arraye[i]; | |
5251 | if(arraye[i] > 15) nbbinwithentries++; | |
5252 | //printf("entries for i %d: %f\n",i,arraye[i]); | |
5253 | } | |
5254 | if ((entries<700) || (nbbinwithentries < ((Int_t)(nBins/2)))) return -4; | |
5255 | //printf("entries %f\n",entries); | |
5256 | //printf("nbbinwithentries %d\n",nbbinwithentries); | |
5257 | ||
5258 | Int_t npoints=0; | |
5259 | Float_t errorm = 0.0; | |
5260 | Float_t errorn = 0.0; | |
5261 | Float_t error = 0.0; | |
5262 | ||
5263 | // | |
5264 | for (Int_t ibin=0;ibin<nBins; ibin++){ | |
5265 | Float_t entriesI = arraye[ibin]; | |
5266 | Float_t valueI = arraym[ibin]; | |
5267 | Double_t xcenter = 0.0; | |
5268 | Float_t val = 0.0; | |
5269 | if ((entriesI>15) && (valueI>0.0)){ | |
5270 | xcenter = xMin+(ibin+0.5)*binWidth; | |
5271 | errorm = 0.0; | |
5272 | errorn = 0.0; | |
5273 | error = 0.0; | |
7bce990c | 5274 | if(!bError){ |
3a0f6479 | 5275 | if((valueI + 0.01) > 0.0) errorm = TMath::Log((valueI + 0.01)/valueI); |
5276 | if((valueI - 0.01) > 0.0) errorn = TMath::Log((valueI - 0.01)/valueI); | |
5277 | error = TMath::Max(TMath::Abs(errorm),TMath::Abs(errorn)); | |
5278 | } | |
5279 | else{ | |
5280 | if((valueI + arrayme[ibin]) > 0.0) errorm = TMath::Log((valueI + arrayme[ibin])/valueI); | |
5281 | if((valueI - arrayme[ibin]) > 0.0) errorn = TMath::Log((valueI - arrayme[ibin])/valueI); | |
5282 | error = TMath::Max(TMath::Abs(errorm),TMath::Abs(errorn)); | |
5283 | } | |
daa7dc79 | 5284 | if(TMath::Abs(error) < 0.000000001) continue; |
3a0f6479 | 5285 | val = TMath::Log(Float_t(valueI)); |
5286 | fitter.AddPoint(&xcenter,val,error); | |
5287 | npoints++; | |
5288 | } | |
5289 | ||
5290 | if(fDebugLevel > 1){ | |
55a288e5 | 5291 | |
3a0f6479 | 5292 | if ( !fDebugStreamer ) { |
5293 | //debug stream | |
5294 | TDirectory *backup = gDirectory; | |
4aad967c | 5295 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPRF.root"); |
3a0f6479 | 5296 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer |
5297 | } | |
5298 | ||
5299 | Int_t detector = fCountDet; | |
053767a4 | 5300 | Int_t layer = GetLayer(fCountDet); |
3a0f6479 | 5301 | Int_t group = ibin; |
5302 | ||
5303 | (* fDebugStreamer) << "FitGausMIFill"<< | |
5304 | "detector="<<detector<< | |
053767a4 | 5305 | "layer="<<layer<< |
3a0f6479 | 5306 | "nbins="<<nBins<< |
5307 | "group="<<group<< | |
5308 | "entriesI="<<entriesI<< | |
5309 | "valueI="<<valueI<< | |
5310 | "val="<<val<< | |
5311 | "xcenter="<<xcenter<< | |
5312 | "errorm="<<errorm<< | |
5313 | "errorn="<<errorn<< | |
5314 | "error="<<error<< | |
7bce990c | 5315 | "bError="<<bError<< |
3a0f6479 | 5316 | "\n"; |
5317 | } | |
5318 | ||
5319 | } | |
5320 | ||
5321 | if(npoints <=3) return -4.0; | |
5322 | ||
5323 | Double_t chi2 = 0; | |
5324 | if (npoints>3){ | |
5325 | fitter.Eval(); | |
5326 | fitter.GetParameters(par); | |
5327 | chi2 = fitter.GetChisquare()/Float_t(npoints); | |
55a288e5 | 5328 | |
3a0f6479 | 5329 | |
5330 | if (!param) param = new TVectorD(3); | |
daa7dc79 | 5331 | if(TMath::Abs(par[2]) <= 0.000000001) return -4.0; |
3a0f6479 | 5332 | Double_t x = TMath::Sqrt(TMath::Abs(-2*par[2])); |
5333 | Double_t deltax = (fitter.GetParError(2))/x; | |
5334 | Double_t errorparam2 = TMath::Abs(deltax)/(x*x); | |
5335 | chi2 = errorparam2; | |
55a288e5 | 5336 | |
3a0f6479 | 5337 | (*param)[1] = par[1]/(-2.*par[2]); |
5338 | (*param)[2] = 1./TMath::Sqrt(TMath::Abs(-2.*par[2])); | |
5339 | Double_t lnparam0 = par[0]+ par[1]* (*param)[1] + par[2]*(*param)[1]*(*param)[1]; | |
5340 | if ( lnparam0>307 ) return -4; | |
5341 | (*param)[0] = TMath::Exp(lnparam0); | |
5342 | ||
5343 | if(fDebugLevel > 1){ | |
5344 | ||
5345 | if ( !fDebugStreamer ) { | |
5346 | //debug stream | |
5347 | TDirectory *backup = gDirectory; | |
4aad967c | 5348 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPRF.root"); |
3a0f6479 | 5349 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer |
5350 | } | |
5351 | ||
5352 | Int_t detector = fCountDet; | |
053767a4 | 5353 | Int_t layer = GetLayer(fCountDet); |
3a0f6479 | 5354 | |
5355 | ||
5356 | (* fDebugStreamer) << "FitGausMIFit"<< | |
5357 | "detector="<<detector<< | |
053767a4 | 5358 | "layer="<<layer<< |
3a0f6479 | 5359 | "nbins="<<nBins<< |
5360 | "errorsigma="<<chi2<< | |
5361 | "mean="<<(*param)[1]<< | |
5362 | "sigma="<<(*param)[2]<< | |
5363 | "constant="<<(*param)[0]<< | |
5364 | "\n"; | |
5365 | } | |
5366 | } | |
5367 | ||
5368 | if((chi2/(*param)[2]) > 0.1){ | |
7bce990c | 5369 | if(bError){ |
3a0f6479 | 5370 | chi2 = FitGausMI(arraye,arraym,arrayme,nBins,xMin,xMax,param,kFALSE); |
5371 | } | |
5372 | else return -4.0; | |
55a288e5 | 5373 | } |
3a0f6479 | 5374 | |
5375 | if(fDebugLevel == 1){ | |
5376 | TString name("PRF"); | |
5377 | name += (Int_t)xMin; | |
5378 | name += (Int_t)xMax; | |
5379 | TCanvas *c1 = new TCanvas((const char *)name,(const char *)name,50,50,600,800); | |
5380 | c1->cd(); | |
5381 | name += "histo"; | |
5382 | TH1F *histo = new TH1F((const char *)name,(const char *)name,nBins,xMin,xMax); | |
5383 | for(Int_t k = 0; k < nBins; k++){ | |
5384 | histo->SetBinContent(k+1,arraym[k]); | |
5385 | histo->SetBinError(k+1,arrayme[k]); | |
5386 | } | |
5387 | histo->Draw(); | |
5388 | name += "functionf"; | |
5389 | TF1 *f1= new TF1((const char*)name,"[0]*exp(-(x-[1])^2/(2*[2]*[2]))",xMin,xMax); | |
5390 | f1->SetParameter(0, (*param)[0]); | |
5391 | f1->SetParameter(1, (*param)[1]); | |
5392 | f1->SetParameter(2, (*param)[2]); | |
5393 | f1->Draw("same"); | |
5394 | } | |
5395 | ||
5396 | ||
5397 | return chi2; | |
5398 | ||
5399 | } | |
5400 | //_____________________________________________________________________________ | |
5401 | void AliTRDCalibraFit::FitPRF(TH1 *projPRF) | |
5402 | { | |
5403 | // | |
5404 | // Fit methode for the sigma of the pad response function | |
5405 | // | |
55a288e5 | 5406 | |
3a0f6479 | 5407 | fCurrentCoef[0] = 0.0; |
5408 | fCurrentCoefE = 0.0; | |
5409 | ||
5410 | if (fDebugLevel != 1) { | |
5411 | projPRF->Fit("gaus","0M","",-fRangeFitPRF,fRangeFitPRF); | |
5412 | } | |
5413 | else { | |
55a288e5 | 5414 | TCanvas *cfit = new TCanvas("cfit","cfit",50,50,600,800); |
5415 | cfit->cd(); | |
5416 | projPRF->Fit("gaus","M+","",-fRangeFitPRF,fRangeFitPRF); | |
5417 | projPRF->Draw(); | |
55a288e5 | 5418 | } |
3a0f6479 | 5419 | fCurrentCoef[0] = projPRF->GetFunction("gaus")->GetParameter(2); |
5420 | fCurrentCoefE = projPRF->GetFunction("gaus")->GetParError(2); | |
5421 | if(fCurrentCoef[0] <= 0.0) fCurrentCoef[0] = -fCurrentCoef[1]; | |
55a288e5 | 5422 | else { |
3a0f6479 | 5423 | fNumberFitSuccess++; |
55a288e5 | 5424 | } |
3a0f6479 | 5425 | } |
5426 | //_____________________________________________________________________________ | |
5427 | void AliTRDCalibraFit::RmsPRF(TH1 *projPRF) | |
5428 | { | |
5429 | // | |
5430 | // Fit methode for the sigma of the pad response function | |
5431 | // | |
5432 | fCurrentCoef[0] = 0.0; | |
5433 | fCurrentCoefE = 0.0; | |
5434 | if (fDebugLevel == 1) { | |
5435 | TCanvas *cfit = new TCanvas("cfit","cfit",50,50,600,800); | |
5436 | cfit->cd(); | |
5437 | projPRF->Draw(); | |
55a288e5 | 5438 | } |
3a0f6479 | 5439 | fCurrentCoef[0] = projPRF->GetRMS(); |
5440 | if(fCurrentCoef[0] <= 0.0) fCurrentCoef[0] = -fCurrentCoef[1]; | |
5441 | else { | |
5442 | fNumberFitSuccess++; | |
55a288e5 | 5443 | } |
55a288e5 | 5444 | } |
55a288e5 | 5445 | //_____________________________________________________________________________ |
3a0f6479 | 5446 | void AliTRDCalibraFit::FitTnpRange(Double_t *arraye, Double_t *arraym, Double_t *arrayme, Int_t nbg, Int_t nybins) |
55a288e5 | 5447 | { |
5448 | // | |
3a0f6479 | 5449 | // Fit methode for the sigma of the pad response function with 2*nbg tan bins |
55a288e5 | 5450 | // |
5451 | ||
3a0f6479 | 5452 | TLinearFitter linearfitter = TLinearFitter(3,"pol2"); |
55a288e5 | 5453 | |
55a288e5 | 5454 | |
3a0f6479 | 5455 | Int_t nbins = (Int_t)(nybins/(2*nbg)); |
5456 | Float_t lowedge = -3.0*nbg; | |
5457 | Float_t upedge = lowedge + 3.0; | |
5458 | Int_t offset = 0; | |
5459 | Int_t npoints = 0; | |
5460 | Double_t xvalues = -0.2*nbg+0.1; | |
5461 | Double_t y = 0.0; | |
5462 | Int_t total = 2*nbg; | |
55a288e5 | 5463 | |
3a0f6479 | 5464 | |
5465 | for(Int_t k = 0; k < total; k++){ | |
5466 | if(FitPRFGausMI(arraye+offset, arraym+offset, arrayme+offset, nbins, lowedge, upedge)){ | |
5467 | npoints++; | |
5468 | y = fCurrentCoef[0]*fCurrentCoef[0]; | |
5469 | linearfitter.AddPoint(&xvalues,y,2*fCurrentCoefE*fCurrentCoef[0]); | |
5470 | } | |
5471 | ||
5472 | if(fDebugLevel > 1){ | |
5473 | ||
5474 | if ( !fDebugStreamer ) { | |
5475 | //debug stream | |
5476 | TDirectory *backup = gDirectory; | |
4aad967c | 5477 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPRF.root"); |
3a0f6479 | 5478 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer |
5479 | } | |
5480 | ||
5481 | Int_t detector = fCountDet; | |
053767a4 | 5482 | Int_t layer = GetLayer(fCountDet); |
3a0f6479 | 5483 | Int_t nbtotal = total; |
5484 | Int_t group = k; | |
5485 | Float_t low = lowedge; | |
5486 | Float_t up = upedge; | |
5487 | Float_t tnp = xvalues; | |
5488 | Float_t wid = fCurrentCoef[0]; | |
5489 | Float_t widfE = fCurrentCoefE; | |
5490 | ||
413153cb | 5491 | (* fDebugStreamer) << "FitTnpRange0"<< |
3a0f6479 | 5492 | "detector="<<detector<< |
053767a4 | 5493 | "layer="<<layer<< |
3a0f6479 | 5494 | "nbtotal="<<nbtotal<< |
5495 | "group="<<group<< | |
5496 | "low="<<low<< | |
5497 | "up="<<up<< | |
5498 | "offset="<<offset<< | |
5499 | "tnp="<<tnp<< | |
5500 | "wid="<<wid<< | |
5501 | "widfE="<<widfE<< | |
5502 | "\n"; | |
5503 | } | |
5504 | ||
5505 | offset += nbins; | |
5506 | lowedge += 3.0; | |
5507 | upedge += 3.0; | |
5508 | xvalues += 0.2; | |
5509 | ||
5510 | } | |
5511 | ||
5512 | fCurrentCoefE = 0.0; | |
5513 | fCurrentCoef[0] = 0.0; | |
5514 | ||
5515 | //printf("npoints\n",npoints); | |
5516 | ||
5517 | if(npoints < 3){ | |
5518 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
5519 | } | |
5520 | else{ | |
5521 | ||
5522 | TVectorD pars0; | |
5523 | linearfitter.Eval(); | |
5524 | linearfitter.GetParameters(pars0); | |
5525 | Double_t pointError0 = TMath::Sqrt(linearfitter.GetChisquare()/npoints); | |
5526 | Double_t errorsx0 = linearfitter.GetParError(2)*pointError0; | |
5527 | Double_t min0 = 0.0; | |
5528 | Double_t ermin0 = 0.0; | |
5529 | //Double_t prfe0 = 0.0; | |
5530 | Double_t prf0 = 0.0; | |
daa7dc79 | 5531 | if((pars0[2] > 0.000000000001) && (TMath::Abs(pars0[1]) >= 0.000000000001)) { |
3a0f6479 | 5532 | min0 = -pars0[1]/(2*pars0[2]); |
5533 | ermin0 = TMath::Abs(min0*(errorsx0/pars0[2]+linearfitter.GetParError(1)*pointError0/pars0[1])); | |
5534 | prf0 = pars0[0]+pars0[1]*min0+pars0[2]*min0*min0; | |
5535 | if(prf0 > 0.0) { | |
5536 | /* | |
5537 | prfe0 = linearfitter->GetParError(0)*pointError0 | |
5538 | +(linearfitter->GetParError(1)*pointError0/pars0[1]+ermin0/min0)*pars0[1]*min0 | |
5539 | +(linearfitter->GetParError(2)*pointError0/pars0[2]+2*ermin0/min0)*pars0[2]*min0*min0; | |
5540 | prfe0 = prfe0/(2*TMath::Sqrt(prf0)); | |
5541 | fCurrentCoefE = (Float_t) prfe0; | |
5542 | */ | |
5543 | fCurrentCoef[0] = (Float_t) TMath::Sqrt(TMath::Abs(prf0)); | |
5544 | } | |
5545 | else{ | |
5546 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
5547 | } | |
5548 | } | |
5549 | else { | |
5550 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
5551 | } | |
55a288e5 | 5552 | |
3a0f6479 | 5553 | if(fDebugLevel > 1){ |
5554 | ||
5555 | if ( !fDebugStreamer ) { | |
5556 | //debug stream | |
5557 | TDirectory *backup = gDirectory; | |
4aad967c | 5558 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitPRF.root"); |
3a0f6479 | 5559 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer |
5560 | } | |
5561 | ||
5562 | Int_t detector = fCountDet; | |
053767a4 | 5563 | Int_t layer = GetLayer(fCountDet); |
3a0f6479 | 5564 | Int_t nbtotal = total; |
5565 | Double_t colsize[6] = {0.635,0.665,0.695,0.725,0.755,0.785}; | |
053767a4 | 5566 | Double_t sigmax = TMath::Sqrt(TMath::Abs(pars0[2]))*10000*colsize[layer]; |
3a0f6479 | 5567 | |
413153cb | 5568 | (* fDebugStreamer) << "FitTnpRange1"<< |
3a0f6479 | 5569 | "detector="<<detector<< |
053767a4 | 5570 | "layer="<<layer<< |
3a0f6479 | 5571 | "nbtotal="<<nbtotal<< |
5572 | "par0="<<pars0[0]<< | |
5573 | "par1="<<pars0[1]<< | |
5574 | "par2="<<pars0[2]<< | |
5575 | "npoints="<<npoints<< | |
5576 | "sigmax="<<sigmax<< | |
5577 | "tan="<<min0<< | |
5578 | "sigmaprf="<<fCurrentCoef[0]<< | |
5579 | "sigprf="<<fCurrentCoef[1]<< | |
5580 | "\n"; | |
5581 | } | |
5582 | ||
55a288e5 | 5583 | } |
5584 | ||
5585 | } | |
55a288e5 | 5586 | //_____________________________________________________________________________ |
3a0f6479 | 5587 | void AliTRDCalibraFit::FitMean(TH1 *projch, Double_t nentries, Double_t mean) |
55a288e5 | 5588 | { |
5589 | // | |
5590 | // Only mean methode for the gain factor | |
5591 | // | |
5592 | ||
3a0f6479 | 5593 | fCurrentCoef[0] = mean; |
5594 | fCurrentCoefE = 0.0; | |
5595 | if(nentries > 0) fCurrentCoefE = projch->GetRMS()/TMath::Sqrt(nentries); | |
5596 | if (fDebugLevel == 1) { | |
55a288e5 | 5597 | TCanvas *cpmean = new TCanvas("cpmean","cpmean",50,50,600,800); |
5598 | cpmean->cd(); | |
5599 | projch->Draw(); | |
5600 | } | |
3a0f6479 | 5601 | CalculChargeCoefMean(kTRUE); |
5602 | fNumberFitSuccess++; | |
55a288e5 | 5603 | } |
55a288e5 | 5604 | //_____________________________________________________________________________ |
3a0f6479 | 5605 | void AliTRDCalibraFit::FitMeanW(TH1 *projch, Double_t nentries) |
55a288e5 | 5606 | { |
5607 | // | |
5608 | // mean w methode for the gain factor | |
5609 | // | |
5610 | ||
5611 | //Number of bins | |
5612 | Int_t nybins = projch->GetNbinsX(); | |
5613 | ||
5614 | //The weight function | |
5615 | Double_t a = 0.00228515; | |
5616 | Double_t b = -0.00231487; | |
5617 | Double_t c = 0.00044298; | |
5618 | Double_t d = -0.00379239; | |
5619 | Double_t e = 0.00338349; | |
5620 | ||
3a0f6479 | 5621 | // 0 |0.00228515 |
5622 | // 1 |-0.00231487 | |
5623 | // 2 |0.00044298 | |
5624 | // 3 |-0.00379239 | |
5625 | // 4 |0.00338349 | |
5626 | ||
5627 | ||
55a288e5 | 5628 | |
5629 | //A arbitrary error for the moment | |
3a0f6479 | 5630 | fCurrentCoefE = 0.0; |
5631 | fCurrentCoef[0] = 0.0; | |
55a288e5 | 5632 | |
5633 | //Calcul | |
5634 | Double_t sumw = 0.0; | |
5635 | Double_t sum = 0.0; | |
3a0f6479 | 5636 | Float_t sumAll = (Float_t) nentries; |
55a288e5 | 5637 | Int_t sumCurrent = 0; |
5638 | for(Int_t k = 0; k <nybins; k++){ | |
5639 | Double_t fraction = Float_t(sumCurrent)/Float_t(sumAll); | |
5640 | if (fraction>0.95) break; | |
5641 | Double_t weight = a + b*fraction + c*fraction*fraction + d *fraction*fraction*fraction+ | |
5642 | e*fraction*fraction*fraction*fraction; | |
5643 | sumw += weight*projch->GetBinContent(k+1)*projch->GetBinCenter(k+1); | |
5644 | sum += weight*projch->GetBinContent(k+1); | |
5645 | sumCurrent += (Int_t) projch->GetBinContent(k+1); | |
5646 | //printf("fraction %f, weight %f, bincontent %f\n",fraction,weight,projch->GetBinContent(k+1)); | |
5647 | } | |
3a0f6479 | 5648 | if(sum > 0.0) fCurrentCoef[0] = (sumw/sum); |
55a288e5 | 5649 | |
3a0f6479 | 5650 | if (fDebugLevel == 1) { |
55a288e5 | 5651 | TCanvas *cpmeanw = new TCanvas("cpmeanw","cpmeanw",50,50,600,800); |
5652 | cpmeanw->cd(); | |
5653 | projch->Draw(); | |
5654 | } | |
3a0f6479 | 5655 | fNumberFitSuccess++; |
5656 | CalculChargeCoefMean(kTRUE); | |
5657 | } | |
5658 | //_____________________________________________________________________________ | |
5659 | void AliTRDCalibraFit::FitMeanWSm(TH1 *projch, Float_t sumAll) | |
5660 | { | |
5661 | // | |
5662 | // mean w methode for the gain factor | |
5663 | // | |
5664 | ||
5665 | //Number of bins | |
5666 | Int_t nybins = projch->GetNbinsX(); | |
5667 | ||
5668 | //The weight function | |
5669 | Double_t a = 0.00228515; | |
5670 | Double_t b = -0.00231487; | |
5671 | Double_t c = 0.00044298; | |
5672 | Double_t d = -0.00379239; | |
5673 | Double_t e = 0.00338349; | |
5674 | ||
5675 | // 0 |0.00228515 | |
5676 | // 1 |-0.00231487 | |
5677 | // 2 |0.00044298 | |
5678 | // 3 |-0.00379239 | |
5679 | // 4 |0.00338349 | |
5680 | ||
5681 | ||
5682 | ||
5683 | //A arbitrary error for the moment | |
5684 | fCurrentCoefE = 0.0; | |
5685 | fCurrentCoef[0] = 0.0; | |
55a288e5 | 5686 | |
3a0f6479 | 5687 | //Calcul |
5688 | Double_t sumw = 0.0; | |
5689 | Double_t sum = 0.0; | |
5690 | Int_t sumCurrent = 0; | |
5691 | for(Int_t k = 0; k <nybins; k++){ | |
5692 | Double_t fraction = Float_t(sumCurrent)/Float_t(sumAll); | |
5693 | if (fraction>0.95) break; | |
5694 | Double_t weight = a + b*fraction + c*fraction*fraction + d *fraction*fraction*fraction+ | |
5695 | e*fraction*fraction*fraction*fraction; | |
5696 | sumw += weight*projch->GetBinContent(k+1)*projch->GetBinCenter(k+1); | |
5697 | sum += weight*projch->GetBinContent(k+1); | |
5698 | sumCurrent += (Int_t) projch->GetBinContent(k+1); | |
5699 | //printf("fraction %f, weight %f, bincontent %f\n",fraction,weight,projch->GetBinContent(k+1)); | |
55a288e5 | 5700 | } |
3a0f6479 | 5701 | if(sum > 0.0) fCurrentCoef[0] = (sumw/sum); |
55a288e5 | 5702 | |
3a0f6479 | 5703 | if (fDebugLevel == 1) { |
5704 | TCanvas *cpmeanw = new TCanvas("cpmeanw","cpmeanw",50,50,600,800); | |
5705 | cpmeanw->cd(); | |
5706 | projch->Draw(); | |
5707 | } | |
5708 | fNumberFitSuccess++; | |
55a288e5 | 5709 | } |
55a288e5 | 5710 | //_____________________________________________________________________________ |
3a0f6479 | 5711 | void AliTRDCalibraFit::FitCH(TH1 *projch, Double_t mean) |
55a288e5 | 5712 | { |
5713 | // | |
5714 | // Fit methode for the gain factor | |
5715 | // | |
5716 | ||
3a0f6479 | 5717 | fCurrentCoef[0] = 0.0; |
5718 | fCurrentCoefE = 0.0; | |
55a288e5 | 5719 | Double_t chisqrl = 0.0; |
5720 | Double_t chisqrg = 0.0; | |
3a0f6479 | 5721 | Double_t chisqr = 0.0; |
55a288e5 | 5722 | TF1 *fLandauGaus = new TF1("fLandauGaus",FuncLandauGaus,0,300,5); |
5723 | ||
5724 | projch->Fit("landau","0","" | |
3a0f6479 | 5725 | ,(Double_t) mean/fBeginFitCharge |
55a288e5 | 5726 | ,projch->GetBinCenter(projch->GetNbinsX())); |
5727 | Double_t l3P0 = projch->GetFunction("landau")->GetParameter(0); | |
5728 | Double_t l3P1 = projch->GetFunction("landau")->GetParameter(1); | |
5729 | Double_t l3P2 = projch->GetFunction("landau")->GetParameter(2); | |
5730 | chisqrl = projch->GetFunction("landau")->GetChisquare(); | |
5731 | ||
5732 | projch->Fit("gaus","0","" | |
3a0f6479 | 5733 | ,(Double_t) mean/fBeginFitCharge |
55a288e5 | 5734 | ,projch->GetBinCenter(projch->GetNbinsX())); |
5735 | Double_t g3P0 = projch->GetFunction("gaus")->GetParameter(0); | |
5736 | Double_t g3P2 = projch->GetFunction("gaus")->GetParameter(2); | |
5737 | chisqrg = projch->GetFunction("gaus")->GetChisquare(); | |
5738 | ||
5739 | fLandauGaus->SetParameters(l3P0,l3P1,l3P2,g3P0,g3P2); | |
3a0f6479 | 5740 | if (fDebugLevel != 1) { |
55a288e5 | 5741 | projch->Fit("fLandauGaus","0","" |
3a0f6479 | 5742 | ,(Double_t) mean/fBeginFitCharge |
55a288e5 | 5743 | ,projch->GetBinCenter(projch->GetNbinsX())); |
5744 | chisqr = projch->GetFunction("fLandauGaus")->GetChisquare(); | |
3a0f6479 | 5745 | } |
5746 | else { | |
55a288e5 | 5747 | TCanvas *cp = new TCanvas("cp","cp",50,50,600,800); |
5748 | cp->cd(); | |
5749 | projch->Fit("fLandauGaus","+","" | |
3a0f6479 | 5750 | ,(Double_t) mean/fBeginFitCharge |
55a288e5 | 5751 | ,projch->GetBinCenter(projch->GetNbinsX())); |
5752 | chisqr = projch->GetFunction("fLandauGaus")->GetChisquare(); | |
5753 | projch->Draw(); | |
5754 | fLandauGaus->Draw("same"); | |
5755 | } | |
5756 | ||
3a0f6479 | 5757 | if ((projch->GetFunction("fLandauGaus")->GetParameter(1) > 0) && (projch->GetFunction("fLandauGaus")->GetParError(1) < (0.05*projch->GetFunction("fLandauGaus")->GetParameter(1))) && (chisqr < chisqrl) && (chisqr < chisqrg)) { |
5758 | //if ((projch->GetFunction("fLandauGaus")->GetParameter(1) > 0) && (chisqr < chisqrl) && (chisqr < chisqrg)) { | |
5759 | fNumberFitSuccess++; | |
5760 | CalculChargeCoefMean(kTRUE); | |
5761 | fCurrentCoef[0] = projch->GetFunction("fLandauGaus")->GetParameter(1); | |
5762 | fCurrentCoefE = projch->GetFunction("fLandauGaus")->GetParError(1); | |
55a288e5 | 5763 | } |
5764 | else { | |
3a0f6479 | 5765 | CalculChargeCoefMean(kFALSE); |
5766 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
55a288e5 | 5767 | } |
5768 | ||
3a0f6479 | 5769 | if (fDebugLevel != 1) { |
55a288e5 | 5770 | delete fLandauGaus; |
5771 | } | |
5772 | ||
5773 | } | |
55a288e5 | 5774 | //_____________________________________________________________________________ |
3a0f6479 | 5775 | void AliTRDCalibraFit::FitBisCH(TH1* projch, Double_t mean) |
55a288e5 | 5776 | { |
5777 | // | |
5778 | // Fit methode for the gain factor more time consuming | |
5779 | // | |
5780 | ||
3a0f6479 | 5781 | |
55a288e5 | 5782 | //Some parameters to initialise |
e6381f8e | 5783 | Double_t widthLandau, widthGaus, mPV, integral; |
55a288e5 | 5784 | Double_t chisquarel = 0.0; |
5785 | Double_t chisquareg = 0.0; | |
55a288e5 | 5786 | projch->Fit("landau","0M+","" |
3a0f6479 | 5787 | ,(Double_t) mean/6 |
55a288e5 | 5788 | ,projch->GetBinCenter(projch->GetNbinsX())); |
5789 | widthLandau = projch->GetFunction("landau")->GetParameter(2); | |
5790 | chisquarel = projch->GetFunction("landau")->GetChisquare(); | |
55a288e5 | 5791 | projch->Fit("gaus","0M+","" |
3a0f6479 | 5792 | ,(Double_t) mean/6 |
55a288e5 | 5793 | ,projch->GetBinCenter(projch->GetNbinsX())); |
5794 | widthGaus = projch->GetFunction("gaus")->GetParameter(2); | |
5795 | chisquareg = projch->GetFunction("gaus")->GetChisquare(); | |
3a0f6479 | 5796 | |
e6381f8e | 5797 | mPV = (projch->GetFunction("landau")->GetParameter(1))/2; |
5798 | integral = (projch->GetFunction("gaus")->Integral(0.3*mean,3*mean)+projch->GetFunction("landau")->Integral(0.3*mean,3*mean))/2; | |
3a0f6479 | 5799 | |
55a288e5 | 5800 | // Setting fit range and start values |
5801 | Double_t fr[2]; | |
5802 | //Double_t sv[4] = { l3P2, fChargeCoef[1], projch->Integral("width"), fG3P2 }; | |
5803 | //Double_t sv[4] = { fL3P2, fChargeCoef[1], fL3P0, fG3P2 }; | |
e6381f8e | 5804 | Double_t sv[4] = { widthLandau, mPV, integral, widthGaus}; |
55a288e5 | 5805 | Double_t pllo[4] = { 0.001, 0.001, projch->Integral()/3, 0.001}; |
5806 | Double_t plhi[4] = { 300.0, 300.0, 30*projch->Integral(), 300.0}; | |
5807 | Double_t fp[4] = { 1.0, 1.0, 1.0, 1.0 }; | |
5808 | Double_t fpe[4] = { 1.0, 1.0, 1.0, 1.0 }; | |
3a0f6479 | 5809 | fr[0] = 0.3 * mean; |
5810 | fr[1] = 3.0 * mean; | |
5811 | fCurrentCoef[0] = 0.0; | |
5812 | fCurrentCoefE = 0.0; | |
55a288e5 | 5813 | |
5814 | Double_t chisqr; | |
5815 | Int_t ndf; | |
5816 | TF1 *fitsnr = LanGauFit(projch,&fr[0],&sv[0] | |
5817 | ,&pllo[0],&plhi[0] | |
5818 | ,&fp[0],&fpe[0] | |
5819 | ,&chisqr,&ndf); | |
5820 | ||
5821 | Double_t projchPeak; | |
5822 | Double_t projchFWHM; | |
5823 | LanGauPro(fp,projchPeak,projchFWHM); | |
5824 | ||
5825 | if ((fp[1] > 0) && ((fpe[1] < (0.05*fp[1])) && (chisqr < chisquarel) && (chisqr < chisquareg))) { | |
5826 | //if ((fp[1] > 0) && ((chisqr < chisquarel) && (chisqr < chisquareg))) { | |
3a0f6479 | 5827 | fNumberFitSuccess++; |
5828 | CalculChargeCoefMean(kTRUE); | |
5829 | fCurrentCoef[0] = fp[1]; | |
5830 | fCurrentCoefE = fpe[1]; | |
55a288e5 | 5831 | //chargeCoefE2 = chisqr; |
5832 | } | |
5833 | else { | |
3a0f6479 | 5834 | CalculChargeCoefMean(kFALSE); |
5835 | fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); | |
55a288e5 | 5836 | } |
3a0f6479 | 5837 | if (fDebugLevel == 1) { |
5838 | AliInfo(Form("fChargeCoef[0]: %f",(Float_t) fCurrentCoef[0])); | |
55a288e5 | 5839 | TCanvas *cpy = new TCanvas("cpy","cpy",50,50,600,800); |
5840 | cpy->cd(); | |
5841 | projch->Draw(); | |
5842 | fitsnr->Draw("same"); | |
5843 | } | |
3a0f6479 | 5844 | else { |
55a288e5 | 5845 | delete fitsnr; |
5846 | } | |
3a0f6479 | 5847 | } |
55a288e5 | 5848 | //_____________________________________________________________________________ |
3b0c1edc | 5849 | void AliTRDCalibraFit::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 |
55a288e5 | 5850 | { |
5851 | // | |
5852 | // Calcul the coefficients of the polynome passant par ces trois points de degre 2 | |
5853 | // | |
55a288e5 | 5854 | Double_t x0 = y[0]/((x[0]-x[1])*(x[0]-x[2])); |
5855 | Double_t x1 = y[1]/((x[1]-x[0])*(x[1]-x[2])); | |
5856 | Double_t x2 = y[2]/((x[2]-x[0])*(x[2]-x[1])); | |
5857 | ||
3b0c1edc | 5858 | c4 = 0.0; |
5859 | c3 = 0.0; | |
5860 | c2 = x0+x1+x2; | |
5861 | c1 = -(x0*(x[1]+x[2])+x1*(x[0]+x[2])+x2*(x[0]+x[1])); | |
5862 | c0 = x0*x[1]*x[2]+x1*x[0]*x[2]+x2*x[0]*x[1]; | |
3a0f6479 | 5863 | |
55a288e5 | 5864 | } |
5865 | ||
5866 | //_____________________________________________________________________________ | |
3b0c1edc | 5867 | void AliTRDCalibraFit::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 |
55a288e5 | 5868 | { |
5869 | // | |
5870 | // Calcul the coefficients of the polynome passant par ces quatre points de degre 3 | |
5871 | // | |
55a288e5 | 5872 | Double_t x0 = y[0]/((x[0]-x[1])*(x[0]-x[2])*(x[0]-x[3])); |
5873 | Double_t x1 = y[1]/((x[1]-x[0])*(x[1]-x[2])*(x[1]-x[3])); | |
5874 | Double_t x2 = y[2]/((x[2]-x[0])*(x[2]-x[1])*(x[2]-x[3])); | |
5875 | Double_t x3 = y[3]/((x[3]-x[0])*(x[3]-x[1])*(x[3]-x[2])); | |
5876 | ||
3b0c1edc | 5877 | c4 = 0.0; |
5878 | c3 = x0+x1+x2+x3; | |
5879 | c2 = -(x0*(x[1]+x[2]+x[3]) | |
55a288e5 | 5880 | +x1*(x[0]+x[2]+x[3]) |
5881 | +x2*(x[0]+x[1]+x[3]) | |
5882 | +x3*(x[0]+x[1]+x[2])); | |
3b0c1edc | 5883 | c1 = (x0*(x[1]*x[2]+x[1]*x[3]+x[2]*x[3]) |
55a288e5 | 5884 | +x1*(x[0]*x[2]+x[0]*x[3]+x[2]*x[3]) |
5885 | +x2*(x[0]*x[1]+x[0]*x[3]+x[1]*x[3]) | |
5886 | +x3*(x[0]*x[1]+x[0]*x[2]+x[1]*x[2])); | |
5887 | ||
3b0c1edc | 5888 | c0 = -(x0*x[1]*x[2]*x[3] |
55a288e5 | 5889 | +x1*x[0]*x[2]*x[3] |
5890 | +x2*x[0]*x[1]*x[3] | |
5891 | +x3*x[0]*x[1]*x[2]); | |
5892 | ||
3a0f6479 | 5893 | |
55a288e5 | 5894 | } |
5895 | ||
5896 | //_____________________________________________________________________________ | |
3b0c1edc | 5897 | void AliTRDCalibraFit::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 |
55a288e5 | 5898 | { |
5899 | // | |
5900 | // Calcul the coefficients of the polynome passant par ces cinqs points de degre 4 | |
5901 | // | |
55a288e5 | 5902 | Double_t x0 = y[0]/((x[0]-x[1])*(x[0]-x[2])*(x[0]-x[3])*(x[0]-x[4])); |
5903 | Double_t x1 = y[1]/((x[1]-x[0])*(x[1]-x[2])*(x[1]-x[3])*(x[1]-x[4])); | |
5904 | Double_t x2 = y[2]/((x[2]-x[0])*(x[2]-x[1])*(x[2]-x[3])*(x[2]-x[4])); | |
5905 | Double_t x3 = y[3]/((x[3]-x[0])*(x[3]-x[1])*(x[3]-x[2])*(x[3]-x[4])); | |
5906 | Double_t x4 = y[4]/((x[4]-x[0])*(x[4]-x[1])*(x[4]-x[2])*(x[4]-x[3])); | |
3a0f6479 | 5907 | |
55a288e5 | 5908 | |
3b0c1edc | 5909 | c4 = x0+x1+x2+x3+x4; |
5910 | c3 = -(x0*(x[1]+x[2]+x[3]+x[4]) | |
55a288e5 | 5911 | +x1*(x[0]+x[2]+x[3]+x[4]) |
5912 | +x2*(x[0]+x[1]+x[3]+x[4]) | |
5913 | +x3*(x[0]+x[1]+x[2]+x[4]) | |
5914 | +x4*(x[0]+x[1]+x[2]+x[3])); | |
3b0c1edc | 5915 | c2 = (x0*(x[1]*x[2]+x[1]*x[3]+x[1]*x[4]+x[2]*x[3]+x[2]*x[4]+x[3]*x[4]) |
55a288e5 | 5916 | +x1*(x[0]*x[2]+x[0]*x[3]+x[0]*x[4]+x[2]*x[3]+x[2]*x[4]+x[3]*x[4]) |
5917 | +x2*(x[0]*x[1]+x[0]*x[3]+x[0]*x[4]+x[1]*x[3]+x[1]*x[4]+x[3]*x[4]) | |
5918 | +x3*(x[0]*x[1]+x[0]*x[2]+x[0]*x[4]+x[1]*x[2]+x[1]*x[4]+x[2]*x[4]) | |
5919 | +x4*(x[0]*x[1]+x[0]*x[2]+x[0]*x[3]+x[1]*x[2]+x[1]*x[3]+x[2]*x[3])); | |
5920 | ||
3b0c1edc | 5921 | c1 = -(x0*(x[1]*x[2]*x[3]+x[1]*x[2]*x[4]+x[1]*x[3]*x[4]+x[2]*x[3]*x[4]) |
55a288e5 | 5922 | +x1*(x[0]*x[2]*x[3]+x[0]*x[2]*x[4]+x[0]*x[3]*x[4]+x[2]*x[3]*x[4]) |
5923 | +x2*(x[0]*x[1]*x[3]+x[0]*x[1]*x[4]+x[0]*x[3]*x[4]+x[1]*x[3]*x[4]) | |
5924 | +x3*(x[0]*x[1]*x[2]+x[0]*x[1]*x[4]+x[0]*x[2]*x[4]+x[1]*x[2]*x[4]) | |
5925 | +x4*(x[0]*x[1]*x[2]+x[0]*x[1]*x[3]+x[0]*x[2]*x[3]+x[1]*x[2]*x[3])); | |
5926 | ||
3b0c1edc | 5927 | c0 = (x0*x[1]*x[2]*x[3]*x[4] |
55a288e5 | 5928 | +x1*x[0]*x[2]*x[3]*x[4] |
5929 | +x2*x[0]*x[1]*x[3]*x[4] | |
5930 | +x3*x[0]*x[1]*x[2]*x[4] | |
5931 | +x4*x[0]*x[1]*x[2]*x[3]); | |
5932 | ||
55a288e5 | 5933 | } |
55a288e5 | 5934 | //_____________________________________________________________________________ |
5935 | void AliTRDCalibraFit::NormierungCharge() | |
5936 | { | |
5937 | // | |
5938 | // Normalisation of the gain factor resulting for the fits | |
5939 | // | |
5940 | ||
5941 | // Calcul of the mean of choosen method by fFitChargeNDB | |
5942 | Double_t sum = 0.0; | |
5943 | //printf("total number of entries %d\n",fVectorFitCH->GetEntriesFast()); | |
3a0f6479 | 5944 | for (Int_t k = 0; k < (Int_t) fVectorFit.GetEntriesFast(); k++) { |
55a288e5 | 5945 | Int_t total = 0; |
3a0f6479 | 5946 | Int_t detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector(); |
5947 | Float_t *coef = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef(); | |
55a288e5 | 5948 | //printf("detector %d coef[0] %f\n",detector,coef[0]); |
053767a4 | 5949 | if (GetStack(detector) == 2) { |
55a288e5 | 5950 | total = 1728; |
5951 | } | |
053767a4 | 5952 | if (GetStack(detector) != 2) { |
55a288e5 | 5953 | total = 2304; |
5954 | } | |
5955 | for (Int_t j = 0; j < total; j++) { | |
5956 | if (coef[j] >= 0) { | |
5957 | sum += coef[j]; | |
5958 | } | |
5959 | } | |
5960 | } | |
5961 | ||
5962 | if (sum > 0) { | |
5963 | fScaleFitFactor = fScaleFitFactor / sum; | |
5964 | } | |
5965 | else { | |
5966 | fScaleFitFactor = 1.0; | |
3a0f6479 | 5967 | } |
55a288e5 | 5968 | |
3a0f6479 | 5969 | //methode de boeuf mais bon... |
5970 | Double_t scalefactor = fScaleFitFactor; | |
55a288e5 | 5971 | |
3a0f6479 | 5972 | if(fDebugLevel > 1){ |
5973 | ||
5974 | if ( !fDebugStreamer ) { | |
5975 | //debug stream | |
5976 | TDirectory *backup = gDirectory; | |
4aad967c | 5977 | fDebugStreamer = new TTreeSRedirector("TRDDebugFitCH.root"); |
3a0f6479 | 5978 | if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer |
5979 | } | |
413153cb | 5980 | (* fDebugStreamer) << "NormierungCharge"<< |
3a0f6479 | 5981 | "scalefactor="<<scalefactor<< |
5982 | "\n"; | |
5983 | } | |
55a288e5 | 5984 | } |
55a288e5 | 5985 | //_____________________________________________________________________________ |
979b168f | 5986 | TH1I *AliTRDCalibraFit::ReBin(const TH1I *hist) const |
55a288e5 | 5987 | { |
5988 | // | |
5989 | // Rebin of the 1D histo for the gain calibration if needed. | |
5990 | // you have to choose fRebin, divider of fNumberBinCharge | |
5991 | // | |
5992 | ||
3a0f6479 | 5993 | TAxis *xhist = hist->GetXaxis(); |
5994 | TH1I *rehist = new TH1I("projrebin","",(Int_t) xhist->GetNbins()/fRebin | |
5995 | ,xhist->GetBinLowEdge(1) | |
5996 | ,xhist->GetBinUpEdge(xhist->GetNbins())); | |
55a288e5 | 5997 | |
3a0f6479 | 5998 | AliInfo(Form("fRebin: %d",fRebin)); |
5999 | Int_t i = 1; | |
6000 | for (Int_t k = 1; k <= (Int_t) xhist->GetNbins()/fRebin; k++) { | |
6001 | Double_t sum = 0.0; | |
6002 | for (Int_t ji = i; ji < i+fRebin; ji++) { | |
6003 | sum += hist->GetBinContent(ji); | |
6004 | } | |
6005 | sum = sum / fRebin; | |
6006 | rehist->SetBinContent(k,sum); | |
6007 | i += fRebin; | |
6008 | } | |
55a288e5 | 6009 | |
3a0f6479 | 6010 | return rehist; |
55a288e5 | 6011 | |
6012 | } | |
6013 | ||
6014 | //_____________________________________________________________________________ | |
979b168f | 6015 | TH1F *AliTRDCalibraFit::ReBin(const TH1F *hist) const |
55a288e5 | 6016 | { |
6017 | // | |
6018 | // Rebin of the 1D histo for the gain calibration if needed | |
6019 | // you have to choose fRebin divider of fNumberBinCharge | |
6020 | // | |
6021 | ||
6022 | TAxis *xhist = hist->GetXaxis(); | |
6023 | TH1F *rehist = new TH1F("projrebin","",(Int_t) xhist->GetNbins()/fRebin | |
6024 | ,xhist->GetBinLowEdge(1) | |
6025 | ,xhist->GetBinUpEdge(xhist->GetNbins())); | |
6026 | ||
6027 | AliInfo(Form("fRebin: %d",fRebin)); | |
6028 | Int_t i = 1; | |
6029 | for (Int_t k = 1; k <= (Int_t) xhist->GetNbins()/fRebin; k++) { | |
6030 | Double_t sum = 0.0; | |
6031 | for (Int_t ji = i; ji < i+fRebin; ji++) { | |
6032 | sum += hist->GetBinContent(ji); | |
6033 | } | |
6034 | sum = sum/fRebin; | |
6035 | rehist->SetBinContent(k,sum); | |
6036 | i += fRebin; | |
6037 | } | |
6038 | ||
55a288e5 | 6039 | return rehist; |
6040 | ||
55a288e5 | 6041 | } |
55a288e5 | 6042 | // |
6043 | //____________Some basic geometry function_____________________________________ | |
6044 | // | |
6045 | ||
6046 | //_____________________________________________________________________________ | |
053767a4 | 6047 | Int_t AliTRDCalibraFit::GetLayer(Int_t d) const |
55a288e5 | 6048 | { |
6049 | // | |
6050 | // Reconstruct the plane number from the detector number | |
6051 | // | |
6052 | ||
6053 | return ((Int_t) (d % 6)); | |
6054 | ||
6055 | } | |
6056 | ||
6057 | //_____________________________________________________________________________ | |
053767a4 | 6058 | Int_t AliTRDCalibraFit::GetStack(Int_t d) const |
55a288e5 | 6059 | { |
6060 | // | |
053767a4 | 6061 | // Reconstruct the stack number from the detector number |
55a288e5 | 6062 | // |
053767a4 | 6063 | const Int_t kNlayer = 6; |
55a288e5 | 6064 | |
053767a4 | 6065 | return ((Int_t) (d % 30) / kNlayer); |
55a288e5 | 6066 | |
6067 | } | |
6068 | ||
6069 | //_____________________________________________________________________________ | |
6070 | Int_t AliTRDCalibraFit::GetSector(Int_t d) const | |
6071 | { | |
6072 | // | |
6073 | // Reconstruct the sector number from the detector number | |
6074 | // | |
6075 | Int_t fg = 30; | |
6076 | ||
6077 | return ((Int_t) (d / fg)); | |
6078 | ||
6079 | } | |
6080 | ||
6081 | // | |
6082 | //____________Fill and Init tree Gain, PRF, Vdrift and T0______________________ | |
6083 | // | |
3a0f6479 | 6084 | //_______________________________________________________________________________ |
6085 | void AliTRDCalibraFit::ResetVectorFit() | |
55a288e5 | 6086 | { |
e6381f8e | 6087 | // |
6088 | // Reset the VectorFits | |
6089 | // | |
6090 | ||
3a0f6479 | 6091 | fVectorFit.SetOwner(); |
6092 | fVectorFit.Clear(); | |
6093 | fVectorFit2.SetOwner(); | |
6094 | fVectorFit2.Clear(); | |
55a288e5 | 6095 | |
55a288e5 | 6096 | } |
55a288e5 | 6097 | // |
6098 | //____________Private Functions________________________________________________ | |
6099 | // | |
6100 | ||
6101 | //_____________________________________________________________________________ | |
979b168f | 6102 | Double_t AliTRDCalibraFit::PH(const Double_t *x, const Double_t *par) |
55a288e5 | 6103 | { |
6104 | // | |
6105 | // Function for the fit | |
6106 | // | |
6107 | ||
6108 | //TF1 *fAsymmGauss = new TF1("fAsymmGauss",AsymmGauss,0,4,6); | |
6109 | ||
6110 | //PARAMETERS FOR FIT PH | |
6111 | // PASAv.4 | |
6112 | //fAsymmGauss->SetParameter(0,0.113755); | |
6113 | //fAsymmGauss->SetParameter(1,0.350706); | |
6114 | //fAsymmGauss->SetParameter(2,0.0604244); | |
6115 | //fAsymmGauss->SetParameter(3,7.65596); | |
6116 | //fAsymmGauss->SetParameter(4,1.00124); | |
6117 | //fAsymmGauss->SetParameter(5,0.870597); // No tail cancelation | |
6118 | ||
6119 | Double_t xx = x[0]; | |
6120 | ||
6121 | if (xx < par[1]) { | |
6122 | return par[5]; | |
6123 | } | |
6124 | ||
6125 | Double_t dx = 0.005; | |
6126 | Double_t xs = par[1]; | |
6127 | Double_t ss = 0.0; | |
6128 | Double_t paras[2] = { 0.0, 0.0 }; | |
6129 | ||
6130 | while (xs < xx) { | |
6131 | if ((xs >= par[1]) && | |
6132 | (xs < (par[1]+par[2]))) { | |
6133 | //fAsymmGauss->SetParameter(0,par[0]); | |
6134 | //fAsymmGauss->SetParameter(1,xs); | |
6135 | //ss += fAsymmGauss->Eval(xx); | |
6136 | paras[0] = par[0]; | |
6137 | paras[1] = xs; | |
6138 | ss += AsymmGauss(&xx,paras); | |
6139 | } | |
6140 | if ((xs >= (par[1]+par[2])) && | |
6141 | (xs < (par[1]+par[2]+par[3]))) { | |
6142 | //fAsymmGauss->SetParameter(0,par[0]*par[4]); | |
6143 | //fAsymmGauss->SetParameter(1,xs); | |
6144 | //ss += fAsymmGauss->Eval(xx); | |
6145 | paras[0] = par[0]*par[4]; | |
6146 | paras[1] = xs; | |
6147 | ss += AsymmGauss(&xx,paras); | |
6148 | } | |
6149 | xs += dx; | |
6150 | } | |
6151 | ||
6152 | return ss + par[5]; | |
6153 | ||
6154 | } | |
6155 | ||
6156 | //_____________________________________________________________________________ | |
979b168f | 6157 | Double_t AliTRDCalibraFit::AsymmGauss(const Double_t *x, const Double_t *par) |
55a288e5 | 6158 | { |
6159 | // | |
6160 | // Function for the fit | |
6161 | // | |
6162 | ||
6163 | //par[0] = normalization | |
6164 | //par[1] = mean | |
6165 | //par[2] = sigma | |
6166 | //norm0 = 1 | |
6167 | //par[3] = lambda0 | |
6168 | //par[4] = norm1 | |
6169 | //par[5] = lambda1 | |
6170 | ||
6171 | Double_t par1save = par[1]; | |
6172 | //Double_t par2save = par[2]; | |
6173 | Double_t par2save = 0.0604244; | |
6174 | //Double_t par3save = par[3]; | |
6175 | Double_t par3save = 7.65596; | |
6176 | //Double_t par5save = par[5]; | |
6177 | Double_t par5save = 0.870597; | |
6178 | Double_t dx = x[0] - par1save; | |
6179 | ||
6180 | Double_t sigma2 = par2save*par2save; | |
6181 | Double_t sqrt2 = TMath::Sqrt(2.0); | |
6182 | Double_t exp1 = par3save * TMath::Exp(-par3save * (dx - 0.5 * par3save * sigma2)) | |
bb7e41dd | 6183 | * (1.0 - AliMathBase::ErfFast((par3save * sigma2 - dx) / (sqrt2 * par2save))); |
55a288e5 | 6184 | Double_t exp2 = par5save * TMath::Exp(-par5save * (dx - 0.5 * par5save * sigma2)) |
bb7e41dd | 6185 | * (1.0 - AliMathBase::ErfFast((par5save * sigma2 - dx) / (sqrt2 * par2save))); |
55a288e5 | 6186 | |
6187 | //return par[0]*(exp1+par[4]*exp2); | |
6188 | return par[0] * (exp1 + 1.00124 * exp2); | |
6189 | ||
6190 | } | |
6191 | ||
6192 | //_____________________________________________________________________________ | |
979b168f | 6193 | Double_t AliTRDCalibraFit::FuncLandauGaus(const Double_t *x, const Double_t *par) |
55a288e5 | 6194 | { |
6195 | // | |
6196 | // Sum Landau + Gaus with identical mean | |
6197 | // | |
6198 | ||
6199 | Double_t valLandau = par[0] * TMath::Landau(x[0],par[1],par[2]); | |
6200 | //Double_t valGaus = par[3] * TMath::Gaus(x[0],par[4],par[5]); | |
6201 | Double_t valGaus = par[3] * TMath::Gaus(x[0],par[1],par[4]); | |
6202 | Double_t val = valLandau + valGaus; | |
6203 | ||
6204 | return val; | |
6205 | ||
6206 | } | |
6207 | ||
6208 | //_____________________________________________________________________________ | |
979b168f | 6209 | Double_t AliTRDCalibraFit::LanGauFun(const Double_t *x, const Double_t *par) |
55a288e5 | 6210 | { |
6211 | // | |
6212 | // Function for the fit | |
6213 | // | |
6214 | // Fit parameters: | |
6215 | // par[0]=Width (scale) parameter of Landau density | |
6216 | // par[1]=Most Probable (MP, location) parameter of Landau density | |
6217 | // par[2]=Total area (integral -inf to inf, normalization constant) | |
6218 | // par[3]=Width (sigma) of convoluted Gaussian function | |
6219 | // | |
6220 | // In the Landau distribution (represented by the CERNLIB approximation), | |
6221 | // the maximum is located at x=-0.22278298 with the location parameter=0. | |
6222 | // This shift is corrected within this function, so that the actual | |
6223 | // maximum is identical to the MP parameter. | |
6224 | // | |
6225 | ||
6226 | // Numeric constants | |
6227 | Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2) | |
6228 | Double_t mpshift = -0.22278298; // Landau maximum location | |
6229 | ||
6230 | // Control constants | |
6231 | Double_t np = 100.0; // Number of convolution steps | |
6232 | Double_t sc = 5.0; // Convolution extends to +-sc Gaussian sigmas | |
6233 | ||
6234 | // Variables | |
6235 | Double_t xx; | |
6236 | Double_t mpc; | |
6237 | Double_t fland; | |
6238 | Double_t sum = 0.0; | |
6239 | Double_t xlow; | |
6240 | Double_t xupp; | |
6241 | Double_t step; | |
6242 | Double_t i; | |
6243 | ||
6244 | // MP shift correction | |
6245 | mpc = par[1] - mpshift * par[0]; | |
6246 | ||
6247 | // Range of convolution integral | |
6248 | xlow = x[0] - sc * par[3]; | |
6249 | xupp = x[0] + sc * par[3]; | |
6250 | ||
6251 | step = (xupp - xlow) / np; | |
6252 | ||
6253 | // Convolution integral of Landau and Gaussian by sum | |
6254 | for (i = 1.0; i <= np/2; i++) { | |
6255 | ||
6256 | xx = xlow + (i-.5) * step; | |
6257 | fland = TMath::Landau(xx,mpc,par[0]) / par[0]; | |
6258 | sum += fland * TMath::Gaus(x[0],xx,par[3]); | |
6259 | ||
6260 | xx = xupp - (i-.5) * step; | |
6261 | fland = TMath::Landau(xx,mpc,par[0]) / par[0]; | |
6262 | sum += fland * TMath::Gaus(x[0],xx,par[3]); | |
6263 | ||
6264 | } | |
6265 | ||
6266 | return (par[2] * step * sum * invsq2pi / par[3]); | |
6267 | ||
6268 | } | |
55a288e5 | 6269 | //_____________________________________________________________________________ |
979b168f | 6270 | TF1 *AliTRDCalibraFit::LanGauFit(TH1 *his, const Double_t *fitrange, const Double_t *startvalues |
6271 | , const Double_t *parlimitslo, const Double_t *parlimitshi | |
55a288e5 | 6272 | , Double_t *fitparams, Double_t *fiterrors |
e6381f8e | 6273 | , Double_t *chiSqr, Int_t *ndf) const |
55a288e5 | 6274 | { |
6275 | // | |
6276 | // Function for the fit | |
6277 | // | |
6278 | ||
6279 | Int_t i; | |
6280 | Char_t funname[100]; | |
6281 | ||
6282 | TF1 *ffitold = (TF1 *) gROOT->GetListOfFunctions()->FindObject(funname); | |
6283 | if (ffitold) { | |
6284 | delete ffitold; | |
6285 | } | |
6286 | ||
6287 | TF1 *ffit = new TF1(funname,LanGauFun,fitrange[0],fitrange[1],4); | |
6288 | ffit->SetParameters(startvalues); | |
6289 | ffit->SetParNames("Width","MP","Area","GSigma"); | |
6290 | ||
6291 | for (i = 0; i < 4; i++) { | |
6292 | ffit->SetParLimits(i,parlimitslo[i],parlimitshi[i]); | |
6293 | } | |
6294 | ||
6295 | his->Fit(funname,"RB0"); // Fit within specified range, use ParLimits, do not plot | |
6296 | ||
6297 | ffit->GetParameters(fitparams); // Obtain fit parameters | |
6298 | for (i = 0; i < 4; i++) { | |
6299 | fiterrors[i] = ffit->GetParError(i); // Obtain fit parameter errors | |
6300 | } | |
6301 | chiSqr[0] = ffit->GetChisquare(); // Obtain chi^2 | |
6302 | ndf[0] = ffit->GetNDF(); // Obtain ndf | |
6303 | ||
6304 | return (ffit); // Return fit function | |
6305 | ||
6306 | } | |
6307 | ||
6308 | //_____________________________________________________________________________ | |
979b168f | 6309 | Int_t AliTRDCalibraFit::LanGauPro(const Double_t *params, Double_t &maxx, Double_t &fwhm) |
55a288e5 | 6310 | { |
6311 | // | |
6312 | // Function for the fit | |
6313 | // | |
6314 | ||
6315 | Double_t p; | |
6316 | Double_t x; | |
6317 | Double_t fy; | |
6318 | Double_t fxr; | |
6319 | Double_t fxl; | |
6320 | Double_t step; | |
6321 | Double_t l; | |
6322 | Double_t lold; | |
6323 | ||
6324 | Int_t i = 0; | |
6325 | Int_t maxcalls = 10000; | |
6326 | ||
6327 | // Search for maximum | |
6328 | p = params[1] - 0.1 * params[0]; | |
6329 | step = 0.05 * params[0]; | |
6330 | lold = -2.0; | |
6331 | l = -1.0; | |
6332 | ||
6333 | while ((l != lold) && (i < maxcalls)) { | |
6334 | i++; | |
6335 | lold = l; | |
6336 | x = p + step; | |
6337 | l = LanGauFun(&x,params); | |
6338 | if (l < lold) { | |
6339 | step = -step / 10.0; | |
6340 | } | |
6341 | p += step; | |
6342 | } | |
6343 | ||
6344 | if (i == maxcalls) { | |
6345 | return (-1); | |
6346 | } | |
6347 | maxx = x; | |
6348 | fy = l / 2.0; | |
6349 | ||
6350 | // Search for right x location of fy | |
6351 | p = maxx + params[0]; | |
6352 | step = params[0]; | |
6353 | lold = -2.0; | |
6354 | l = -1e300; | |
6355 | i = 0; | |
6356 | ||
6357 | while ( (l != lold) && (i < maxcalls) ) { | |
6358 | i++; | |
6359 | ||
6360 | lold = l; | |
6361 | x = p + step; | |
6362 | l = TMath::Abs(LanGauFun(&x,params) - fy); | |
6363 | ||
6364 | if (l > lold) | |
6365 | step = -step/10; | |
6366 | ||
6367 | p += step; | |
6368 | } | |
6369 | ||
6370 | if (i == maxcalls) | |
6371 | return (-2); | |
6372 | ||
6373 | fxr = x; | |
6374 | ||
3a0f6479 | 6375 | |
55a288e5 | 6376 | // Search for left x location of fy |
6377 | ||
6378 | p = maxx - 0.5 * params[0]; | |
6379 | step = -params[0]; | |
6380 | lold = -2.0; | |
6381 | l = -1.0e300; | |
6382 | i = 0; | |
6383 | ||
6384 | while ((l != lold) && (i < maxcalls)) { | |
6385 | i++; | |
6386 | lold = l; | |
6387 | x = p + step; | |
6388 | l = TMath::Abs(LanGauFun(&x,params) - fy); | |
6389 | if (l > lold) { | |
6390 | step = -step / 10.0; | |
6391 | } | |
6392 | p += step; | |
6393 | } | |
6394 | ||
6395 | if (i == maxcalls) { | |
6396 | return (-3); | |
6397 | } | |
6398 | ||
6399 | fxl = x; | |
6400 | fwhm = fxr - fxl; | |
6401 | ||
6402 | return (0); | |
55a288e5 | 6403 | } |
55a288e5 | 6404 | //_____________________________________________________________________________ |
979b168f | 6405 | Double_t AliTRDCalibraFit::GausConstant(const Double_t *x, const Double_t *par) |
55a288e5 | 6406 | { |
6407 | // | |
6408 | // Gaus with identical mean | |
6409 | // | |
6410 | ||
e6381f8e | 6411 | Double_t gauss = par[0] * TMath::Gaus(x[0],0.0,par[1])+par[2]; |
55a288e5 | 6412 | |
e6381f8e | 6413 | return gauss; |
55a288e5 | 6414 | |
ef19f1da | 6415 | } |
4c865c34 | 6416 | |
3b0c1edc | 6417 | |
6418 |