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