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