Coverity fix
[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
64942b85 31// _fDebug = 1: only the fit of the choosen calibration group fFitVoir (SetFitVoir)
32// _fDebug = 2: a comparaison of the coefficients found and the default values
55a288e5 33// in the choosen database.
34// fCoef , histogram of the coefs as function of the calibration group number
35// fDelta , histogram of the relative difference of the coef with the default
36// value in the database as function of the calibration group number
37// fError , dirstribution of this relative difference
55a288e5 38// _fDebug = 3: The coefficients in the choosen detector fDet (SetDet) as function of the
39// pad row and col number
40// _fDebug = 4; The coeffcicients in the choosen detector fDet (SetDet) like in the 3 but with
41// also the comparaison histograms of the 1 for this detector
42//
43//
44// Author:
45// R. Bailhache (R.Bailhache@gsi.de)
46//
47//////////////////////////////////////////////////////////////////////////////////////
48
55a288e5 49#include <TLine.h>
50#include <TH1I.h>
51#include <TStyle.h>
52#include <TProfile2D.h>
55a288e5 53#include <TCanvas.h>
54#include <TGraphErrors.h>
55a288e5 55#include <TObjArray.h>
56#include <TH1.h>
57#include <TH1F.h>
58#include <TF1.h>
55a288e5 59#include <TAxis.h>
55a288e5 60#include <TMath.h>
55a288e5 61#include <TDirectory.h>
3a0f6479 62#include <TTreeStream.h>
63#include <TLinearFitter.h>
64#include <TVectorD.h>
daa7dc79 65#include <TROOT.h>
4c865c34 66#include <TString.h>
595cfc12 67#include <TLine.h>
55a288e5 68
69#include "AliLog.h"
3a0f6479 70#include "AliMathBase.h"
55a288e5 71
72#include "AliTRDCalibraFit.h"
73#include "AliTRDCalibraMode.h"
74#include "AliTRDCalibraVector.h"
3a0f6479 75#include "AliTRDCalibraVdriftLinearFit.h"
a0bb5615 76#include "AliTRDCalibraExbAltFit.h"
55a288e5 77#include "AliTRDcalibDB.h"
78#include "AliTRDgeometry.h"
3a0f6479 79#include "AliTRDpadPlane.h"
80#include "AliTRDgeometry.h"
a076fc2f 81#include "AliTRDCommonParam.h"
55a288e5 82#include "./Cal/AliTRDCalROC.h"
83#include "./Cal/AliTRDCalPad.h"
84#include "./Cal/AliTRDCalDet.h"
85
86
87ClassImp(AliTRDCalibraFit)
88
89AliTRDCalibraFit* AliTRDCalibraFit::fgInstance = 0;
90Bool_t AliTRDCalibraFit::fgTerminated = kFALSE;
91
92//_____________singleton implementation_________________________________________________
93AliTRDCalibraFit *AliTRDCalibraFit::Instance()
94{
95 //
96 // Singleton implementation
97 //
98
99 if (fgTerminated != kFALSE) {
100 return 0;
101 }
102
103 if (fgInstance == 0) {
104 fgInstance = new AliTRDCalibraFit();
105 }
106
107 return fgInstance;
108
109}
55a288e5 110//______________________________________________________________________________________
111void AliTRDCalibraFit::Terminate()
112{
113 //
114 // Singleton implementation
115 // Deletes the instance of this class
116 //
117
118 fgTerminated = kTRUE;
119
120 if (fgInstance != 0) {
121 delete fgInstance;
122 fgInstance = 0;
123 }
124
125}
55a288e5 126//______________________________________________________________________________________
127AliTRDCalibraFit::AliTRDCalibraFit()
128 :TObject()
f162af62 129 ,fGeo(0)
3a0f6479 130 ,fNumberOfBinsExpected(0)
131 ,fMethod(0)
132 ,fBeginFitCharge(3.5)
595cfc12 133 ,fOutliersFitChargeLow(0.03)
134 ,fOutliersFitChargeHigh(0.80)
3a0f6479 135 ,fFitPHPeriode(1)
413153cb 136 ,fTakeTheMaxPH(kTRUE)
137 ,fT0Shift0(0.124797)
138 ,fT0Shift1(0.267451)
3a0f6479 139 ,fRangeFitPRF(1.0)
55a288e5 140 ,fAccCDB(kFALSE)
3a0f6479 141 ,fMinEntries(800)
142 ,fRebin(1)
54f2ff1c 143 ,fScaleGain(0.02431)
55a288e5 144 ,fNumberFit(0)
145 ,fNumberFitSuccess(0)
146 ,fNumberEnt(0)
147 ,fStatisticMean(0.0)
3a0f6479 148 ,fDebugStreamer(0x0)
149 ,fDebugLevel(0)
55a288e5 150 ,fFitVoir(0)
3a0f6479 151 ,fMagneticField(0.5)
152 ,fCalibraMode(new AliTRDCalibraMode())
153 ,fCurrentCoefE(0.0)
154 ,fCurrentCoefE2(0.0)
155 ,fDect1(0)
156 ,fDect2(0)
55a288e5 157 ,fScaleFitFactor(0.0)
158 ,fEntriesCurrent(0)
3a0f6479 159 ,fCountDet(0)
160 ,fCount(0)
64942b85 161 ,fNbDet(0)
3a0f6479 162 ,fCalDet(0x0)
163 ,fCalROC(0x0)
164 ,fCalDet2(0x0)
165 ,fCalROC2(0x0)
840ec79d 166 ,fCalDetVdriftUsed(0x0)
167 ,fCalDetExBUsed(0x0)
3a0f6479 168 ,fCurrentCoefDetector(0x0)
169 ,fCurrentCoefDetector2(0x0)
170 ,fVectorFit(0)
171 ,fVectorFit2(0)
55a288e5 172{
173 //
174 // Default constructor
175 //
176
3a0f6479 177 fGeo = new AliTRDgeometry();
178
179 // Current variables initialised
180 for (Int_t k = 0; k < 2; k++) {
181 fCurrentCoef[k] = 0.0;
182 fCurrentCoef2[k] = 0.0;
55a288e5 183 }
55a288e5 184 for (Int_t i = 0; i < 3; i++) {
3a0f6479 185 fPhd[i] = 0.0;
186 fDet[i] = 0;
55a288e5 187 }
3a0f6479 188
55a288e5 189}
55a288e5 190//______________________________________________________________________________________
191AliTRDCalibraFit::AliTRDCalibraFit(const AliTRDCalibraFit &c)
3a0f6479 192:TObject(c)
193,fGeo(0)
194,fNumberOfBinsExpected(c.fNumberOfBinsExpected)
195,fMethod(c.fMethod)
196,fBeginFitCharge(c.fBeginFitCharge)
595cfc12 197,fOutliersFitChargeLow(c.fOutliersFitChargeLow)
198,fOutliersFitChargeHigh(c.fOutliersFitChargeHigh)
3a0f6479 199,fFitPHPeriode(c.fFitPHPeriode)
200,fTakeTheMaxPH(c.fTakeTheMaxPH)
413153cb 201,fT0Shift0(c.fT0Shift0)
202,fT0Shift1(c.fT0Shift1)
3a0f6479 203,fRangeFitPRF(c.fRangeFitPRF)
204,fAccCDB(c.fAccCDB)
205,fMinEntries(c.fMinEntries)
206,fRebin(c.fRebin)
54f2ff1c 207,fScaleGain(c.fScaleGain)
3a0f6479 208,fNumberFit(c.fNumberFit)
209,fNumberFitSuccess(c.fNumberFitSuccess)
210,fNumberEnt(c.fNumberEnt)
211,fStatisticMean(c.fStatisticMean)
212,fDebugStreamer(0x0)
213,fDebugLevel(c.fDebugLevel)
214,fFitVoir(c.fFitVoir)
215,fMagneticField(c.fMagneticField)
216,fCalibraMode(0x0)
217,fCurrentCoefE(c.fCurrentCoefE)
218,fCurrentCoefE2(c.fCurrentCoefE2)
219,fDect1(c.fDect1)
220,fDect2(c.fDect2)
221,fScaleFitFactor(c.fScaleFitFactor)
222,fEntriesCurrent(c.fEntriesCurrent)
223,fCountDet(c.fCountDet)
224,fCount(c.fCount)
64942b85 225,fNbDet(c.fNbDet)
3a0f6479 226,fCalDet(0x0)
227,fCalROC(0x0)
228,fCalDet2(0x0)
229,fCalROC2(0x0)
840ec79d 230,fCalDetVdriftUsed(0x0)
231,fCalDetExBUsed(0x0)
3a0f6479 232,fCurrentCoefDetector(0x0)
233,fCurrentCoefDetector2(0x0)
234,fVectorFit(0)
235,fVectorFit2(0)
55a288e5 236{
237 //
238 // Copy constructor
239 //
240
3a0f6479 241 if(c.fCalibraMode) fCalibraMode = new AliTRDCalibraMode(*c.fCalibraMode);
242
243 //Current variables initialised
244 for (Int_t k = 0; k < 2; k++) {
245 fCurrentCoef[k] = 0.0;
246 fCurrentCoef2[k] = 0.0;
247 }
248 for (Int_t i = 0; i < 3; i++) {
249 fPhd[i] = 0.0;
250 fDet[i] = 0;
251 }
252 if(c.fCalDet) fCalDet = new AliTRDCalDet(*c.fCalDet);
253 if(c.fCalDet2) fCalDet2 = new AliTRDCalDet(*c.fCalDet2);
64942b85 254
3a0f6479 255 if(c.fCalROC) fCalROC = new AliTRDCalROC(*c.fCalROC);
256 if(c.fCalROC2) fCalROC = new AliTRDCalROC(*c.fCalROC2);
257
840ec79d 258 if(c.fCalDetVdriftUsed) fCalDetVdriftUsed = new AliTRDCalDet(*c.fCalDetVdriftUsed);
259 if(c.fCalDetExBUsed) fCalDetExBUsed = new AliTRDCalDet(*c.fCalDetExBUsed);
260
3a0f6479 261 fVectorFit.SetName(c.fVectorFit.GetName());
262 for(Int_t k = 0; k < c.fVectorFit.GetEntriesFast(); k++){
263 AliTRDFitInfo *fitInfo = new AliTRDFitInfo();
264 Int_t detector = ((AliTRDFitInfo *)c.fVectorFit.UncheckedAt(k))->GetDetector();
265 Int_t ntotal = 1;
053767a4 266 if (GetStack(detector) == 2) {
3a0f6479 267 ntotal = 1728;
268 }
269 else {
270 ntotal = 2304;
271 }
272 Float_t *coef = new Float_t[ntotal];
273 for (Int_t i = 0; i < ntotal; i++) {
274 coef[i] = ((AliTRDFitInfo *)c.fVectorFit.UncheckedAt(k))->GetCoef()[i];
275 }
276 fitInfo->SetCoef(coef);
277 fitInfo->SetDetector(detector);
278 fVectorFit.Add((TObject *) fitInfo);
279 }
280 fVectorFit.SetName(c.fVectorFit.GetName());
281 for(Int_t k = 0; k < c.fVectorFit2.GetEntriesFast(); k++){
282 AliTRDFitInfo *fitInfo = new AliTRDFitInfo();
283 Int_t detector = ((AliTRDFitInfo *)c.fVectorFit2.UncheckedAt(k))->GetDetector();
284 Int_t ntotal = 1;
053767a4 285 if (GetStack(detector) == 2) {
3a0f6479 286 ntotal = 1728;
287 }
288 else {
289 ntotal = 2304;
290 }
291 Float_t *coef = new Float_t[ntotal];
292 for (Int_t i = 0; i < ntotal; i++) {
293 coef[i] = ((AliTRDFitInfo *)c.fVectorFit2.UncheckedAt(k))->GetCoef()[i];
294 }
295 fitInfo->SetCoef(coef);
296 fitInfo->SetDetector(detector);
297 fVectorFit2.Add((TObject *) fitInfo);
298 }
299 if (fGeo) {
300 delete fGeo;
301 }
302 fGeo = new AliTRDgeometry();
55a288e5 303
3a0f6479 304}
55a288e5 305//____________________________________________________________________________________
306AliTRDCalibraFit::~AliTRDCalibraFit()
307{
308 //
309 // AliTRDCalibraFit destructor
310 //
3a0f6479 311 if ( fDebugStreamer ) delete fDebugStreamer;
312 if ( fCalDet ) delete fCalDet;
313 if ( fCalDet2 ) delete fCalDet2;
314 if ( fCalROC ) delete fCalROC;
1ca79a00 315 if ( fCalROC2 ) delete fCalROC2;
840ec79d 316 if ( fCalDetVdriftUsed) delete fCalDetVdriftUsed;
317 if ( fCalDetExBUsed) delete fCalDetExBUsed;
1ca79a00 318 if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
319 if( fCurrentCoefDetector2 ) delete [] fCurrentCoefDetector2;
3a0f6479 320 fVectorFit.Delete();
321 fVectorFit2.Delete();
f162af62 322 if (fGeo) {
323 delete fGeo;
324 }
325
55a288e5 326}
55a288e5 327//_____________________________________________________________________________
328void AliTRDCalibraFit::Destroy()
329{
330 //
331 // Delete instance
332 //
333
334 if (fgInstance) {
335 delete fgInstance;
336 fgInstance = 0x0;
337 }
338
339}
64942b85 340//_____________________________________________________________________________
341void AliTRDCalibraFit::DestroyDebugStreamer()
342{
343 //
344 // Delete DebugStreamer
345 //
346
347 if ( fDebugStreamer ) delete fDebugStreamer;
348 fDebugStreamer = 0x0;
349
350}
55a288e5 351//____________Functions fit Online CH2d________________________________________
979b168f 352Bool_t AliTRDCalibraFit::AnalyseCH(const TH2I *ch)
55a288e5 353{
354 //
355 // Fit the 1D histos, projections of the 2D ch on the Xaxis, for each
356 // calibration group normalized the resulted coefficients (to 1 normally)
55a288e5 357 //
358
3a0f6479 359 // Set the calibration mode
4c865c34 360 //const char *name = ch->GetTitle();
361 TString name = ch->GetTitle();
64942b85 362 if(!SetModeCalibration(name,0)) return kFALSE;
3a0f6479 363
364 // Number of Ybins (detectors or groups of pads)
365 Int_t nbins = ch->GetNbinsX();// charge
366 Int_t nybins = ch->GetNbinsY();// groups number
367 if (!InitFit(nybins,0)) {
55a288e5 368 return kFALSE;
369 }
3a0f6479 370 if (!InitFitCH()) {
55a288e5 371 return kFALSE;
372 }
373 fStatisticMean = 0.0;
374 fNumberFit = 0;
375 fNumberFitSuccess = 0;
376 fNumberEnt = 0;
55a288e5 377 // Init fCountDet and fCount
378 InitfCountDetAndfCount(0);
55a288e5 379 // Beginning of the loop betwwen dect1 and dect2
3a0f6479 380 for (Int_t idect = fDect1; idect < fDect2; idect++) {
381 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi...
55a288e5 382 UpdatefCountDetAndfCount(idect,0);
55a288e5 383 ReconstructFitRowMinRowMax(idect, 0);
3a0f6479 384 // Take the histo
385 TH1I *projch = (TH1I *) ch->ProjectionX("projch",idect+1,idect+1,(Option_t *)"e");
386 projch->SetDirectory(0);
55a288e5 387 // Number of entries for this calibration group
388 Double_t nentries = 0.0;
389 Double_t mean = 0.0;
3a0f6479 390 for (Int_t k = 0; k < nbins; k++) {
391 Int_t binnb = (nbins+2)*(idect+1)+(k+1);
392 nentries += ch->GetBinContent(binnb);
55a288e5 393 mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1);
3a0f6479 394 projch->SetBinError(k+1,TMath::Sqrt(projch->GetBinContent(k+1)));
55a288e5 395 }
3a0f6479 396 projch->SetEntries(nentries);
397 //printf("The number of entries for the group %d is %f\n",idect,nentries);
55a288e5 398 if (nentries > 0) {
399 fNumberEnt++;
400 mean /= nentries;
401 }
55a288e5 402 // Rebin and statistic stuff
55a288e5 403 if (fRebin > 1) {
404 projch = ReBin((TH1I *) projch);
405 }
406 // This detector has not enough statistics or was off
3a0f6479 407 if (nentries <= fMinEntries) {
408 NotEnoughStatisticCH(idect);
409 if (fDebugLevel != 1) {
55a288e5 410 delete projch;
411 }
412 continue;
413 }
55a288e5 414 // Statistics of the group fitted
55a288e5 415 fStatisticMean += nentries;
416 fNumberFit++;
3a0f6479 417 //Method choosen
418 switch(fMethod)
419 {
420 case 0: FitMeanW((TH1 *) projch, nentries); break;
421 case 1: FitMean((TH1 *) projch, nentries, mean); break;
595cfc12 422 case 2: FitLandau((TH1 *) projch, mean, nentries); break;
423 case 3: FitCH((TH1 *) projch, mean, nentries); break;
424 case 4: FitBisCH((TH1 *) projch, mean, nentries); break;
425 case 5: FitBisCHEx((TH1 *) projch, mean, nentries); break;
3a0f6479 426 default: return kFALSE;
427 }
55a288e5 428 // Fill Infos Fit
3a0f6479 429 FillInfosFitCH(idect);
55a288e5 430 // Memory!!!
3a0f6479 431 if (fDebugLevel != 1) {
55a288e5 432 delete projch;
433 }
55a288e5 434 } // Boucle object
55a288e5 435 // Normierungcharge
3a0f6479 436 if (fDebugLevel != 1) {
55a288e5 437 NormierungCharge();
438 }
55a288e5 439 // Mean Statistic
440 if (fNumberFit > 0) {
6245a86f 441 AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %f over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Double_t) (fStatisticMean/fNumberFit), fNumberFitSuccess));
55a288e5 442 fStatisticMean = fStatisticMean / fNumberFit;
443 }
444 else {
445 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
446 }
3a0f6479 447 delete fDebugStreamer;
448 fDebugStreamer = 0x0;
449
55a288e5 450 return kTRUE;
55a288e5 451}
55a288e5 452//____________Functions fit Online CH2d________________________________________
3a0f6479 453Bool_t AliTRDCalibraFit::AnalyseCH(AliTRDCalibraVector *calvect)
55a288e5 454{
455 //
456 // Reconstruct a 1D histo from the vectorCH for each calibration group,
457 // fit the histo, normalized the resulted coefficients (to 1 normally)
55a288e5 458 //
459
3a0f6479 460 // Set the calibraMode
4c865c34 461 //const char *name = calvect->GetNameCH();
462 TString name = calvect->GetNameCH();
64942b85 463 if(!SetModeCalibration(name,0)) return kFALSE;
55a288e5 464
3a0f6479 465 // Number of Xbins (detectors or groups of pads)
466 if (!InitFit((432*calvect->GetDetCha0(0)+108*calvect->GetDetCha2(0)),0)) {
55a288e5 467 return kFALSE;
468 }
3a0f6479 469 if (!InitFitCH()) {
55a288e5 470 return kFALSE;
471 }
472 fStatisticMean = 0.0;
473 fNumberFit = 0;
474 fNumberFitSuccess = 0;
475 fNumberEnt = 0;
55a288e5 476 // Init fCountDet and fCount
477 InitfCountDetAndfCount(0);
55a288e5 478 // Beginning of the loop between dect1 and dect2
3a0f6479 479 for (Int_t idect = fDect1; idect < fDect2; idect++) {
480 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi...........
55a288e5 481 UpdatefCountDetAndfCount(idect,0);
55a288e5 482 ReconstructFitRowMinRowMax(idect,0);
3a0f6479 483 // Take the histo
55a288e5 484 Double_t nentries = 0.0;
485 Double_t mean = 0.0;
e526983e 486 if(!calvect->GetCHEntries(fCountDet)) {
487 NotEnoughStatisticCH(idect);
488 continue;
489 }
490
491 TString tname("CH");
492 tname += idect;
493 TH1F *projch = calvect->ConvertVectorCHHisto(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0)))),(const char *) tname);
494 projch->SetDirectory(0);
495 for (Int_t k = 0; k < calvect->GetNumberBinCharge(); k++) {
496 nentries += projch->GetBinContent(k+1);
497 mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1);
498 }
499 if (nentries > 0) {
500 fNumberEnt++;
501 mean /= nentries;
502 }
503 //printf("The number of entries for the group %d is %f\n",idect,nentries);
504 // Rebin
505 if (fRebin > 1) {
506 projch = ReBin((TH1F *) projch);
55a288e5 507 }
55a288e5 508 // This detector has not enough statistics or was not found in VectorCH
3a0f6479 509 if (nentries <= fMinEntries) {
510 NotEnoughStatisticCH(idect);
55a288e5 511 continue;
55a288e5 512 }
55a288e5 513 // Statistic of the histos fitted
55a288e5 514 fStatisticMean += nentries;
515 fNumberFit++;
3a0f6479 516 //Method choosen
517 switch(fMethod)
518 {
519 case 0: FitMeanW((TH1 *) projch, nentries); break;
520 case 1: FitMean((TH1 *) projch, nentries, mean); break;
595cfc12 521 case 2: FitLandau((TH1 *) projch, mean, nentries); break;
522 case 3: FitCH((TH1 *) projch, mean, nentries); break;
523 case 4: FitBisCH((TH1 *) projch, mean, nentries); break;
524 case 5: FitBisCHEx((TH1 *) projch, mean, nentries); break;
3a0f6479 525 default: return kFALSE;
526 }
55a288e5 527 // Fill Infos Fit
3a0f6479 528 FillInfosFitCH(idect);
55a288e5 529 } // Boucle object
55a288e5 530 // Normierungcharge
3a0f6479 531 if (fDebugLevel != 1) {
55a288e5 532 NormierungCharge();
533 }
55a288e5 534 // Mean Statistics
535 if (fNumberFit > 0) {
6245a86f 536 AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %f over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Double_t) (fStatisticMean/fNumberFit), fNumberFitSuccess));
55a288e5 537 fStatisticMean = fStatisticMean / fNumberFit;
538 }
539 else {
540 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
541 }
3a0f6479 542 delete fDebugStreamer;
543 fDebugStreamer = 0x0;
55a288e5 544 return kTRUE;
55a288e5 545}
54f2ff1c 546//____________Functions fit Online CH2d________________________________________
547Double_t AliTRDCalibraFit::AnalyseCHAllTogether(const TH2I *ch)
548{
549 //
550 // Fit the 1D histos, projections of the 2D ch on the Xaxis, for each
551 // calibration group normalized the resulted coefficients (to 1 normally)
552 //
553 Int_t nbins = ch->GetNbinsX();// charge
554 Int_t nybins = ch->GetNbinsY();// groups number
555 // Take the histo
556 TH1I *projch = (TH1I *) ch->ProjectionX("projch",1,nybins+1,(Option_t *)"e");
557 projch->SetDirectory(0);
558 // Number of entries for this calibration group
559 Double_t nentries = 0.0;
560 Double_t mean = 0.0;
561 for (Int_t k = 0; k < nbins; k++) {
562 nentries += projch->GetBinContent(k+1);
563 mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1);
564 projch->SetBinError(k+1,TMath::Sqrt(projch->GetBinContent(k+1)));
565 }
566 projch->SetEntries(nentries);
567 //printf("The number of entries for the group %d is %f\n",idect,nentries);
568 if (nentries > 0) {
54f2ff1c 569 mean /= nentries;
570 }
571 // This detector has not enough statistics or was off
572 if (nentries <= fMinEntries) {
573 delete projch;
574 AliInfo(Form("There are %d entries for all together, it is not enough (%d)",(Int_t) nentries, fMinEntries));
575 return -100.0;
576 }
577 //Method choosen
578 switch(fMethod)
579 {
580 case 0: FitMeanW((TH1 *) projch, nentries); break;
581 case 1: FitMean((TH1 *) projch, nentries, mean); break;
595cfc12 582 case 2: FitLandau((TH1 *) projch, mean, nentries); break;
583 case 3: FitCH((TH1 *) projch, mean, nentries); break;
584 case 4: FitBisCH((TH1 *) projch, mean, nentries); break;
585 case 5: FitBisCHEx((TH1 *) projch, mean, nentries); break;
b88b6bcc 586 default: return -100.0;
54f2ff1c 587 }
588 delete fDebugStreamer;
589 fDebugStreamer = 0x0;
590
591 if(fCurrentCoef[0] > 0.0) return fCurrentCoef[0];
592 else return -100.0;
593
594}
55a288e5 595//________________functions fit Online PH2d____________________________________
b88b6bcc 596Double_t AliTRDCalibraFit::AnalysePHAllTogether(const TProfile2D *ph)
55a288e5 597{
598 //
599 // Take the 1D profiles (average pulse height), projections of the 2D PH
600 // on the Xaxis, for each calibration group
3a0f6479 601 // Reconstruct a drift velocity
602 // A first calibration of T0 is also made using the same method
55a288e5 603 //
604
55a288e5 605 // Number of Xbins (detectors or groups of pads)
3a0f6479 606 Int_t nbins = ph->GetNbinsX();// time
607 Int_t nybins = ph->GetNbinsY();// calibration group
b88b6bcc 608
609 // Take the histo
610 TH1D *projph = (TH1D *) ph->ProjectionX("projph",1,nybins+1,(Option_t *) "e");
611 projph->SetDirectory(0);
612 // Number of entries for this calibration group
613 Double_t nentries = 0;
614 for(Int_t idect = 0; idect < nybins; idect++){
615 for (Int_t k = 0; k < nbins; k++) {
616 Int_t binnb = (nbins+2)*(idect+1)+(k+1);
617 nentries += ph->GetBinEntries(binnb);
618 }
3a0f6479 619 }
b88b6bcc 620 //printf("AnalysePHAllTogether:: the number of entries is %f\n",nentries);
621 // This detector has not enough statistics or was off
622 if (nentries <= fMinEntries) {
623 AliInfo(Form("There are %d entries for all together, it is not enough (%d)",(Int_t) nentries, fMinEntries));
624 if (fDebugLevel != 1) {
625 delete projph;
626 }
627 return -100.0;
628 }
629 //Method choosen
630 //printf("Method\n");
631 switch(fMethod)
632 {
633 case 0: FitLagrangePoly((TH1 *) projph); break;
634 case 1: FitPente((TH1 *) projph); break;
635 case 2: FitPH((TH1 *) projph,0); break;
636 default: return -100.0;
637 }
638 // Memory!!!
639 if (fDebugLevel != 1) {
640 delete projph;
641 }
642 delete fDebugStreamer;
643 fDebugStreamer = 0x0;
644
645 if(fCurrentCoef[0] > 0.0) return fCurrentCoef[0];
646 else return -100.0;
647
648}
649//____________Functions fit Online PH2d________________________________________
650Bool_t AliTRDCalibraFit::AnalysePH(AliTRDCalibraVector *calvect)
651{
652 //
653 // Reconstruct the average pulse height from the vectorPH for each
654 // calibration group
655 // Reconstruct a drift velocity
656 // A first calibration of T0 is also made using the same method (slope method)
657 //
6aafa7ea 658
b88b6bcc 659 // Set the calibration mode
660 //const char *name = calvect->GetNamePH();
661 TString name = calvect->GetNamePH();
662 if(!SetModeCalibration(name,1)) return kFALSE;
6aafa7ea 663
b88b6bcc 664 // Number of Xbins (detectors or groups of pads)
665 if (!InitFit((432*calvect->GetDetCha0(1)+108*calvect->GetDetCha2(1)),1)) {
666 return kFALSE;
667 }
3a0f6479 668 if (!InitFitPH()) {
55a288e5 669 return kFALSE;
670 }
671 fStatisticMean = 0.0;
672 fNumberFit = 0;
673 fNumberFitSuccess = 0;
674 fNumberEnt = 0;
55a288e5 675 // Init fCountDet and fCount
676 InitfCountDetAndfCount(1);
55a288e5 677 // Beginning of the loop
3a0f6479 678 for (Int_t idect = fDect1; idect < fDect2; idect++) {
b88b6bcc 679 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi...........
3a0f6479 680 UpdatefCountDetAndfCount(idect,1);
681 ReconstructFitRowMinRowMax(idect,1);
682 // Take the histo
b88b6bcc 683 fEntriesCurrent = 0;
684 if(!calvect->GetPHEntries(fCountDet)) {
685 NotEnoughStatisticPH(idect,fEntriesCurrent);
686 continue;
55a288e5 687 }
b88b6bcc 688 TString tname("PH");
689 tname += idect;
690 TH1F *projph = calvect->CorrectTheError((TGraphErrors *) (calvect->ConvertVectorPHTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname)),fEntriesCurrent);
691 projph->SetDirectory(0);
692 if(fEntriesCurrent > 0) fNumberEnt++;
693 //printf("The number of entries for the group %d is %d\n",idect,fEntriesCurrent);
55a288e5 694 // This detector has not enough statistics or was off
b88b6bcc 695 if (fEntriesCurrent <= fMinEntries) {
696 //printf("Not enough stat!\n");
697 NotEnoughStatisticPH(idect,fEntriesCurrent);
55a288e5 698 continue;
55a288e5 699 }
b88b6bcc 700 // Statistic of the histos fitted
55a288e5 701 fNumberFit++;
b88b6bcc 702 fStatisticMean += fEntriesCurrent;
55a288e5 703 // Calcul of "real" coef
3a0f6479 704 CalculVdriftCoefMean();
705 CalculT0CoefMean();
706 //Method choosen
707 switch(fMethod)
708 {
709 case 0: FitLagrangePoly((TH1 *) projph); break;
710 case 1: FitPente((TH1 *) projph); break;
711 case 2: FitPH((TH1 *) projph,(Int_t) (idect - fDect1)); break;
712 default: return kFALSE;
713 }
55a288e5 714 // Fill the tree if end of a detector or only the pointer to the branch!!!
b88b6bcc 715 FillInfosFitPH(idect,fEntriesCurrent);
55a288e5 716 } // Boucle object
b88b6bcc 717
55a288e5 718 // Mean Statistic
719 if (fNumberFit > 0) {
6245a86f 720 AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %f over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Double_t) (fStatisticMean/fNumberFit),fNumberFitSuccess));
55a288e5 721 fStatisticMean = fStatisticMean / fNumberFit;
722 }
723 else {
724 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
725 }
3a0f6479 726 delete fDebugStreamer;
727 fDebugStreamer = 0x0;
55a288e5 728 return kTRUE;
55a288e5 729}
b88b6bcc 730//________________functions fit Online PH2d____________________________________
731Bool_t AliTRDCalibraFit::AnalysePH(const TProfile2D *ph)
55a288e5 732{
733 //
b88b6bcc 734 // Take the 1D profiles (average pulse height), projections of the 2D PH
735 // on the Xaxis, for each calibration group
3a0f6479 736 // Reconstruct a drift velocity
b88b6bcc 737 // A first calibration of T0 is also made using the same method
55a288e5 738 //
739
3a0f6479 740 // Set the calibration mode
b88b6bcc 741 //const char *name = ph->GetTitle();
742 TString name = ph->GetTitle();
64942b85 743 if(!SetModeCalibration(name,1)) return kFALSE;
b88b6bcc 744
745 //printf("Mode calibration set\n");
55a288e5 746
3a0f6479 747 // Number of Xbins (detectors or groups of pads)
b88b6bcc 748 Int_t nbins = ph->GetNbinsX();// time
749 Int_t nybins = ph->GetNbinsY();// calibration group
750 if (!InitFit(nybins,1)) {
55a288e5 751 return kFALSE;
752 }
b88b6bcc 753
754 //printf("Init fit\n");
755
3a0f6479 756 if (!InitFitPH()) {
55a288e5 757 return kFALSE;
758 }
b88b6bcc 759
760 //printf("Init fit PH\n");
761
55a288e5 762 fStatisticMean = 0.0;
763 fNumberFit = 0;
764 fNumberFitSuccess = 0;
765 fNumberEnt = 0;
55a288e5 766 // Init fCountDet and fCount
767 InitfCountDetAndfCount(1);
b88b6bcc 768 //printf("Init Count Det and fCount %d, %d\n",fDect1,fDect2);
769
55a288e5 770 // Beginning of the loop
3a0f6479 771 for (Int_t idect = fDect1; idect < fDect2; idect++) {
b88b6bcc 772 //printf("idect = %d\n",idect);
773 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi.......
55a288e5 774 UpdatefCountDetAndfCount(idect,1);
55a288e5 775 ReconstructFitRowMinRowMax(idect,1);
3a0f6479 776 // Take the histo
b88b6bcc 777 TH1D *projph = (TH1D *) ph->ProjectionX("projph",idect+1,idect+1,(Option_t *) "e");
778 projph->SetDirectory(0);
779 // Number of entries for this calibration group
780 Double_t nentries = 0;
781 for (Int_t k = 0; k < nbins; k++) {
782 Int_t binnb = (nbins+2)*(idect+1)+(k+1);
783 nentries += ph->GetBinEntries(binnb);
3a0f6479 784 }
b88b6bcc 785 if (nentries > 0) {
786 fNumberEnt++;
787 }
788 //printf("The number of entries for the group %d is %f\n",idect,nentries);
55a288e5 789 // This detector has not enough statistics or was off
b88b6bcc 790 if (nentries <= fMinEntries) {
791 //printf("Not enough statistic!\n");
792 NotEnoughStatisticPH(idect,nentries);
793 if (fDebugLevel != 1) {
794 delete projph;
795 }
55a288e5 796 continue;
55a288e5 797 }
b88b6bcc 798 // Statistics of the histos fitted
55a288e5 799 fNumberFit++;
b88b6bcc 800 fStatisticMean += nentries;
55a288e5 801 // Calcul of "real" coef
3a0f6479 802 CalculVdriftCoefMean();
803 CalculT0CoefMean();
804 //Method choosen
b88b6bcc 805 //printf("Method\n");
3a0f6479 806 switch(fMethod)
807 {
808 case 0: FitLagrangePoly((TH1 *) projph); break;
809 case 1: FitPente((TH1 *) projph); break;
810 case 2: FitPH((TH1 *) projph,(Int_t) (idect - fDect1)); break;
811 default: return kFALSE;
812 }
55a288e5 813 // Fill the tree if end of a detector or only the pointer to the branch!!!
b88b6bcc 814 FillInfosFitPH(idect,nentries);
815 // Memory!!!
816 if (fDebugLevel != 1) {
817 delete projph;
818 }
55a288e5 819 } // Boucle object
55a288e5 820 // Mean Statistic
821 if (fNumberFit > 0) {
6245a86f 822 AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %f over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Double_t) (fStatisticMean/fNumberFit),fNumberFitSuccess));
55a288e5 823 fStatisticMean = fStatisticMean / fNumberFit;
824 }
825 else {
826 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
827 }
3a0f6479 828 delete fDebugStreamer;
829 fDebugStreamer = 0x0;
55a288e5 830 return kTRUE;
55a288e5 831}
3a0f6479 832//____________Functions fit Online PRF2d_______________________________________
979b168f 833Bool_t AliTRDCalibraFit::AnalysePRF(const TProfile2D *prf)
55a288e5 834{
835 //
3a0f6479 836 // Take the 1D profiles (pad response function), projections of the 2D PRF
837 // on the Xaxis, for each calibration group
838 // Fit with a gaussian to reconstruct the sigma of the pad response function
55a288e5 839 //
3a0f6479 840
841 // Set the calibration mode
4c865c34 842 //const char *name = prf->GetTitle();
843 TString name = prf->GetTitle();
64942b85 844 if(!SetModeCalibration(name,2)) return kFALSE;
3a0f6479 845
846 // Number of Ybins (detectors or groups of pads)
847 Int_t nybins = prf->GetNbinsY();// calibration groups
848 Int_t nbins = prf->GetNbinsX();// bins
849 Int_t nbg = GetNumberOfGroupsPRF((const char *)prf->GetTitle());
850 if((nbg > 0) || (nbg == -1)) return kFALSE;
851 if (!InitFit(nybins,2)) {
55a288e5 852 return kFALSE;
853 }
3a0f6479 854 if (!InitFitPRF()) {
55a288e5 855 return kFALSE;
856 }
857 fStatisticMean = 0.0;
3a0f6479 858 fNumberFit = 0;
55a288e5 859 fNumberFitSuccess = 0;
860 fNumberEnt = 0;
55a288e5 861 // Init fCountDet and fCount
3a0f6479 862 InitfCountDetAndfCount(2);
55a288e5 863 // Beginning of the loop
3a0f6479 864 for (Int_t idect = fDect1; idect < fDect2; idect++) {
865 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi......
866 UpdatefCountDetAndfCount(idect,2);
867 ReconstructFitRowMinRowMax(idect,2);
868 // Take the histo
869 TH1D *projprf = (TH1D *) prf->ProjectionX("projprf",idect+1,idect+1,(Option_t *) "e");
870 projprf->SetDirectory(0);
871 // Number of entries for this calibration group
872 Double_t nentries = 0;
873 for (Int_t k = 0; k < nbins; k++) {
874 Int_t binnb = (nbins+2)*(idect+1)+(k+1);
875 nentries += prf->GetBinEntries(binnb);
55a288e5 876 }
3a0f6479 877 if(nentries > 0) fNumberEnt++;
55a288e5 878 // This detector has not enough statistics or was off
3a0f6479 879 if (nentries <= fMinEntries) {
880 NotEnoughStatisticPRF(idect);
881 if (fDebugLevel != 1) {
882 delete projprf;
55a288e5 883 }
55a288e5 884 continue;
55a288e5 885 }
55a288e5 886 // Statistics of the histos fitted
55a288e5 887 fNumberFit++;
3a0f6479 888 fStatisticMean += nentries;
55a288e5 889 // Calcul of "real" coef
3a0f6479 890 CalculPRFCoefMean();
891 //Method choosen
892 switch(fMethod)
893 {
894 case 0: FitPRF((TH1 *) projprf); break;
895 case 1: RmsPRF((TH1 *) projprf); break;
896 default: return kFALSE;
897 }
55a288e5 898 // Fill the tree if end of a detector or only the pointer to the branch!!!
3a0f6479 899 FillInfosFitPRF(idect);
55a288e5 900 // Memory!!!
3a0f6479 901 if (fDebugLevel != 1) {
902 delete projprf;
55a288e5 903 }
55a288e5 904 } // Boucle object
3a0f6479 905 // Mean Statistic
55a288e5 906 if (fNumberFit > 0) {
907 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
908 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
6245a86f 909 AliInfo(Form("There is a mean statistic of: %f over these fitted histograms and %d successfulled fits"
910 ,(Double_t) (fStatisticMean/fNumberFit),fNumberFitSuccess));
55a288e5 911 fStatisticMean = fStatisticMean / fNumberFit;
912 }
913 else {
914 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
915 }
3a0f6479 916 delete fDebugStreamer;
917 fDebugStreamer = 0x0;
55a288e5 918 return kTRUE;
55a288e5 919}
55a288e5 920//____________Functions fit Online PRF2d_______________________________________
979b168f 921Bool_t AliTRDCalibraFit::AnalysePRFMarianFit(const TProfile2D *prf)
55a288e5 922{
923 //
924 // Take the 1D profiles (pad response function), projections of the 2D PRF
925 // on the Xaxis, for each calibration group
926 // Fit with a gaussian to reconstruct the sigma of the pad response function
55a288e5 927 //
928
3a0f6479 929 // Set the calibration mode
4c865c34 930 //const char *name = prf->GetTitle();
931 TString name = prf->GetTitle();
64942b85 932 if(!SetModeCalibration(name,2)) return kFALSE;
55a288e5 933
3a0f6479 934 // Number of Ybins (detectors or groups of pads)
55a288e5 935 TAxis *xprf = prf->GetXaxis();
936 TAxis *yprf = prf->GetYaxis();
3a0f6479 937 Int_t nybins = yprf->GetNbins();// calibration groups
938 Int_t nbins = xprf->GetNbins();// bins
939 Float_t lowedge = (Float_t) xprf->GetBinLowEdge(1);//lowedge in bins
940 Float_t upedge = (Float_t) xprf->GetBinUpEdge(nbins);//upedge in bins
941 Int_t nbg = GetNumberOfGroupsPRF((const char *)name);
942 if(nbg == -1) return kFALSE;
943 if(nbg > 0) fMethod = 1;
944 else fMethod = 0;
945 if (!InitFit(nybins,2)) {
946 return kFALSE;
947 }
948 if (!InitFitPRF()) {
55a288e5 949 return kFALSE;
950 }
951 fStatisticMean = 0.0;
952 fNumberFit = 0;
953 fNumberFitSuccess = 0;
954 fNumberEnt = 0;
55a288e5 955 // Init fCountDet and fCount
956 InitfCountDetAndfCount(2);
55a288e5 957 // Beginning of the loop
3a0f6479 958 for (Int_t idect = fDect1; idect < fDect2; idect++) {
959 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi.......
960 UpdatefCountDetAndfCount(idect,2);
961 ReconstructFitRowMinRowMax(idect,2);
962 // Build the array of entries and sum
963 TArrayD arraye = TArrayD(nbins);
964 TArrayD arraym = TArrayD(nbins);
965 TArrayD arrayme = TArrayD(nbins);
55a288e5 966 Double_t nentries = 0;
3a0f6479 967 //printf("nbins %d\n",nbins);
968 for (Int_t k = 0; k < nbins; k++) {
969 Int_t binnb = (nbins+2)*(idect+1)+(k+1);
970 Double_t entries = (Double_t)prf->GetBinEntries(binnb);
971 Double_t mean = (Double_t)prf->GetBinContent(binnb);
972 Double_t error = (Double_t)prf->GetBinError(binnb);
973 //printf("for %d we have %f\n",k,entries);
974 nentries += entries;
975 arraye.AddAt(entries,k);
976 arraym.AddAt(mean,k);
977 arrayme.AddAt(error,k);
55a288e5 978 }
979 if(nentries > 0) fNumberEnt++;
3a0f6479 980 //printf("The number of entries for the group %d is %f\n",idect,nentries);
55a288e5 981 // This detector has not enough statistics or was off
3a0f6479 982 if (nentries <= fMinEntries) {
983 NotEnoughStatisticPRF(idect);
55a288e5 984 continue;
55a288e5 985 }
55a288e5 986 // Statistics of the histos fitted
55a288e5 987 fNumberFit++;
988 fStatisticMean += nentries;
55a288e5 989 // Calcul of "real" coef
3a0f6479 990 CalculPRFCoefMean();
991 //Method choosen
992 switch(fMethod)
993 {
994 case 0: FitPRFGausMI( arraye.GetArray(), arraym.GetArray(), arrayme.GetArray(), nbins, lowedge, upedge); break;
995 case 1: FitTnpRange( arraye.GetArray(), arraym.GetArray(), arrayme.GetArray(), nbg, nbins); break;
996 default: return kFALSE;
997 }
55a288e5 998 // Fill the tree if end of a detector or only the pointer to the branch!!!
3a0f6479 999 FillInfosFitPRF(idect);
55a288e5 1000 } // Boucle object
55a288e5 1001 // Mean Statistic
1002 if (fNumberFit > 0) {
1003 AliInfo(Form("There are %d with at least one entries.",fNumberEnt));
1004 AliInfo(Form("%d fits have been proceeded (sucessfully or not...).",fNumberFit));
6245a86f 1005 AliInfo(Form("There is a mean statistic of: %f over these fitted histograms and %d successfulled fits"
1006 ,(Double_t) (fStatisticMean/fNumberFit),fNumberFitSuccess));
55a288e5 1007 fStatisticMean = fStatisticMean / fNumberFit;
1008 }
1009 else {
1010 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1011 }
3a0f6479 1012 delete fDebugStreamer;
1013 fDebugStreamer = 0x0;
55a288e5 1014 return kTRUE;
55a288e5 1015}
55a288e5 1016//____________Functions fit Online PRF2d_______________________________________
3a0f6479 1017Bool_t AliTRDCalibraFit::AnalysePRF(AliTRDCalibraVector *calvect)
55a288e5 1018{
1019 //
1020 // Reconstruct the 1D histo (pad response function) from the vectorPRD for
1021 // each calibration group
1022 // Fit with a gaussian to reconstruct the sigma of the pad response function
55a288e5 1023 //
1024
3a0f6479 1025 // Set the calibra mode
4c865c34 1026 //const char *name = calvect->GetNamePRF();
1027 TString name = calvect->GetNamePRF();
64942b85 1028 if(!SetModeCalibration(name,2)) return kFALSE;
3a0f6479 1029 //printf("test0 %s\n",name);
55a288e5 1030
3a0f6479 1031 // Number of Xbins (detectors or groups of pads)
1032 if (!InitFit((432*calvect->GetDetCha0(2)+108*calvect->GetDetCha2(2)),2)) {
1033 //printf("test1\n");
55a288e5 1034 return kFALSE;
1035 }
3a0f6479 1036 if (!InitFitPRF()) {
1037 ///printf("test2\n");
55a288e5 1038 return kFALSE;
1039 }
1040 fStatisticMean = 0.0;
1041 fNumberFit = 0;
1042 fNumberFitSuccess = 0;
1043 fNumberEnt = 0;
55a288e5 1044 // Init fCountDet and fCount
1045 InitfCountDetAndfCount(2);
55a288e5 1046 // Beginning of the loop
3a0f6479 1047 for (Int_t idect = fDect1; idect < fDect2; idect++) {
1048 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi........
55a288e5 1049 UpdatefCountDetAndfCount(idect,2);
55a288e5 1050 ReconstructFitRowMinRowMax(idect,2);
3a0f6479 1051 // Take the histo
3a0f6479 1052 fEntriesCurrent = 0;
e526983e 1053 if(!calvect->GetPRFEntries(fCountDet)) {
1054 NotEnoughStatisticPRF(idect);
1055 continue;
3a0f6479 1056 }
e526983e 1057 TString tname("PRF");
1058 tname += idect;
1059 TH1F *projprf = calvect->CorrectTheError((TGraphErrors *) (calvect->ConvertVectorPRFTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname)),fEntriesCurrent);
1060 projprf->SetDirectory(0);
1061 if(fEntriesCurrent > 0) fNumberEnt++;
55a288e5 1062 // This detector has not enough statistics or was off
3a0f6479 1063 if (fEntriesCurrent <= fMinEntries) {
1064 NotEnoughStatisticPRF(idect);
55a288e5 1065 continue;
55a288e5 1066 }
55a288e5 1067 // Statistic of the histos fitted
55a288e5 1068 fNumberFit++;
1069 fStatisticMean += fEntriesCurrent;
55a288e5 1070 // Calcul of "real" coef
3a0f6479 1071 CalculPRFCoefMean();
1072 //Method choosen
1073 switch(fMethod)
1074 {
1075 case 1: FitPRF((TH1 *) projprf); break;
1076 case 2: RmsPRF((TH1 *) projprf); break;
1077 default: return kFALSE;
1078 }
55a288e5 1079 // Fill the tree if end of a detector or only the pointer to the branch!!!
3a0f6479 1080 FillInfosFitPRF(idect);
55a288e5 1081 } // Boucle object
55a288e5 1082 // Mean Statistics
1083 if (fNumberFit > 0) {
6245a86f 1084 AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %f over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Double_t) (fStatisticMean/fNumberFit),fNumberFitSuccess));
55a288e5 1085 }
1086 else {
1087 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1088 }
3a0f6479 1089 delete fDebugStreamer;
1090 fDebugStreamer = 0x0;
55a288e5 1091 return kTRUE;
55a288e5 1092}
55a288e5 1093//____________Functions fit Online PRF2d_______________________________________
3a0f6479 1094Bool_t AliTRDCalibraFit::AnalysePRFMarianFit(AliTRDCalibraVector *calvect)
55a288e5 1095{
1096 //
3a0f6479 1097 // Reconstruct the 1D histo (pad response function) from the vectorPRD for
1098 // each calibration group
1099 // Fit with a gaussian to reconstruct the sigma of the pad response function
55a288e5 1100 //
1101
3a0f6479 1102 // Set the calibra mode
4c865c34 1103 //const char *name = calvect->GetNamePRF();
1104 TString name = calvect->GetNamePRF();
64942b85 1105 if(!SetModeCalibration(name,2)) return kFALSE;
3a0f6479 1106 //printf("test0 %s\n",name);
1107 Int_t nbg = GetNumberOfGroupsPRF((const char *)name);
64942b85 1108 //printf("test1 %d\n",nbg);
3a0f6479 1109 if(nbg == -1) return kFALSE;
1110 if(nbg > 0) fMethod = 1;
1111 else fMethod = 0;
1112 // Number of Xbins (detectors or groups of pads)
1113 if (!InitFit((432*calvect->GetDetCha0(2)+108*calvect->GetDetCha2(2)),2)) {
1114 //printf("test2\n");
55a288e5 1115 return kFALSE;
1116 }
3a0f6479 1117 if (!InitFitPRF()) {
1118 //printf("test3\n");
55a288e5 1119 return kFALSE;
1120 }
1121 fStatisticMean = 0.0;
1122 fNumberFit = 0;
1123 fNumberFitSuccess = 0;
1124 fNumberEnt = 0;
3a0f6479 1125 // Variables
1126 Int_t nbins = 0;
1127 Double_t *arrayx = 0;
1128 Double_t *arraye = 0;
1129 Double_t *arraym = 0;
1130 Double_t *arrayme = 0;
1131 Float_t lowedge = 0.0;
1132 Float_t upedge = 0.0;
55a288e5 1133 // Init fCountDet and fCount
1134 InitfCountDetAndfCount(2);
55a288e5 1135 // Beginning of the loop
3a0f6479 1136 for (Int_t idect = fDect1; idect < fDect2; idect++) {
1137 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi......
55a288e5 1138 UpdatefCountDetAndfCount(idect,2);
55a288e5 1139 ReconstructFitRowMinRowMax(idect,2);
3a0f6479 1140 // Take the histo
3a0f6479 1141 fEntriesCurrent = 0;
e526983e 1142 if(!calvect->GetPRFEntries(fCountDet)) {
1143 NotEnoughStatisticPRF(idect);
1144 continue;
3a0f6479 1145 }
e526983e 1146 TString tname("PRF");
1147 tname += idect;
1148 TGraphErrors *projprftree = calvect->ConvertVectorPRFTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname);
1149 nbins = projprftree->GetN();
1150 arrayx = (Double_t *)projprftree->GetX();
1151 arraye = (Double_t *)projprftree->GetEX();
1152 arraym = (Double_t *)projprftree->GetY();
1153 arrayme = (Double_t *)projprftree->GetEY();
1154 Float_t step = arrayx[1]-arrayx[0];
1155 lowedge = arrayx[0] - step/2.0;
1156 upedge = arrayx[(nbins-1)] + step/2.0;
1157 //printf("nbins est %d\n",nbins);
1158 for(Int_t k = 0; k < nbins; k++){
1159 fEntriesCurrent += (Int_t)arraye[k];
1160 //printf("for %d we have %f, %f\n",k,arraye[k],((projprftree->GetEX())[k]));
1161 if(arraye[k]>0.0) arrayme[k] = TMath::Sqrt(TMath::Abs(arrayme[k]-arraym[k]*arraym[k])/arraye[k]);
1162 }
1163 if(fEntriesCurrent > 0) fNumberEnt++;
3a0f6479 1164 //printf("The number of entries for the group %d is %d\n",idect,fEntriesCurrent);
1165 // This detector has not enough statistics or was off
1166 if (fEntriesCurrent <= fMinEntries) {
1167 NotEnoughStatisticPRF(idect);
55a288e5 1168 continue;
55a288e5 1169 }
3a0f6479 1170 // Statistic of the histos fitted
55a288e5 1171 fNumberFit++;
1172 fStatisticMean += fEntriesCurrent;
55a288e5 1173 // Calcul of "real" coef
3a0f6479 1174 CalculPRFCoefMean();
1175 //Method choosen
1176 switch(fMethod)
1177 {
1178 case 0: FitPRFGausMI(arraye,arraym,arrayme,nbins,lowedge,upedge); break;
1179 case 1: FitTnpRange(arraye,arraym,arrayme,nbg,nbins); break;
1180 default: return kFALSE;
1181 }
1182 // Fill the tree if end of a detector or only the pointer to the branch!!!
1183 FillInfosFitPRF(idect);
3a0f6479 1184 } // Boucle object
1185 // Mean Statistics
1186 if (fNumberFit > 0) {
6245a86f 1187 AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %f over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Double_t) (fStatisticMean/fNumberFit),fNumberFitSuccess));
3a0f6479 1188 }
1189 else {
1190 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1191 }
1192 delete fDebugStreamer;
1193 fDebugStreamer = 0x0;
1194 return kTRUE;
1195}
1196//____________Functions fit Online CH2d________________________________________
1197Bool_t AliTRDCalibraFit::AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *calivdli)
1198{
1199 //
1200 // The linear method
1201 //
1202
1203 fStatisticMean = 0.0;
1204 fNumberFit = 0;
1205 fNumberFitSuccess = 0;
1206 fNumberEnt = 0;
1207 if(!InitFitLinearFitter()) return kFALSE;
1208
1209
1210 for(Int_t idet = 0; idet < 540; idet++){
1211
1212
1213 //printf("detector number %d\n",idet);
1214
1215 // Take the result
1216 TVectorD param(2);
1217 TVectorD error(3);
6245a86f 1218 Double_t entriesCurrent = 0;
3a0f6479 1219 fCountDet = idet;
1220 Bool_t here = calivdli->GetParam(idet,&param);
1221 Bool_t heree = calivdli->GetError(idet,&error);
1222 //printf("here %d and heree %d\n",here, heree);
1223 if(heree) {
6245a86f 1224 entriesCurrent = error[2];
3a0f6479 1225 fNumberEnt++;
55a288e5 1226 }
3a0f6479 1227 //printf("Number of entries %d\n",fEntriesCurrent);
1228 // Nothing found or not enough statistic
6245a86f 1229 if((!heree) || (!here) || (entriesCurrent <= fMinEntries)) {
3a0f6479 1230 NotEnoughStatisticLinearFitter();
1231 continue;
55a288e5 1232 }
3a0f6479 1233 //param.Print();
1234 //error.Print();
1235 //Statistics
1236 fNumberFit++;
6245a86f 1237 fStatisticMean += entriesCurrent;
3a0f6479 1238
1239 // Check the fit
6245a86f 1240 if((-(param[1])) <= 0.000001) {
3a0f6479 1241 NotEnoughStatisticLinearFitter();
1242 continue;
55a288e5 1243 }
55a288e5 1244
3a0f6479 1245 // CalculDatabaseVdriftandTan
1246 CalculVdriftLorentzCoef();
840ec79d 1247 //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFit detector %d, vdrift %f and %f and exB %f and %f\n",idet,fCalDetVdriftUsed->GetValue(idet),fCurrentCoef[1],fCalDetExBUsed->GetValue(idet),fCurrentCoef2[1]);
3a0f6479 1248
1249 // Statistics
1250 fNumberFitSuccess ++;
1251
1252 // Put the fCurrentCoef
1253 fCurrentCoef[0] = -param[1];
1254 // here the database must be the one of the reconstruction for the lorentz angle....
1255 fCurrentCoef2[0] = (param[0]+fCurrentCoef[1]*fCurrentCoef2[1])/fCurrentCoef[0];
1256 fCurrentCoefE = error[1];
1257 fCurrentCoefE2 = error[0];
daa7dc79 1258 if((TMath::Abs(fCurrentCoef2[0]) > 0.0000001) && (TMath::Abs(param[0]) > 0.0000001)){
3a0f6479 1259 fCurrentCoefE2 = (fCurrentCoefE2/param[0]+fCurrentCoefE/fCurrentCoef[0])*fCurrentCoef2[0];
1260 }
1261
1262 // Fill
1263 FillInfosFitLinearFitter();
1264
55a288e5 1265
55a288e5 1266 }
55a288e5 1267 // Mean Statistics
1268 if (fNumberFit > 0) {
6245a86f 1269 AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %f over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Double_t) (fStatisticMean/fNumberFit),fNumberFitSuccess));
55a288e5 1270 }
1271 else {
1272 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1273 }
3a0f6479 1274 delete fDebugStreamer;
1275 fDebugStreamer = 0x0;
55a288e5 1276 return kTRUE;
1277
1278}
a0bb5615 1279//______________________________________________________________________________________
1280Bool_t AliTRDCalibraFit::AnalyseExbAltFit(AliTRDCalibraExbAltFit *calivdli)
1281{
1282 //
1283 // The linear method
1284 //
1285
1286 fStatisticMean = 0.0;
1287 fNumberFit = 0;
1288 fNumberFitSuccess = 0;
1289 fNumberEnt = 0;
1290 if(!InitFitExbAlt()) return kFALSE;
1291
1292
1293 for(Int_t idet = 0; idet < 540; idet++){
1294
1295
1296 //printf("detector number %d\n",idet);
1297
1298 // Take the result
1299 TVectorD param(3);
1300 TVectorD error(3);
6245a86f 1301 Double_t entriesCurrent = 0;
a0bb5615 1302 fCountDet = idet;
1303 Bool_t here = calivdli->GetParam(idet,&param);
1304 Bool_t heree = calivdli->GetError(idet,&error);
1305 //printf("here %d and heree %d\n",here, heree);
1306 if(heree) {
6245a86f 1307 entriesCurrent = error[2];
a0bb5615 1308 fNumberEnt++;
1309 }
1310 //printf("Number of entries %d\n",fEntriesCurrent);
1311 // Nothing found or not enough statistic
6245a86f 1312 if((!heree) || (!here) || (entriesCurrent <= fMinEntries)) {
a0bb5615 1313 NotEnoughStatisticExbAlt();
1314 continue;
1315 }
1316 //param.Print();
1317 //error.Print();
1318 //Statistics
1319 fNumberFit++;
6245a86f 1320 fStatisticMean += entriesCurrent;
a0bb5615 1321
1322 // Statistics
1323 fNumberFitSuccess ++;
1324
1325 // Put the fCurrentCoef
1326 if(TMath::Abs(param[2])>0.0001){
1327 fCurrentCoef2[0] = -param[1]/2/param[2];
1328 fCurrentCoefE2 = 0;//error[1];
1329 }else{
1330 fCurrentCoef2[0] = 100;
1331 fCurrentCoefE2 = 0;//error[1];
1332 }
1333
1334 // Fill
1335 FillInfosFitExbAlt();
1336
1337 }
1338 // Mean Statistics
1339 if (fNumberFit > 0) {
6245a86f 1340 AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %f over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Double_t) (fStatisticMean/fNumberFit),fNumberFitSuccess));
a0bb5615 1341 }
1342 else {
1343 AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
1344 }
1345 delete fDebugStreamer;
1346 fDebugStreamer = 0x0;
1347 return kTRUE;
1348
1349}
54f2ff1c 1350//____________Functions fit Online CH2d________________________________________
840ec79d 1351void AliTRDCalibraFit::AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLinearFit *calivdli, Double_t &vdriftoverall, Double_t &exboverall)
54f2ff1c 1352{
1353 //
1354 // The linear method
1355 //
1356
840ec79d 1357 // Get the mean vdrift and exb used
1358 Double_t meanvdriftused = 0.0;
1359 Double_t meanexbused = 0.0;
1360 Double_t counterdet = 0.0;
1361 if((!fCalDetVdriftUsed) || (!fCalDetExBUsed)) {
1362 vdriftoverall = -100.0;
1363 exboverall = 100.0;
1364 return;
1365 }
1366
54f2ff1c 1367 // Add histos
1368
1369 TH2S *linearfitterhisto = 0x0;
1370
1371 for(Int_t idet = 0; idet < 540; idet++){
1372
1373 TH2S * u = calivdli->GetLinearFitterHistoForce(idet);
840ec79d 1374 Double_t detectorentries = u->Integral();
1375 meanvdriftused += fCalDetVdriftUsed->GetValue(idet)*detectorentries;
1376 meanexbused += fCalDetExBUsed->GetValue(idet)*detectorentries;
1377 counterdet += detectorentries;
1378
1379 //printf("detectorentries %f\n",detectorentries);
1380
1381 //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFitsAllTogether detector %d, vdrift %f and exB %f\n",idet,fCalDetVdriftUsed->GetValue(idet),fCalDetExBUsed->GetValue(idet));
1382
54f2ff1c 1383 if(idet == 0) linearfitterhisto = u;
1384 else linearfitterhisto->Add(u);
1385
1386 }
840ec79d 1387 if(counterdet > 0.0){
1388 meanvdriftused = meanvdriftused/counterdet;
1389 meanexbused = meanexbused/counterdet;
1390 }
1391 else {
1392 vdriftoverall = -100.0;
1393 exboverall = 100.0;
1394 return;
1395 }
1396
1397
1398 //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFitsAllTogether MEAN vdrift %f and exB %f\n",meanvdriftused,meanexbused);
54f2ff1c 1399
1400 // Fit
1401
6245a86f 1402 Double_t entries = 0;
54f2ff1c 1403 TAxis *xaxis = linearfitterhisto->GetXaxis();
1404 TAxis *yaxis = linearfitterhisto->GetYaxis();
1405 TLinearFitter linearfitter = TLinearFitter(2,"pol1");
1406 //printf("test\n");
1407 Double_t integral = linearfitterhisto->Integral();
1408 //printf("Integral is %f\n",integral);
1409 Bool_t securitybreaking = kFALSE;
1410 if(TMath::Abs(integral-1199) < 0.00001) securitybreaking = kTRUE;
1411 for(Int_t ibinx = 0; ibinx < linearfitterhisto->GetNbinsX(); ibinx++){
1412 for(Int_t ibiny = 0; ibiny < linearfitterhisto->GetNbinsY(); ibiny++){
1413 if(linearfitterhisto->GetBinContent(ibinx+1,ibiny+1)>0){
1414 Double_t x = xaxis->GetBinCenter(ibinx+1);
1415 Double_t y = yaxis->GetBinCenter(ibiny+1);
1416
1417 for(Int_t k = 0; k < (Int_t)linearfitterhisto->GetBinContent(ibinx+1,ibiny+1); k++){
1418 if(!securitybreaking){
1419 linearfitter.AddPoint(&x,y);
6245a86f 1420 entries = entries+1.;
54f2ff1c 1421 }
1422 else {
6245a86f 1423 if(entries< 1198.0){
54f2ff1c 1424 linearfitter.AddPoint(&x,y);
6245a86f 1425 entries = entries + 1.;
54f2ff1c 1426 }
1427 }
1428 }
1429
1430 }
1431 }
1432 }
1433
b88b6bcc 1434 //printf("AnalyseLinearFittersAllTogether::Find %d entries\n",entries);
1435 //printf("Minstats %d\n",fMinEntries);
54f2ff1c 1436
840ec79d 1437
1438
1439 // Eval the linear fitter
54f2ff1c 1440 if(entries > fMinEntries){
1441 TVectorD par = TVectorD(2);
1442 //printf("Fit\n");
1443 if((linearfitter.EvalRobust(0.8)==0)) {
1444 //printf("Take the param\n");
1445 linearfitter.GetParameters(par);
1446 //printf("Done\n");
840ec79d 1447 //par.Print();
54f2ff1c 1448 //printf("Finish\n");
1449 // Put the fCurrentCoef
1450 fCurrentCoef[0] = -par[1];
1451 // here the database must be the one of the reconstruction for the lorentz angle....
6245a86f 1452 if(fCurrentCoef[0] > 0.00001) fCurrentCoef2[0] = (par[0]+meanvdriftused*meanexbused)/fCurrentCoef[0];
840ec79d 1453 else fCurrentCoef2[0] = 100.0;
1454
1455 }
1456 else {
1457
1458 fCurrentCoef[0] = -100.0;
1459 fCurrentCoef2[0] = 100.0;
54f2ff1c 1460
54f2ff1c 1461 }
54f2ff1c 1462
1463
1464 }
1465 else {
840ec79d 1466
1467 fCurrentCoef[0] = -100.0;
1468 fCurrentCoef2[0] = 100.0;
1469
54f2ff1c 1470 }
1471
840ec79d 1472 vdriftoverall = fCurrentCoef[0];
1473 exboverall = fCurrentCoef2[0];
1474
1475
54f2ff1c 1476 delete linearfitterhisto;
1477 delete fDebugStreamer;
1478 fDebugStreamer = 0x0;
1479
1480}
55a288e5 1481//____________Functions for seeing if the pad is really okey___________________
3a0f6479 1482//_____________________________________________________________________________
4c865c34 1483Int_t AliTRDCalibraFit::GetNumberOfGroupsPRF(TString nametitle)
3a0f6479 1484{
1485 //
1486 // Get numberofgroupsprf
1487 //
1488
1489 // Some patterns
1490 const Char_t *pattern0 = "Ngp0";
1491 const Char_t *pattern1 = "Ngp1";
1492 const Char_t *pattern2 = "Ngp2";
1493 const Char_t *pattern3 = "Ngp3";
1494 const Char_t *pattern4 = "Ngp4";
1495 const Char_t *pattern5 = "Ngp5";
1496 const Char_t *pattern6 = "Ngp6";
55a288e5 1497
3a0f6479 1498 // Nrphi mode
4c865c34 1499 if (strstr(nametitle.Data(),pattern0)) {
3a0f6479 1500 return 0;
1501 }
4c865c34 1502 if (strstr(nametitle.Data(),pattern1)) {
3a0f6479 1503 return 1;
1504 }
4c865c34 1505 if (strstr(nametitle.Data(),pattern2)) {
3a0f6479 1506 return 2;
1507 }
4c865c34 1508 if (strstr(nametitle.Data(),pattern3)) {
3a0f6479 1509 return 3;
1510 }
4c865c34 1511 if (strstr(nametitle.Data(),pattern4)) {
3a0f6479 1512 return 4;
1513 }
4c865c34 1514 if (strstr(nametitle.Data(),pattern5)) {
3a0f6479 1515 return 5;
1516 }
4c865c34 1517 if (strstr(nametitle.Data(),pattern6)){
3a0f6479 1518 return 6;
1519 }
1520 else return -1;
1521
1522
1523}
55a288e5 1524//_____________________________________________________________________________
4c865c34 1525Bool_t AliTRDCalibraFit::SetModeCalibration(TString name, Int_t i)
55a288e5 1526{
1527 //
1528 // Set fNz[i] and fNrphi[i] of the AliTRDCalibraFit::Instance()
3a0f6479 1529 // corresponding to the given name
55a288e5 1530 //
1531
3a0f6479 1532 if(!SetNzFromTObject(name,i)) return kFALSE;
1533 if(!SetNrphiFromTObject(name,i)) return kFALSE;
1534
1535 return kTRUE;
55a288e5 1536
3a0f6479 1537}
1538//_____________________________________________________________________________
4c865c34 1539Bool_t AliTRDCalibraFit::SetNrphiFromTObject(TString name, Int_t i)
3a0f6479 1540{
1541 //
1542 // Set fNrphi[i] of the AliTRDCalibraFit::Instance()
1543 // corresponding to the given TObject
1544 //
1545
55a288e5 1546 // Some patterns
55a288e5 1547 const Char_t *patternrphi0 = "Nrphi0";
1548 const Char_t *patternrphi1 = "Nrphi1";
1549 const Char_t *patternrphi2 = "Nrphi2";
1550 const Char_t *patternrphi3 = "Nrphi3";
1551 const Char_t *patternrphi4 = "Nrphi4";
1552 const Char_t *patternrphi5 = "Nrphi5";
1553 const Char_t *patternrphi6 = "Nrphi6";
1554
64942b85 1555
1556 const Char_t *patternrphi10 = "Nrphi10";
1557 const Char_t *patternrphi100 = "Nrphi100";
1558 const Char_t *patternz10 = "Nz10";
1559 const Char_t *patternz100 = "Nz100";
1560
55a288e5 1561 // Nrphi mode
4c865c34 1562 if ((strstr(name.Data(),patternrphi100)) && (strstr(name.Data(),patternz100))) {
64942b85 1563 fCalibraMode->SetAllTogether(i);
1564 fNbDet = 540;
1565 if (fDebugLevel > 1) {
1566 AliInfo(Form("fNbDet %d and 100",fNbDet));
1567 }
1568 return kTRUE;
1569 }
4c865c34 1570 if ((strstr(name.Data(),patternrphi10)) && (strstr(name.Data(),patternz10))) {
64942b85 1571 fCalibraMode->SetPerSuperModule(i);
1572 fNbDet = 30;
1573 if (fDebugLevel > 1) {
1574 AliInfo(Form("fNDet %d and 100",fNbDet));
1575 }
1576 return kTRUE;
1577 }
1578
4c865c34 1579 if (strstr(name.Data(),patternrphi0)) {
55a288e5 1580 fCalibraMode->SetNrphi(i ,0);
64942b85 1581 if (fDebugLevel > 1) {
1582 AliInfo(Form("fNbDet %d and 0",fNbDet));
1583 }
3a0f6479 1584 return kTRUE;
55a288e5 1585 }
4c865c34 1586 if (strstr(name.Data(),patternrphi1)) {
55a288e5 1587 fCalibraMode->SetNrphi(i, 1);
64942b85 1588 if (fDebugLevel > 1) {
1589 AliInfo(Form("fNbDet %d and 1",fNbDet));
1590 }
3a0f6479 1591 return kTRUE;
55a288e5 1592 }
4c865c34 1593 if (strstr(name.Data(),patternrphi2)) {
55a288e5 1594 fCalibraMode->SetNrphi(i, 2);
64942b85 1595 if (fDebugLevel > 1) {
1596 AliInfo(Form("fNbDet %d and 2",fNbDet));
1597 }
3a0f6479 1598 return kTRUE;
55a288e5 1599 }
4c865c34 1600 if (strstr(name.Data(),patternrphi3)) {
55a288e5 1601 fCalibraMode->SetNrphi(i, 3);
64942b85 1602 if (fDebugLevel > 1) {
1603 AliInfo(Form("fNbDet %d and 3",fNbDet));
1604 }
3a0f6479 1605 return kTRUE;
55a288e5 1606 }
4c865c34 1607 if (strstr(name.Data(),patternrphi4)) {
55a288e5 1608 fCalibraMode->SetNrphi(i, 4);
64942b85 1609 if (fDebugLevel > 1) {
1610 AliInfo(Form("fNbDet %d and 4",fNbDet));
1611 }
3a0f6479 1612 return kTRUE;
55a288e5 1613 }
4c865c34 1614 if (strstr(name.Data(),patternrphi5)) {
55a288e5 1615 fCalibraMode->SetNrphi(i, 5);
64942b85 1616 if (fDebugLevel > 1) {
1617 AliInfo(Form("fNbDet %d and 5",fNbDet));
1618 }
3a0f6479 1619 return kTRUE;
55a288e5 1620 }
4c865c34 1621 if (strstr(name.Data(),patternrphi6)) {
55a288e5 1622 fCalibraMode->SetNrphi(i, 6);
64942b85 1623 if (fDebugLevel > 1) {
1624 AliInfo(Form("fNbDet %d and 6",fNbDet));
1625 }
55a288e5 1626 return kTRUE;
1627 }
55a288e5 1628
64942b85 1629 if (fDebugLevel > 1) {
1630 AliInfo(Form("fNbDet %d and rest",fNbDet));
1631 }
3a0f6479 1632 fCalibraMode->SetNrphi(i ,0);
1633 return kFALSE;
64942b85 1634
55a288e5 1635}
55a288e5 1636//_____________________________________________________________________________
4c865c34 1637Bool_t AliTRDCalibraFit::SetNzFromTObject(TString name, Int_t i)
55a288e5 1638{
1639 //
3a0f6479 1640 // Set fNz[i] of the AliTRDCalibraFit::Instance()
1641 // corresponding to the given TObject
55a288e5 1642 //
3a0f6479 1643
1644 // Some patterns
1645 const Char_t *patternz0 = "Nz0";
1646 const Char_t *patternz1 = "Nz1";
1647 const Char_t *patternz2 = "Nz2";
1648 const Char_t *patternz3 = "Nz3";
1649 const Char_t *patternz4 = "Nz4";
64942b85 1650
1651 const Char_t *patternrphi10 = "Nrphi10";
1652 const Char_t *patternrphi100 = "Nrphi100";
1653 const Char_t *patternz10 = "Nz10";
1654 const Char_t *patternz100 = "Nz100";
1655
4c865c34 1656 if ((strstr(name.Data(),patternrphi100)) && (strstr(name.Data(),patternz100))) {
64942b85 1657 fCalibraMode->SetAllTogether(i);
1658 fNbDet = 540;
1659 if (fDebugLevel > 1) {
1660 AliInfo(Form("fNbDet %d and 100",fNbDet));
1661 }
1662 return kTRUE;
1663 }
4c865c34 1664 if ((strstr(name.Data(),patternrphi10)) && (strstr(name.Data(),patternz10))) {
64942b85 1665 fCalibraMode->SetPerSuperModule(i);
1666 fNbDet = 30;
1667 if (fDebugLevel > 1) {
1668 AliInfo(Form("fNbDet %d and 10",fNbDet));
1669 }
1670 return kTRUE;
1671 }
4c865c34 1672 if (strstr(name.Data(),patternz0)) {
3a0f6479 1673 fCalibraMode->SetNz(i, 0);
64942b85 1674 if (fDebugLevel > 1) {
1675 AliInfo(Form("fNbDet %d and 0",fNbDet));
1676 }
3a0f6479 1677 return kTRUE;
55a288e5 1678 }
4c865c34 1679 if (strstr(name.Data(),patternz1)) {
3a0f6479 1680 fCalibraMode->SetNz(i ,1);
64942b85 1681 if (fDebugLevel > 1) {
1682 AliInfo(Form("fNbDet %d and 1",fNbDet));
1683 }
3a0f6479 1684 return kTRUE;
55a288e5 1685 }
4c865c34 1686 if (strstr(name.Data(),patternz2)) {
3a0f6479 1687 fCalibraMode->SetNz(i ,2);
64942b85 1688 if (fDebugLevel > 1) {
1689 AliInfo(Form("fNbDet %d and 2",fNbDet));
1690 }
3a0f6479 1691 return kTRUE;
55a288e5 1692 }
4c865c34 1693 if (strstr(name.Data(),patternz3)) {
3a0f6479 1694 fCalibraMode->SetNz(i ,3);
64942b85 1695 if (fDebugLevel > 1) {
1696 AliInfo(Form("fNbDet %d and 3",fNbDet));
1697 }
3a0f6479 1698 return kTRUE;
55a288e5 1699 }
4c865c34 1700 if (strstr(name.Data(),patternz4)) {
3a0f6479 1701 fCalibraMode->SetNz(i ,4);
64942b85 1702 if (fDebugLevel > 1) {
1703 AliInfo(Form("fNbDet %d and 4",fNbDet));
1704 }
3a0f6479 1705 return kTRUE;
55a288e5 1706 }
64942b85 1707
1708 if (fDebugLevel > 1) {
1709 AliInfo(Form("fNbDet %d and rest",fNbDet));
1710 }
3a0f6479 1711 fCalibraMode->SetNz(i ,0);
1712 return kFALSE;
1713}
64942b85 1714//______________________________________________________________________
6aafa7ea 1715void AliTRDCalibraFit::RemoveOutliers(Int_t type, Bool_t perdetector){
1716 //
1717 // Remove the results too far from the mean value and rms
1718 // type: 0 gain, 1 vdrift
1719 // perdetector
1720 //
1721
1722 Int_t loop = (Int_t) fVectorFit.GetEntriesFast();
1723 if(loop != 540) {
1724 AliInfo("The Vector Fit is not complete!");
1725 return;
1726 }
1727 Int_t detector = -1;
1728 Int_t sector = -1;
1729 Float_t value = 0.0;
1730
1731 /////////////////////////////////
1732 // Calculate the mean values
1733 ////////////////////////////////
1734 // Initialisation
1735 ////////////////////////
1736 Double_t meanAll = 0.0;
4f3bd513 1737 Double_t rmsAll = 0.0;
1738 Int_t countAll = 0;
1739 ////////////
6aafa7ea 1740 // compute
1741 ////////////
1742 for (Int_t k = 0; k < loop; k++) {
1743 detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector();
1744 sector = GetSector(detector);
1745 if(perdetector){
1746 value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[0];
1747 if(value > 0.0) {
1748 rmsAll += value*value;
1749 meanAll += value;
1750 countAll++;
1751 }
1752 }
1753 else {
1754 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1755 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1756 for (Int_t row = 0; row < rowMax; row++) {
1757 for (Int_t col = 0; col < colMax; col++) {
1758 value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
1759 if(value > 0.0) {
1760 rmsAll += value*value;
1761 meanAll += value;
1762 countAll++;
1763 }
1764
1765 } // Col
1766 } // Row
1767 }
1768 }
1769 if(countAll > 0) {
1770 meanAll = meanAll/countAll;
1771 rmsAll = TMath::Sqrt(TMath::Abs(rmsAll/countAll - (meanAll*meanAll)));
1772 }
1773 //printf("RemoveOutliers: meanAll %f and rmsAll %f\n",meanAll,rmsAll);
1774 /////////////////////////////////////////////////
1775 // Remove outliers
1776 ////////////////////////////////////////////////
1777 Double_t defaultvalue = -1.0;
1778 if(type==1) defaultvalue = -1.5;
1779 for (Int_t k = 0; k < loop; k++) {
1780 detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector();
1781 sector = GetSector(detector);
1782 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1783 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1784 Float_t *coef = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef();
1785
1786 // remove the results too far away
1787 for (Int_t row = 0; row < rowMax; row++) {
1788 for (Int_t col = 0; col < colMax; col++) {
1789 value = coef[(Int_t)(col*rowMax+row)];
1790 if((value > 0.0) && (rmsAll > 0.0) && (TMath::Abs(value-meanAll) > (2*rmsAll))) {
1791 coef[(Int_t)(col*rowMax+row)] = defaultvalue;
1792 }
1793 } // Col
1794 } // Row
1795 }
1796}
1797//______________________________________________________________________
1798void AliTRDCalibraFit::RemoveOutliers2(Bool_t perdetector){
1799 //
1800 // Remove the results too far from the mean and rms
1801 // perdetector
1802 //
1803
1804 Int_t loop = (Int_t) fVectorFit2.GetEntriesFast();
1805 if(loop != 540) {
1806 AliInfo("The Vector Fit is not complete!");
1807 return;
1808 }
1809 Int_t detector = -1;
1810 Int_t sector = -1;
1811 Float_t value = 0.0;
1812
1813 /////////////////////////////////
1814 // Calculate the mean values
1815 ////////////////////////////////
1816 // Initialisation
1817 ////////////////////////
1818 Double_t meanAll = 0.0;
1819 Double_t rmsAll = 0.0;
1820 Int_t countAll = 0;
1821 /////////////
1822 // compute
1823 ////////////
1824 for (Int_t k = 0; k < loop; k++) {
1825 detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector();
1826 sector = GetSector(detector);
1827 if(perdetector){
1828 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[0];
1829 if(value < 70.0) {
1830 meanAll += value;
1831 rmsAll += value*value;
1832 countAll++;
1833 }
1834 }
1835 else {
1836 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1837 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1838 for (Int_t row = 0; row < rowMax; row++) {
1839 for (Int_t col = 0; col < colMax; col++) {
1840 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
1841 if(value < 70.0) {
1842 rmsAll += value*value;
1843 meanAll += value;
1844 countAll++;
1845 }
1846 } // Col
1847 } // Row
1848 }
1849 }
1850 if(countAll > 0) {
1851 meanAll = meanAll/countAll;
1852 rmsAll = TMath::Sqrt(TMath::Abs(rmsAll/countAll - (meanAll*meanAll)));
1853 }
1854 //printf("Remove outliers 2: meanAll %f, rmsAll %f\n",meanAll,rmsAll);
1855 /////////////////////////////////////////////////
1856 // Remove outliers
1857 ////////////////////////////////////////////////
1858 for (Int_t k = 0; k < loop; k++) {
1859 detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector();
1860 sector = GetSector(detector);
1861 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1862 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1863 Float_t *coef = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef();
1864
1865 // remove the results too far away
1866 for (Int_t row = 0; row < rowMax; row++) {
1867 for (Int_t col = 0; col < colMax; col++) {
1868 value = coef[(Int_t)(col*rowMax+row)];
b88b6bcc 1869 if((value < 70.0) && (rmsAll > 0.0) && (TMath::Abs(value-meanAll) > (2.5*rmsAll))) {
1870 //printf("value outlier %f\n",value);
1871 coef[(Int_t)(col*rowMax+row)] = 100.0;
1872 }
6aafa7ea 1873 } // Col
1874 } // Row
1875 }
1876}
1877//______________________________________________________________________
64942b85 1878void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetector){
1879 //
1880 // ofwhat is equaled to 0: mean value of all passing detectors
1881 // ofwhat is equaled to 1: mean value of the detector, otherwise supermodule, otherwise all
1882 //
1883
1884 Int_t loop = (Int_t) fVectorFit.GetEntriesFast();
1885 if(loop != 540) {
1886 AliInfo("The Vector Fit is not complete!");
1887 return;
1888 }
1889 Int_t detector = -1;
1890 Int_t sector = -1;
1891 Float_t value = 0.0;
1892
1893 /////////////////////////////////
1894 // Calculate the mean values
1895 ////////////////////////////////
1896 // Initialisation
1897 ////////////////////////
1898 Double_t meanAll = 0.0;
1899 Double_t meanSupermodule[18];
1900 Double_t meanDetector[540];
6aafa7ea 1901 Double_t rmsAll = 0.0;
1902 Double_t rmsSupermodule[18];
1903 Double_t rmsDetector[540];
64942b85 1904 Int_t countAll = 0;
1905 Int_t countSupermodule[18];
1906 Int_t countDetector[540];
1907 for(Int_t sm = 0; sm < 18; sm++){
6aafa7ea 1908 rmsSupermodule[sm] = 0.0;
64942b85 1909 meanSupermodule[sm] = 0.0;
1910 countSupermodule[sm] = 0;
1911 }
1912 for(Int_t det = 0; det < 540; det++){
6aafa7ea 1913 rmsDetector[det] = 0.0;
64942b85 1914 meanDetector[det] = 0.0;
1915 countDetector[det] = 0;
1916 }
6aafa7ea 1917 ////////////
64942b85 1918 // compute
1919 ////////////
1920 for (Int_t k = 0; k < loop; k++) {
1921 detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector();
1922 sector = GetSector(detector);
1923 if(perdetector){
1924 value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[0];
1925 if(value > 0.0) {
6aafa7ea 1926 rmsDetector[detector] += value*value;
64942b85 1927 meanDetector[detector] += value;
1928 countDetector[detector]++;
6aafa7ea 1929 rmsSupermodule[sector] += value*value;
64942b85 1930 meanSupermodule[sector] += value;
1931 countSupermodule[sector]++;
6aafa7ea 1932 rmsAll += value*value;
64942b85 1933 meanAll += value;
1934 countAll++;
1935 }
1936 }
1937 else {
1938 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1939 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1940 for (Int_t row = 0; row < rowMax; row++) {
1941 for (Int_t col = 0; col < colMax; col++) {
1942 value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
1943 if(value > 0.0) {
6aafa7ea 1944 rmsDetector[detector] += value*value;
64942b85 1945 meanDetector[detector] += value;
1946 countDetector[detector]++;
6aafa7ea 1947 rmsSupermodule[sector] += value*value;
64942b85 1948 meanSupermodule[sector] += value;
1949 countSupermodule[sector]++;
6aafa7ea 1950 rmsAll += value*value;
64942b85 1951 meanAll += value;
1952 countAll++;
1953 }
1954
1955 } // Col
1956 } // Row
1957 }
1958 }
6aafa7ea 1959 if(countAll > 0) {
1960 meanAll = meanAll/countAll;
1961 rmsAll = TMath::Abs(rmsAll/countAll - (meanAll*meanAll));
1962 }
64942b85 1963 for(Int_t sm = 0; sm < 18; sm++){
6aafa7ea 1964 if(countSupermodule[sm] > 0) {
1965 meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm];
1966 rmsSupermodule[sm] = TMath::Abs(rmsSupermodule[sm]/countSupermodule[sm] - (meanSupermodule[sm]*meanSupermodule[sm]));
1967 }
64942b85 1968 }
1969 for(Int_t det = 0; det < 540; det++){
6aafa7ea 1970 if(countDetector[det] > 0) {
1971 meanDetector[det] = meanDetector[det]/countDetector[det];
1972 rmsDetector[det] = TMath::Abs(rmsDetector[det]/countDetector[det] - (meanDetector[det]*meanDetector[det]));
1973 }
64942b85 1974 }
6aafa7ea 1975 //printf("Put mean value, meanAll %f, rmsAll %f\n",meanAll,rmsAll);
1976 ///////////////////////////////////////////////
64942b85 1977 // Put the mean value for the no-fitted
1978 /////////////////////////////////////////////
1979 for (Int_t k = 0; k < loop; k++) {
1980 detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector();
1981 sector = GetSector(detector);
1982 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1983 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1984 Float_t *coef = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef();
1985
1986 for (Int_t row = 0; row < rowMax; row++) {
1987 for (Int_t col = 0; col < colMax; col++) {
1988 value = coef[(Int_t)(col*rowMax+row)];
1989 if(value < 0.0) {
6aafa7ea 1990 if((ofwhat == 0) && (meanAll > 0.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll);
64942b85 1991 if(ofwhat == 1){
6aafa7ea 1992 if((meanDetector[detector] > 0.0) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanDetector[detector]);
1993 else if((meanSupermodule[sector] > 0.0) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanSupermodule[sector]);
1994 else if((meanAll > 0.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll);
64942b85 1995 }
1996 }
1997 // Debug
1998 if(fDebugLevel > 1){
1999
2000 if ( !fDebugStreamer ) {
2001 //debug stream
2002 TDirectory *backup = gDirectory;
2003 fDebugStreamer = new TTreeSRedirector("TRDDebugFit.root");
2004 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2005 }
2006
2007 Float_t coefnow = coef[(Int_t)(col*rowMax+row)];
2008
2009 (* fDebugStreamer) << "PutMeanValueOtherVectorFit"<<
2010 "detector="<<detector<<
2011 "sector="<<sector<<
2012 "row="<<row<<
2013 "col="<<col<<
2014 "before="<<value<<
2015 "after="<<coefnow<<
2016 "\n";
2017 }
2018 } // Col
2019 } // Row
2020 }
64942b85 2021}
2022//______________________________________________________________________
2023void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetector){
2024 //
2025 // ofwhat is equaled to 0: mean value of all passing detectors
2026 // ofwhat is equaled to 1: mean value of the detector, otherwise supermodule, otherwise all
2027 //
2028
2029 Int_t loop = (Int_t) fVectorFit2.GetEntriesFast();
2030 if(loop != 540) {
2031 AliInfo("The Vector Fit is not complete!");
2032 return;
2033 }
2034 Int_t detector = -1;
2035 Int_t sector = -1;
2036 Float_t value = 0.0;
2037
2038 /////////////////////////////////
2039 // Calculate the mean values
2040 ////////////////////////////////
2041 // Initialisation
2042 ////////////////////////
2043 Double_t meanAll = 0.0;
6aafa7ea 2044 Double_t rmsAll = 0.0;
64942b85 2045 Double_t meanSupermodule[18];
6aafa7ea 2046 Double_t rmsSupermodule[18];
64942b85 2047 Double_t meanDetector[540];
6aafa7ea 2048 Double_t rmsDetector[540];
64942b85 2049 Int_t countAll = 0;
2050 Int_t countSupermodule[18];
2051 Int_t countDetector[540];
2052 for(Int_t sm = 0; sm < 18; sm++){
6aafa7ea 2053 rmsSupermodule[sm] = 0.0;
64942b85 2054 meanSupermodule[sm] = 0.0;
2055 countSupermodule[sm] = 0;
2056 }
2057 for(Int_t det = 0; det < 540; det++){
6aafa7ea 2058 rmsDetector[det] = 0.0;
64942b85 2059 meanDetector[det] = 0.0;
2060 countDetector[det] = 0;
2061 }
2062 // compute
2063 ////////////
2064 for (Int_t k = 0; k < loop; k++) {
2065 detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector();
2066 sector = GetSector(detector);
2067 if(perdetector){
2068 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[0];
2069 if(value < 70.0) {
6aafa7ea 2070 rmsDetector[detector] += value*value;
64942b85 2071 meanDetector[detector] += value;
2072 countDetector[detector]++;
6aafa7ea 2073 rmsSupermodule[sector] += value*value;
64942b85 2074 meanSupermodule[sector] += value;
2075 countSupermodule[sector]++;
2076 meanAll += value;
6aafa7ea 2077 rmsAll += value*value;
64942b85 2078 countAll++;
2079 }
2080 }
2081 else {
2082 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2083 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
2084 for (Int_t row = 0; row < rowMax; row++) {
2085 for (Int_t col = 0; col < colMax; col++) {
2086 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2087 if(value < 70.0) {
6aafa7ea 2088 rmsDetector[detector] += value*value;
64942b85 2089 meanDetector[detector] += value;
2090 countDetector[detector]++;
6aafa7ea 2091 rmsSupermodule[sector] += value*value;
64942b85 2092 meanSupermodule[sector] += value;
2093 countSupermodule[sector]++;
6aafa7ea 2094 rmsAll += value*value;
64942b85 2095 meanAll += value;
2096 countAll++;
2097 }
2098
2099 } // Col
2100 } // Row
2101 }
2102 }
6aafa7ea 2103 if(countAll > 0) {
2104 meanAll = meanAll/countAll;
2105 rmsAll = TMath::Abs(rmsAll/countAll - (meanAll*meanAll));
2106 }
64942b85 2107 for(Int_t sm = 0; sm < 18; sm++){
6aafa7ea 2108 if(countSupermodule[sm] > 0) {
2109 meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm];
2110 rmsSupermodule[sm] = TMath::Abs(rmsSupermodule[sm]/countSupermodule[sm] - (meanSupermodule[sm]*meanSupermodule[sm]));
2111 }
64942b85 2112 }
2113 for(Int_t det = 0; det < 540; det++){
6aafa7ea 2114 if(countDetector[det] > 0) {
2115 meanDetector[det] = meanDetector[det]/countDetector[det];
2116 rmsDetector[det] = TMath::Abs(rmsDetector[det]/countDetector[det] - (meanDetector[det]*meanDetector[det]));
2117 }
64942b85 2118 }
6aafa7ea 2119 //printf("Put mean value 2: meanAll %f, rmsAll %f\n",meanAll,rmsAll);
2120 ////////////////////////////////////////////
64942b85 2121 // Put the mean value for the no-fitted
2122 /////////////////////////////////////////////
2123 for (Int_t k = 0; k < loop; k++) {
2124 detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector();
2125 sector = GetSector(detector);
2126 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2127 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
2128 Float_t *coef = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef();
2129
2130 for (Int_t row = 0; row < rowMax; row++) {
2131 for (Int_t col = 0; col < colMax; col++) {
2132 value = coef[(Int_t)(col*rowMax+row)];
2133 if(value > 70.0) {
840ec79d 2134 if((ofwhat == 0) && (meanAll > -3.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0;
64942b85 2135 if(ofwhat == 1){
840ec79d 2136 if((meanDetector[detector] > -3.0) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = meanDetector[detector]+100.0;
2137 else if((meanSupermodule[sector] > -3.0) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = meanSupermodule[sector]+100.0;
2138 else if((meanAll > -3.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0;
64942b85 2139 }
2140 }
2141 // Debug
2142 if(fDebugLevel > 1){
2143
2144 if ( !fDebugStreamer ) {
2145 //debug stream
2146 TDirectory *backup = gDirectory;
2147 fDebugStreamer = new TTreeSRedirector("TRDDebugFit.root");
2148 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2149 }
2150
2151 Float_t coefnow = coef[(Int_t)(col*rowMax+row)];
2152
2153 (* fDebugStreamer) << "PutMeanValueOtherVectorFit2"<<
2154 "detector="<<detector<<
2155 "sector="<<sector<<
2156 "row="<<row<<
2157 "col="<<col<<
2158 "before="<<value<<
2159 "after="<<coefnow<<
2160 "\n";
2161 }
2162 } // Col
2163 } // Row
2164 }
2165
2166}
3a0f6479 2167//_____________________________________________________________________________
979b168f 2168AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectVdrift(const TObjArray *vectorFit, Bool_t perdetector)
3a0f6479 2169{
2170 //
2171 // It creates the AliTRDCalDet object from the AliTRDFitInfo
2172 // It takes the mean value of the coefficients per detector
2173 // This object has to be written in the database
2174 //
55a288e5 2175
3a0f6479 2176 // Create the DetObject
2177 AliTRDCalDet *object = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)");
2178
2179 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2180 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2181 Int_t detector = -1;
2182 Float_t value = 0.0;
64942b85 2183
2184 //
3a0f6479 2185 for (Int_t k = 0; k < loop; k++) {
2186 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2187 Float_t mean = 0.0;
2188 if(perdetector){
2189 mean = TMath::Abs(((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0]);
55a288e5 2190 }
2191 else {
3a0f6479 2192 Int_t count = 0;
053767a4 2193 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2194 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
3a0f6479 2195 for (Int_t row = 0; row < rowMax; row++) {
2196 for (Int_t col = 0; col < colMax; col++) {
2197 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2198 mean += TMath::Abs(value);
2199 count++;
2200 } // Col
2201 } // Row
2202 if(count > 0) mean = mean/count;
55a288e5 2203 }
2204 object->SetValue(detector,mean);
2205 }
3a0f6479 2206
55a288e5 2207 return object;
55a288e5 2208}
55a288e5 2209//_____________________________________________________________________________
979b168f 2210AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectGain(const TObjArray *vectorFit, Bool_t meanOtherBefore, Double_t scaleFitFactor, Bool_t perdetector)
55a288e5 2211{
2212 //
3a0f6479 2213 // It creates the AliTRDCalDet object from the AliTRDFitInfo
2214 // It takes the mean value of the coefficients per detector
55a288e5 2215 // This object has to be written in the database
2216 //
2217
2218 // Create the DetObject
3a0f6479 2219 AliTRDCalDet *object = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)");
55a288e5 2220
54f2ff1c 2221 fScaleGain = scaleFitFactor;
3a0f6479 2222
2223 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2224 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2225 Int_t detector = -1;
2226 Float_t value = 0.0;
2227
2228 for (Int_t k = 0; k < loop; k++) {
2229 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2230 Float_t mean = 0.0;
2231 if(perdetector){
2232 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
64942b85 2233 if(!meanOtherBefore){
2234 if(value > 0) value = value*scaleFitFactor;
2235 }
2236 else value = value*scaleFitFactor;
3a0f6479 2237 mean = TMath::Abs(value);
2238 }
2239 else{
2240 Int_t count = 0;
053767a4 2241 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2242 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
3a0f6479 2243 for (Int_t row = 0; row < rowMax; row++) {
2244 for (Int_t col = 0; col < colMax; col++) {
2245 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
64942b85 2246 if(!meanOtherBefore) {
2247 if(value > 0) value = value*scaleFitFactor;
2248 }
2249 else value = value*scaleFitFactor;
3a0f6479 2250 mean += TMath::Abs(value);
2251 count++;
2252 } // Col
2253 } // Row
2254 if(count > 0) mean = mean/count;
2255 }
ba1aa7a7 2256 if(mean < 0.1) mean = 0.1;
3a0f6479 2257 object->SetValue(detector,mean);
55a288e5 2258 }
3a0f6479 2259
2260 return object;
2261}
2262//_____________________________________________________________________________
979b168f 2263AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectT0(const TObjArray *vectorFit, Bool_t perdetector)
3a0f6479 2264{
2265 //
2266 // It creates the AliTRDCalDet object from the AliTRDFitInfo2
2267 // It takes the min value of the coefficients per detector
2268 // This object has to be written in the database
2269 //
55a288e5 2270
3a0f6479 2271 // Create the DetObject
2272 AliTRDCalDet *object = new AliTRDCalDet("ChamberT0","T0 (detector value)");
55a288e5 2273
3a0f6479 2274 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2275 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2276 Int_t detector = -1;
2277 Float_t value = 0.0;
2278
2279 for (Int_t k = 0; k < loop; k++) {
2280 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2281 Float_t min = 100.0;
2282 if(perdetector){
64942b85 2283 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
b88b6bcc 2284 //printf("Create det object %f for %d\n",value,k);
64942b85 2285 // check successful
2286 if(value > 70.0) value = value-100.0;
2287 //
2288 min = value;
55a288e5 2289 }
3a0f6479 2290 else{
053767a4 2291 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2292 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
3a0f6479 2293 for (Int_t row = 0; row < rowMax; row++) {
2294 for (Int_t col = 0; col < colMax; col++) {
2295 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
64942b85 2296 // check successful
2297 if(value > 70.0) value = value-100.0;
2298 //
3a0f6479 2299 if(min > value) min = value;
2300 } // Col
2301 } // Row
2302 }
2303 object->SetValue(detector,min);
55a288e5 2304 }
2305
2306 return object;
2307
2308}
55a288e5 2309//_____________________________________________________________________________
979b168f 2310AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectLorentzAngle(const TObjArray *vectorFit)
55a288e5 2311{
2312 //
3a0f6479 2313 // It creates the AliTRDCalDet object from the AliTRDFitInfo2
2314 // It takes the min value of the coefficients per detector
55a288e5 2315 // This object has to be written in the database
2316 //
2317
2318 // Create the DetObject
3a0f6479 2319 AliTRDCalDet *object = new AliTRDCalDet("tan(lorentzangle)","tan(lorentzangle) (detector value)");
2320
2321
2322 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2323 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2324 Int_t detector = -1;
2325 Float_t value = 0.0;
55a288e5 2326
3a0f6479 2327 for (Int_t k = 0; k < loop; k++) {
2328 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2329 /*
053767a4 2330 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2331 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
3a0f6479 2332 Float_t min = 100.0;
2333 for (Int_t row = 0; row < rowMax; row++) {
2334 for (Int_t col = 0; col < colMax; col++) {
2335 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2336 mean += -TMath::Abs(value);
2337 count++;
55a288e5 2338 } // Col
3a0f6479 2339 } // Row
2340 if(count > 0) mean = mean/count;
2341 */
2342 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
840ec79d 2343 if(value > 70.0) value = value-100.0;
2344 object->SetValue(detector,value);
55a288e5 2345 }
2346
2347 return object;
3a0f6479 2348
55a288e5 2349}
55a288e5 2350//_____________________________________________________________________________
a0bb5615 2351AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectExbAlt(const TObjArray *vectorFit)
2352{
2353 //
2354 // It creates the AliTRDCalDet object from the AliTRDFitInfo2
2355 // It takes the min value of the coefficients per detector
2356 // This object has to be written in the database
2357 //
2358
2359 // Create the DetObject
2360 AliTRDCalDet *object = new AliTRDCalDet("tan(lorentzangle)","tan(lorentzangle) (detector value)");
2361
2362
2363 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2364 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2365 Int_t detector = -1;
2366 Float_t value = 0.0;
2367
2368 for (Int_t k = 0; k < loop; k++) {
2369 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2370 /*
2371 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2372 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
2373 Float_t min = 100.0;
2374 for (Int_t row = 0; row < rowMax; row++) {
2375 for (Int_t col = 0; col < colMax; col++) {
2376 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2377 mean += -TMath::Abs(value);
2378 count++;
2379 } // Col
2380 } // Row
2381 if(count > 0) mean = mean/count;
2382 */
2383 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
2384 //if(value > 70.0) value = value-100.0;
2385 object->SetValue(detector,value);
2386 }
2387
2388 return object;
2389
2390}
2391//_____________________________________________________________________________
979b168f 2392TObject *AliTRDCalibraFit::CreatePadObjectGain(const TObjArray *vectorFit, Double_t scaleFitFactor, const AliTRDCalDet *detobject)
3a0f6479 2393{
55a288e5 2394 //
3a0f6479 2395 // It Creates the AliTRDCalPad object from AliTRDFitInfo
2396 // You need first to create the object for the detectors,
2397 // where the mean value is put.
2398 // This object has to be written in the database
55a288e5 2399 //
3a0f6479 2400
2401 // Create the DetObject
2402 AliTRDCalPad *object = new AliTRDCalPad("GainFactor","GainFactor (local variations)");
2403
2404 if(!vectorFit){
2405 for(Int_t k = 0; k < 540; k++){
2406 AliTRDCalROC *calROC = object->GetCalROC(k);
2407 Int_t nchannels = calROC->GetNchannels();
2408 for(Int_t ch = 0; ch < nchannels; ch++){
2409 calROC->SetValue(ch,1.0);
2410 }
2411 }
55a288e5 2412 }
3a0f6479 2413 else{
2414
2415 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2416 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2417 Int_t detector = -1;
2418 Float_t value = 0.0;
2419
2420 for (Int_t k = 0; k < loop; k++) {
2421 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2422 AliTRDCalROC *calROC = object->GetCalROC(detector);
2423 Float_t mean = detobject->GetValue(detector);
daa7dc79 2424 if(TMath::Abs(mean) <= 0.0000000001) continue;
3a0f6479 2425 Int_t rowMax = calROC->GetNrows();
2426 Int_t colMax = calROC->GetNcols();
2427 for (Int_t row = 0; row < rowMax; row++) {
2428 for (Int_t col = 0; col < colMax; col++) {
2429 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2430 if(value > 0) value = value*scaleFitFactor;
2431 calROC->SetValue(col,row,TMath::Abs(value)/mean);
2432 } // Col
2433 } // Row
2434 }
55a288e5 2435 }
2436
3a0f6479 2437 return object;
55a288e5 2438}
55a288e5 2439//_____________________________________________________________________________
979b168f 2440TObject *AliTRDCalibraFit::CreatePadObjectVdrift(const TObjArray *vectorFit, const AliTRDCalDet *detobject)
3a0f6479 2441{
55a288e5 2442 //
3a0f6479 2443 // It Creates the AliTRDCalPad object from AliTRDFitInfo
2444 // You need first to create the object for the detectors,
2445 // where the mean value is put.
2446 // This object has to be written in the database
55a288e5 2447 //
2448
3a0f6479 2449 // Create the DetObject
2450 AliTRDCalPad *object = new AliTRDCalPad("LocalVdrift","TRD drift velocities (local variations)");
2451
2452 if(!vectorFit){
2453 for(Int_t k = 0; k < 540; k++){
2454 AliTRDCalROC *calROC = object->GetCalROC(k);
2455 Int_t nchannels = calROC->GetNchannels();
2456 for(Int_t ch = 0; ch < nchannels; ch++){
2457 calROC->SetValue(ch,1.0);
2458 }
2459 }
55a288e5 2460 }
2461 else {
3a0f6479 2462
2463 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2464 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2465 Int_t detector = -1;
2466 Float_t value = 0.0;
2467
2468 for (Int_t k = 0; k < loop; k++) {
2469 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2470 AliTRDCalROC *calROC = object->GetCalROC(detector);
2471 Float_t mean = detobject->GetValue(detector);
2472 if(mean == 0) continue;
2473 Int_t rowMax = calROC->GetNrows();
2474 Int_t colMax = calROC->GetNcols();
2475 for (Int_t row = 0; row < rowMax; row++) {
2476 for (Int_t col = 0; col < colMax; col++) {
2477 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2478 calROC->SetValue(col,row,TMath::Abs(value)/mean);
2479 } // Col
2480 } // Row
2481 }
55a288e5 2482 }
3a0f6479 2483 return object;
55a288e5 2484
2485}
55a288e5 2486//_____________________________________________________________________________
979b168f 2487TObject *AliTRDCalibraFit::CreatePadObjectT0(const TObjArray *vectorFit, const AliTRDCalDet *detobject)
3a0f6479 2488{
55a288e5 2489 //
3a0f6479 2490 // It Creates the AliTRDCalPad object from AliTRDFitInfo2
2491 // You need first to create the object for the detectors,
2492 // where the mean value is put.
2493 // This object has to be written in the database
55a288e5 2494 //
3a0f6479 2495
2496 // Create the DetObject
2497 AliTRDCalPad *object = new AliTRDCalPad("LocalT0","T0 (local variations)");
2498
2499 if(!vectorFit){
2500 for(Int_t k = 0; k < 540; k++){
2501 AliTRDCalROC *calROC = object->GetCalROC(k);
2502 Int_t nchannels = calROC->GetNchannels();
2503 for(Int_t ch = 0; ch < nchannels; ch++){
2504 calROC->SetValue(ch,0.0);
2505 }
2506 }
55a288e5 2507 }
2508 else {
3a0f6479 2509
2510 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2511 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2512 Int_t detector = -1;
2513 Float_t value = 0.0;
2514
2515 for (Int_t k = 0; k < loop; k++) {
2516 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2517 AliTRDCalROC *calROC = object->GetCalROC(detector);
2518 Float_t min = detobject->GetValue(detector);
2519 Int_t rowMax = calROC->GetNrows();
2520 Int_t colMax = calROC->GetNcols();
2521 for (Int_t row = 0; row < rowMax; row++) {
2522 for (Int_t col = 0; col < colMax; col++) {
2523 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
64942b85 2524 // check successful
2525 if(value > 70.0) value = value - 100.0;
2526 //
3a0f6479 2527 calROC->SetValue(col,row,value-min);
2528 } // Col
2529 } // Row
2530 }
55a288e5 2531 }
3a0f6479 2532 return object;
55a288e5 2533
2534}
3a0f6479 2535//_____________________________________________________________________________
979b168f 2536TObject *AliTRDCalibraFit::CreatePadObjectPRF(const TObjArray *vectorFit)
3a0f6479 2537{
2538 //
2539 // It Creates the AliTRDCalPad object from AliTRDFitInfo
2540 // This object has to be written in the database
2541 //
2542
2543 // Create the DetObject
2544 AliTRDCalPad *object = new AliTRDCalPad("PRFWidth","PRFWidth");
2545
2546 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2547 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2548 Int_t detector = -1;
2549 Float_t value = 0.0;
2550
2551 for (Int_t k = 0; k < loop; k++) {
2552 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2553 AliTRDCalROC *calROC = object->GetCalROC(detector);
2554 Int_t rowMax = calROC->GetNrows();
2555 Int_t colMax = calROC->GetNcols();
2556 for (Int_t row = 0; row < rowMax; row++) {
2557 for (Int_t col = 0; col < colMax; col++) {
2558 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2559 calROC->SetValue(col,row,TMath::Abs(value));
2560 } // Col
2561 } // Row
2562 }
55a288e5 2563
3a0f6479 2564 return object;
2565
2566}
55a288e5 2567//_____________________________________________________________________________
979b168f 2568AliTRDCalDet *AliTRDCalibraFit::MakeOutliersStatDet(const TObjArray *vectorFit, const char *name, Double_t &mean)
3a0f6479 2569{
2570 //
2571 // It Creates the AliTRDCalDet object from AliTRDFitInfo
2572 // 0 successful fit 1 not successful fit
2573 // mean is the mean value over the successful fit
2574 // do not use it for t0: no meaning
2575 //
2576
2577 // Create the CalObject
2578 AliTRDCalDet *object = new AliTRDCalDet(name,name);
2579 mean = 0.0;
2580 Int_t count = 0;
2581
2582 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2583 if(loop != 540) {
2584 AliInfo("The Vector Fit is not complete! We initialise all outliers");
2585 for(Int_t k = 0; k < 540; k++){
2586 object->SetValue(k,1.0);
2587 }
2588 }
2589 Int_t detector = -1;
2590 Float_t value = 0.0;
2591
2592 for (Int_t k = 0; k < loop; k++) {
2593 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2594 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
2595 if(value <= 0) object->SetValue(detector,1.0);
2596 else {
2597 object->SetValue(detector,0.0);
2598 mean += value;
2599 count++;
2600 }
2601 }
2602 if(count > 0) mean /= count;
2603 return object;
2604}
2605//_____________________________________________________________________________
979b168f 2606TObject *AliTRDCalibraFit::MakeOutliersStatPad(const TObjArray *vectorFit, const char *name, Double_t &mean)
3a0f6479 2607{
2608 //
2609 // It Creates the AliTRDCalPad object from AliTRDFitInfo
2610 // 0 not successful fit 1 successful fit
2611 // mean mean value over the successful fit
2612 //
2613
2614 // Create the CalObject
2615 AliTRDCalPad *object = new AliTRDCalPad(name,name);
2616 mean = 0.0;
2617 Int_t count = 0;
2618
2619 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2620 if(loop != 540) {
2621 AliInfo("The Vector Fit is not complete! We initialise all outliers");
2622 for(Int_t k = 0; k < 540; k++){
2623 AliTRDCalROC *calROC = object->GetCalROC(k);
2624 Int_t nchannels = calROC->GetNchannels();
2625 for(Int_t ch = 0; ch < nchannels; ch++){
2626 calROC->SetValue(ch,1.0);
2627 }
2628 }
2629 }
2630 Int_t detector = -1;
2631 Float_t value = 0.0;
2632
2633 for (Int_t k = 0; k < loop; k++) {
2634 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2635 AliTRDCalROC *calROC = object->GetCalROC(detector);
2636 Int_t nchannels = calROC->GetNchannels();
2637 for (Int_t ch = 0; ch < nchannels; ch++) {
2638 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[ch];
2639 if(value <= 0) calROC->SetValue(ch,1.0);
2640 else {
2641 calROC->SetValue(ch,0.0);
2642 mean += value;
2643 count++;
2644 }
2645 } // channels
2646 }
2647 if(count > 0) mean /= count;
2648 return object;
2649}
2650//_____________________________________________________________________________
2651void AliTRDCalibraFit::SetPeriodeFitPH(Int_t periodeFitPH)
55a288e5 2652{
2653 //
3a0f6479 2654 // Set FitPH if 1 then each detector will be fitted
55a288e5 2655 //
2656
3a0f6479 2657 if (periodeFitPH > 0) {
2658 fFitPHPeriode = periodeFitPH;
55a288e5 2659 }
2660 else {
3a0f6479 2661 AliInfo("periodeFitPH must be higher than 0!");
55a288e5 2662 }
2663
2664}
55a288e5 2665//_____________________________________________________________________________
2666void AliTRDCalibraFit::SetBeginFitCharge(Float_t beginFitCharge)
2667{
2668 //
2669 // The fit of the deposited charge distribution begins at
2670 // histo->Mean()/beginFitCharge
2671 // You can here set beginFitCharge
2672 //
2673
2674 if (beginFitCharge > 0) {
2675 fBeginFitCharge = beginFitCharge;
2676 }
2677 else {
2678 AliInfo("beginFitCharge must be strict positif!");
2679 }
2680
2681}
2682
2683//_____________________________________________________________________________
413153cb 2684void AliTRDCalibraFit::SetT0Shift0(Float_t t0Shift)
2685{
2686 //
2687 // The t0 calculated with the maximum positif slope is shift from t0Shift0
2688 // You can here set t0Shift0
2689 //
2690
2691 if (t0Shift > 0) {
2692 fT0Shift0 = t0Shift;
2693 }
2694 else {
2695 AliInfo("t0Shift0 must be strict positif!");
2696 }
2697
2698}
2699
2700//_____________________________________________________________________________
2701void AliTRDCalibraFit::SetT0Shift1(Float_t t0Shift)
55a288e5 2702{
2703 //
413153cb 2704 // The t0 calculated with the maximum of the amplification region is shift from t0Shift1
2705 // You can here set t0Shift1
55a288e5 2706 //
2707
2708 if (t0Shift > 0) {
413153cb 2709 fT0Shift1 = t0Shift;
55a288e5 2710 }
2711 else {
2712 AliInfo("t0Shift must be strict positif!");
2713 }
2714
2715}
2716
2717//_____________________________________________________________________________
2718void AliTRDCalibraFit::SetRangeFitPRF(Float_t rangeFitPRF)
2719{
2720 //
2721 // The fit of the PRF is from -rangeFitPRF to rangeFitPRF
2722 // You can here set rangeFitPRF
2723 //
2724
2725 if ((rangeFitPRF > 0) &&
2726 (rangeFitPRF <= 1.5)) {
2727 fRangeFitPRF = rangeFitPRF;
2728 }
2729 else {
2730 AliInfo("rangeFitPRF must be between 0 and 1.0");
2731 }
2732
2733}
2734
2735//_____________________________________________________________________________
3a0f6479 2736void AliTRDCalibraFit::SetMinEntries(Int_t minEntries)
55a288e5 2737{
2738 //
3a0f6479 2739 // Minimum entries for fitting
55a288e5 2740 //
2741
3a0f6479 2742 if (minEntries > 0) {
2743 fMinEntries = minEntries;
55a288e5 2744 }
2745 else {
3a0f6479 2746 AliInfo("fMinEntries must be >= 0.");
55a288e5 2747 }
2748
2749}
2750
55a288e5 2751//_____________________________________________________________________________
3a0f6479 2752void AliTRDCalibraFit::SetRebin(Short_t rebin)
2753{
55a288e5 2754 //
3a0f6479 2755 // Rebin with rebin time less bins the Ch histo
2756 // You can set here rebin that should divide the number of bins of CH histo
55a288e5 2757 //
55a288e5 2758
3a0f6479 2759 if (rebin > 0) {
2760 fRebin = rebin;
2761 AliInfo("You have to be sure that fRebin divides fNumberBinCharge used!");
2762 }
2763 else {
2764 AliInfo("You have to choose a positiv value!");
55a288e5 2765 }
2766
2767}
55a288e5 2768//_____________________________________________________________________________
3a0f6479 2769Bool_t AliTRDCalibraFit::FillVectorFit()
55a288e5 2770{
2771 //
3a0f6479 2772 // For the Fit functions fill the vector Fit
55a288e5 2773 //
2774
3a0f6479 2775 AliTRDFitInfo *fitInfo = new AliTRDFitInfo();
55a288e5 2776
3a0f6479 2777 Int_t ntotal = 1;
053767a4 2778 if (GetStack(fCountDet) == 2) {
3a0f6479 2779 ntotal = 1728;
55a288e5 2780 }
3a0f6479 2781 else {
2782 ntotal = 2304;
55a288e5 2783 }
2784
3a0f6479 2785 //printf("For the detector %d , ntotal %d and fCoefCH[0] %f\n",countdet,ntotal,fCoefCH[0]);
2786 Float_t *coef = new Float_t[ntotal];
2787 for (Int_t i = 0; i < ntotal; i++) {
2788 coef[i] = fCurrentCoefDetector[i];
55a288e5 2789 }
55a288e5 2790
3a0f6479 2791 Int_t detector = fCountDet;
2792 // Set
2793 fitInfo->SetCoef(coef);
2794 fitInfo->SetDetector(detector);
2795 fVectorFit.Add((TObject *) fitInfo);
55a288e5 2796
3a0f6479 2797 return kTRUE;
55a288e5 2798
55a288e5 2799}
55a288e5 2800//_____________________________________________________________________________
3a0f6479 2801Bool_t AliTRDCalibraFit::FillVectorFit2()
55a288e5 2802{
2803 //
3a0f6479 2804 // For the Fit functions fill the vector Fit
55a288e5 2805 //
2806
3a0f6479 2807 AliTRDFitInfo *fitInfo = new AliTRDFitInfo();
55a288e5 2808
2809 Int_t ntotal = 1;
053767a4 2810 if (GetStack(fCountDet) == 2) {
55a288e5 2811 ntotal = 1728;
2812 }
2813 else {
2814 ntotal = 2304;
2815 }
2816
2817 //printf("For the detector %d , ntotal %d and fCoefCH[0] %f\n",countdet,ntotal,fCoefCH[0]);
2818 Float_t *coef = new Float_t[ntotal];
2819 for (Int_t i = 0; i < ntotal; i++) {
3a0f6479 2820 coef[i] = fCurrentCoefDetector2[i];
55a288e5 2821 }
2822
3a0f6479 2823 Int_t detector = fCountDet;
55a288e5 2824 // Set
3a0f6479 2825 fitInfo->SetCoef(coef);
2826 fitInfo->SetDetector(detector);
2827 fVectorFit2.Add((TObject *) fitInfo);
55a288e5 2828
2829 return kTRUE;
2830
2831}
55a288e5 2832//____________Functions for initialising the AliTRDCalibraFit in the code_________
2833Bool_t AliTRDCalibraFit::InitFit(Int_t nbins, Int_t i)
2834{
2835 //
3a0f6479 2836 // Init the number of expected bins and fDect1[i] fDect2[i]
55a288e5 2837 //
2838
2839 gStyle->SetPalette(1);
2840 gStyle->SetOptStat(1111);
2841 gStyle->SetPadBorderMode(0);
2842 gStyle->SetCanvasColor(10);
2843 gStyle->SetPadLeftMargin(0.13);
2844 gStyle->SetPadRightMargin(0.01);
3a0f6479 2845
55a288e5 2846 // Mode groups of pads: the total number of bins!
3a0f6479 2847 CalculNumberOfBinsExpected(i);
55a288e5 2848
3a0f6479 2849 // Quick verification that we have the good pad calibration mode!
2850 if (fNumberOfBinsExpected != nbins) {
64942b85 2851 AliInfo(Form("It doesn't correspond to the mode of pad group calibration: expected %d and seen %d!",fNumberOfBinsExpected,nbins));
3a0f6479 2852 return kFALSE;
55a288e5 2853 }
3a0f6479 2854
55a288e5 2855 // Security for fDebug 3 and 4
3a0f6479 2856 if ((fDebugLevel >= 3) &&
55a288e5 2857 ((fDet[0] > 5) ||
2858 (fDet[1] > 4) ||
2859 (fDet[2] > 17))) {
2860 AliInfo("This detector doesn't exit!");
2861 return kFALSE;
2862 }
2863
3a0f6479 2864 // Determine fDet1 and fDet2 and set the fNfragZ and fNfragRphi for debug 3 and 4
2865 CalculDect1Dect2(i);
55a288e5 2866
3a0f6479 2867
2868 return kTRUE;
2869}
2870//____________Functions for initialising the AliTRDCalibraFit in the code_________
2871Bool_t AliTRDCalibraFit::InitFitCH()
2872{
2873 //
2874 // Init the fVectorFitCH for normalisation
2875 // Init the histo for debugging
2876 //
55a288e5 2877
3a0f6479 2878 gDirectory = gROOT;
2879
2880 fScaleFitFactor = 0.0;
f29cf84c 2881 if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
3a0f6479 2882 fCurrentCoefDetector = new Float_t[2304];
2883 for (Int_t k = 0; k < 2304; k++) {
2884 fCurrentCoefDetector[k] = 0.0;
55a288e5 2885 }
3a0f6479 2886 fVectorFit.SetName("gainfactorscoefficients");
55a288e5 2887
3a0f6479 2888 // fDebug == 0 nothing
2889 // fDebug == 1 and fFitVoir no histo
2890 if (fDebugLevel == 1) {
2891 if(!CheckFitVoir()) return kFALSE;
2892 }
2893 //Get the CalDet object
2894 if(fAccCDB){
2895 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
2896 if (!cal) {
2897 AliInfo("Could not get calibDB");
2898 return kFALSE;
55a288e5 2899 }
3a0f6479 2900 if(fCalDet) delete fCalDet;
2901 fCalDet = new AliTRDCalDet(*(cal->GetGainFactorDet()));
55a288e5 2902 }
3a0f6479 2903 else{
2904 Float_t devalue = 1.0;
2905 if(fCalDet) delete fCalDet;
2906 fCalDet = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)");
2907 for(Int_t k = 0; k < 540; k++){
2908 fCalDet->SetValue(k,devalue);
55a288e5 2909 }
3a0f6479 2910 }
2911 return kTRUE;
2912
2913}
2914//____________Functions for initialising the AliTRDCalibraFit in the code_________
2915Bool_t AliTRDCalibraFit::InitFitPH()
2916{
2917 //
2918 // Init the arrays of results
2919 // Init the histos for debugging
2920 //
55a288e5 2921
3a0f6479 2922 gDirectory = gROOT;
2923 fVectorFit.SetName("driftvelocitycoefficients");
2924 fVectorFit2.SetName("t0coefficients");
55a288e5 2925
f29cf84c 2926 if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
3a0f6479 2927 fCurrentCoefDetector = new Float_t[2304];
2928 for (Int_t k = 0; k < 2304; k++) {
2929 fCurrentCoefDetector[k] = 0.0;
2930 }
f29cf84c 2931 if( fCurrentCoefDetector2 ) delete [] fCurrentCoefDetector2;
3a0f6479 2932 fCurrentCoefDetector2 = new Float_t[2304];
2933 for (Int_t k = 0; k < 2304; k++) {
2934 fCurrentCoefDetector2[k] = 0.0;
2935 }
2936
2937 //fDebug == 0 nothing
2938 // fDebug == 1 and fFitVoir no histo
2939 if (fDebugLevel == 1) {
2940 if(!CheckFitVoir()) return kFALSE;
2941 }
2942 //Get the CalDet object
2943 if(fAccCDB){
2944 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
2945 if (!cal) {
2946 AliInfo("Could not get calibDB");
2947 return kFALSE;
55a288e5 2948 }
3a0f6479 2949 if(fCalDet) delete fCalDet;
2950 if(fCalDet2) delete fCalDet2;
2951 fCalDet = new AliTRDCalDet(*(cal->GetVdriftDet()));
2952 fCalDet2 = new AliTRDCalDet(*(cal->GetT0Det()));
2953 }
2954 else{
2955 Float_t devalue = 1.5;
2956 Float_t devalue2 = 0.0;
2957 if(fCalDet) delete fCalDet;
2958 if(fCalDet2) delete fCalDet2;
2959 fCalDet = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)");
2960 fCalDet2 = new AliTRDCalDet("ChamberT0","T0 (detector value)");
2961 for(Int_t k = 0; k < 540; k++){
2962 fCalDet->SetValue(k,devalue);
2963 fCalDet2->SetValue(k,devalue2);
55a288e5 2964 }
55a288e5 2965 }
55a288e5 2966 return kTRUE;
3a0f6479 2967}
2968//____________Functions for initialising the AliTRDCalibraFit in the code_________
2969Bool_t AliTRDCalibraFit::InitFitPRF()
2970{
2971 //
2972 // Init the calibration mode (Nz, Nrphi), the histograms for
2973 // debugging the fit methods if fDebug > 0,
2974 //
55a288e5 2975
3a0f6479 2976 gDirectory = gROOT;
2977 fVectorFit.SetName("prfwidthcoefficients");
2978
f29cf84c 2979 if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
3a0f6479 2980 fCurrentCoefDetector = new Float_t[2304];
2981 for (Int_t k = 0; k < 2304; k++) {
2982 fCurrentCoefDetector[k] = 0.0;
2983 }
2984
2985 // fDebug == 0 nothing
2986 // fDebug == 1 and fFitVoir no histo
2987 if (fDebugLevel == 1) {
2988 if(!CheckFitVoir()) return kFALSE;
2989 }
2990 return kTRUE;
2991}
2992//____________Functions for initialising the AliTRDCalibraFit in the code_________
2993Bool_t AliTRDCalibraFit::InitFitLinearFitter()
2994{
2995 //
2996 // Init the fCalDet, fVectorFit fCurrentCoefDetector
2997 //
2998
2999 gDirectory = gROOT;
3000
f29cf84c 3001 if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
3002 if( fCurrentCoefDetector2 ) delete [] fCurrentCoefDetector2;
3a0f6479 3003 fCurrentCoefDetector = new Float_t[2304];
3004 fCurrentCoefDetector2 = new Float_t[2304];
3005 for (Int_t k = 0; k < 2304; k++) {
3006 fCurrentCoefDetector[k] = 0.0;
3007 fCurrentCoefDetector2[k] = 0.0;
3008 }
3009
840ec79d 3010 if((!fCalDetVdriftUsed) || (!fCalDetExBUsed)) return kFALSE;
3011
3a0f6479 3012 return kTRUE;
55a288e5 3013}
55a288e5 3014//____________Functions for initialising the AliTRDCalibraFit in the code_________
a0bb5615 3015Bool_t AliTRDCalibraFit::InitFitExbAlt()
3016{
3017 //
3018 // Init the fCalDet, fVectorFit fCurrentCoefDetector
3019 //
3020
3021 gDirectory = gROOT;
3022
f29cf84c 3023 if( fCurrentCoefDetector2 ) delete [] fCurrentCoefDetector2;
3024 fCurrentCoefDetector2 = new Float_t[2304];
a0bb5615 3025 for (Int_t k = 0; k < 2304; k++) {
3026 fCurrentCoefDetector2[k] = 0.0;
3027 }
3028
3029 return kTRUE;
3030}
3031//____________Functions for initialising the AliTRDCalibraFit in the code_________
55a288e5 3032void AliTRDCalibraFit::InitfCountDetAndfCount(Int_t i)
3033{
3034 //
3035 // Init the current detector where we are fCountDet and the
3036 // next fCount for the functions Fit...
3037 //
3a0f6479 3038
55a288e5 3039 // Loop on the Xbins of ch!!
3a0f6479 3040 fCountDet = -1; // Current detector
3041 fCount = 0; // To find the next detector
55a288e5 3042
3043 // If fDebug >= 3
3a0f6479 3044 if (fDebugLevel >= 3) {
55a288e5 3045 // Set countdet to the detector
3a0f6479 3046 fCountDet = AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]);
55a288e5 3047 // Set counter to write at the end of the detector
3a0f6479 3048 fCount = fDect2;
3049 // Get the right calib objects
3050 SetCalROC(i);
3051 }
3052 if(fDebugLevel == 1) {
3053 fCountDet = 0;
3054 fCalibraMode->CalculXBins(fCountDet,i);
6aafa7ea 3055 if((fCalibraMode->GetNz(i)!=100) && (fCalibraMode->GetNrphi(i)!=100)){
3056 while(fCalibraMode->GetXbins(i) <=fFitVoir){
3057 fCountDet++;
3058 fCalibraMode->CalculXBins(fCountDet,i);
3059 //printf("GetXBins %d\n",fCalibraMode->GetXbins(i));
3060 }
3061 }
3062 else {
3a0f6479 3063 fCountDet++;
6aafa7ea 3064 }
3a0f6479 3065 fCount = fCalibraMode->GetXbins(i);
3066 fCountDet--;
3067 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
053767a4 3068 fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),i);
3069 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet)
3070 ,(Int_t) GetStack(fCountDet)
3071 ,(Int_t) GetSector(fCountDet),i);
55a288e5 3072 }
55a288e5 3073}
3a0f6479 3074//_______________________________________________________________________________
3075void AliTRDCalibraFit::CalculNumberOfBinsExpected(Int_t i)
3076{
3077 //
3078 // Calculate the number of bins expected (calibration groups)
3079 //
3080
3081 fNumberOfBinsExpected = 0;
64942b85 3082 // All
3083 if((fCalibraMode->GetNz(i) == 100) && (fCalibraMode->GetNrphi(i) == 100)){
3084 fNumberOfBinsExpected = 1;
3085 return;
3086 }
3087 // Per supermodule
3088 if((fCalibraMode->GetNz(i) == 10) && (fCalibraMode->GetNrphi(i) == 10)){
3089 fNumberOfBinsExpected = 18;
3090 return;
3091 }
3092 // More
3a0f6479 3093 fCalibraMode->ModePadCalibration(2,i);
3094 fCalibraMode->ModePadFragmentation(0,2,0,i);
3095 fCalibraMode->SetDetChamb2(i);
3096 if (fDebugLevel > 1) {
3097 AliInfo(Form("For the chamber 2: %d",fCalibraMode->GetDetChamb2(i)));
3098 }
3099 fNumberOfBinsExpected += 6 * 18 * fCalibraMode->GetDetChamb2(i);
3100 fCalibraMode->ModePadCalibration(0,i);
3101 fCalibraMode->ModePadFragmentation(0,0,0,i);
3102 fCalibraMode->SetDetChamb0(i);
3103 if (fDebugLevel > 1) {
3104 AliInfo(Form("For the other chamber 0: %d",fCalibraMode->GetDetChamb0(i)));
3105 }
3106 fNumberOfBinsExpected += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(i);
3107
3108}
3109//_______________________________________________________________________________
3110void AliTRDCalibraFit::CalculDect1Dect2(Int_t i)
3111{
3112 //
3113 // Calculate the range of fits
3114 //
3115
3116 fDect1 = -1;
3117 fDect2 = -1;
3118 if (fDebugLevel == 1) {
3119 fDect1 = fFitVoir;
3120 fDect2 = fDect1 +1;
3121 }
3122 if ((fDebugLevel == 2) || (fDebugLevel == 0)) {
3123 fDect1 = 0;
3124 fDect2 = fNumberOfBinsExpected;
3125 }
3126 if (fDebugLevel >= 3) {
3127 fCountDet = AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]);
3128 fCalibraMode->CalculXBins(fCountDet,i);
3129 fDect1 = fCalibraMode->GetXbins(i);
3130 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
053767a4 3131 fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),i);
3132 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet)
3133 ,(Int_t) GetStack(fCountDet)
3134 ,(Int_t) GetSector(fCountDet),i);
3a0f6479 3135 // Set for the next detector
3136 fDect2 = fDect1 + fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i);
3137 }
3138}
3139//_______________________________________________________________________________
3140Bool_t AliTRDCalibraFit::CheckFitVoir()
3141{
3142 //
3143 // Check if fFitVoir is in the range
3144 //
3145
3146 if (fFitVoir < fNumberOfBinsExpected) {
3147 AliInfo(Form("We will see the fit of the object %d",fFitVoir));
3148 }
3149 else {
3150 AliInfo("fFitVoir is out of range of the histo!");
3151 return kFALSE;
3152 }
3153 return kTRUE;
3154}
55a288e5 3155//____________Functions for initialising the AliTRDCalibraFit in the code_________
3156void AliTRDCalibraFit::UpdatefCountDetAndfCount(Int_t idect, Int_t i)
3157{
3158 //
3159 // See if we are in a new detector and update the
3160 // variables fNfragZ and fNfragRphi if yes
3a0f6479 3161 // Will never happen for only one detector (3 and 4)
3162 // Doesn't matter for 2
3163 //
3164 if (fCount == idect) {
64942b85 3165 // On en est au detector (or first detector in the group)
3166 fCountDet += 1;
3167 AliDebug(2,Form("We are at the detector %d\n",fCountDet));
3168 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
3169 fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),i);
3170 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet)
053767a4 3171 ,(Int_t) GetStack(fCountDet)
3172 ,(Int_t) GetSector(fCountDet),i);
64942b85 3173 // Set for the next detector
3174 fCount += fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i);
3175 // calib objects
3176 SetCalROC(i);
3177 }
55a288e5 3178}
55a288e5 3179//____________Functions for initialising the AliTRDCalibraFit in the code_________
3180void AliTRDCalibraFit::ReconstructFitRowMinRowMax(Int_t idect, Int_t i)
3181{
3182 //
3183 // Reconstruct the min pad row, max pad row, min pad col and
3184 // max pad col of the calibration group for the Fit functions
64942b85 3185 // idect is the calibration group inside the detector
55a288e5 3186 //
3a0f6479 3187 if (fDebugLevel != 1) {
3188 fCalibraMode->ReconstructionRowPadGroup((Int_t) (idect-(fCount-(fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i)))),i);
55a288e5 3189 }
64942b85 3190 AliDebug(2,Form("AliTRDCalibraFit::ReconstructFitRowMinRowMax: the local calibration group is %d",idect-(fCount-(fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i)))));
3191 AliDebug(2,Form("AliTRDCalibraFit::ReconstructFitRowMinRowMax: the number of group per detector is %d",fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i)));
55a288e5 3192}
55a288e5 3193//____________Functions for initialising the AliTRDCalibraFit in the code_________
3a0f6479 3194Bool_t AliTRDCalibraFit::NotEnoughStatisticCH(Int_t idect)
55a288e5 3195{
3196 //
3197 // For the case where there are not enough entries in the histograms
3198 // of the calibration group, the value present in the choosen database