Fix for 64-bit platforms
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFit.cxx
CommitLineData
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
31// _fDebug = 1: a comparaison of the coefficients found and the default values
32// in the choosen database.
33// fCoef , histogram of the coefs as function of the calibration group number
34// fDelta , histogram of the relative difference of the coef with the default
35// value in the database as function of the calibration group number
36// fError , dirstribution of this relative difference
37// _fDebug = 2: only the fit of the choosen calibration group fFitVoir (SetFitVoir)
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
49#include <TTree.h>
50#include <TLine.h>
51#include <TH1I.h>
52#include <TStyle.h>
53#include <TProfile2D.h>
54#include <TFile.h>
55#include <TCanvas.h>
56#include <TGraphErrors.h>
57#include <TGraph.h>
58#include <TObjArray.h>
59#include <TH1.h>
60#include <TH1F.h>
61#include <TF1.h>
62#include <TH2F.h>
63#include <TAxis.h>
64#include <TStopwatch.h>
65#include <TMath.h>
66#include <TLegend.h>
67#include <TDirectory.h>
68#include <TROOT.h>
69
70#include "AliLog.h"
71#include "AliCDBManager.h"
72
73#include "AliTRDCalibraFit.h"
74#include "AliTRDCalibraMode.h"
75#include "AliTRDCalibraVector.h"
76#include "AliTRDcalibDB.h"
77#include "AliTRDgeometry.h"
55a288e5 78#include "./Cal/AliTRDCalROC.h"
79#include "./Cal/AliTRDCalPad.h"
80#include "./Cal/AliTRDCalDet.h"
81
82
83ClassImp(AliTRDCalibraFit)
84
85AliTRDCalibraFit* AliTRDCalibraFit::fgInstance = 0;
86Bool_t AliTRDCalibraFit::fgTerminated = kFALSE;
87
88//_____________singleton implementation_________________________________________________
89AliTRDCalibraFit *AliTRDCalibraFit::Instance()
90{
91 //
92 // Singleton implementation
93 //
94
95 if (fgTerminated != kFALSE) {
96 return 0;
97 }
98
99 if (fgInstance == 0) {
100 fgInstance = new AliTRDCalibraFit();
101 }
102
103 return fgInstance;
104
105}
106
107//______________________________________________________________________________________
108void AliTRDCalibraFit::Terminate()
109{
110 //
111 // Singleton implementation
112 // Deletes the instance of this class
113 //
114
115 fgTerminated = kTRUE;
116
117 if (fgInstance != 0) {
118 delete fgInstance;
119 fgInstance = 0;
120 }
121
122}
123
124//______________________________________________________________________________________
125AliTRDCalibraFit::AliTRDCalibraFit()
126 :TObject()
f162af62 127 ,fGeo(0)
55a288e5 128 ,fWriteNameCoef(0)
129 ,fFitPHOn(kFALSE)
130 ,fFitPol2On(kFALSE)
131 ,fFitLagrPolOn(kFALSE)
132 ,fTakeTheMaxPH(kFALSE)
133 ,fFitPHPeriode(0)
134 ,fFitPHNDB(1)
135 ,fBeginFitCharge(0.0)
136 ,fT0Shift(0.0)
137 ,fRangeFitPRF(0.0)
138 ,fFitPRFOn(kFALSE)
139 ,fRMSPRFOn(kFALSE)
140 ,fFitPRFNDB(0)
141 ,fMeanChargeOn(kFALSE)
142 ,fFitChargeBisOn(kFALSE)
143 ,fFitChargeOn(kFALSE)
144 ,fFitMeanWOn(kFALSE)
145 ,fFitChargeNDB(0)
146 ,fAccCDB(kFALSE)
147 ,fMinEntries(0)
148 ,fRebin(0)
149 ,fNumberFit(0)
150 ,fNumberFitSuccess(0)
151 ,fNumberEnt(0)
152 ,fStatisticMean(0.0)
153 ,fDebug(0)
154 ,fFitVoir(0)
155 ,fCalibraMode(0)
156 ,fPRF(0)
157 ,fGain(0)
158 ,fT0(0)
159 ,fVdrift(0)
160 ,fVdriftDetector(0)
161 ,fVdriftPad(0x0)
162 ,fT0Detector(0)
163 ,fT0Pad(0x0)
164 ,fPRFDetector(0)
165 ,fPRFPad(0x0)
166 ,fCoefCH(0x0)
167 ,fScaleFitFactor(0.0)
168 ,fEntriesCurrent(0)
169 ,fCalibraVector(0)
170 ,fVectorFitCH(0)
171{
172 //
173 // Default constructor
174 //
175
f162af62 176 fGeo = new AliTRDgeometry();
55a288e5 177 fCalibraMode = new AliTRDCalibraMode();
178
179 // Write
180 for (Int_t i = 0; i < 3; i++) {
181 fWriteCoef[i] = kFALSE;
182 }
183
184 // Debug Mode
185 for (Int_t k = 0; k < 3; k++) {
186 fDet[k] = 0;
187 }
188
189 for (Int_t i = 0; i < 3; i++) {
190 fPhd[i] = 0.0;
191 }
192
193 // Init
194 Init();
195
196}
197
198//______________________________________________________________________________________
199AliTRDCalibraFit::AliTRDCalibraFit(const AliTRDCalibraFit &c)
200 :TObject(c)
f162af62 201 ,fGeo(0)
55a288e5 202 ,fWriteNameCoef(0)
203 ,fFitPHOn(kFALSE)
204 ,fFitPol2On(kFALSE)
205 ,fFitLagrPolOn(kFALSE)
206 ,fTakeTheMaxPH(kFALSE)
207 ,fFitPHPeriode(0)
208 ,fFitPHNDB(1)
209 ,fBeginFitCharge(0.0)
210 ,fT0Shift(0.0)
211 ,fRangeFitPRF(0.0)
212 ,fFitPRFOn(kFALSE)
213 ,fRMSPRFOn(kFALSE)
214 ,fFitPRFNDB(0)
215 ,fMeanChargeOn(kFALSE)
216 ,fFitChargeBisOn(kFALSE)
217 ,fFitChargeOn(kFALSE)
218 ,fFitMeanWOn(kFALSE)
219 ,fFitChargeNDB(0)
220 ,fAccCDB(kFALSE)
221 ,fMinEntries(0)
222 ,fRebin(0)
223 ,fNumberFit(0)
224 ,fNumberFitSuccess(0)
225 ,fNumberEnt(0)
226 ,fStatisticMean(0.0)
227 ,fDebug(0)
228 ,fFitVoir(0)
229 ,fCalibraMode(0)
230 ,fPRF(0)
231 ,fGain(0)
232 ,fT0(0)
233 ,fVdrift(0)
234 ,fVdriftDetector(0)
235 ,fVdriftPad(0x0)
236 ,fT0Detector(0)
237 ,fT0Pad(0x0)
238 ,fPRFDetector(0)
239 ,fPRFPad(0x0)
240 ,fCoefCH(0x0)
241 ,fScaleFitFactor(0.0)
242 ,fEntriesCurrent(0)
243 ,fCalibraVector(0)
244 ,fVectorFitCH(0)
245{
246 //
247 // Copy constructor
248 //
249
250}
251
252//____________________________________________________________________________________
253AliTRDCalibraFit::~AliTRDCalibraFit()
254{
255 //
256 // AliTRDCalibraFit destructor
257 //
258
259 ClearTree();
260
f162af62 261 if (fGeo) {
262 delete fGeo;
263 }
264
55a288e5 265}
266
267//_____________________________________________________________________________
268void AliTRDCalibraFit::Destroy()
269{
270 //
271 // Delete instance
272 //
273
274 if (fgInstance) {
275 delete fgInstance;
276 fgInstance = 0x0;
277 }
278
279}
280
281//_____________________________________________________________________________
282void AliTRDCalibraFit::ClearTree()
283{
284 //
285 // Delete the trees
286 //
287
288 if (fPRF) {
289 delete fPRF;
290 fPRF = 0x0;
291 }
292 if (fGain) {
293 delete fGain;
294 fGain = 0x0;
295 }
296 if (fT0) {
297 delete fT0;
298 fT0 = 0x0;
299 }
300 if (fVdrift) {
301 delete fVdrift;
302 fVdrift = 0x0;
303 }
304
305}
306
307//_____________________________________________________________________________
308void AliTRDCalibraFit::Init()
309{
310 //
311 // Init some default values
312 //
313
314 // Write
315 fWriteNameCoef = "TRD.coefficient.root";
316
317 // Fit
318 fFitPHPeriode = 1;
319 fBeginFitCharge = 3.5;
320 fRangeFitPRF = 1.0;
321 fMinEntries = 800;
322 fT0Shift = 0.126256;
323
324 // Internal variables
325
326 // Variables in the loop
327 for (Int_t k = 0; k < 4; k++) {
328 fChargeCoef[k] = 1.0;
329 fVdriftCoef[k] = 1.5;
330 fT0Coef[k] = -1.0;
331 }
332 fChargeCoef[4] = 1.0;
333 for (Int_t i = 0; i < 3; i++) {
334 fPRFCoef[i] = -1.0;
335 }
336
337 // Local database to be changed
338 fRebin = 1;
339
340}
341
342//____________Functions fit Online CH2d________________________________________
343Bool_t AliTRDCalibraFit::FitCHOnline(TH2I *ch)
344{
345 //
346 // Fit the 1D histos, projections of the 2D ch on the Xaxis, for each
347 // calibration group normalized the resulted coefficients (to 1 normally)
348 // and write the results in a tree
349 //
350
351 //A small check
352 if((fFitChargeNDB == 0) && (!fFitChargeOn)){
353 AliInfo("You have choosen to write the default fit method but it is not on!");
354 return kFALSE;
355 }
356 if((fFitChargeNDB == 1) && (!fMeanChargeOn)){
357 AliInfo("You have choosen to write the mean method but it is not on!");
358 return kFALSE;
359 }
360 if((fFitChargeNDB == 2) && (!fFitChargeBisOn)){
361 AliInfo("You have choosen to write the second fit method but it is not on!");
362 return kFALSE;
363 }
364 if((fFitChargeNDB == 4) && (!fFitMeanWOn)){
365 AliInfo("You have choosen to write the mean w method but it is not on!");
366 return kFALSE;
367 }
368
369
370 // Number of Xbins (detectors or groups of pads)
371 TAxis *xch = ch->GetXaxis();
372 Int_t nbins = xch->GetNbins();
373 TAxis *yph = ch->GetYaxis();
374 Int_t nybins = yph->GetNbins();
375 if (!InitFit(nbins,0)) {
376 return kFALSE;
377 }
378 fStatisticMean = 0.0;
379 fNumberFit = 0;
380 fNumberFitSuccess = 0;
381 fNumberEnt = 0;
382
383 // Init fCountDet and fCount
384 InitfCountDetAndfCount(0);
385
386 // Beginning of the loop betwwen dect1 and dect2
387 for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) {
388
389 TH1I *projch = (TH1I *) ch->ProjectionY("projch",idect+1,idect+1,(Option_t *)"e");
390 projch->SetDirectory(0);
391
392 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
393 UpdatefCountDetAndfCount(idect,0);
394
395 // Reconstruction of the row and pad group: rowmin, row max ...
396 ReconstructFitRowMinRowMax(idect, 0);
397
398 // Number of entries for this calibration group
399 Double_t nentries = 0.0;
400 Double_t mean = 0.0;
401 for (Int_t k = 0; k < nybins; k++) {
402 nentries += ch->GetBinContent(ch->GetBin(idect+1,k+1));
403 mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1);
404 }
405 if (nentries > 0) {
406 fNumberEnt++;
407 mean /= nentries;
408 }
409
410
411 // Rebin and statistic stuff
412 // Rebin
413 if (fRebin > 1) {
414 projch = ReBin((TH1I *) projch);
415 }
416 // This detector has not enough statistics or was off
417 if (nentries < fMinEntries) {
418 // Fill with the default infos
419 NotEnoughStatistic(idect,0);
420 // Memory!!!
421 if (fDebug != 2) {
422 delete projch;
423 }
424 continue;
425 }
426
427 // Statistics of the group fitted
428 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
429 fStatisticMean += nentries;
430 fNumberFit++;
431
432
433 // Method Mean and fit
434 // idect is egal for fDebug = 0 and 2, only to fill the hist
435 fChargeCoef[1] = mean;
436 if(fMeanChargeOn){
437 FitMean((TH1 *) projch,(Int_t) (idect-fDect1[0]),nentries);
438 }
439 if(fFitChargeOn){
440 FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
441 }
442 if(fFitChargeBisOn) {
443 FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
444 }
445 if(fFitMeanWOn){
446 FitMeanW((TH1 *) projch,(Int_t) (idect-fDect1[0]));
447 }
448
449 // Visualise the detector for fDebug 3 or 4
450 // Here is the reconstruction of the pad and row group is used!
451 if (fDebug >= 3) {
452 FillCoefChargeDB();
453 }
454 // Fill Infos Fit
455 FillInfosFit(idect,0);
456
457 // Memory!!!
458 if (fDebug != 2) {
459 delete projch;
460 }
461
462
463 } // Boucle object
464
465
466 // Normierungcharge
467 if (fDebug != 2) {
468 NormierungCharge();
469 }
470
471 // Plot
472 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
473 if ((fDebug == 1) ||
474 (fDebug == 4)) {
475 PlotWriteCH();
476 }
477 if ((fDebug == 4) ||
478 (fDebug == 3)) {
479 PlotCHDB();
480 }
481
482 // Mean Statistic
483 if (fNumberFit > 0) {
484 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
485 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
486 AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits"
487 , (Int_t) fStatisticMean/fNumberFit, fNumberFitSuccess));
488 fStatisticMean = fStatisticMean / fNumberFit;
489 }
490 else {
491 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
492 }
493
494 // Write the things!
495 ConvertVectorFitCHTree();
496 if (fWriteCoef[0]) {
497 WriteFitInfos(0);
498 }
499
500 return kTRUE;
501
502}
503
504//____________Functions fit Online CH2d________________________________________
505Bool_t AliTRDCalibraFit::FitCHOnline()
506{
507 //
508 // Reconstruct a 1D histo from the vectorCH for each calibration group,
509 // fit the histo, normalized the resulted coefficients (to 1 normally)
510 // and write the results in a tree
511 //
512
513 //A small check
514 if((fFitChargeNDB == 0) && (!fFitChargeOn)){
515 AliInfo("You have choosen to write the default fit method but it is not on!");
516 return kFALSE;
517 }
518 if((fFitChargeNDB == 1) && (!fMeanChargeOn)){
519 AliInfo("You have choosen to write the mean method but it is not on!");
520 return kFALSE;
521 }
522 if((fFitChargeNDB == 2) && (!fFitChargeBisOn)){
523 AliInfo("You have choosen to write the second fit method but it is not on!");
524 return kFALSE;
525 }
526 if((fFitChargeNDB == 4) && (!fFitMeanWOn)){
527 AliInfo("You have choosen to write the mean w method but it is not on!");
528 return kFALSE;
529 }
530
531
532 //Warning
533 if (!fCalibraVector) {
534 AliError("You have first to set the calibravector before using this function!");
535 return kFALSE;
536 }
537
538 // Number of Xbins (detectors or groups of pads)
539 if (!InitFit(0,0)) {
540 return kFALSE;
541 }
542 fStatisticMean = 0.0;
543 fNumberFit = 0;
544 fNumberFitSuccess = 0;
545 fNumberEnt = 0;
546
547 // Init fCountDet and fCount
548 InitfCountDetAndfCount(0);
549
550 // Beginning of the loop between dect1 and dect2
551 for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) {
552
553 // Search if the group is in the VectorCH
554 Int_t place = fCalibraVector->SearchInVector(idect,0);
555
556 // Is in
557 TH1F *projch = 0x0;
558 TString name("CH");
559 name += idect;
560 if (place != -1) {
561 projch = fCalibraVector->ConvertVectorCTHisto(place,(const char *) name);
562 projch->SetDirectory(0);
563 }
564
565 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
566 UpdatefCountDetAndfCount(idect,0);
567
568 // Reconstruction of the row and pad group: rowmin, row max ...
569 ReconstructFitRowMinRowMax(idect,0);
570
571 // Number of entries and mean
572 Double_t nentries = 0.0;
573 Double_t mean = 0.0;
574 if (projch) {
575 for (Int_t k = 0; k < fCalibraVector->GetNumberBinCharge(); k++) {
576 nentries += projch->GetBinContent(k+1);
577 mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1);
578 }
579 }
580 if (nentries > 0) {
581 fNumberEnt++;
582 mean /= nentries;
583 }
584
585 // Rebin and statistic stuff
586 // Rebin
587 if ((fRebin > 1) &&
588 (place != -1)) {
589 projch = ReBin((TH1F *) projch);
590 }
591
592 // This detector has not enough statistics or was not found in VectorCH
593 if ((place == -1) ||
594 ((place != -1) &&
595 (nentries < fMinEntries))) {
596
597 // Fill with the default infos
598 NotEnoughStatistic(idect,0);
599
600 // Memory!!!
601 if (fDebug != 2) {
602 delete projch;
603 }
604
605 continue;
606
607 }
608
609 // Statistic of the histos fitted
610 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
611 fStatisticMean += nentries;
612 fNumberFit++;
613
614
615 // Method Mean and fit
616 // idect is egal for fDebug = 0 and 2, only to fill the hist
617 fChargeCoef[1] = mean;
618 if(fMeanChargeOn){
619 FitMean((TH1 *) projch,(Int_t) (idect-fDect1[0]),nentries);
620 }
621 if(fFitChargeOn){
622 FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
623 }
624 if(fFitChargeBisOn) {
625 FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
626 }
627 if(fFitMeanWOn){
628 FitMeanW((TH1 *) projch,(Int_t) (idect-fDect1[0]));
629 }
630
631 // Visualise the detector for fDebug 3 or 4
632 // Here is the reconstruction of the pad and row group is used!
633 if (fDebug >= 3) {
634 FillCoefChargeDB();
635 }
636
637 // Fill Infos Fit
638 FillInfosFit(idect,0);
639
640 // Memory!!!
641 if (fDebug != 2) {
642 delete projch;
643 }
644
645 } // Boucle object
646
647
648 // Normierungcharge
649 if (fDebug != 2) {
650 NormierungCharge();
651 }
652
653
654 // Plot
655 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
656 if ((fDebug == 1) ||
657 (fDebug == 4)){
658 PlotWriteCH();
659 }
660 if((fDebug == 4) ||
661 (fDebug == 3)){
662 PlotCHDB();
663 }
664
665 // Mean Statistics
666 if (fNumberFit > 0) {
667 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
668 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
669 AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits"
670 ,(Int_t) fStatisticMean/fNumberFit, fNumberFitSuccess));
671 fStatisticMean = fStatisticMean / fNumberFit;
672 }
673 else {
674 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
675 }
676
677 // Write the things!
678 ConvertVectorFitCHTree();
679 if (fWriteCoef[0]) {
680 WriteFitInfos(0);
681 }
682
683 return kTRUE;
684
685}
686
687//____________Functions fit Online CH2d________________________________________
688Bool_t AliTRDCalibraFit::FitCHOnline(TTree *tree)
689{
690 //
691 // Look if the calibration group can be found in the tree, if yes take the
692 // histo, fit it, normalized the resulted coefficients (to 1 normally) and
693 // write the results in a tree
694 //
695
696 //A small check
697 if((fFitChargeNDB == 0) && (!fFitChargeOn)){
698 AliInfo("You have choosen to write the default fit method but it is not on!");
699 return kFALSE;
700 }
701 if((fFitChargeNDB == 1) && (!fMeanChargeOn)){
702 AliInfo("You have choosen to write the mean method but it is not on!");
703 return kFALSE;
704 }
705 if((fFitChargeNDB == 2) && (!fFitChargeBisOn)){
706 AliInfo("You have choosen to write the second fit method but it is not on!");
707 return kFALSE;
708 }
709 if((fFitChargeNDB == 4) && (!fFitMeanWOn)){
710 AliInfo("You have choosen to write the mean w method but it is not on!");
711 return kFALSE;
712 }
713
714
715 // Number of Xbins (detectors or groups of pads)
716 if (!InitFit(0,0)) {
717 return kFALSE;
718 }
719 fStatisticMean = 0.0;
720 fNumberFit = 0;
721 fNumberFitSuccess = 0;
722 fNumberEnt = 0;
723
724 // Initialise
725 fCalibraVector = new AliTRDCalibraVector();
726
727
728 // Init fCountDet and fCount
729 InitfCountDetAndfCount(0);
730 TH1F *projch = 0x0;
731 tree->SetBranchAddress("histo",&projch);
732 TObjArray *vectorplace = fCalibraVector->ConvertTreeVector(tree);
733
734 // Beginning of the loop between dect1 and dect2
735 for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) {
736
737 //Search if the group is in the VectorCH
738 Int_t place = fCalibraVector->SearchInTreeVector(vectorplace,idect);
739
740 // Is in
741 if (place != -1) {
742 // Variable
743 tree->GetEntry(place);
744 }
745
746 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
747 UpdatefCountDetAndfCount(idect,0);
748
749 // Reconstruction of the row and pad group: rowmin, row max ...
750 ReconstructFitRowMinRowMax(idect,0);
751
752 // Number of entries and mean
753 Double_t nentries = 0.0;
754 Double_t mean = 0.0;
755 if (projch) {
756 for (Int_t k = 0; k < projch->GetXaxis()->GetNbins(); k++) {
757 nentries += projch->GetBinContent(k+1);
758 mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1);
759 }
760 }
761 if (nentries > 0) {
762 fNumberEnt++;
763 mean /= nentries;
764 }
765
766
767 // Rebin and statistic stuff
768 // Rebin
769 if ((fRebin > 1) &&
770 (place != -1)) {
771 projch = ReBin((TH1F *) projch);
772 }
773
774 // This detector has not enough statistics or was not found in VectorCH
775 if((place == -1) ||
776 ((place != -1) &&
777 (nentries < fMinEntries))) {
778
779 // Fill with the default infos
780 NotEnoughStatistic(idect,0);
781
782 continue;
783
784 }
785
786 // Statistics of the group fitted
787 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
788 fNumberFit++;
789 fStatisticMean += nentries;
790
791 // Method Mean and fit
792 // idect is egal for fDebug = 0 and 2, only to fill the hist
793 fChargeCoef[1] = mean;
794 if(fMeanChargeOn){
795 FitMean((TH1 *) projch,(Int_t) (idect-fDect1[0]),nentries);
796 }
797 if(fFitChargeOn){
798 FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
799 }
800 if(fFitChargeBisOn) {
801 FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
802 }
803 if(fFitMeanWOn){
804 FitMeanW((TH1 *) projch,(Int_t) (idect-fDect1[0]));
805 }
806
807 // Visualise the detector for fDebug 3 or 4
808 // Here is the reconstruction of the pad and row group is used!
809 if (fDebug >= 3) {
810 FillCoefChargeDB();
811 }
812
813 // Fill Infos Fit
814 FillInfosFit(idect,0);
815
816 } // Boucle object
817
818
819 // Normierungcharge
820 if (fDebug != 2) {
821 NormierungCharge();
822 }
823
824
825 // Plot
826 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
827 if ((fDebug == 1) ||
828 (fDebug == 4)){
829 PlotWriteCH();
830 }
831 if ((fDebug == 4) ||
832 (fDebug == 3)){
833 PlotCHDB();
834 }
835
836 // Mean Statistic
837 if (fNumberFit > 0) {
838 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
839 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
840 AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits"
841 ,(Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess));
842 fStatisticMean = fStatisticMean / fNumberFit;
843 }
844 else {
845 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
846 }
847
848 // Write the things!
849 ConvertVectorFitCHTree();
850 if (fWriteCoef[0]) {
851 WriteFitInfos(0);
852 }
853
854
855 return kTRUE;
856
857}
858
859//________________functions fit Online PH2d____________________________________
860Bool_t AliTRDCalibraFit::FitPHOnline(TProfile2D *ph)
861{
862 //
863 // Take the 1D profiles (average pulse height), projections of the 2D PH
864 // on the Xaxis, for each calibration group
865 // Fit or use the slope of the average pulse height to reconstruct the
866 // drift velocity write the results in a tree
867 // A first calibration of T0 is also made using the same method (slope method)
868 //
869
870 //A small check
871 if((fFitPHNDB == 0) && (!fFitPHOn)){
872 AliInfo("You have choosen to write the fit method but it is not on!");
873 return kFALSE;
874 }
875 if((fFitPHNDB == 1) && (!fFitPol2On)){
876 AliInfo("You have choosen to write the Pol2 method but it is not on!");
877 return kFALSE;
878 }
879 if((fFitPHNDB == 3) && (!fFitLagrPolOn)){
880 AliInfo("You have choosen to write the LagrPol2 method but it is not on!");
881 return kFALSE;
882 }
883
884 // Number of Xbins (detectors or groups of pads)
885 TAxis *xph = ph->GetXaxis();
886 TAxis *yph = ph->GetYaxis();
887 Int_t nbins = xph->GetNbins();
888 Int_t nybins = yph->GetNbins();
889 if (!InitFit(nbins,1)) {
890 return kFALSE;
891 }
892 fStatisticMean = 0.0;
893 fNumberFit = 0;
894 fNumberFitSuccess = 0;
895 fNumberEnt = 0;
896
897 // Init fCountDet and fCount
898 InitfCountDetAndfCount(1);
899
900 // Beginning of the loop
901 for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) {
902
903 TH1D *projph = (TH1D *) ph->ProjectionY("projph",idect+1,idect+1,(Option_t *) "e");
904 projph->SetDirectory(0);
905
906 // Number of entries for this calibration group
907 Double_t nentries = 0;
908 for (Int_t k = 0; k < nybins; k++) {
909 nentries += ph->GetBinEntries(ph->GetBin(idect+1,k+1));
910 }
911 if (nentries > 0) {
912 fNumberEnt++;
913 }
914
915 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
916 UpdatefCountDetAndfCount(idect,1);
917
918 // Reconstruction of the row and pad group: rowmin, row max ...
919 ReconstructFitRowMinRowMax(idect,1);
920
921 // Rebin and statistic stuff
922 // This detector has not enough statistics or was off
923 if (nentries < fMinEntries) {
924
925 // Fill with the default values
926 NotEnoughStatistic(idect,1);
927
928 // Memory!!!
929 if (fDebug != 2) {
930 delete projph;
931 }
932
933 continue;
934
935 }
936
937 // Statistics of the histos fitted
938 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
939 fNumberFit++;
940 fStatisticMean += nentries;
941
942 // Calcul of "real" coef
943 CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
944 CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
945
946 // Method Mean and fit
947 // idect is egal for fDebug = 0 and 2, only to fill the hist
948 if(fFitPol2On){
949 FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1]));
950 }
951 if(fFitLagrPolOn){
952 FitLagrangePoly((TH1 *) projph,(Int_t) (idect - fDect1[1]));
953 }
954 if (fFitPHOn) {
955 FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1]));
956 }
957
958 // Visualise the detector for fDebug 3 or 4
959 // Here is the reconstruction of the pad and row group is used!
960 if (fDebug >= 3) {
961 FillCoefVdriftDB();
962 FillCoefT0DB();
963 }
964 // Fill the tree if end of a detector or only the pointer to the branch!!!
965 FillInfosFit(idect,1);
966 // Memory!!!
967 if (fDebug != 2) {
968 delete projph;
969 }
970
971 } // Boucle object
972
973
974 // Plot
975 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
976 if ((fDebug == 1) ||
977 (fDebug == 4)) {
978 PlotWritePH();
979 PlotWriteT0();
980 }
981 if ((fDebug == 4) ||
982 (fDebug == 3)) {
983 PlotPHDB();
984 PlotT0DB();
985 }
986
987 // Mean Statistic
988 if (fNumberFit > 0) {
989 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
990 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
991 AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits"
992 ,(Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess));
993 fStatisticMean = fStatisticMean / fNumberFit;
994 }
995 else {
996 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
997 }
998
999 // Write the things!
1000 if(fWriteCoef[1]) {
1001 WriteFitInfos(1);
1002 }
1003
1004 return kTRUE;
1005
1006}
1007
1008//____________Functions fit Online PH2d________________________________________
1009Bool_t AliTRDCalibraFit::FitPHOnline()
1010{
1011 //
1012 // Reconstruct the average pulse height from the vectorPH for each
1013 // calibration group
1014 // Fit or use the slope of the average pulse height to reconstruct the
1015 // drift velocity write the results in a tree
1016 // A first calibration of T0 is also made using the same method (slope method)
1017 //
1018
1019 //A small check
1020 if((fFitPHNDB == 0) && (!fFitPHOn)){
1021 AliInfo("You have choosen to write the fit method but it is not on!");
1022 return kFALSE;
1023 }
1024 if((fFitPHNDB == 1) && (!fFitPol2On)){
1025 AliInfo("You have choosen to write the Pol2 method but it is not on!");
1026 return kFALSE;
1027 }
1028 if((fFitPHNDB == 3) && (!fFitLagrPolOn)){
1029 AliInfo("You have choosen to write the LagrPol2 method but it is not on!");
1030 return kFALSE;
1031 }
1032
1033 //Warning
1034 if (!fCalibraVector) {
1035 AliError("You have first to set the calibravector before using this function!");
1036 return kFALSE;
1037 }
1038
1039
1040 // Number of Xbins (detectors or groups of pads)
1041 if (!InitFit(0,1)) {
1042 return kFALSE;
1043 }
1044 fStatisticMean = 0.0;
1045 fNumberFit = 0;
1046 fNumberFitSuccess = 0;
1047 fNumberEnt = 0;
1048
1049 // Init fCountDet and fCount
1050 InitfCountDetAndfCount(1);
1051
1052 // Beginning of the loop
1053 for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) {
1054
1055 // Search if the group is in the VectorCH
1056 Int_t place = fCalibraVector->SearchInVector(idect,1);
1057
1058 // Is in
1059 TH1F *projph = 0x0;
1060 TString name("PH");
1061 name += idect;
1062 if (place != -1) {
1063 //Entries
1064 fNumberEnt++;
1065 projph = CorrectTheError((TGraphErrors *) (fCalibraVector->ConvertVectorPHisto(place,(const char *) name)));
1066 projph->SetDirectory(0);
1067 }
1068
1069 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1070 UpdatefCountDetAndfCount(idect,1);
1071
1072 // Reconstruction of the row and pad group: rowmin, row max ...
1073 ReconstructFitRowMinRowMax(idect,1);
1074
1075 // Rebin and statistic stuff
1076 // This detector has not enough statistics or was off
1077 if ((place == -1) ||
1078 ((place != -1) &&
1079 (fEntriesCurrent < fMinEntries))) {
1080
1081 // Fill with the default values
1082 NotEnoughStatistic(idect,1);
1083
1084 // Memory!!!
1085 if (fDebug != 2) {
1086 delete projph;
1087 }
1088
1089 continue;
1090
1091 }
1092
1093 // Statistic of the histos fitted
1094 AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent));
1095 fNumberFit++;
1096 fStatisticMean += fEntriesCurrent;
1097
1098 // Calcul of "real" coef
1099 CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
1100 CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
1101
1102 // Method Mean and fit
1103 // idect is egal for fDebug = 0 and 2, only to fill the hist
1104 if(fFitPol2On){
1105 FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1]));
1106 }
1107 if(fFitLagrPolOn){
1108 FitLagrangePoly((TH1 *) projph,(Int_t) (idect - fDect1[1]));
1109 }
1110 if (fFitPHOn) {
1111 FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1]));
1112 }
1113
1114 // Visualise the detector for fDebug 3 or 4
1115 // Here is the reconstruction of the pad and row group is used!
1116 if (fDebug >= 3) {
1117 FillCoefVdriftDB();
1118 FillCoefT0DB();
1119 }
1120
1121 // Fill the tree if end of a detector or only the pointer to the branch!!!
1122 FillInfosFit(idect,1);
1123
1124 // Memory!!!
1125 if (fDebug != 2) {
1126 delete projph;
1127 }
1128
1129 } // Boucle object
1130
1131
1132 // Plot
1133 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
1134 if ((fDebug == 1) ||
1135 (fDebug == 4)) {
1136 PlotWritePH();
1137 PlotWriteT0();
1138 }
1139 if ((fDebug == 4) ||
1140 (fDebug == 3)) {
1141 PlotPHDB();
1142 PlotT0DB();
1143 }
1144
1145 // Mean Statistic
1146 if (fNumberFit > 0) {
1147 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
1148 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
1149 AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits"
1150 ,(Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess));
1151 fStatisticMean = fStatisticMean / fNumberFit;
1152 }
1153 else {
1154 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1155 }
1156
1157 // Write the things!
1158 if (fWriteCoef[1]) {
1159 WriteFitInfos(1);
1160 }
1161
1162 return kTRUE;
1163
1164}
1165
1166//____________Functions fit Online PH2d________________________________________
1167Bool_t AliTRDCalibraFit::FitPHOnline(TTree *tree)
1168{
1169 //
1170 // Look if the calibration group can be found in the tree, if yes take the
1171 // histo, fit it, and write the results in a tree
1172 // A first calibration of T0 is also made using the same method (slope method)
1173 //
1174
1175 //A small check
1176 if ((fFitPHNDB == 0) && (!fFitPHOn)){
1177 AliInfo("You have choosen to write the fit method but it is not on!");
1178 return kFALSE;
1179 }
1180 if ((fFitPHNDB == 1) && (!fFitPol2On)){
1181 AliInfo("You have choosen to write the Pol2 method but it is not on!");
1182 return kFALSE;
1183 }
1184 if ((fFitPHNDB == 3) && (!fFitLagrPolOn)){
1185 AliInfo("You have choosen to write the LagrPol2 method but it is not on!");
1186 return kFALSE;
1187 }
1188
1189 // Number of Xbins (detectors or groups of pads)
1190 if (!InitFit(0,1)) {
1191 return kFALSE;
1192 }
1193 fStatisticMean = 0.0;
1194 fNumberFit = 0;
1195 fNumberFitSuccess = 0;
1196 fNumberEnt = 0;
1197
1198 // Initialise
1199 fCalibraVector = new AliTRDCalibraVector();
1200
1201 // Init fCountDet and fCount
1202 InitfCountDetAndfCount(1);
1203 TGraphErrors *projphtree = 0x0;
1204 tree->SetBranchAddress("histo",&projphtree);
1205 TObjArray *vectorplace = fCalibraVector->ConvertTreeVector(tree);
1206
1207 // Beginning of the loop
1208 for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) {
1209
1210 // Search if the group is in the VectorCH
1211 Int_t place = fCalibraVector->SearchInTreeVector(vectorplace,idect);
1212
1213 TH1F *projph = 0x0;
1214 // Is in
1215 if (place != -1) {
1216 //Entries
1217 fNumberEnt++;
1218 // Variable
1219 tree->GetEntry(place);
1220 projph = CorrectTheError(projphtree);
1221 }
1222
1223 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1224 UpdatefCountDetAndfCount(idect,1);
1225
1226 // Reconstruction of the row and pad group: rowmin, row max ...
1227 ReconstructFitRowMinRowMax(idect,1);
1228
1229 // Rebin and statistic stuff
1230 // This detector has not enough statistics or was off
1231 if((place == -1) ||
1232 ((place != -1) &&
1233 (fEntriesCurrent < fMinEntries))) {
1234
1235 // Fill with the default values
1236 NotEnoughStatistic(idect,1);
1237
1238 // Memory!!!
1239 if (fDebug != 2) {
1240 delete projph;
1241 }
1242
1243 continue;
1244
1245 }
1246
1247 // Statistics of the histos fitted
1248 AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent));
1249 fNumberFit++;
1250 fStatisticMean += fEntriesCurrent;
1251
1252 // Calcul of "real" coef
1253 CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
1254 CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
1255
1256 // Method Mean and fit
1257 // idect is egal for fDebug = 0 and 2, only to fill the hist
1258 if(fFitPol2On){
1259 FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1]));
1260 }
1261 if(fFitLagrPolOn){
1262 FitLagrangePoly((TH1 *) projph,(Int_t) (idect - fDect1[1]));
1263 }
1264 if (fFitPHOn) {
1265 FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1]));
1266 }
1267
1268 // Visualise the detector for fDebug 3 or 4
1269 // Here is the reconstruction of the pad and row group is used!
1270 if (fDebug >= 3) {
1271 FillCoefVdriftDB();
1272 FillCoefT0DB();
1273 }
1274
1275 // Fill the tree if end of a detector or only the pointer to the branch!!!
1276 FillInfosFit(idect,1);
1277
1278 // Memory!!!
1279 if (fDebug != 2) {
1280 delete projph;
1281 }
1282
1283 } // Boucle object
1284
1285 // Plot
1286 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
1287 if ((fDebug == 1) ||
1288 (fDebug == 4)){
1289 PlotWritePH();
1290 PlotWriteT0();
1291 }
1292 if ((fDebug == 4) ||
1293 (fDebug == 3)){
1294 PlotPHDB();
1295 PlotT0DB();
1296 }
1297
1298 // Mean Statistics
1299 if (fNumberFit > 0) {
1300 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
1301 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
1302 AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits"
1303 ,(Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess));
1304 fStatisticMean = fStatisticMean / fNumberFit;
1305 }
1306 else {
1307 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1308 }
1309
1310 // Write the things!
1311 if (fWriteCoef[1]) {
1312 WriteFitInfos(1);
1313 }
1314
1315 return kTRUE;
1316
1317}
1318
1319//____________Functions fit Online PRF2d_______________________________________
1320Bool_t AliTRDCalibraFit::FitPRFOnline(TProfile2D *prf)
1321{
1322 //
1323 // Take the 1D profiles (pad response function), projections of the 2D PRF
1324 // on the Xaxis, for each calibration group
1325 // Fit with a gaussian to reconstruct the sigma of the pad response function
1326 // write the results in a tree
1327 //
1328
1329 // A small check
1330 if ((fFitPRFNDB == 2) && (!fRMSPRFOn)){
1331 AliInfo("You have choosen to write the RMS method but it is not on!");
1332 return kFALSE;
1333 }
1334 if ((fFitPRFNDB == 0) && (!fFitPRFOn)){
1335 AliInfo("You have choosen to write the fit method but it is not on!");
1336 return kFALSE;
1337 }
1338
1339 // Number of Xbins (detectors or groups of pads)
1340 TAxis *xprf = prf->GetXaxis();
1341 TAxis *yprf = prf->GetYaxis();
1342 Int_t nybins = yprf->GetNbins();
1343 Int_t nbins = xprf->GetNbins();
1344 if (!InitFit(nbins,2)) {
1345 return kFALSE;
1346 }
1347 fStatisticMean = 0.0;
1348 fNumberFit = 0;
1349 fNumberFitSuccess = 0;
1350 fNumberEnt = 0;
1351
1352 // Init fCountDet and fCount
1353 InitfCountDetAndfCount(2);
1354
1355 // Beginning of the loop
1356 for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) {
1357
1358 TH1D *projprf = (TH1D *) prf->ProjectionY("projprf",idect+1,idect+1,(Option_t *) "e");
1359 projprf->SetDirectory(0);
1360
1361 // Number of entries for this calibration group
1362 Double_t nentries = 0;
1363 for (Int_t k = 0; k < nybins; k++) {
1364 nentries += prf->GetBinEntries(prf->GetBin(idect+1,k+1));
1365 }
1366 if(nentries > 0) fNumberEnt++;
1367
1368 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1369 UpdatefCountDetAndfCount(idect,2);
1370
1371 // Reconstruction of the row and pad group: rowmin, row max ...
1372 ReconstructFitRowMinRowMax(idect,2);
1373
1374 // Rebin and statistic stuff
1375 // This detector has not enough statistics or was off
1376 if (nentries < fMinEntries) {
1377
1378 // Fill with the default values
1379 NotEnoughStatistic(idect,2);
1380
1381 // Memory!
1382 if (fDebug != 2) {
1383 delete projprf;
1384 }
1385
1386 continue;
1387
1388 }
1389
1390 // Statistics of the histos fitted
1391 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
1392 fNumberFit++;
1393 fStatisticMean += nentries;
1394
1395 // Calcul of "real" coef
1396 if ((fDebug == 1) ||
1397 (fDebug == 4)) {
1398 CalculPRFCoefMean(fCountDet[2],(Int_t) (idect - fDect1[2]));
1399 }
1400
1401 // Method Mean and fit
1402 // idect is egal for fDebug = 0 and 2, only to fill the hist
1403 if(fFitPRFOn){
1404 FitPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2]));
1405 }
1406 if(fRMSPRFOn){
1407 RmsPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2]));
1408 }
1409
1410
1411 // Visualise the detector for fDebug 3 or 4
1412 // Here is the reconstruction of the pad and row group is used!
1413 if (fDebug >= 3) {
1414 FillCoefPRFDB();
1415 }
1416
1417 // Fill the tree if end of a detector or only the pointer to the branch!!!
1418 FillInfosFit(idect,2);
1419
1420 // Memory!!!
1421 if (fDebug != 2) {
1422 delete projprf;
1423 }
1424
1425 } // Boucle object
1426
1427 // Plot
1428 // No plot, 1 and 4 error plot, 3 and 4 DB plot
1429 if ((fDebug == 1) ||
1430 (fDebug == 4)) {
1431 PlotWritePRF();
1432 }
1433 if ((fDebug == 4) ||
1434 (fDebug == 3)){
1435 PlotPRFDB();
1436 }
1437
1438 // Mean Statistic
1439 if (fNumberFit > 0) {
1440 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
1441 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
1442 AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits"
1443 ,(Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess));
1444 fStatisticMean = fStatisticMean / fNumberFit;
1445 }
1446 else {
1447 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1448 }
1449
1450 // Write the things!
1451 if (fWriteCoef[2]) {
1452 WriteFitInfos(2);
1453 }
1454
1455 return kTRUE;
1456
1457}
1458
1459//____________Functions fit Online PRF2d_______________________________________
1460Bool_t AliTRDCalibraFit::FitPRFOnline()
1461{
1462 //
1463 // Reconstruct the 1D histo (pad response function) from the vectorPRD for
1464 // each calibration group
1465 // Fit with a gaussian to reconstruct the sigma of the pad response function
1466 // write the results in a tree
1467 //
1468
1469 // A small check
1470 if ((fFitPRFNDB == 2) && (!fRMSPRFOn)){
1471 AliInfo("You have choosen to write the RMS method but it is not on!");
1472 return kFALSE;
1473 }
1474 if ((fFitPRFNDB == 0) && (!fFitPRFOn)){
1475 AliInfo("You have choosen to write the fit method but it is not on!");
1476 return kFALSE;
1477 }
1478
1479 // Warning
1480 if (!fCalibraVector) {
1481 AliError("You have first to set the calibravector before using this function!");
1482 return kFALSE;
1483 }
1484
1485 // Number of Xbins (detectors or groups of pads)
1486 if (!InitFit(0,2)) {
1487 return kFALSE;
1488 }
1489 fStatisticMean = 0.0;
1490 fNumberFit = 0;
1491 fNumberFitSuccess = 0;
1492 fNumberEnt = 0;
1493
1494 // Init fCountDet and fCount
1495 InitfCountDetAndfCount(2);
1496
1497 // Beginning of the loop
1498 for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) {
1499
1500 // Search if the group is in the VectorCH
1501 Int_t place = fCalibraVector->SearchInVector(idect,2);
1502
1503 // Is in
1504 TH1F *projprf = 0x0;
1505 TString name("PRF");
1506 name += idect;
1507 if (place != -1) {
1508 //Entries
1509 fNumberEnt++;
1510 projprf = CorrectTheError((TGraphErrors *) (fCalibraVector->ConvertVectorPHisto(place,(const char *)name)));
1511 projprf->SetDirectory(0);
1512 }
1513
1514 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1515 UpdatefCountDetAndfCount(idect,2);
1516
1517 // Reconstruction of the row and pad group: rowmin, row max ...
1518 ReconstructFitRowMinRowMax(idect,2);
1519
1520 // Rebin and statistic stuff
1521 // This detector has not enough statistics or was off
1522 if ((place == -1) ||
1523 ((place != -1) &&
1524 (fEntriesCurrent < fMinEntries))) {
1525
1526 // Fill with the default values
1527 NotEnoughStatistic(idect,2);
1528
1529 // Memory
1530 if (fDebug != 2) {
1531 delete projprf;
1532 }
1533
1534 continue;
1535
1536 }
1537
1538 // Statistic of the histos fitted
1539 AliInfo(Form("For the group number %d there are %d stats", idect,fEntriesCurrent));
1540 fNumberFit++;
1541 fStatisticMean += fEntriesCurrent;
1542
1543 // Calcul of "real" coef
1544 if ((fDebug == 1) ||
1545 (fDebug == 4)) {
1546 CalculPRFCoefMean(fCountDet[2],(Int_t) (idect-fDect1[2]));
1547 }
1548
1549 // Method Mean and fit
1550 // idect is egal for fDebug = 0 and 2, only to fill the hist
1551 if(fFitPRFOn){
1552 FitPRF((TH1 *) projprf,(Int_t) (idect-fDect1[2]));
1553 }
1554 if(fRMSPRFOn){
1555 RmsPRF((TH1 *) projprf,(Int_t) (idect-fDect1[2]));
1556 }
1557
1558 // Visualise the detector for fDebug 3 or 4
1559 // Here is the reconstruction of the pad and row group is used!
1560 if (fDebug >= 3) {
1561 FillCoefPRFDB();
1562 }
1563 // Fill the tree if end of a detector or only the pointer to the branch!!!
1564 FillInfosFit(idect,2);
1565
1566 // Memory!!!
1567 if (fDebug != 2) {
1568 delete projprf;
1569 }
1570
1571 } // Boucle object
1572
1573 // Plot
1574 // No plot, 1 and 4 error plot, 3 and 4 DB plot
1575 if ((fDebug == 1) ||
1576 (fDebug == 4)) {
1577 PlotWritePRF();
1578 }
1579 if ((fDebug == 4) ||
1580 (fDebug == 3)) {
1581 PlotPRFDB();
1582 }
1583
1584 // Mean Statistics
1585 if (fNumberFit > 0) {
1586 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
1587 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
1588 AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits"
1589 ,(Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess));
1590 }
1591 else {
1592 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1593 }
1594
1595 // Write the things!
1596 if (fWriteCoef[2]) {
1597 WriteFitInfos(2);
1598 }
1599
1600 return kTRUE;
1601
1602}
1603
1604//____________Functions fit Online PRF2d_______________________________________
1605Bool_t AliTRDCalibraFit::FitPRFOnline(TTree *tree)
1606{
1607 //
1608 // Look if the calibration group can be found in the tree, if yes take
1609 // the histo, fit it, and write the results in a tree
1610 //
1611
1612 // A small check
1613 if ((fFitPRFNDB == 2) && (!fRMSPRFOn)){
1614 AliInfo("You have choosen to write the RMS method but it is not on!");
1615 return kFALSE;
1616 }
1617 if ((fFitPRFNDB == 0) && (!fFitPRFOn)){
1618 AliInfo("You have choosen to write the fit method but it is not on!");
1619 return kFALSE;
1620 }
1621
1622 // Number of Xbins (detectors or groups of pads)
1623 if (!InitFit(0,2)) {
1624 return kFALSE;
1625 }
1626 fStatisticMean = 0.0;
1627 fNumberFit = 0;
1628 fNumberFitSuccess = 0;
1629 fNumberEnt = 0;
1630
1631 // Initialise
1632 fCalibraVector = new AliTRDCalibraVector();
1633
1634 // Init fCountDet and fCount
1635 InitfCountDetAndfCount(2);
1636 TGraphErrors *projprftree = 0x0;
1637 tree->SetBranchAddress("histo",&projprftree);
1638 TObjArray *vectorplace = fCalibraVector->ConvertTreeVector(tree);
1639
1640 // Beginning of the loop
1641 for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) {
1642
1643 // Search if the group is in the VectorCH
1644 Int_t place = fCalibraVector->SearchInTreeVector(vectorplace,idect);
1645
1646 // Is in
1647 TH1F *projprf = 0x0;
1648 if (place != -1) {
1649 //Entries
1650 fNumberEnt++;
1651 // Variable
1652 tree->GetEntry(place);
1653 projprf = CorrectTheError(projprftree);
1654 }
1655
1656 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1657 UpdatefCountDetAndfCount(idect,2);
1658
1659 // Reconstruction of the row and pad group: rowmin, row max ...
1660 ReconstructFitRowMinRowMax(idect,2);
1661
1662 // Rebin and statistic stuff
1663 // This detector has not enough statistics or was off
1664 if ((place == -1) ||
1665 ((place != -1) &&
1666 (fEntriesCurrent < fMinEntries))) {
1667
1668 // Fill with the default values
1669 NotEnoughStatistic(idect,2);
1670
1671 // Memory!!!
1672 if (fDebug != 2) {
1673 delete projprf;
1674 }
1675
1676 continue;
1677
1678 }
1679
1680 // Statistics of the histos fitted
1681 AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent));
1682 fNumberFit++;
1683 fStatisticMean += fEntriesCurrent;
1684
1685 // Calcul of "real" coef
1686 if ((fDebug == 1) ||
1687 (fDebug == 4)){
1688 CalculPRFCoefMean(fCountDet[2],(Int_t) (idect - fDect1[2]));
1689 }
1690
1691 // Method Mean and fit
1692 // idect is egal for fDebug = 0 and 2, only to fill the hist
1693 if(fFitPRFOn){
1694 FitPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2]));
1695 }
1696 if(fRMSPRFOn){
1697 RmsPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2]));
1698 }
1699
1700 // Visualise the detector for fDebug 3 or 4
1701 // Here is the reconstruction of the pad and row group is used!
1702 if (fDebug >= 3) {
1703 FillCoefPRFDB();
1704 }
1705 // Fill the tree if end of a detector or only the pointer to the branch!!!
1706 FillInfosFit(idect,2);
1707
1708 // Memory!!!
1709 if (fDebug != 2) {
1710 delete projprf;
1711 }
1712
1713 } // Boucle object
1714
1715 // Plot
1716 // No plot, 1 and 4 error plot, 3 and 4 DB plot
1717 if ((fDebug == 1) ||
1718 (fDebug == 4)){
1719 PlotWritePRF();
1720 }
1721 if ((fDebug == 4) ||
1722 (fDebug == 3)){
1723 PlotPRFDB();
1724 }
1725
1726 // Mean Statistics
1727 if (fNumberFit > 0) {
1728 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
1729 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
1730 AliInfo(Form("There is a mean statistic of: %d over these fitted histograms and %d successfulled fits"
1731 ,(Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess));
1732 fStatisticMean = fStatisticMean / fNumberFit;
1733 }
1734 else {
1735 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1736 }
1737
1738 // Write the things!
1739 if (fWriteCoef[2]) {
1740 WriteFitInfos(2);
1741 }
1742
1743 return kTRUE;
1744
1745}
1746
1747//____________Functions for seeing if the pad is really okey___________________
1748
1749//_____________________________________________________________________________
1750Bool_t AliTRDCalibraFit::SetModeCalibrationFromTObject(TObject *object, Int_t i)
1751{
1752 //
1753 // Set fNz[i] and fNrphi[i] of the AliTRDCalibraFit::Instance()
1754 // corresponding to the given TObject
1755 //
1756
1757 const char *nametitle = object->GetTitle();
1758
1759 // Some patterns
1760 const Char_t *patternz0 = "Nz0";
1761 const Char_t *patternz1 = "Nz1";
1762 const Char_t *patternz2 = "Nz2";
1763 const Char_t *patternz3 = "Nz3";
1764 const Char_t *patternz4 = "Nz4";
1765 const Char_t *patternrphi0 = "Nrphi0";
1766 const Char_t *patternrphi1 = "Nrphi1";
1767 const Char_t *patternrphi2 = "Nrphi2";
1768 const Char_t *patternrphi3 = "Nrphi3";
1769 const Char_t *patternrphi4 = "Nrphi4";
1770 const Char_t *patternrphi5 = "Nrphi5";
1771 const Char_t *patternrphi6 = "Nrphi6";
1772
1773 UShort_t testz = 0;
1774 UShort_t testrphi = 0;
1775
1776 // Nz mode
1777 if (strstr(nametitle,patternz0)) {
1778 testz++;
1779 fCalibraMode->SetNz(i, 0);
1780 }
1781 if (strstr(nametitle,patternz1)) {
1782 testz++;
1783 fCalibraMode->SetNz(i ,1);
1784 }
1785 if (strstr(nametitle,patternz2)) {
1786 testz++;
1787 fCalibraMode->SetNz(i ,2);
1788 }
1789 if (strstr(nametitle,patternz3)) {
1790 testz++;
1791 fCalibraMode->SetNz(i ,3);
1792 }
1793 if (strstr(nametitle,patternz4)) {
1794 testz++;
1795 fCalibraMode->SetNz(i ,4);
1796 }
1797
1798 // Nrphi mode
1799 if (strstr(nametitle,patternrphi0)) {
1800 testrphi++;
1801 fCalibraMode->SetNrphi(i ,0);
1802 }
1803 if (strstr(nametitle,patternrphi1)) {
1804 testrphi++;
1805 fCalibraMode->SetNrphi(i, 1);
1806 }
1807 if (strstr(nametitle,patternrphi2)) {
1808 testrphi++;
1809 fCalibraMode->SetNrphi(i, 2);
1810 }
1811 if (strstr(nametitle,patternrphi3)) {
1812 testrphi++;
1813 fCalibraMode->SetNrphi(i, 3);
1814 }
1815 if (strstr(nametitle,patternrphi4)) {
1816 testrphi++;
1817 fCalibraMode->SetNrphi(i, 4);
1818 }
1819 if (strstr(nametitle,patternrphi5)) {
1820 testrphi++;
1821 fCalibraMode->SetNrphi(i, 5);
1822 }
1823 if (strstr(nametitle,patternrphi6)) {
1824 testrphi++;
1825 fCalibraMode->SetNrphi(i, 6);
1826 }
1827
1828 // Look if all is okey
1829 if ((testz == 1) &&
1830 (testrphi == 1)) {
1831 return kTRUE;
1832 }
1833 else {
1834 fCalibraMode->SetNrphi(i ,0);
1835 fCalibraMode->SetNz(i ,0);
1836 return kFALSE;
1837 }
1838
1839}
1840
1841//_____________________________________________________________________________
1842AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectTree(TTree *tree, Int_t i)
1843{
1844 //
1845 // It creates the AliTRDCalDet object from the tree of the coefficient
1846 // for the calibration i (i != 2)
1847 // It takes the mean value of the coefficients per detector
1848 // This object has to be written in the database
1849 //
1850
1851 // Create the DetObject
1852 AliTRDCalDet *object = 0x0;
1853 if (i == 0) {
1854 object = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)");
1855 }
1856 if (i == 1) {
1857 object = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)");
1858 }
1859 else {
1860 object = new AliTRDCalDet("ChamberT0","T0 (detector value)");
1861 }
1862
1863 // Read the Tree
1864 Int_t detector = -1;
1865 Float_t values[2304];
1866 tree->SetBranchAddress("detector",&detector);
1867 if (i == 0) {
1868 tree->SetBranchAddress("gainPad",values);
1869 }
1870 if (i == 1) {
1871 tree->SetBranchAddress("vdrift" ,values);
1872 }
1873 if (i == 3) {
1874 tree->SetBranchAddress("t0" ,values);
1875 }
1876
1877 // For calculating the mean
1878 Float_t mean = 0.0;
1879 Int_t nto = 0;
1880 Int_t numberofentries = tree->GetEntries();
1881
1882 if (numberofentries != 540) {
1883 AliInfo("The tree is not complete");
1884 }
1885
1886 for (Int_t det = 0; det < numberofentries; ++det) {
1887 tree->GetEntry(det);
1888 if (GetChamber(detector) == 2) {
1889 nto = 1728;
1890 }
1891 else {
1892 nto = 2304;
1893 }
1894 mean = 0.0;
1895 if(i != 3){
1896 for (Int_t k = 0; k < nto; k++) {
1897 mean += TMath::Abs(values[k]) / nto;
1898 }
1899 }
1900 else {
1901 for (Int_t k = 0; k < nto; k++) {
1902 if(k == 0) mean = values[k];
1903 if(mean > values[k]) mean = values[k];
1904 }
1905 }
1906 object->SetValue(detector,mean);
1907 }
1908
1909 return object;
1910
1911}
1912
1913//_____________________________________________________________________________
1914TObject *AliTRDCalibraFit::CreatePadObjectTree(TTree *tree, Int_t i
1915 , AliTRDCalDet *detobject)
1916{
1917 //
1918 // It Creates the AliTRDCalPad object from the tree of the
1919 // coefficient for the calibration i (i != 2)
1920 // You need first to create the object for the detectors,
1921 // where the mean value is put.
1922 // This object has to be written in the database
1923 //
1924
1925 // Create the DetObject
1926 AliTRDCalPad *object = 0x0;
1927 if (i == 0) {
1928 object = new AliTRDCalPad("GainFactor","GainFactor (local variations)");
1929 }
1930 if (i == 1) {
1931 object = new AliTRDCalPad("LocalVdrift","TRD drift velocities (local variations)");
1932 }
1933 else {
1934 object = new AliTRDCalPad("LocalT0","T0 (local variations)");
1935 }
1936
1937 // Read the Tree
1938 Int_t detector = -1;
1939 Float_t values[2304];
1940 tree->SetBranchAddress("detector",&detector);
1941 if (i == 0) {
1942 tree->SetBranchAddress("gainPad",values);
1943 }
1944 if (i == 1) {
1945 tree->SetBranchAddress("vdrift" ,values);
1946 }
1947 if (i == 3) {
1948 tree->SetBranchAddress("t0" ,values);
1949 }
1950
1951 // Variables
1952 Float_t mean = 0.0;
1953 Int_t numberofentries = tree->GetEntries();
1954
1955 if (numberofentries != 540) {
1956 AliInfo("The tree is not complete");
1957 }
1958
1959 for (Int_t det = 0; det < numberofentries; ++det) {
1960 tree->GetEntry(det);
1961 AliTRDCalROC *calROC = object->GetCalROC(detector);
1962 mean = detobject->GetValue(detector);
1963 if ((mean == 0) && (i != 3)) {
1964 continue;
1965 }
1966 Int_t rowMax = calROC->GetNrows();
1967 Int_t colMax = calROC->GetNcols();
1968 for (Int_t row = 0; row < rowMax; ++row) {
1969 for (Int_t col = 0; col < colMax; ++col) {
1970 if(i != 3) calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])/mean);
1971 else calROC->SetValue(col,row,values[(Int_t) (col*rowMax+row)]-mean);
1972
1973 } // Col
1974 } // Row
1975 }
1976
1977 return object;
1978
1979}
1980
1981//_____________________________________________________________________________
1982TObject *AliTRDCalibraFit::CreatePadObjectTree(TTree *tree)
1983{
1984 //
1985 // It Creates the AliTRDCalPad object from the tree of the
1986 // coefficient for the calibration PRF (i = 2)
1987 // This object has to be written in the database
1988 //
1989
1990 // Create the DetObject
1991 AliTRDCalPad *object = new AliTRDCalPad("PRFWidth","PRFWidth");
1992
1993 // Read the Tree
1994 Int_t detector = -1;
1995 Float_t values[2304];
1996 tree->SetBranchAddress("detector",&detector);
1997 tree->SetBranchAddress("width" ,values);
1998
1999 // Variables
2000 Int_t numberofentries = tree->GetEntries();
2001
2002 if (numberofentries != 540) {
2003 AliInfo("The tree is not complete");
2004 }
2005
2006 for (Int_t det = 0; det < numberofentries; ++det) {
2007 tree->GetEntry(det);
2008 AliTRDCalROC *calROC = object->GetCalROC(detector);
2009 Int_t rowMax = calROC->GetNrows();
2010 Int_t colMax = calROC->GetNcols();
2011 for (Int_t row = 0; row < rowMax; ++row) {
2012 for (Int_t col = 0; col < colMax; ++col) {
2013 calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)]));
2014 } // Col
2015 } // Row
2016 }
2017
2018 return object;
2019
2020}
2021
2022//_____________________________________________________________________________
2023void AliTRDCalibraFit::SetPeriodeFitPH(Int_t periodeFitPH)
2024{
2025 //
2026 // Set FitPH if 1 then each detector will be fitted
2027 //
2028
2029 if (periodeFitPH > 0) {
2030 fFitPHPeriode = periodeFitPH;
2031 }
2032 else {
2033 AliInfo("periodeFitPH must be higher than 0!");
2034 }
2035
2036}
2037
2038//_____________________________________________________________________________
2039void AliTRDCalibraFit::SetFitPRFNDB(Int_t fitPRFNDB)
2040{
2041 //
2042 // TO choose the method that you write into the database
2043 //
2044
2045 if ((fitPRFNDB >= 3) || (fitPRFNDB == 1)) {
2046 AliInfo("fitPRFNDB is not a correct number!");
2047 }
2048 else {
2049 fFitPRFNDB = fitPRFNDB;
2050 }
2051
2052}
2053
2054//_____________________________________________________________________________
2055void AliTRDCalibraFit::SetFitChargeNDB(Int_t fitChargeNDB)
2056{
2057 //
2058 // To choose the method that you write into the database
2059 //
2060 if ((fitChargeNDB >= 5) || (fitChargeNDB == 3)) {
2061 AliInfo("fitChargeNDB is not a correct number!");
2062 }
2063 else {
2064 fFitChargeNDB = fitChargeNDB;
2065 }
2066
2067}
2068
2069//_____________________________________________________________________________
2070void AliTRDCalibraFit::SetFitPHNDB(Int_t fitPHNDB)
2071{
2072 //
2073 // To choose the method that you write into the database
2074 //
2075
2076 if ((fitPHNDB >= 4) || (fitPHNDB == 2)) {
2077 AliInfo("fitPHNDB is not a correct number!");
2078 }
2079 else {
2080 fFitPHNDB = fitPHNDB;
2081 }
2082
2083}
2084
2085//_____________________________________________________________________________
2086void AliTRDCalibraFit::SetBeginFitCharge(Float_t beginFitCharge)
2087{
2088 //
2089 // The fit of the deposited charge distribution begins at
2090 // histo->Mean()/beginFitCharge
2091 // You can here set beginFitCharge
2092 //
2093
2094 if (beginFitCharge > 0) {
2095 fBeginFitCharge = beginFitCharge;
2096 }
2097 else {
2098 AliInfo("beginFitCharge must be strict positif!");
2099 }
2100
2101}
2102
2103//_____________________________________________________________________________
2104void AliTRDCalibraFit::SetT0Shift(Float_t t0Shift)
2105{
2106 //
2107 // The t0 calculated with the maximum positif slope is shift from t0Shift
2108 // You can here set t0Shift
2109 //
2110
2111 if (t0Shift > 0) {
2112 fT0Shift = t0Shift;
2113 }
2114 else {
2115 AliInfo("t0Shift must be strict positif!");
2116 }
2117
2118}
2119
2120//_____________________________________________________________________________
2121void AliTRDCalibraFit::SetRangeFitPRF(Float_t rangeFitPRF)
2122{
2123 //
2124 // The fit of the PRF is from -rangeFitPRF to rangeFitPRF
2125 // You can here set rangeFitPRF
2126 //
2127
2128 if ((rangeFitPRF > 0) &&
2129 (rangeFitPRF <= 1.5)) {
2130 fRangeFitPRF = rangeFitPRF;
2131 }
2132 else {
2133 AliInfo("rangeFitPRF must be between 0 and 1.0");
2134 }
2135
2136}
2137
2138//_____________________________________________________________________________
2139void AliTRDCalibraFit::SetRebin(Short_t rebin)
2140{
2141 //
2142 // Rebin with rebin time less bins the Ch histo
2143 // You can set here rebin that should divide the number of bins of CH histo
2144 //
2145
2146 if (rebin > 0) {
2147 fRebin = rebin;
2148 AliInfo("You have to be sure that fRebin divides fNumberBinCharge used!");
2149 }
2150 else {
2151 AliInfo("You have to choose a positiv value!");
2152 }
2153
2154}
2155
2156//____________Pad Calibration Public___________________________________________
2157
2158//____________Protected Functions______________________________________________
2159//____________Create the 2D histo to be filled online__________________________
2160//
2161//____________Fit______________________________________________________________
2162//____________Create histos if fDebug == 1 or fDebug >= 3______________________
2163
2164//_____________________________________________________________________________
2165void AliTRDCalibraFit::InitArrayFitPH()
2166{
2167 //
2168 // Initialise fCoefVdrift[3] and fCoefVdriftE[2] to the right dimension
2169 //
2170
2171 Int_t nbins = fDect2[1]-fDect1[1];
2172
2173 fCoefVdrift[2] = new Double_t[nbins];
2174
2175 // Init the pointer to nbins
2176 if (fFitPHOn) {
2177 fCoefVdrift[0] = new Double_t[nbins];
2178 fCoefVdriftE[0] = new Double_t[nbins];
2179 for(Int_t k = 0; k < nbins; k++){
2180 fCoefVdriftE[0][k] = 0.0;
2181 }
2182 }
2183
2184
2185 if (fFitPol2On){
2186 fCoefVdrift[1] = new Double_t[nbins];
2187 fCoefVdriftE[1] = new Double_t[nbins];
2188 for(Int_t k = 0; k < nbins; k++){
2189 fCoefVdriftE[1][k] = 0.0;
2190 }
2191 }
2192 if (fFitLagrPolOn){
2193 fCoefVdrift[3] = new Double_t[nbins];
2194 fCoefVdriftE[2] = new Double_t[nbins];
2195 for(Int_t k = 0; k < nbins; k++){
2196 fCoefVdriftE[2][k] = 0.0;
2197 }
2198 }
2199
2200}
2201
2202//_____________________________________________________________________________
2203void AliTRDCalibraFit::InitArrayFitT0()
2204{
2205 //
2206 // Initialise fCoefT0[3] and fCoefT0E[2] to the right dimension
2207 //
2208
2209 Int_t nbins = fDect2[1]-fDect1[1];
2210
2211 fCoefT0[2] = new Double_t[nbins];
2212
2213 // Init the pointer to nbins
2214 if(fFitPHOn){
2215 fCoefT0[0] = new Double_t[nbins];
2216 fCoefT0E[0] = new Double_t[nbins];
2217 for(Int_t k = 0; k < nbins; k++){
2218 fCoefT0E[0][k] = 0.0;
2219 }
2220 }
2221 if(fFitPol2On){
2222 fCoefT0[1] = new Double_t[nbins];
2223 fCoefT0E[1] = new Double_t[nbins];
2224 for(Int_t k = 0; k < nbins; k++){
2225 fCoefT0E[1][k] = 0.0;
2226 }
2227 }
2228 if(fFitLagrPolOn){
2229 fCoefT0[3] = new Double_t[nbins];
2230 fCoefT0E[2] = new Double_t[nbins];
2231 for(Int_t k = 0; k < nbins; k++){
2232 fCoefT0E[2][k] = 0.0;
2233 }
2234 }
2235
2236}
2237
2238//_____________________________________________________________________________
2239void AliTRDCalibraFit::InitArrayFitCH()
2240{
2241 //
2242 // Initialise fCoefCharge[4] and fCoefChargeE[3] to the right dimension
2243 //
2244
2245 Int_t nbins = fDect2[0]-fDect1[0];
2246
2247 //Init the pointer to nbins
2248 if(fMeanChargeOn){
2249 fCoefCharge[1] = new Double_t[nbins];
2250 fCoefChargeE[1] = new Double_t[nbins];
2251 for(Int_t k = 0; k < nbins; k++){
2252 fCoefChargeE[1][k] = 0.0;
2253 }
2254 }
2255 if(fFitMeanWOn){
2256 fCoefCharge[4] = new Double_t[nbins];
2257 fCoefChargeE[3] = new Double_t[nbins];
2258 for(Int_t k = 0; k < nbins; k++){
2259 fCoefChargeE[3][k] = 0.0;
2260 }
2261 }
2262 if(fFitChargeOn){
2263 fCoefCharge[0] = new Double_t[nbins];
2264 fCoefChargeE[0] = new Double_t[nbins];
2265 for(Int_t k = 0; k < nbins; k++){
2266 fCoefChargeE[0][k] = 0.0;
2267 }
2268 }
2269
2270 if(fFitChargeBisOn){
2271 fCoefCharge[2] = new Double_t[nbins];
2272 fCoefChargeE[2] = new Double_t[nbins];
2273 for(Int_t k = 0; k < nbins; k++){
2274 fCoefChargeE[2][k] = 0.0;
2275 }
2276 }
2277
2278 fCoefCharge[3] = new Double_t[nbins];
2279
2280}
2281
2282//_____________________________________________________________________________
2283void AliTRDCalibraFit::InitArrayFitPRF()
2284{
2285 //
2286 // Initialise fCoefPRF[2] and fCoefPRFE to the right dimension
2287 //
2288
2289 Int_t nbins = fDect2[2]-fDect1[2];
2290 fCoefPRF[1] = new Double_t[nbins];
2291
2292 //Init the pointer to nbins
2293 if(fFitPRFOn){
2294 fCoefPRF[0] = new Double_t[nbins];
2295 fCoefPRFE[0] = new Double_t[nbins];
2296 for(Int_t k = 0; k < nbins; k++){
2297 fCoefPRFE[0][k] = 0.0;
2298 }
2299 }
2300 if(fRMSPRFOn){
2301 fCoefPRF[2] = new Double_t[nbins];
2302 fCoefPRFE[1] = new Double_t[nbins];
2303 for(Int_t k = 0; k < nbins; k++){
2304 fCoefPRFE[1][k] = 0.0;
2305 }
2306 }
2307}
2308
2309//_____________________________________________________________________________
2310void AliTRDCalibraFit::CreateFitHistoPRFDB(Int_t rowMax, Int_t colMax)
2311{
2312 //
2313 // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions)
2314 //
2315 if(fFitPRFOn){
2316 fCoefPRFDB[0] = new TH2F("coefPRF0","",rowMax,0,rowMax,colMax,0,colMax);
2317 fCoefPRFDB[0]->SetStats(0);
2318 fCoefPRFDB[0]->SetXTitle("row Number");
2319 fCoefPRFDB[0]->SetYTitle("col Number");
2320 fCoefPRFDB[0]->SetZTitle("PRF width [pad width units]");
2321 fCoefPRFDB[0]->SetFillColor(6);
2322 fCoefPRFDB[0]->SetLineColor(6);
2323 }
2324 if(fRMSPRFOn){
2325 fCoefPRFDB[1] = new TH2F("coefPRF1","",rowMax,0,rowMax,colMax,0,colMax);
2326 fCoefPRFDB[1]->SetStats(0);
2327 fCoefPRFDB[1]->SetXTitle("row Number");
2328 fCoefPRFDB[1]->SetYTitle("col Number");
2329 fCoefPRFDB[1]->SetZTitle("PRF width [pad width units]");
2330 fCoefPRFDB[1]->SetFillColor(1);
2331 fCoefPRFDB[1]->SetLineColor(1);
2332 }
2333}
2334
2335//_____________________________________________________________________________
2336void AliTRDCalibraFit::CreateFitHistoCHDB(Int_t rowMax, Int_t colMax)
2337{
2338 //
2339 // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions)
2340 //
2341
2342 if(fFitChargeOn){
2343 fCoefChargeDB[0] = new TH2F("coefchargedb0","",rowMax,0,rowMax,colMax,0,colMax);
2344 fCoefChargeDB[0]->SetStats(0);
2345 fCoefChargeDB[0]->SetXTitle("row Number");
2346 fCoefChargeDB[0]->SetYTitle("col Number");
2347 fCoefChargeDB[0]->SetZTitle("f_{g} Fit method");
2348 fCoefChargeDB[0]->SetFillColor(6);
2349 fCoefChargeDB[0]->SetLineColor(6);
2350 }
2351 if(fFitChargeBisOn){
2352 fCoefChargeDB[2] = new TH2F("coefchargedb2","",rowMax,0,rowMax,colMax,0,colMax);
2353 fCoefChargeDB[2]->SetStats(0);
2354 fCoefChargeDB[2]->SetXTitle("row Number");
2355 fCoefChargeDB[2]->SetYTitle("col Number");
2356 fCoefChargeDB[2]->SetZTitle("f_{g} Fitbis method");
2357 fCoefChargeDB[2]->SetFillColor(8);
2358 fCoefChargeDB[2]->SetLineColor(8);
2359 }
2360 if(fFitMeanWOn){
2361 fCoefChargeDB[3] = new TH2F("coefchargedb3","",rowMax,0,rowMax,colMax,0,colMax);
2362 fCoefChargeDB[3]->SetStats(0);
2363 fCoefChargeDB[3]->SetXTitle("row Number");
2364 fCoefChargeDB[3]->SetYTitle("col Number");
2365 fCoefChargeDB[3]->SetFillColor(1);
2366 fCoefChargeDB[3]->SetLineColor(1);
2367
2368 }
2369 if(fMeanChargeOn){
2370 fCoefChargeDB[1] = new TH2F("coefchargedb1","",rowMax,0,rowMax,colMax,0,colMax);
2371 fCoefChargeDB[1]->SetStats(0);
2372 fCoefChargeDB[1]->SetXTitle("row Number");
2373 fCoefChargeDB[1]->SetYTitle("col Number");
2374 fCoefChargeDB[1]->SetZTitle("f_{g} Mean method");
2375 fCoefChargeDB[1]->SetFillColor(2);
2376 fCoefChargeDB[1]->SetLineColor(2);
2377 }
2378
2379}
2380
2381//_____________________________________________________________________________
2382void AliTRDCalibraFit::CreateFitHistoPHDB(Int_t rowMax, Int_t colMax)
2383{
2384 //
2385 // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions)
2386 //
2387
2388 if(fFitPHOn){
2389 fCoefVdriftDB[0] = new TH2F("coefvdriftdb0","",rowMax,0,rowMax,colMax,0,colMax);
2390 fCoefVdriftDB[0]->SetStats(0);
2391 fCoefVdriftDB[0]->SetXTitle("row Number");
2392 fCoefVdriftDB[0]->SetYTitle("col Number");
2393 fCoefVdriftDB[0]->SetZTitle("v_{drift} Fit method");
2394 fCoefVdriftDB[0]->SetFillColor(6);
2395 fCoefVdriftDB[0]->SetLineColor(6);
2396 }
2397
2398 if(fFitPol2On){
2399 fCoefVdriftDB[1] = new TH2F("coefvdriftdb1","",rowMax,0,rowMax,colMax,0,colMax);
2400 fCoefVdriftDB[1]->SetStats(0);
2401 fCoefVdriftDB[1]->SetXTitle("row Number");
2402 fCoefVdriftDB[1]->SetYTitle("col Number");
2403 fCoefVdriftDB[1]->SetZTitle("v_{drift} slope method");
2404 fCoefVdriftDB[1]->SetFillColor(2);
2405 fCoefVdriftDB[1]->SetLineColor(2);
2406 }
2407 if(fFitLagrPolOn){
2408 fCoefVdriftDB[2] = new TH2F("coefvdriftdb1","",rowMax,0,rowMax,colMax,0,colMax);
2409 fCoefVdriftDB[2]->SetStats(0);
2410 fCoefVdriftDB[2]->SetXTitle("row Number");
2411 fCoefVdriftDB[2]->SetYTitle("col Number");
2412 fCoefVdriftDB[2]->SetZTitle("v_{drift} slope method");
2413 fCoefVdriftDB[2]->SetFillColor(1);
2414 fCoefVdriftDB[2]->SetLineColor(1);
2415 }
2416
2417}
2418
2419//_____________________________________________________________________________
2420void AliTRDCalibraFit::CreateFitHistoT0DB(Int_t rowMax, Int_t colMax)
2421{
2422 //
2423 // Create the histos for fDebug = 3 and fDebug = 4 (Fit functions)
2424 //
2425
2426 if(fFitPHOn){
2427 fCoefT0DB[0] = new TH2F("coefT0db0","",rowMax,0,rowMax,colMax,0,colMax);
2428 fCoefT0DB[0]->SetStats(0);
2429 fCoefT0DB[0]->SetXTitle("row Number");
2430 fCoefT0DB[0]->SetYTitle("col Number");
2431 fCoefT0DB[0]->SetZTitle("t0 Fit method");
2432 fCoefT0DB[0]->SetFillColor(6);
2433 fCoefT0DB[0]->SetLineColor(6);
2434 }
2435 if(fFitPol2On){
2436 fCoefT0DB[1] = new TH2F("coefT0db1","",rowMax,0,rowMax,colMax,0,colMax);
2437 fCoefT0DB[1]->SetStats(0);
2438 fCoefT0DB[1]->SetXTitle("row Number");
2439 fCoefT0DB[1]->SetYTitle("col Number");
2440 fCoefT0DB[1]->SetZTitle("t0 slope method");
2441 fCoefT0DB[1]->SetFillColor(2);
2442 fCoefT0DB[1]->SetLineColor(2);
2443 }
2444 if(fFitLagrPolOn){
2445 fCoefT0DB[2] = new TH2F("coefT0db1","",rowMax,0,rowMax,colMax,0,colMax);
2446 fCoefT0DB[2]->SetStats(0);
2447 fCoefT0DB[2]->SetXTitle("row Number");
2448 fCoefT0DB[2]->SetYTitle("col Number");
2449 fCoefT0DB[2]->SetZTitle("t0 slope method");
2450 fCoefT0DB[2]->SetFillColor(1);
2451 fCoefT0DB[2]->SetLineColor(1);
2452 }
2453
2454}
2455
2456//_____________________________________________________________________________
2457Bool_t AliTRDCalibraFit::FillVectorFitCH(Int_t countdet)
2458{
2459 //
2460 // For the Fit functions fill the vector FitCH special for the gain calibration
2461 //
2462
2463 AliTRDFitCHInfo *fitCHInfo = new AliTRDFitCHInfo();
2464
2465 Int_t ntotal = 1;
2466 if (GetChamber(countdet) == 2) {
2467 ntotal = 1728;
2468 }
2469 else {
2470 ntotal = 2304;
2471 }
2472
2473 //printf("For the detector %d , ntotal %d and fCoefCH[0] %f\n",countdet,ntotal,fCoefCH[0]);
2474 Float_t *coef = new Float_t[ntotal];
2475 for (Int_t i = 0; i < ntotal; i++) {
2476 coef[i] = fCoefCH[i];
2477 }
2478
2479 Int_t detector = countdet;
2480 // Set
2481 fitCHInfo->SetCoef(coef);
2482 fitCHInfo->SetDetector(detector);
2483 fVectorFitCH->Add((TObject *) fitCHInfo);
2484
2485 return kTRUE;
2486
2487}
2488
2489//____________Functions for initialising the AliTRDCalibraFit in the code_________
2490Bool_t AliTRDCalibraFit::InitFit(Int_t nbins, Int_t i)
2491{
2492 //
2493 // Init the calibration mode (Nz, Nrphi), the histograms for
2494 // debugging the fit methods if fDebug > 0,
2495 //
2496
2497 gStyle->SetPalette(1);
2498 gStyle->SetOptStat(1111);
2499 gStyle->SetPadBorderMode(0);
2500 gStyle->SetCanvasColor(10);
2501 gStyle->SetPadLeftMargin(0.13);
2502 gStyle->SetPadRightMargin(0.01);
2503
55a288e5 2504 // Mode groups of pads: the total number of bins!
2505 Int_t numberofbinsexpected = 0;
2506 fCalibraMode->ModePadCalibration(2,i);
2507 fCalibraMode->ModePadFragmentation(0,2,0,i);
2508 fCalibraMode->SetDetChamb2(i);
2509 if (fDebug == 1) {
2510 AliInfo(Form("For the chamber 2: %d",fCalibraMode->GetDetChamb2(i)));
2511 }
2512 numberofbinsexpected += 6 * 18 * fCalibraMode->GetDetChamb2(i);
2513 fCalibraMode->ModePadCalibration(0,i);
2514 fCalibraMode->ModePadFragmentation(0,0,0,i);
2515 fCalibraMode->SetDetChamb0(i);
2516 if (fDebug == 1) {
2517 AliInfo(Form("For the other chamber 0: %d",fCalibraMode->GetDetChamb0(i)));
2518 }
2519 numberofbinsexpected += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(i);
2520
2521 // Quick verification that we have the good pad calibration mode if 2D histos!
2522 if (nbins != 0) {
2523 if (numberofbinsexpected != nbins) {
2524 AliInfo("It doesn't correspond to the mode of pad group calibration!");
2525 return kFALSE;
2526 }
2527 }
2528
2529 // Security for fDebug 3 and 4
2530 if ((fDebug >= 3) &&
2531 ((fDet[0] > 5) ||
2532 (fDet[1] > 4) ||
2533 (fDet[2] > 17))) {
2534 AliInfo("This detector doesn't exit!");
2535 return kFALSE;
2536 }
2537
2538 // Determine fDet1 and fDet2
2539 fDect1[i] = -1;
2540 fDect2[i] = -1;
2541 if (fDebug == 2) {
2542 fDect1[i] = fFitVoir;
2543 fDect2[i] = fDect1[i] +1;
2544 }
2545 if (fDebug <= 1) {
2546 fDect1[i] = 0;
2547 fDect2[i] = numberofbinsexpected;
2548 }
2549 if (fDebug >= 3) {
2550 fCalibraMode->CalculXBins(AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]),i);
2551 fDect1[i] = fCalibraMode->GetXbins(i);
2552 fCalibraMode->CalculXBins((AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2])+1),i);
2553 fDect2[i] = fCalibraMode->GetXbins(i);
2554 }
2555
2556 // Create the histos for debugging
2557 // CH
2558 if (i == 0) {
2559
2560 gDirectory = gROOT;
2561 // Init the VectorFitCH
2562 fVectorFitCH = new TObjArray();
2563 fCoefCH = new Float_t[2304];
2564 for (Int_t k = 0; k < 2304; k++) {
2565 fCoefCH[k] = 0.0;
2566 }
2567 fScaleFitFactor = 0.0;
2568
2569 // Number of Xbins(detectors or groups of pads) if Vector2d
2570 // Quick verification that we are not out of range!
2571 if (fCalibraVector) {
2572 if ((nbins == 0) &&
2573 (fCalibraVector->GetVectorCH()->GetEntriesFast() > 0) &&
2574 ((Int_t) fCalibraVector->GetPlaCH()->GetEntriesFast() > 0)) {
2575 if ((Int_t) fCalibraVector->GetVectorCH()->GetEntriesFast() > numberofbinsexpected) {
2576 AliInfo("ch doesn't correspond to the mode of pad group calibration!");
2577 return kFALSE;
2578 }
2579 if ((Int_t) fCalibraVector->GetVectorCH()->GetEntriesFast() !=
2580 (Int_t) fCalibraVector->GetPlaCH()->GetEntriesFast()) {
2581 AliInfo("VectorCH doesn't correspond to PlaCH!");
2582 return kFALSE;
2583 }
2584 }
2585 }
2586
2587 //
2588 // Debugging: Create the histos
2589 //
2590
2591 // fDebug == 0 nothing
2592
2593 // fDebug == 1
2594 if (fDebug == 1) {
2595 InitArrayFitCH();
2596 }
2597
2598 // fDebug == 2 and fFitVoir no histo
2599 if (fDebug == 2) {
2600 if (fFitVoir < numberofbinsexpected) {
2601 AliInfo(Form("We will see the fit of the object %d",fFitVoir));
2602 }
2603 else {
2604 AliInfo("fFitVoir is out of range of the histo!");
2605 return kFALSE;
2606 }
2607 }
2608
2609 // fDebug == 3 or 4 and fDet
2610 if (fDebug >= 3) {
2611 if ((fCalibraMode->GetNz(0) == 0) && (fCalibraMode->GetNrphi(0) == 0)) {
2612 AliInfo("Do you really want to see one detector without pad groups?");
2613 return kFALSE;
2614 }
2615 else {
2616 AliInfo(Form("You will see the detector: iPlane %d, iChamb %d, iSect %d"
2617 ,fDet[0],fDet[1],fDet[2]));
2618 // A little geometry:
f162af62 2619 Int_t rowMax = fGeo->GetRowMax(fDet[0],fDet[1],fDet[2]);
2620 Int_t colMax = fGeo->GetColMax(fDet[0]);
55a288e5 2621 // Create the histos to visualise
2622 CreateFitHistoCHDB(rowMax,colMax);
2623 if (fDebug == 4) {
2624 InitArrayFitCH();
2625 }
2626 }
2627 }
2628
2629 }
2630
2631 // PH and T0
2632 if (i == 1) {
2633
2634 // Number of Xbins (detectors or groups of pads) if vector2d
2635 // Quick verification that we are not out of range!
2636 if (fCalibraVector) {
2637 if ((nbins == 0) &&
2638 (fCalibraVector->GetVectorPH()->GetEntriesFast() > 0) &&
2639 ((Int_t) fCalibraVector->GetPlaPH()->GetEntriesFast() > 0)) {
2640 if ((Int_t) fCalibraVector->GetVectorPH()->GetEntriesFast() > numberofbinsexpected) {
2641 AliInfo("ph doesn't correspond to the mode of pad group calibration!");
2642 return kFALSE;
2643 }
2644 if ((Int_t) fCalibraVector->GetVectorPH()->GetEntriesFast() !=
2645 (Int_t) fCalibraVector->GetPlaPH()->GetEntriesFast()) {
2646 AliInfo("VectorPH doesn't correspond to PlaPH!");
2647 return kFALSE;
2648 }
2649 }
2650 }
2651
2652 // Init tree
2653 InitTreePH();
2654 InitTreeT0();
2655
2656 //
2657 // Debugging: Create the histos
2658 //
2659
2660 // fDebug == 0 nothing
2661
2662 // fDebug == 1
2663 if (fDebug == 1) {
2664 // Create the histos replique de ph
2665 InitArrayFitPH();
2666 InitArrayFitT0();
2667 }
2668
2669 // fDebug == 2 and fFitVoir no histo
2670 if (fDebug == 2) {
2671 if (fFitVoir < numberofbinsexpected) {
2672 AliInfo(Form("We will see the fit of the object %d",fFitVoir));
2673 }
2674 else {
2675 AliInfo("fFitVoir is out of range of the histo!");
2676 return kFALSE;
2677 }
2678 }
2679
2680 // fDebug == 3 or 4 and fDet
2681 if (fDebug >= 3) {
2682 if ((fCalibraMode->GetNz(1) == 0) &&
2683 (fCalibraMode->GetNrphi(1) == 0)) {
2684 AliInfo("Do you really want to see one detector without pad groups?");
2685 return kFALSE;
2686 }
2687 else {
2688 AliInfo(Form("You will see the detector: iPlane %d, iChamb %d, iSect %d"
2689 ,fDet[0],fDet[1],fDet[2]));
2690 // A little geometry:
f162af62 2691 Int_t rowMax = fGeo->GetRowMax(fDet[0],fDet[1],fDet[2]);
2692 Int_t colMax = fGeo->GetColMax(fDet[0]);
55a288e5 2693 // Create the histos to visualise
2694 CreateFitHistoPHDB(rowMax,colMax);
2695 CreateFitHistoT0DB(rowMax,colMax);
2696 if (fDebug == 4) {
2697 InitArrayFitPH();
2698 InitArrayFitT0();
2699 }
2700 }
2701 }
2702
2703 }
2704
2705 // PRF
2706 if (i == 2) {
2707
2708 // Number of Xbins(detectors or groups of pads) if vector2d
2709 if (fCalibraVector){
2710 if ((nbins == 0) &&
2711 (fCalibraVector->GetVectorPRF()->GetEntriesFast() > 0) &&
2712 (fCalibraVector->GetPlaPRF()->GetEntriesFast() > 0)) {
2713 // Quick verification that we are not out of range!
2714 if ((Int_t) fCalibraVector->GetVectorPRF()->GetEntriesFast() > numberofbinsexpected) {
2715 AliInfo("ch doesn't correspond to the mode of pad group calibration!");
2716 return kFALSE;
2717 }
2718 if ((Int_t) fCalibraVector->GetVectorPRF()->GetEntriesFast() !=
2719 (Int_t) fCalibraVector->GetPlaPRF()->GetEntriesFast()) {
2720 AliInfo("VectorPRF doesn't correspond to PlaCH!");
2721 return kFALSE;
2722 }
2723 }
2724 }
2725
2726 // Init tree
2727 InitTreePRF();
2728
2729 //
2730 // Debugging: Create the histos
2731 //
2732
2733 // fDebug == 0 nothing
2734
2735 // fDebug == 1
2736 if (fDebug == 1) {
2737 // Create the histos replique de ch
2738 InitArrayFitPRF();
2739 }
2740
2741 // fDebug == 2 and fFitVoir no histo
2742 if (fDebug == 2) {
2743 if (fFitVoir < numberofbinsexpected) {
2744 AliInfo(Form("We will see the fit of the object %d",fFitVoir));
2745 }
2746 else {
2747 AliInfo("fFitVoir is out of range of the histo!");
2748 return kFALSE;
2749 }
2750 }
2751
2752 // fDebug == 3 or 4 and fDet
2753 if (fDebug >= 3) {
2754 if ((fCalibraMode->GetNz(2) == 0) &&
2755 (fCalibraMode->GetNrphi(2) == 0)) {
2756 AliInfo("Do you really want to see one detector without pad groups?");
2757 return kFALSE;
2758 }
2759 else {
2760 AliInfo(Form("You will see the detector: iPlane %d, iChamb %d, iSect %d"
2761 ,fDet[0],fDet[1],fDet[2]));
2762 // A little geometry:
f162af62 2763 Int_t rowMax = fGeo->GetRowMax(fDet[0],fDet[1],fDet[2]);
2764 Int_t colMax = fGeo->GetColMax(fDet[0]);
55a288e5 2765 // Create the histos to visualise
2766 CreateFitHistoPRFDB(rowMax,colMax);
2767 if (fDebug == 4) {
2768 InitArrayFitPRF();
2769 }
2770 }
2771 }
2772
2773 }
2774
2775 return kTRUE;
2776
2777}
2778
2779//____________Functions for initialising the AliTRDCalibraFit in the code_________
2780void AliTRDCalibraFit::InitfCountDetAndfCount(Int_t i)
2781{
2782 //
2783 // Init the current detector where we are fCountDet and the
2784 // next fCount for the functions Fit...
2785 //
2786
2787 // Loop on the Xbins of ch!!
2788 fCountDet[i] = -1; // Current detector
2789 fCount[i] = 0; // To find the next detector
2790
2791 // If fDebug >= 3
2792 if (fDebug >= 3) {
2793
2794 // Set countdet to the detector
2795 fCountDet[i] = AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]);
2796
2797 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
2798 fCalibraMode->ModePadCalibration(fDet[1],i);
2799 fCalibraMode->ModePadFragmentation(fDet[0],fDet[1],fDet[2],i);
2800
2801 // Set counter to write at the end of the detector
2802 fCount[i] = fDect1[i] + fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i);
2803
2804 }
2805
2806}
2807
2808//____________Functions for initialising the AliTRDCalibraFit in the code_________
2809void AliTRDCalibraFit::UpdatefCountDetAndfCount(Int_t idect, Int_t i)
2810{
2811 //
2812 // See if we are in a new detector and update the
2813 // variables fNfragZ and fNfragRphi if yes
2814 //
2815
2816 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
2817 // If fDebug == 1 or 0
2818 if ((fDebug == 0) ||
2819 (fDebug == 1)) {
2820
2821 if (fCount[i] == idect) {
2822
2823 // On en est au detector
2824 fCountDet[i] += 1;
2825
2826 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
2827 fCalibraMode->ModePadCalibration((Int_t) GetChamber(fCountDet[i]),i);
2828 fCalibraMode->ModePadFragmentation((Int_t) GetPlane(fCountDet[i])
2829 ,(Int_t) GetChamber(fCountDet[i])
2830 ,(Int_t) GetSector(fCountDet[i]),i);
2831
2832 // Set for the next detector
2833 fCount[i] += fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i);
2834
2835 }
2836
2837 }
2838
2839}
2840
2841//____________Functions for initialising the AliTRDCalibraFit in the code_________
2842void AliTRDCalibraFit::ReconstructFitRowMinRowMax(Int_t idect, Int_t i)
2843{
2844 //
2845 // Reconstruct the min pad row, max pad row, min pad col and
2846 // max pad col of the calibration group for the Fit functions
2847 //
2848
2849 if (fDebug < 2) {
2850 fCalibraMode->ReconstructionRowPadGroup((Int_t) (idect-(fCount[i]-(fCalibraMode->GetNfragZ(i)
2851 *fCalibraMode->GetNfragRphi(i)))),i);
2852 }
2853 if (fDebug >= 3) {
2854 fCalibraMode->ReconstructionRowPadGroup((Int_t) (idect-fDect1[i]),i);
2855 }
2856
2857}
2858
2859//____________Functions for initialising the AliTRDCalibraFit in the code_________
2860Bool_t AliTRDCalibraFit::NotEnoughStatistic(Int_t idect, Int_t i)
2861{
2862 //
2863 // For the case where there are not enough entries in the histograms
2864 // of the calibration group, the value present in the choosen database
2865 // will be put. A negativ sign enables to know that a fit was not possible.
2866 //
f162af62 2867
55a288e5 2868 // Get cal
2869 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
2870 if (!cal) {
2871 AliInfo("Could not get calibDB");
2872 return kFALSE;
2873 }
2874
2875 if (fDebug != 2) {
2876 AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted"
2877 ,idect-(fCount[i]-(fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i))),fCountDet[i]));
2878 }
2879 if (fDebug == 2) {
2880 AliInfo("The element has not enough statistic to be fitted");
2881 }
2882
2883 if ((i == 0) && (fDebug != 2)) {
2884
2885 // Calcul the coef from the database choosen
2886 CalculChargeCoefMean(fCountDet[0],(Int_t) (idect-fDect1[0]),kFALSE);
2887
2888 // Fill the coefCH[2304] with negative value to say: not fitted
2889 AliInfo(Form("The row min %d, the row max %d, the colmin %d and the col max %d"
2890 ,fCalibraMode->GetRowMin(0)
2891 ,fCalibraMode->GetRowMax(0)
2892 ,fCalibraMode->GetColMin(0)
2893 ,fCalibraMode->GetColMax(0)));
2894 for (Int_t k = fCalibraMode->GetRowMin(0); k < fCalibraMode->GetRowMax(0); k++) {
2895 for (Int_t j = fCalibraMode->GetColMin(0); j < fCalibraMode->GetColMax(0); j++) {
2896 if (GetChamber(fCountDet[0]) == 2) {
2897 fCoefCH[(Int_t)(j*12+k)] = -TMath::Abs(fChargeCoef[3]);
2898 }
2899 if (GetChamber(fCountDet[0]) != 2) {
2900 fCoefCH[(Int_t)(j*16+k)] = -TMath::Abs(fChargeCoef[3]);
2901 }
2902 }
2903 }
2904
2905 // Put the default value negative
2906 if ((fDebug == 1) ||
2907 (fDebug == 4)) {
2908
2909 if (fFitChargeBisOn) {
2910 fCoefCharge[2][idect-fDect1[0]]=-TMath::Abs(fChargeCoef[3]);
2911 }
2912 if (fMeanChargeOn) {
2913 fCoefCharge[1][idect-fDect1[0]]=-TMath::Abs(fChargeCoef[3]);
2914 }
2915 if(fFitChargeOn){
2916 fCoefCharge[0][idect-fDect1[0]]=-TMath::Abs(fChargeCoef[3]);
2917 }
2918
2919 }
2920
2921 // End of one detector
2922 if ((idect == (fCount[0]-1))) {
2923 FillVectorFitCH((Int_t) fCountDet[0]);
2924 // Reset
2925 for (Int_t k = 0; k < 2304; k++) {
2926 fCoefCH[k] = 0.0;
2927 }
2928 }
2929
2930 }
2931
2932 if ((i == 1) && (fDebug != 2)) {
2933
2934 CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect-fDect1[1]));
2935 CalculT0CoefMean(fCountDet[1],(Int_t) (idect-fDect1[1]));
2936
2937 // Put the default value (time0 can be negativ, so we stay with + )
2938 if ((fDebug == 1) ||
2939 (fDebug == 4)) {
2940
2941 if (fFitPHOn) {
2942 fCoefVdrift[0][(idect-fDect1[1])] = -fVdriftCoef[2];
2943 fCoefT0[0][(idect-fDect1[1])] = fT0Coef[2];
2944 }
2945
2946 if(fFitPol2On) {
2947 fCoefVdrift[1][(idect-fDect1[1])] = -fVdriftCoef[2];
2948 fCoefT0[1][(idect-fDect1[1])] = fT0Coef[2];
2949 }
2950 if(fFitLagrPolOn) {
2951 fCoefVdrift[3][(idect-fDect1[1])] = -fVdriftCoef[2];
2952 fCoefT0[3][(idect-fDect1[1])] = fT0Coef[2];
2953 }
2954
2955 }
2956
2957 // Put the default value
2958 if (fDebug >= 3) {
2959 if(fFitPHOn){
2960 fVdriftCoef[0] = fVdriftCoef[2];
2961 fT0Coef[0] = fT0Coef[2];
2962 }
2963 if(fFitPol2On){
2964 fVdriftCoef[1] = fVdriftCoef[2];
2965 fT0Coef[1] = fT0Coef[2];
2966 }
2967 if(fFitLagrPolOn){
2968 fVdriftCoef[3] = fVdriftCoef[2];
2969 fT0Coef[3] = fT0Coef[2];
2970 }
2971 FillCoefVdriftDB();
2972 FillCoefT0DB();
2973 }
2974
2975 // Fill the tree if end of a detector.
2976 // The pointer to the branch stays with the default value negative!!!
2977 // PH
2978 // Pointer to the branch
2979 for (Int_t k = fCalibraMode->GetRowMin(1); k < fCalibraMode->GetRowMax(1); k++) {
2980 for (Int_t j = fCalibraMode->GetColMin(1); j < fCalibraMode->GetColMax(1); j++) {
2981 if (GetChamber(fCountDet[1]) == 2) {
2982 fVdriftPad[(Int_t)(j*12+k)] = -TMath::Abs(fVdriftCoef[2]);
2983 }
2984 if (GetChamber(fCountDet[1]) != 2) {
2985 fVdriftPad[(Int_t)(j*16+k)] = -TMath::Abs(fVdriftCoef[2]);
2986 }
2987 }
2988 }
2989
2990 // End of one detector
2991 if ((idect == (fCount[1]-1)) && (fDebug != 2)) {
2992 FillTreeVdrift((Int_t) fCountDet[1]);
2993 }
2994
2995 // T0
2996 // Fill the tree if end of a detector.
2997 // The pointer to the branch stays with the default value positive!!!
2998 // Pointer to the branch
2999 for (Int_t k = fCalibraMode->GetRowMin(1); k < fCalibraMode->GetRowMax(1); k++) {
3000 for (Int_t j = fCalibraMode->GetColMin(1); j < fCalibraMode->GetColMax(1); j++) {
3001 if (GetChamber(fCountDet[1]) == 2) {
3002 fT0Pad[(Int_t)(j*12+k)] = fT0Coef[2];
3003 }
3004 if (GetChamber(fCountDet[1]) != 2) {
3005 fT0Pad[(Int_t)(j*16+k)] = fT0Coef[2];
3006 }
3007 }
3008 }
3009
3010 // End of one detector
3011 if ((idect == (fCount[1]-1)) && (fDebug != 2)) {
3012 FillTreeT0((Int_t) fCountDet[1]);
3013 }
3014
3015 }
3016
3017 if ((i == 2) && (fDebug != 2)) {
3018
3019 CalculPRFCoefMean(fCountDet[2],(Int_t) (idect-fDect1[2]));
3020
3021 if ((fDebug == 1) ||
3022 (fDebug == 4)) {
3023 if(fFitPRFOn){
3024 fCoefPRF[0][(idect-fDect1[2])] = -fPRFCoef[1];
3025 }
3026 if(fRMSPRFOn){
3027 fCoefPRF[2][(idect-fDect1[2])] = -fPRFCoef[1];
3028 }
3029 }
3030
3031 if (fDebug >= 3){
3032 if(fFitPRFOn){
3033 fPRFCoef[0] = fPRFCoef[1];
3034 }
3035 if(fRMSPRFOn){
3036 fPRFCoef[2] = fPRFCoef[1];
3037 }
3038 FillCoefPRFDB();
3039 }
3040
3041 // Fill the tree if end of a detector.
3042 // The pointer to the branch stays with the default value 1.5!!!
3043 // Pointer to the branch
3044 for (Int_t k = fCalibraMode->GetRowMin(2); k < fCalibraMode->GetRowMax(2); k++) {
3045 for (Int_t j = fCalibraMode->GetColMin(2); j < fCalibraMode->GetColMax(2); j++) {
f162af62 3046 if((fGeo->GetColMax(GetPlane(fCountDet[2])) != (j+1)) && (j != 0)){
55a288e5 3047 if (GetChamber(fCountDet[2]) == 2) {
3048 fPRFPad[(Int_t)(j*12+k)] = -fPRFCoef[1];
3049 }
3050 if (GetChamber(fCountDet[2]) != 2) {
3051 fPRFPad[(Int_t)(j*16+k)] = -fPRFCoef[1];
3052 }
3053 }
3054 else {
3055 if (fAccCDB) {
3056 if (GetChamber(fCountDet[2]) == 2) {
3057 fPRFPad[(Int_t)(j*12+k)] = -((Float_t) cal->GetPRFWidth(fCountDet[2],j,k));
3058 }
3059 if (GetChamber(fCountDet[2]) != 2) {
3060 fPRFPad[(Int_t)(j*16+k)] = -((Float_t) cal->GetPRFWidth(fCountDet[2],j,k));
3061 }
3062 }
3063 if (!fAccCDB) {
3064 if (GetChamber(fCountDet[2]) == 2) {
3065 fPRFPad[(Int_t)(j*12+k)] = -((Float_t) GetPRFDefault(GetPlane(fCountDet[2])));
3066 }
3067 if (GetChamber(fCountDet[2]) != 2) {
3068 fPRFPad[(Int_t)(j*16+k)] = -((Float_t) GetPRFDefault(GetPlane(fCountDet[2])));
3069 }
3070 }
3071 }
3072 }
3073 }
3074
3075 // End of one detector
3076 if ((idect == (fCount[2]-1)) && (fDebug != 2)) {
3077 FillTreePRF((Int_t) fCountDet[2]);
3078 }
3079
3080 }
3081
3082 return kTRUE;
3083
3084}
3085
3086//____________Functions for initialising the AliTRDCalibraFit in the code_________
3087Bool_t AliTRDCalibraFit::FillInfosFit(Int_t idect, Int_t i)
3088{
3089 //
3090 // Fill the coefficients found with the fits or other
3091 // methods from the Fit functions
3092 //
3093
55a288e5 3094 // Get cal
3095 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
3096 if (!cal) {
3097 AliInfo("Could not get calibDB");
3098 return kFALSE;
3099 }
3100
3101 if ((i == 0) && (fDebug != 2)) {
3102 // Fill the coefCH[2304] with fChargeCoef[0]
3103 // that would be negativ only if the fit failed totally
3104 //printf("for fCountDet %d we have %f\n",fCountDet[0],fChargeCoef[fFitChargeNDB]);
3105 //printf("RowMin %d RowMax %d ColMin %d ColMax %d\n",fCalibraMode->GetRowMin(0),fCalibraMode->GetRowMax(0),fCalibraMode->GetColMin(0),fCalibraMode->GetColMax(0));
3106 for (Int_t k = fCalibraMode->GetRowMin(0); k < fCalibraMode->GetRowMax(0); k++) {
3107 for (Int_t j = fCalibraMode->GetColMin(0); j < fCalibraMode->GetColMax(0); j++) {
3108 if (GetChamber(fCountDet[0]) == 2) {
3109 fCoefCH[(Int_t)(j*12+k)] = fChargeCoef[fFitChargeNDB];
3110 }
3111 if (GetChamber(fCountDet[0]) != 2) {
3112 fCoefCH[(Int_t)(j*16+k)] = fChargeCoef[fFitChargeNDB];
3113 }
3114 }
3115 }
3116 // End of one detector
3117 if ((idect == (fCount[0]-1))) {
3118 FillVectorFitCH((Int_t) fCountDet[0]);
3119 // Reset
3120 for (Int_t k = 0; k < 2304; k++) {
3121 fCoefCH[k] = 0.0;
3122 }
3123 }
3124 }
3125
3126 if ((i == 1) && (fDebug != 2)) {
3127
3128 // PH
3129 // Pointer to the branch: fVdriftCoef[1] will ne negativ only if the fit failed totally
3130 for (Int_t k = fCalibraMode->GetRowMin(1); k < fCalibraMode->GetRowMax(1); k++) {
3131 for (Int_t j = fCalibraMode->GetColMin(1); j < fCalibraMode->GetColMax(1); j++) {
3132 if (GetChamber(fCountDet[1]) == 2) {
3133 fVdriftPad[(Int_t)(j*12+k)]=fVdriftCoef[fFitPHNDB];
3134 }
3135 if (GetChamber(fCountDet[1]) != 2) {
3136 fVdriftPad[(Int_t)(j*16+k)]=fVdriftCoef[fFitPHNDB];
3137 }
3138 }
3139 }
3140 // End of one detector
3141 if ((idect == (fCount[1]-1)) && (fDebug != 2)) {
3142 FillTreeVdrift((Int_t) fCountDet[1]);
3143 }
3144
3145 // T0
3146 // Pointer to the branch: fT0Coef[1] will ne negativ only if the fit failed totally
3147 for (Int_t k = fCalibraMode->GetRowMin(1); k < fCalibraMode->GetRowMax(1); k++) {
3148 for (Int_t j = fCalibraMode->GetColMin(1); j < fCalibraMode->GetColMax(1); j++) {
3149 if (GetChamber(fCountDet[1]) == 2) {
3150 fT0Pad[(Int_t)(j*12+k)]=fT0Coef[fFitPHNDB];
3151 }
3152 if (GetChamber(fCountDet[1]) != 2) {
3153 fT0Pad[(Int_t)(j*16+k)]=fT0Coef[fFitPHNDB];
3154 }
3155 }
3156 }
3157 // End of one detector
3158 if ((idect == (fCount[1]-1)) && (fDebug != 2)) {
3159 FillTreeT0((Int_t) fCountDet[1]);
3160 }
3161
3162 }
3163
3164 if ((i == 2) && (fDebug != 2)) {
3165 // Pointer to the branch
3166 for (Int_t k = fCalibraMode->GetRowMin(2); k < fCalibraMode->GetRowMax(2); k++) {
3167 for (Int_t j = fCalibraMode->GetColMin(2); j < fCalibraMode->GetColMax(2); j++) {
f162af62 3168 if ((fGeo->GetColMax(GetPlane(fCountDet[2])) != (j+1)) && (j != 0)) {
55a288e5 3169 if (GetChamber(fCountDet[2]) == 2) {
3170 fPRFPad[(Int_t)(j*12+k)] = fPRFCoef[fFitPRFNDB];
3171 }
3172 if (GetChamber(fCountDet[2]) != 2) {
3173 fPRFPad[(Int_t)(j*16+k)] = fPRFCoef[fFitPRFNDB];
3174 }
3175 }
3176 else {
3177 if (fAccCDB) {
3178 if (GetChamber(fCountDet[2]) == 2) {
3179 fPRFPad[(Int_t)(j*12+k)] = (Float_t) cal->GetPRFWidth(fCountDet[2],j,k);
3180 }
3181 if (GetChamber(fCountDet[2]) != 2) {
3182 fPRFPad[(Int_t)(j*16+k)] = (Float_t) cal->GetPRFWidth(fCountDet[2],j,k);
3183 }
3184 }
3185 if (!fAccCDB) {
3186 if (GetChamber(fCountDet[2]) == 2) {
3187 fPRFPad[(Int_t)(j*12+k)] = (Float_t) GetPRFDefault(GetPlane(fCountDet[2]));
3188 }
3189 if (GetChamber(fCountDet[2]) != 2) {
3190 fPRFPad[(Int_t)(j*16+k)] = (Float_t) GetPRFDefault(GetPlane(fCountDet[2]));
3191 }
3192 }
3193 }
3194 }
3195 }
3196 // End of one detector
3197 if ((idect == (fCount[2]-1)) && (fDebug != 2)) {
3198 FillTreePRF((Int_t) fCountDet[2]);
3199 }
3200 }
3201
3202 return kTRUE;
3203
3204}
3205
3206//____________Functions for initialising the AliTRDCalibraFit in the code_________
3207Bool_t AliTRDCalibraFit::WriteFitInfos(Int_t i)
3208{
3209 //
3210 // In the case the user wants to write a file with a tree of the found
3211 // coefficients for the calibration before putting them in the database
3212 //
3213
3214 TFile *fout = TFile::Open(fWriteNameCoef,"UPDATE");
3215 // Check if the file could be opened
3216 if (!fout || !fout->IsOpen()) {
3217 AliInfo("No File found!");
3218 return kFALSE;
3219 }
3220
3221 if ((i == 0) && (fDebug != 2)) {
3222 // The DB stuff
3223 if ((fDebug == 4) ||
3224 (fDebug == 3)) {
3225 WriteCHDB(fout);
3226 }
3227 // The tree
3228 fout->WriteTObject(fGain,fGain->GetName(),(Option_t *) "writedelete");
3229 }
3230
3231 if ((i == 1) && (fDebug != 2)) {
3232 // The DB stuff
3233 if ((fDebug == 4) ||
3234 (fDebug == 3)) {
3235 WritePHDB(fout);
3236 }
3237 // The tree
3238 fout->WriteTObject(fVdrift,fVdrift->GetName(),(Option_t *) "writedelete");
3239 // The DB stuff
3240 if ((fDebug == 4) ||
3241 (fDebug == 3)) {
3242 WriteT0DB(fout);
3243 }
3244 // The tree
3245 fout->WriteTObject(fT0,fT0->GetName(),(Option_t *) "writedelete");
3246 }
3247
3248 if ((i == 2) && (fDebug != 2)) {
3249 // The DB stuff
3250 if ((fDebug == 4) ||
3251 (fDebug == 3)) {
3252 WritePRFDB(fout);
3253 }
3254 // The tree
3255 fout->WriteTObject(fPRF,fPRF->GetName(),(Option_t *) "writedelete");
3256 }
3257
3258 fout->Close();
3259
3260 return kTRUE;
3261
3262}
3263
3264//
3265//____________Fill Coef DB in case of visualisation of one detector____________
3266//
3267
3268//_____________________________________________________________________________
3269void AliTRDCalibraFit::FillCoefVdriftDB()
3270{
3271 //
3272 // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector
3273 //
3274
3275 for (Int_t row = fCalibraMode->GetRowMin(1); row < fCalibraMode->GetRowMax(1); row++) {
3276 for (Int_t col = fCalibraMode->GetColMin(1); col < fCalibraMode->GetColMax(1); col++) {
3277 if(fFitPol2On){
3278 fCoefVdriftDB[1]->SetBinContent(row+1,col+1,TMath::Abs(fVdriftCoef[1]));
3279 }
3280 if (fFitPHOn ) {
3281 fCoefVdriftDB[0]->SetBinContent(row+1,col+1,TMath::Abs(fVdriftCoef[0]));
3282 }
3283 if (fFitLagrPolOn ) {
3284 fCoefVdriftDB[2]->SetBinContent(row+1,col+1,TMath::Abs(fVdriftCoef[3]));
3285 }
3286 }
3287 }
3288
3289}
3290
3291//_____________________________________________________________________________
3292void AliTRDCalibraFit::FillCoefT0DB()
3293{
3294 //
3295 // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector
3296 //
3297
3298 for (Int_t row = fCalibraMode->GetRowMin(1); row < fCalibraMode->GetRowMax(1); row++) {
3299 for (Int_t col = fCalibraMode->GetColMin(1); col < fCalibraMode->GetColMax(1); col++) {
3300 if(fFitPol2On){
3301 fCoefT0DB[1]->SetBinContent(row+1,col+1,TMath::Abs(fT0Coef[1]));
3302 }
3303 if (fFitPHOn) {
3304 fCoefT0DB[0]->SetBinContent(row+1,col+1,TMath::Abs(fT0Coef[0]));
3305 }
3306 if (fFitLagrPolOn) {
3307 fCoefT0DB[2]->SetBinContent(row+1,col+1,TMath::Abs(fT0Coef[3]));
3308 }
3309 }
3310 }
3311
3312}
3313
3314//_____________________________________________________________________________
3315void AliTRDCalibraFit::FillCoefChargeDB()
3316{
3317 //
3318 // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector
3319 //
3320
3321 for (Int_t row = fCalibraMode->GetRowMin(0); row < fCalibraMode->GetRowMax(0); row++) {
3322 for (Int_t col = fCalibraMode->GetColMin(0); col < fCalibraMode->GetColMax(0); col++) {
3323 if (fMeanChargeOn) {
3324 fCoefChargeDB[1]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[1]));
3325 }
3326 if (fFitChargeBisOn) {
3327 fCoefChargeDB[2]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[2]));
3328 }
3329 if(fFitChargeOn){
3330 fCoefChargeDB[0]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[0]));
3331 }
3332 if(fFitMeanWOn){
3333 fCoefChargeDB[3]->SetBinContent(row+1,col+1,TMath::Abs(fChargeCoef[4]));
3334 }
3335 }
3336 }
3337
3338}
3339
3340//_____________________________________________________________________________
3341void AliTRDCalibraFit::FillCoefPRFDB()
3342{
3343 //
3344 // Fill the histos for fDebug = 3 and fDebug = 4 to visualise the detector
3345 //
3346 if(fFitPRFOn){
3347 for (Int_t row = fCalibraMode->GetRowMin(2); row < fCalibraMode->GetRowMax(2); row++) {
3348 for (Int_t col = fCalibraMode->GetColMin(2); col < fCalibraMode->GetColMax(2); col++) {
3349 fCoefPRFDB[0]->SetBinContent(row+1,col+1,fPRFCoef[0]);
3350 }
3351 }
3352 }
3353 if(fRMSPRFOn){
3354 for (Int_t row = fCalibraMode->GetRowMin(2); row < fCalibraMode->GetRowMax(2); row++) {
3355 for (Int_t col = fCalibraMode->GetColMin(2); col < fCalibraMode->GetColMax(2); col++) {
3356 fCoefPRFDB[1]->SetBinContent(row+1,col+1,fPRFCoef[2]);
3357 }
3358 }
3359 }
3360
3361}
3362
3363//
3364//____________Plot histos CoefPRF....__________________________________________
3365//
3366
3367//_____________________________________________________________________________
3368void AliTRDCalibraFit::PlotWriteCH()
3369{
3370 //
3371 // Scale the coefficients to one, create the graph errors and write them if wanted
3372 //
3373
3374 //TObjArray of the grapherrors and so on
3375 TObjArray *listofgraphs = new TObjArray();
3376
3377 Int_t nbins = fDect2[0]-fDect1[0];
3378
3379 // Scale the coefs
3380 // We will check fScaleFitFactor for the fFitChargeNDB, otherwise we calculate and normalise to 1
3381 // It can be that fScaleFitFactor is different from scale if we have taken a no default database as reference
3382 //
3383
3384 //counter
3385 Int_t counter[4];
3386 counter[0] = 0; //how many groups are fitted for 0
3387 counter[1] = 0; //how many groups are with mean for 1
3388 counter[2] = 0; //how many groups are fitted for 2
3389 counter[3] = 0; //how many groups are fitted for 4
3390 Double_t sum = 0.0;
3391 Double_t scale = 1.0;
3392
3393 // Scale the histo
3394 // Is -1 if no fit or mean, is 1 if fit or mean
3395 Double_t *xValuesFitted = new Double_t[nbins];
3396 Double_t *xValuesFittedMean = new Double_t[nbins];
3397 Double_t *xValuesFittedBis = new Double_t[nbins];
3398 Double_t *xValuesFittedMeanW = new Double_t[nbins];
3399 for(Int_t k = 0; k < nbins; k ++){
3400 xValuesFitted[k] = -1;
3401 xValuesFittedMean[k] = -1;
3402 xValuesFittedMeanW[k] = -1;
3403 xValuesFittedBis[k] = -1;
3404 }
3405
3406 if(fFitChargeOn){
3407 sum = 0.0;
3408 for(Int_t l = 0; l < nbins; l++){
3409 if(fCoefCharge[0][l] > 0){
3410 sum += fCoefCharge[0][l];
3411 xValuesFitted[counter[0]]= l;
3412 counter[0]++;
3413 }
3414 }
3415 scale = 1.0;
3416 if(sum > 0.0) scale = counter[0]/sum;
3417 if(fFitChargeNDB == 0){
3418 if(scale != fScaleFitFactor){
3419 AliInfo(Form("The normalisation is different from a nomalisation to one."));
3420 AliInfo(Form("For one we have %f and here %f",scale,fScaleFitFactor));
bb9cc02b 3421 if(!fAccCDB) {
3422 AliInfo(Form("It is not normal because we didn't choose a reference database!"));
3423 }
55a288e5 3424 }
3425 scale = fScaleFitFactor;
3426 }
3427 for(Int_t l = 0; l < nbins; l++){
3428 if(fCoefCharge[0][l] > 0){
3429 fCoefCharge[0][l]=fCoefCharge[0][l]*scale;
3430 fCoefChargeE[0][l]=fCoefChargeE[0][l]*scale;
3431 }
3432 }
3433 }
3434
3435 if(fFitMeanWOn){
3436 sum = 0.0;
3437 for(Int_t l = 0; l < nbins; l++){
3438 if(fCoefCharge[4][l] > 0){
3439 sum += fCoefCharge[4][l];
3440 xValuesFittedMeanW[counter[3]]= l;
3441 counter[3]++;
3442 }
3443 }
3444 scale = 1.0;
3445 if(sum > 0.0) scale = counter[3]/sum;
3446 if(fFitChargeNDB == 4){
3447 if(scale != fScaleFitFactor){
3448 AliInfo(Form("The normalisation is different from a nomalisation to one."));
3449 AliInfo(Form("For one we have %f and here %f",scale,fScaleFitFactor));
bb9cc02b 3450 if(!fAccCDB) {
3451 AliInfo(Form("It is not normal because we didn't choose a reference database!"));
3452 }
55a288e5 3453 }
3454 scale = fScaleFitFactor;
3455 }
3456 for(Int_t l = 0; l < nbins; l++){
3457 if(fCoefCharge[4][l] > 0){
3458 fCoefCharge[4][l]=fCoefCharge[4][l]*scale;
3459 fCoefChargeE[3][l]=fCoefChargeE[3][l]*scale;
3460 }
3461 }
3462 }
3463
3464 if(fMeanChargeOn){
3465 sum = 0.0;
3466 for(Int_t l = 0; l < nbins; l++){
3467 if(fCoefCharge[1][l] > 0){
3468 sum += fCoefCharge[1][l];
3469 xValuesFittedMean[counter[1]]= l;
3470 counter[1]++;
3471 }
3472 }
3473 scale = 1.0;
3474 if(sum > 0.0) scale = counter[1]/sum;
3475 if(fFitChargeNDB == 1){
3476 if(scale != fScaleFitFactor){
3477 AliInfo(Form("The normalisation is different from a nomalisation to one."));
3478 AliInfo(Form("For one we have %f and here %f",scale,fScaleFitFactor));
bb9cc02b 3479 if(!fAccCDB) {
3480 AliInfo(Form("It is not normal because we didn't choose a reference database!"));
3481 }
55a288e5 3482 }
3483 scale = fScaleFitFactor;
3484 }
3485 for(Int_t l = 0; l < nbins; l++){
3486 if(fCoefCharge[1][l] > 0){
3487 fCoefCharge[1][l]=fCoefCharge[1][l]*scale;
3488 fCoefChargeE[1][l]=fCoefChargeE[1][l]*scale;
3489 }
3490 }
3491 }
3492
3493 if(fFitChargeBisOn){
3494 sum = 0.0;
3495 for(Int_t l = 0; l < nbins; l++){
3496 if(fCoefCharge[2][l] > 0){
3497 sum += fCoefCharge[2][l];
3498 xValuesFittedBis[counter[2]]= l;
3499 counter[2]++;
3500 }
3501 }
3502 scale = 1.0;
3503 if(sum > 0.0) scale = counter[2]/sum;
3504 if(fFitChargeNDB == 0){
3505 if(scale != fScaleFitFactor){
3506 AliInfo(Form("The normalisation is different from a nomalisation to one."));
3507 AliInfo(Form("For one we have %f and here %f",scale,fScaleFitFactor));
bb9cc02b 3508 if(!fAccCDB) {
3509 AliInfo(Form("It is not normal because we didn't choose a reference database!"));
3510 }
55a288e5 3511 }
3512 scale = fScaleFitFactor;
3513 }
3514 for(Int_t l = 0; l < nbins; l++){
3515 if(fCoefCharge[2][l] > 0){
3516 fCoefCharge[2][l]=fCoefCharge[2][l]*scale;
3517 fCoefChargeE[2][l]=fCoefChargeE[2][l]*scale;
3518 }
3519 }
3520 }
3521
3522 // Create the X and Xerror
3523 Double_t *xValues = new Double_t[nbins];
3524 Double_t *xValuesE = new Double_t[nbins];
3525 for(Int_t k = 0; k < nbins; k ++){
3526 xValues[k] = k;
3527 xValuesE[k] = 0.0;
3528 }
3529
3530 // Create the graph erros and plot them
3531 TCanvas *cch1 = new TCanvas("cch1","",50,50,600,800);
3532 cch1->cd();
3533 TLegend *legch1 = new TLegend(0.4,0.6,0.89,0.89);
3534
3535 TGraph *graphCharge3 = new TGraph(nbins,xValues,fCoefCharge[3]);
3536 graphCharge3->SetName("coefcharge3");
3537 graphCharge3->SetTitle("");
3538 graphCharge3->GetXaxis()->SetTitle("Det/Pad groups");
3539 graphCharge3->GetYaxis()->SetTitle("gain factor");
3540 graphCharge3->SetLineColor(4);
3541 graphCharge3->SetMarkerStyle(25);
3542 graphCharge3->SetMarkerColor(4);
3543 listofgraphs->Add((TObject *)graphCharge3);
3544 legch1->AddEntry(graphCharge3,"f_{g} simulated","p");
3545 graphCharge3->Draw("AP");
3546
3547 if (fFitChargeOn) {
3548 TGraphErrors *graphCharge0 = new TGraphErrors(nbins,xValues,fCoefCharge[0],xValuesE,fCoefChargeE[0]);
3549 graphCharge0->SetName("coefcharge0");
3550 graphCharge0->SetTitle("");
3551 graphCharge0->GetXaxis()->SetTitle("Det/Pad groups");
3552 graphCharge0->GetYaxis()->SetTitle("gain factor");
3553 graphCharge0->SetMarkerColor(6);
3554 graphCharge0->SetLineColor(6);
3555 graphCharge0->SetMarkerStyle(26);
3556 listofgraphs->Add((TObject *)graphCharge0);
3557 legch1->AddEntry(graphCharge0,"f_{g} fit","p");
3558 graphCharge0->Draw("P");
3559 }
3560 if (fFitMeanWOn) {
3561 TGraphErrors *graphCharge4 = new TGraphErrors(nbins,xValues,fCoefCharge[4],xValuesE,fCoefChargeE[3]);
3562 graphCharge4->SetName("coefcharge4");
3563 graphCharge4->SetTitle("");
3564 graphCharge4->GetXaxis()->SetTitle("Det/Pad groups");
3565 graphCharge4->GetYaxis()->SetTitle("gain factor");
3566 graphCharge4->SetMarkerColor(1);
3567 graphCharge4->SetLineColor(1);
3568 graphCharge4->SetMarkerStyle(30);
3569 listofgraphs->Add((TObject *)graphCharge4);
3570 legch1->AddEntry(graphCharge4,"f_{g} Mean W","p");
3571 graphCharge4->Draw("P");
3572 }
3573 if (fMeanChargeOn) {
3574 TGraphErrors *graphCharge1 = new TGraphErrors(nbins,xValues,fCoefCharge[1],xValuesE,fCoefChargeE[1]);
3575 graphCharge1->SetName("coefcharge1");
3576 graphCharge1->GetXaxis()->SetTitle("Det/Pad groups");
3577 graphCharge1->GetYaxis()->SetTitle("gain factor");
3578 graphCharge1->SetTitle("");
3579 graphCharge1->SetMarkerColor(2);
3580 graphCharge1->SetLineColor(2);
3581 graphCharge1->SetMarkerStyle(24);
3582 legch1->AddEntry(graphCharge1,"f_{g} mean","p");
3583 graphCharge1->Draw("P");
3584 listofgraphs->Add((TObject *)graphCharge1);
3585 }
3586 if (fFitChargeBisOn ) {
3587 TGraphErrors *graphCharge2 = new TGraphErrors(nbins,xValues,fCoefCharge[2],xValuesE,fCoefChargeE[2]);
3588 graphCharge2->SetName("coefcharge2");
3589 graphCharge2->SetTitle("");
3590 graphCharge2->GetXaxis()->SetTitle("Det/Pad groups");
3591 graphCharge2->GetYaxis()->SetTitle("gain factor");
3592 graphCharge2->SetMarkerColor(8);
3593 graphCharge2->SetLineColor(8);
3594 graphCharge2->SetMarkerStyle(25);
3595 legch1->AddEntry(graphCharge2,"f_{g} fitbis","p");
3596 graphCharge2->Draw("P");
3597 listofgraphs->Add((TObject *)graphCharge2);
3598 }
3599 legch1->Draw("same");
3600
3601 //Create the arrays and the graphs for the delta
3602 Int_t thefirst = 0;
3603 TCanvas *cch2 = new TCanvas("cch2","",50,50,600,800);
3604 cch2->Divide(2,1);
3605 TLegend *legch3 = new TLegend(0.4,0.6,0.89,0.89);
3606 TLegend *legch2 = new TLegend(0.4,0.6,0.89,0.89);
3607
3608 if(fFitChargeOn){
3609 cch2->cd(2);
3610 Double_t *yValuesDelta = new Double_t[counter[0]];
3611 for(Int_t k = 0; k < counter[0]; k++){
3612 if (fCoefCharge[3][(Int_t)(xValuesFitted[k])] > 0.0) {
3613 yValuesDelta[k] = (fCoefCharge[0][(Int_t)xValuesFitted[k]]-fCoefCharge[3][(Int_t)xValuesFitted[k]])
3614 / fCoefCharge[3][(Int_t)xValuesFitted[k]];
3615 }
3616 else {
3617 yValuesDelta[k] = 0.0;
3618 }
3619 }
3620 TGraph *graphDeltaCharge0 = new TGraph(counter[0],&xValuesFitted[0],yValuesDelta);
3621 graphDeltaCharge0->SetName("deltacharge0");
3622 graphDeltaCharge0->GetXaxis()->SetTitle("Det/Pad groups");
3623 graphDeltaCharge0->GetYaxis()->SetTitle("#Deltag/g_{sim}");
3624 graphDeltaCharge0->SetMarkerColor(6);
3625 graphDeltaCharge0->SetTitle("");
3626 graphDeltaCharge0->SetLineColor(6);
3627 graphDeltaCharge0->SetMarkerStyle(26);
3628 listofgraphs->Add((TObject *)graphDeltaCharge0);
3629 legch3->AddEntry(graphDeltaCharge0,"fit","p");
3630 graphDeltaCharge0->Draw("AP");
3631
3632 cch2->cd(1);
3633 TH1I *histoErrorCharge0 = new TH1I("errorcharge0","",100 ,-0.10,0.10);
3634 histoErrorCharge0->SetXTitle("#Deltag/g_{sim}");
3635 histoErrorCharge0->SetYTitle("counts");
3636 histoErrorCharge0->SetLineColor(6);
3637 histoErrorCharge0->SetLineStyle(1);
3638 histoErrorCharge0->SetStats(0);
3639 Double_t maxvalue = 0.0;
3640 for(Int_t k = 0; k < counter[0]; k++){
3641 histoErrorCharge0->Fill(yValuesDelta[k]);
3642 if(k == 0) maxvalue = TMath::Abs(yValuesDelta[k]);
3643 if(maxvalue < (TMath::Abs(yValuesDelta[k]))) maxvalue = TMath::Abs(yValuesDelta[k]);
3644 }
3645 AliInfo(Form("The maximum deviation found dor the fit method is %f",maxvalue));
3646 legch2->AddEntry(histoErrorCharge0,"f_{g} fit","l");
3647 histoErrorCharge0->Draw();
3648 listofgraphs->Add((TObject *)histoErrorCharge0);
3649 thefirst =1;
3650 }
3651
3652 if(fFitMeanWOn){
3653 cch2->cd(2);
3654 Double_t *yValuesDelta = new Double_t[counter[3]];
3655 for(Int_t k = 0; k < counter[3]; k++){
3656 if (fCoefCharge[3][(Int_t)(xValuesFittedMeanW[k])] > 0.0) {
3657 yValuesDelta[k] = (fCoefCharge[4][(Int_t)xValuesFittedMeanW[k]]-fCoefCharge[3][(Int_t)xValuesFittedMeanW[k]])
3658 / fCoefCharge[3][(Int_t)xValuesFittedMeanW[k]];
3659 }
3660 else {
3661 yValuesDelta[k] = 0.0;
3662 }
3663 }
3664 TGraph *graphDeltaCharge4 = new TGraph(counter[3],&xValuesFittedMeanW[0],yValuesDelta);
3665 graphDeltaCharge4->SetName("deltacharge4");
3666 graphDeltaCharge4->GetXaxis()->SetTitle("Det/Pad groups");
3667 graphDeltaCharge4->GetYaxis()->SetTitle("#Deltag/g_{sim}");
3668 graphDeltaCharge4->SetMarkerColor(1);
3669 graphDeltaCharge4->SetTitle("");
3670 graphDeltaCharge4->SetLineColor(1);
3671 graphDeltaCharge4->SetMarkerStyle(30);
3672 listofgraphs->Add((TObject *)graphDeltaCharge4);
3673 legch3->AddEntry(graphDeltaCharge4,"Mean W","p");
3674 if(thefirst == 0){
3675 graphDeltaCharge4->Draw("AP");
3676 }
3677 else {
3678 graphDeltaCharge4->Draw("P");
3679 }
3680
3681 cch2->cd(1);
3682 TH1I *histoErrorCharge4 = new TH1I("errorcharge4","",100 ,-0.10,0.10);
3683 histoErrorCharge4->SetXTitle("#Deltag/g_{sim}");
3684 histoErrorCharge4->SetYTitle("counts");
3685 histoErrorCharge4->SetLineColor(1);
3686 histoErrorCharge4->SetLineStyle(1);
3687 histoErrorCharge4->SetStats(0);
3688 Double_t maxvalue = 0.0;
3689 for(Int_t k = 0; k < counter[3]; k++){
3690 histoErrorCharge4->Fill(yValuesDelta[k]);
3691 if(k == 0) maxvalue = yValuesDelta[k];
3692 if(maxvalue < (TMath::Abs(yValuesDelta[k]))) maxvalue = TMath::Abs(yValuesDelta[k]);
3693 }
3694 AliInfo(Form("The maximum deviation found for the meanW method is %f",maxvalue));
3695 legch2->AddEntry(histoErrorCharge4,"f_{g} Mean W","l");
3696 if(thefirst == 0){
3697 histoErrorCharge4->Draw();
3698 }
3699 else {
3700 histoErrorCharge4->Draw("same");
3701 }
3702 listofgraphs->Add((TObject *)histoErrorCharge4);
3703 thefirst =1;
3704 }
3705
3706 if (fMeanChargeOn) {
3707 cch2->cd(2);
3708 Double_t *yValuesDeltaMean = new Double_t[counter[1]];
3709 for (Int_t k = 0; k < counter[1]; k++){
3710 if (fCoefCharge[3][(Int_t)xValuesFittedMean[k]] > 0.0) {
3711 yValuesDeltaMean[k] = (fCoefCharge[1][(Int_t)xValuesFittedMean[k]]-fCoefCharge[3][(Int_t)xValuesFittedMean[k]])
3712 / fCoefCharge[3][(Int_t)xValuesFittedMean[k]];
3713 }
3714 else {
3715 yValuesDeltaMean[k] = 0.0;
3716 }
3717 }
3718 TGraph *graphDeltaCharge1 = new TGraph(counter[1],&xValuesFittedMean[0],yValuesDeltaMean);
3719 graphDeltaCharge1->SetName("deltacharge1");
3720 graphDeltaCharge1->GetXaxis()->SetTitle("Det/Pad groups");
3721 graphDeltaCharge1->GetYaxis()->SetTitle("#Deltag/g_{sim}");
3722 graphDeltaCharge1->SetMarkerColor(2);
3723 graphDeltaCharge1->SetMarkerStyle(24);
3724 graphDeltaCharge1->SetLineColor(2);
3725 graphDeltaCharge1->SetTitle("");
3726 legch3->AddEntry(graphDeltaCharge1,"mean","p");
3727 if(thefirst == 0){
3728 graphDeltaCharge1->Draw("AP");
3729 }
3730 else {
3731 graphDeltaCharge1->Draw("P");
3732 }
3733 listofgraphs->Add((TObject *)graphDeltaCharge1);
3734
3735 cch2->cd(1);
3736 TH1I *histoErrorCharge1 = new TH1I("errorcharge1","",100 ,-0.10,0.10);
3737 histoErrorCharge1->SetXTitle("#Deltag/g_{sim}");
3738 histoErrorCharge1->SetYTitle("counts");
3739 histoErrorCharge1->SetLineColor(2);
3740 histoErrorCharge1->SetLineStyle(2);
3741 histoErrorCharge1->SetStats(0);
3742 Double_t maxvalue = 0.0;
3743 for(Int_t k = 0; k < counter[1]; k++){
3744 histoErrorCharge1->Fill(yValuesDeltaMean[k]);
3745 if(k == 0) maxvalue = TMath::Abs(yValuesDeltaMean[k]);
3746 if(maxvalue < (TMath::Abs(yValuesDeltaMean[k]))) maxvalue = TMath::Abs(yValuesDeltaMean[k]);
3747 }
3748 AliInfo(Form("The maximum deviation found for the mean method is %f",maxvalue));
3749 legch2->AddEntry(histoErrorCharge1,"f_{g} mean","l");
3750 if(thefirst == 0){
3751 histoErrorCharge1->Draw();
3752 }
3753 else {
3754 histoErrorCharge1->Draw("same");
3755 }
3756 listofgraphs->Add((TObject *)histoErrorCharge1);
3757 thefirst = 1;
3758 }
3759
3760 if (fFitChargeBisOn) {
3761 cch2->cd(2);
3762 Double_t *yValuesDeltaBis = new Double_t[counter[2]];
3763 for(Int_t k = 0; k < counter[2]; k++){
3764 if (fCoefCharge[3][(Int_t)xValuesFittedBis[k]] > 0.0) {
3765 yValuesDeltaBis[k] = (fCoefCharge[2][(Int_t)xValuesFittedBis[k]]-fCoefCharge[3][(Int_t)xValuesFittedBis[k]])
3766 / fCoefCharge[3][(Int_t)xValuesFittedBis[k]];
3767 }
3768 else {
3769 yValuesDeltaBis[k] = 0.0;
3770 }
3771 }
3772 TGraph *graphDeltaCharge2 = new TGraph(counter[2],&xValuesFittedBis[0],yValuesDeltaBis);
3773 graphDeltaCharge2->SetName("deltacharge2");
3774 graphDeltaCharge2->GetXaxis()->SetTitle("Det/Pad groups");
3775 graphDeltaCharge2->GetYaxis()->SetTitle("#Deltag/g_{sim}");
3776 graphDeltaCharge2->SetMarkerColor(8);
3777 graphDeltaCharge2->SetLineColor(8);
3778 graphDeltaCharge2->SetMarkerStyle(25);
3779 legch3->AddEntry(graphDeltaCharge2,"fit","p");
3780 graphDeltaCharge2->SetTitle("");
3781 if(thefirst == 0){
3782 graphDeltaCharge2->Draw("AP");
3783 }
3784 else {
3785 graphDeltaCharge2->Draw("P");
3786 }
3787 listofgraphs->Add((TObject *)graphDeltaCharge2);
3788
3789 cch2->cd(1);
3790 TH1I *histoErrorCharge2 = new TH1I("errorcharge2","",100 ,-0.10, 0.10);
3791 histoErrorCharge2->SetXTitle("#Deltag/g_{sim}");
3792 histoErrorCharge2->SetYTitle("counts");
3793 histoErrorCharge2->SetLineColor(8);
3794 histoErrorCharge2->SetLineStyle(5);
3795 histoErrorCharge2->SetLineWidth(3);
3796 histoErrorCharge2->SetStats(0);
3797 Double_t maxvalue = 0.0;
3798 for(Int_t k = 0; k < counter[2]; k++){
3799 histoErrorCharge2->Fill(yValuesDeltaBis[k]);
3800 if(k == 0) maxvalue = TMath::Abs(yValuesDeltaBis[k]);
3801 if(maxvalue < (TMath::Abs(yValuesDeltaBis[k]))) maxvalue = TMath::Abs(yValuesDeltaBis[k]);
3802 }
3803 AliInfo(Form("The maximum deviation found for the fit bis method is %f",maxvalue));
3804 legch2->AddEntry(histoErrorCharge2,"f_{g} fitbis","l");
3805 if(thefirst == 0){
3806 histoErrorCharge2->Draw();
3807 }
3808 else {
3809 histoErrorCharge2->Draw("same");
3810 }
3811 listofgraphs->Add((TObject *)histoErrorCharge2);
3812 //it doesn't matter anymore but...
3813 thefirst = 1;
3814 }
3815
3816 cch2->cd(2);
3817 legch3->Draw("same");
3818 cch2->cd(1);
3819 legch2->Draw("same");
3820
3821 //Write if wanted
3822 if (fWriteCoef[0]){
3823 TFile *fout = TFile::Open(fWriteNameCoef,"UPDATE");
3824 // Check if the file could be opened
3825 if (!fout || !fout->IsOpen()) {