Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[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)
700a5a26 935 const TAxis *xprf = prf->GetXaxis();
936 const 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;
81f82b26 1728 // Coverity
1729 //Int_t sector = -1;
6aafa7ea 1730 Float_t value = 0.0;
1731
1732 /////////////////////////////////
1733 // Calculate the mean values
1734 ////////////////////////////////
1735 // Initialisation
1736 ////////////////////////
1737 Double_t meanAll = 0.0;
4f3bd513 1738 Double_t rmsAll = 0.0;
1739 Int_t countAll = 0;
1740 ////////////
6aafa7ea 1741 // compute
1742 ////////////
1743 for (Int_t k = 0; k < loop; k++) {
1744 detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector();
81f82b26 1745 // Coverity
1746 //sector = GetSector(detector);
6aafa7ea 1747 if(perdetector){
1748 value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[0];
1749 if(value > 0.0) {
1750 rmsAll += value*value;
1751 meanAll += value;
1752 countAll++;
1753 }
1754 }
1755 else {
1756 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1757 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1758 for (Int_t row = 0; row < rowMax; row++) {
1759 for (Int_t col = 0; col < colMax; col++) {
1760 value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
1761 if(value > 0.0) {
1762 rmsAll += value*value;
1763 meanAll += value;
1764 countAll++;
1765 }
1766
1767 } // Col
1768 } // Row
1769 }
1770 }
1771 if(countAll > 0) {
1772 meanAll = meanAll/countAll;
1773 rmsAll = TMath::Sqrt(TMath::Abs(rmsAll/countAll - (meanAll*meanAll)));
1774 }
1775 //printf("RemoveOutliers: meanAll %f and rmsAll %f\n",meanAll,rmsAll);
1776 /////////////////////////////////////////////////
1777 // Remove outliers
1778 ////////////////////////////////////////////////
1779 Double_t defaultvalue = -1.0;
1780 if(type==1) defaultvalue = -1.5;
1781 for (Int_t k = 0; k < loop; k++) {
1782 detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector();
81f82b26 1783 // Coverity
1784 //sector = GetSector(detector);
6aafa7ea 1785 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1786 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1787 Float_t *coef = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef();
1788
1789 // remove the results too far away
1790 for (Int_t row = 0; row < rowMax; row++) {
1791 for (Int_t col = 0; col < colMax; col++) {
1792 value = coef[(Int_t)(col*rowMax+row)];
1793 if((value > 0.0) && (rmsAll > 0.0) && (TMath::Abs(value-meanAll) > (2*rmsAll))) {
1794 coef[(Int_t)(col*rowMax+row)] = defaultvalue;
1795 }
1796 } // Col
1797 } // Row
1798 }
1799}
1800//______________________________________________________________________
1801void AliTRDCalibraFit::RemoveOutliers2(Bool_t perdetector){
1802 //
1803 // Remove the results too far from the mean and rms
1804 // perdetector
1805 //
1806
1807 Int_t loop = (Int_t) fVectorFit2.GetEntriesFast();
1808 if(loop != 540) {
1809 AliInfo("The Vector Fit is not complete!");
1810 return;
1811 }
1812 Int_t detector = -1;
81f82b26 1813 // Coverity
1814 //Int_t sector = -1;
6aafa7ea 1815 Float_t value = 0.0;
1816
1817 /////////////////////////////////
1818 // Calculate the mean values
1819 ////////////////////////////////
1820 // Initialisation
1821 ////////////////////////
1822 Double_t meanAll = 0.0;
1823 Double_t rmsAll = 0.0;
1824 Int_t countAll = 0;
1825 /////////////
1826 // compute
1827 ////////////
1828 for (Int_t k = 0; k < loop; k++) {
1829 detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector();
81f82b26 1830 // Coverity
1831 //sector = GetSector(detector);
6aafa7ea 1832 if(perdetector){
1833 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[0];
1834 if(value < 70.0) {
1835 meanAll += value;
1836 rmsAll += value*value;
1837 countAll++;
1838 }
1839 }
1840 else {
1841 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1842 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1843 for (Int_t row = 0; row < rowMax; row++) {
1844 for (Int_t col = 0; col < colMax; col++) {
1845 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
1846 if(value < 70.0) {
1847 rmsAll += value*value;
1848 meanAll += value;
1849 countAll++;
1850 }
1851 } // Col
1852 } // Row
1853 }
1854 }
1855 if(countAll > 0) {
1856 meanAll = meanAll/countAll;
1857 rmsAll = TMath::Sqrt(TMath::Abs(rmsAll/countAll - (meanAll*meanAll)));
1858 }
1859 //printf("Remove outliers 2: meanAll %f, rmsAll %f\n",meanAll,rmsAll);
1860 /////////////////////////////////////////////////
1861 // Remove outliers
1862 ////////////////////////////////////////////////
1863 for (Int_t k = 0; k < loop; k++) {
1864 detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector();
81f82b26 1865 // Coverity
1866 //sector = GetSector(detector);
6aafa7ea 1867 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1868 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1869 Float_t *coef = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef();
1870
1871 // remove the results too far away
1872 for (Int_t row = 0; row < rowMax; row++) {
1873 for (Int_t col = 0; col < colMax; col++) {
1874 value = coef[(Int_t)(col*rowMax+row)];
b88b6bcc 1875 if((value < 70.0) && (rmsAll > 0.0) && (TMath::Abs(value-meanAll) > (2.5*rmsAll))) {
1876 //printf("value outlier %f\n",value);
1877 coef[(Int_t)(col*rowMax+row)] = 100.0;
1878 }
6aafa7ea 1879 } // Col
1880 } // Row
1881 }
1882}
1883//______________________________________________________________________
64942b85 1884void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetector){
1885 //
1886 // ofwhat is equaled to 0: mean value of all passing detectors
1887 // ofwhat is equaled to 1: mean value of the detector, otherwise supermodule, otherwise all
1888 //
1889
1890 Int_t loop = (Int_t) fVectorFit.GetEntriesFast();
1891 if(loop != 540) {
1892 AliInfo("The Vector Fit is not complete!");
1893 return;
1894 }
1895 Int_t detector = -1;
1896 Int_t sector = -1;
1897 Float_t value = 0.0;
1898
1899 /////////////////////////////////
1900 // Calculate the mean values
1901 ////////////////////////////////
1902 // Initialisation
1903 ////////////////////////
1904 Double_t meanAll = 0.0;
1905 Double_t meanSupermodule[18];
1906 Double_t meanDetector[540];
6aafa7ea 1907 Double_t rmsAll = 0.0;
1908 Double_t rmsSupermodule[18];
1909 Double_t rmsDetector[540];
64942b85 1910 Int_t countAll = 0;
1911 Int_t countSupermodule[18];
1912 Int_t countDetector[540];
1913 for(Int_t sm = 0; sm < 18; sm++){
6aafa7ea 1914 rmsSupermodule[sm] = 0.0;
64942b85 1915 meanSupermodule[sm] = 0.0;
1916 countSupermodule[sm] = 0;
1917 }
1918 for(Int_t det = 0; det < 540; det++){
6aafa7ea 1919 rmsDetector[det] = 0.0;
64942b85 1920 meanDetector[det] = 0.0;
1921 countDetector[det] = 0;
1922 }
6aafa7ea 1923 ////////////
64942b85 1924 // compute
1925 ////////////
1926 for (Int_t k = 0; k < loop; k++) {
1927 detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector();
1928 sector = GetSector(detector);
1929 if(perdetector){
1930 value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[0];
1931 if(value > 0.0) {
6aafa7ea 1932 rmsDetector[detector] += value*value;
64942b85 1933 meanDetector[detector] += value;
1934 countDetector[detector]++;
6aafa7ea 1935 rmsSupermodule[sector] += value*value;
64942b85 1936 meanSupermodule[sector] += value;
1937 countSupermodule[sector]++;
6aafa7ea 1938 rmsAll += value*value;
64942b85 1939 meanAll += value;
1940 countAll++;
1941 }
1942 }
1943 else {
1944 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1945 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1946 for (Int_t row = 0; row < rowMax; row++) {
1947 for (Int_t col = 0; col < colMax; col++) {
1948 value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
1949 if(value > 0.0) {
6aafa7ea 1950 rmsDetector[detector] += value*value;
64942b85 1951 meanDetector[detector] += value;
1952 countDetector[detector]++;
6aafa7ea 1953 rmsSupermodule[sector] += value*value;
64942b85 1954 meanSupermodule[sector] += value;
1955 countSupermodule[sector]++;
6aafa7ea 1956 rmsAll += value*value;
64942b85 1957 meanAll += value;
1958 countAll++;
1959 }
1960
1961 } // Col
1962 } // Row
1963 }
1964 }
6aafa7ea 1965 if(countAll > 0) {
1966 meanAll = meanAll/countAll;
1967 rmsAll = TMath::Abs(rmsAll/countAll - (meanAll*meanAll));
1968 }
64942b85 1969 for(Int_t sm = 0; sm < 18; sm++){
6aafa7ea 1970 if(countSupermodule[sm] > 0) {
1971 meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm];
1972 rmsSupermodule[sm] = TMath::Abs(rmsSupermodule[sm]/countSupermodule[sm] - (meanSupermodule[sm]*meanSupermodule[sm]));
1973 }
64942b85 1974 }
1975 for(Int_t det = 0; det < 540; det++){
6aafa7ea 1976 if(countDetector[det] > 0) {
1977 meanDetector[det] = meanDetector[det]/countDetector[det];
1978 rmsDetector[det] = TMath::Abs(rmsDetector[det]/countDetector[det] - (meanDetector[det]*meanDetector[det]));
1979 }
64942b85 1980 }
6aafa7ea 1981 //printf("Put mean value, meanAll %f, rmsAll %f\n",meanAll,rmsAll);
1982 ///////////////////////////////////////////////
64942b85 1983 // Put the mean value for the no-fitted
1984 /////////////////////////////////////////////
1985 for (Int_t k = 0; k < loop; k++) {
1986 detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector();
1987 sector = GetSector(detector);
1988 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
1989 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
1990 Float_t *coef = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef();
1991
1992 for (Int_t row = 0; row < rowMax; row++) {
1993 for (Int_t col = 0; col < colMax; col++) {
1994 value = coef[(Int_t)(col*rowMax+row)];
1995 if(value < 0.0) {
6aafa7ea 1996 if((ofwhat == 0) && (meanAll > 0.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll);
64942b85 1997 if(ofwhat == 1){
6aafa7ea 1998 if((meanDetector[detector] > 0.0) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanDetector[detector]);
1999 else if((meanSupermodule[sector] > 0.0) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanSupermodule[sector]);
2000 else if((meanAll > 0.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll);
64942b85 2001 }
2002 }
2003 // Debug
2004 if(fDebugLevel > 1){
2005
2006 if ( !fDebugStreamer ) {
2007 //debug stream
2008 TDirectory *backup = gDirectory;
2009 fDebugStreamer = new TTreeSRedirector("TRDDebugFit.root");
2010 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2011 }
2012
2013 Float_t coefnow = coef[(Int_t)(col*rowMax+row)];
2014
2015 (* fDebugStreamer) << "PutMeanValueOtherVectorFit"<<
2016 "detector="<<detector<<
2017 "sector="<<sector<<
2018 "row="<<row<<
2019 "col="<<col<<
2020 "before="<<value<<
2021 "after="<<coefnow<<
2022 "\n";
2023 }
2024 } // Col
2025 } // Row
2026 }
64942b85 2027}
2028//______________________________________________________________________
2029void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetector){
2030 //
2031 // ofwhat is equaled to 0: mean value of all passing detectors
2032 // ofwhat is equaled to 1: mean value of the detector, otherwise supermodule, otherwise all
2033 //
2034
2035 Int_t loop = (Int_t) fVectorFit2.GetEntriesFast();
2036 if(loop != 540) {
2037 AliInfo("The Vector Fit is not complete!");
2038 return;
2039 }
2040 Int_t detector = -1;
2041 Int_t sector = -1;
2042 Float_t value = 0.0;
2043
2044 /////////////////////////////////
2045 // Calculate the mean values
2046 ////////////////////////////////
2047 // Initialisation
2048 ////////////////////////
2049 Double_t meanAll = 0.0;
6aafa7ea 2050 Double_t rmsAll = 0.0;
64942b85 2051 Double_t meanSupermodule[18];
6aafa7ea 2052 Double_t rmsSupermodule[18];
64942b85 2053 Double_t meanDetector[540];
6aafa7ea 2054 Double_t rmsDetector[540];
64942b85 2055 Int_t countAll = 0;
2056 Int_t countSupermodule[18];
2057 Int_t countDetector[540];
2058 for(Int_t sm = 0; sm < 18; sm++){
6aafa7ea 2059 rmsSupermodule[sm] = 0.0;
64942b85 2060 meanSupermodule[sm] = 0.0;
2061 countSupermodule[sm] = 0;
2062 }
2063 for(Int_t det = 0; det < 540; det++){
6aafa7ea 2064 rmsDetector[det] = 0.0;
64942b85 2065 meanDetector[det] = 0.0;
2066 countDetector[det] = 0;
2067 }
2068 // compute
2069 ////////////
2070 for (Int_t k = 0; k < loop; k++) {
2071 detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector();
2072 sector = GetSector(detector);
2073 if(perdetector){
2074 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[0];
2075 if(value < 70.0) {
6aafa7ea 2076 rmsDetector[detector] += value*value;
64942b85 2077 meanDetector[detector] += value;
2078 countDetector[detector]++;
6aafa7ea 2079 rmsSupermodule[sector] += value*value;
64942b85 2080 meanSupermodule[sector] += value;
2081 countSupermodule[sector]++;
2082 meanAll += value;
6aafa7ea 2083 rmsAll += value*value;
64942b85 2084 countAll++;
2085 }
2086 }
2087 else {
2088 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2089 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
2090 for (Int_t row = 0; row < rowMax; row++) {
2091 for (Int_t col = 0; col < colMax; col++) {
2092 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2093 if(value < 70.0) {
6aafa7ea 2094 rmsDetector[detector] += value*value;
64942b85 2095 meanDetector[detector] += value;
2096 countDetector[detector]++;
6aafa7ea 2097 rmsSupermodule[sector] += value*value;
64942b85 2098 meanSupermodule[sector] += value;
2099 countSupermodule[sector]++;
6aafa7ea 2100 rmsAll += value*value;
64942b85 2101 meanAll += value;
2102 countAll++;
2103 }
2104
2105 } // Col
2106 } // Row
2107 }
2108 }
6aafa7ea 2109 if(countAll > 0) {
2110 meanAll = meanAll/countAll;
2111 rmsAll = TMath::Abs(rmsAll/countAll - (meanAll*meanAll));
2112 }
64942b85 2113 for(Int_t sm = 0; sm < 18; sm++){
6aafa7ea 2114 if(countSupermodule[sm] > 0) {
2115 meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm];
2116 rmsSupermodule[sm] = TMath::Abs(rmsSupermodule[sm]/countSupermodule[sm] - (meanSupermodule[sm]*meanSupermodule[sm]));
2117 }
64942b85 2118 }
2119 for(Int_t det = 0; det < 540; det++){
6aafa7ea 2120 if(countDetector[det] > 0) {
2121 meanDetector[det] = meanDetector[det]/countDetector[det];
2122 rmsDetector[det] = TMath::Abs(rmsDetector[det]/countDetector[det] - (meanDetector[det]*meanDetector[det]));
2123 }
64942b85 2124 }
6aafa7ea 2125 //printf("Put mean value 2: meanAll %f, rmsAll %f\n",meanAll,rmsAll);
2126 ////////////////////////////////////////////
64942b85 2127 // Put the mean value for the no-fitted
2128 /////////////////////////////////////////////
2129 for (Int_t k = 0; k < loop; k++) {
2130 detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector();
2131 sector = GetSector(detector);
2132 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2133 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
2134 Float_t *coef = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef();
2135
2136 for (Int_t row = 0; row < rowMax; row++) {
2137 for (Int_t col = 0; col < colMax; col++) {
2138 value = coef[(Int_t)(col*rowMax+row)];
2139 if(value > 70.0) {
840ec79d 2140 if((ofwhat == 0) && (meanAll > -3.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0;
64942b85 2141 if(ofwhat == 1){
840ec79d 2142 if((meanDetector[detector] > -3.0) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = meanDetector[detector]+100.0;
2143 else if((meanSupermodule[sector] > -3.0) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = meanSupermodule[sector]+100.0;
2144 else if((meanAll > -3.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0;
64942b85 2145 }
2146 }
2147 // Debug
2148 if(fDebugLevel > 1){
2149
2150 if ( !fDebugStreamer ) {
2151 //debug stream
2152 TDirectory *backup = gDirectory;
2153 fDebugStreamer = new TTreeSRedirector("TRDDebugFit.root");
2154 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2155 }
2156
2157 Float_t coefnow = coef[(Int_t)(col*rowMax+row)];
2158
2159 (* fDebugStreamer) << "PutMeanValueOtherVectorFit2"<<
2160 "detector="<<detector<<
2161 "sector="<<sector<<
2162 "row="<<row<<
2163 "col="<<col<<
2164 "before="<<value<<
2165 "after="<<coefnow<<
2166 "\n";
2167 }
2168 } // Col
2169 } // Row
2170 }
2171
2172}
3a0f6479 2173//_____________________________________________________________________________
979b168f 2174AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectVdrift(const TObjArray *vectorFit, Bool_t perdetector)
3a0f6479 2175{
2176 //
2177 // It creates the AliTRDCalDet object from the AliTRDFitInfo
2178 // It takes the mean value of the coefficients per detector
2179 // This object has to be written in the database
2180 //
55a288e5 2181
3a0f6479 2182 // Create the DetObject
2183 AliTRDCalDet *object = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)");
2184
2185 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2186 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2187 Int_t detector = -1;
2188 Float_t value = 0.0;
64942b85 2189
2190 //
3a0f6479 2191 for (Int_t k = 0; k < loop; k++) {
2192 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2193 Float_t mean = 0.0;
2194 if(perdetector){
2195 mean = TMath::Abs(((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0]);
55a288e5 2196 }
2197 else {
3a0f6479 2198 Int_t count = 0;
053767a4 2199 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2200 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
3a0f6479 2201 for (Int_t row = 0; row < rowMax; row++) {
2202 for (Int_t col = 0; col < colMax; col++) {
2203 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2204 mean += TMath::Abs(value);
2205 count++;
2206 } // Col
2207 } // Row
2208 if(count > 0) mean = mean/count;
55a288e5 2209 }
2210 object->SetValue(detector,mean);
2211 }
3a0f6479 2212
55a288e5 2213 return object;
55a288e5 2214}
55a288e5 2215//_____________________________________________________________________________
979b168f 2216AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectGain(const TObjArray *vectorFit, Bool_t meanOtherBefore, Double_t scaleFitFactor, Bool_t perdetector)
55a288e5 2217{
2218 //
3a0f6479 2219 // It creates the AliTRDCalDet object from the AliTRDFitInfo
2220 // It takes the mean value of the coefficients per detector
55a288e5 2221 // This object has to be written in the database
2222 //
2223
2224 // Create the DetObject
3a0f6479 2225 AliTRDCalDet *object = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)");
55a288e5 2226
54f2ff1c 2227 fScaleGain = scaleFitFactor;
3a0f6479 2228
2229 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2230 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2231 Int_t detector = -1;
2232 Float_t value = 0.0;
2233
2234 for (Int_t k = 0; k < loop; k++) {
2235 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2236 Float_t mean = 0.0;
2237 if(perdetector){
2238 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
64942b85 2239 if(!meanOtherBefore){
2240 if(value > 0) value = value*scaleFitFactor;
2241 }
2242 else value = value*scaleFitFactor;
3a0f6479 2243 mean = TMath::Abs(value);
2244 }
2245 else{
2246 Int_t count = 0;
053767a4 2247 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2248 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
3a0f6479 2249 for (Int_t row = 0; row < rowMax; row++) {
2250 for (Int_t col = 0; col < colMax; col++) {
2251 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
64942b85 2252 if(!meanOtherBefore) {
2253 if(value > 0) value = value*scaleFitFactor;
2254 }
2255 else value = value*scaleFitFactor;
3a0f6479 2256 mean += TMath::Abs(value);
2257 count++;
2258 } // Col
2259 } // Row
2260 if(count > 0) mean = mean/count;
2261 }
ba1aa7a7 2262 if(mean < 0.1) mean = 0.1;
3a0f6479 2263 object->SetValue(detector,mean);
55a288e5 2264 }
3a0f6479 2265
2266 return object;
2267}
2268//_____________________________________________________________________________
979b168f 2269AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectT0(const TObjArray *vectorFit, Bool_t perdetector)
3a0f6479 2270{
2271 //
2272 // It creates the AliTRDCalDet object from the AliTRDFitInfo2
2273 // It takes the min value of the coefficients per detector
2274 // This object has to be written in the database
2275 //
55a288e5 2276
3a0f6479 2277 // Create the DetObject
2278 AliTRDCalDet *object = new AliTRDCalDet("ChamberT0","T0 (detector value)");
55a288e5 2279
3a0f6479 2280 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2281 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2282 Int_t detector = -1;
2283 Float_t value = 0.0;
2284
2285 for (Int_t k = 0; k < loop; k++) {
2286 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2287 Float_t min = 100.0;
2288 if(perdetector){
64942b85 2289 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
b88b6bcc 2290 //printf("Create det object %f for %d\n",value,k);
64942b85 2291 // check successful
2292 if(value > 70.0) value = value-100.0;
2293 //
2294 min = value;
55a288e5 2295 }
3a0f6479 2296 else{
053767a4 2297 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2298 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
3a0f6479 2299 for (Int_t row = 0; row < rowMax; row++) {
2300 for (Int_t col = 0; col < colMax; col++) {
2301 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
64942b85 2302 // check successful
2303 if(value > 70.0) value = value-100.0;
2304 //
3a0f6479 2305 if(min > value) min = value;
2306 } // Col
2307 } // Row
2308 }
2309 object->SetValue(detector,min);
55a288e5 2310 }
2311
2312 return object;
2313
2314}
55a288e5 2315//_____________________________________________________________________________
979b168f 2316AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectLorentzAngle(const TObjArray *vectorFit)
55a288e5 2317{
2318 //
3a0f6479 2319 // It creates the AliTRDCalDet object from the AliTRDFitInfo2
2320 // It takes the min value of the coefficients per detector
55a288e5 2321 // This object has to be written in the database
2322 //
2323
2324 // Create the DetObject
3a0f6479 2325 AliTRDCalDet *object = new AliTRDCalDet("tan(lorentzangle)","tan(lorentzangle) (detector value)");
2326
2327
2328 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2329 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2330 Int_t detector = -1;
2331 Float_t value = 0.0;
55a288e5 2332
3a0f6479 2333 for (Int_t k = 0; k < loop; k++) {
2334 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2335 /*
053767a4 2336 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2337 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
3a0f6479 2338 Float_t min = 100.0;
2339 for (Int_t row = 0; row < rowMax; row++) {
2340 for (Int_t col = 0; col < colMax; col++) {
2341 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2342 mean += -TMath::Abs(value);
2343 count++;
55a288e5 2344 } // Col
3a0f6479 2345 } // Row
2346 if(count > 0) mean = mean/count;
2347 */
2348 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
840ec79d 2349 if(value > 70.0) value = value-100.0;
2350 object->SetValue(detector,value);
55a288e5 2351 }
2352
2353 return object;
3a0f6479 2354
55a288e5 2355}
55a288e5 2356//_____________________________________________________________________________
a0bb5615 2357AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectExbAlt(const TObjArray *vectorFit)
2358{
2359 //
2360 // It creates the AliTRDCalDet object from the AliTRDFitInfo2
2361 // It takes the min value of the coefficients per detector
2362 // This object has to be written in the database
2363 //
2364
2365 // Create the DetObject
2366 AliTRDCalDet *object = new AliTRDCalDet("tan(lorentzangle)","tan(lorentzangle) (detector value)");
2367
2368
2369 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2370 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2371 Int_t detector = -1;
2372 Float_t value = 0.0;
2373
2374 for (Int_t k = 0; k < loop; k++) {
2375 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2376 /*
2377 Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector));
2378 Int_t colMax = fGeo->GetColMax(GetLayer(detector));
2379 Float_t min = 100.0;
2380 for (Int_t row = 0; row < rowMax; row++) {
2381 for (Int_t col = 0; col < colMax; col++) {
2382 value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2383 mean += -TMath::Abs(value);
2384 count++;
2385 } // Col
2386 } // Row
2387 if(count > 0) mean = mean/count;
2388 */
2389 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
2390 //if(value > 70.0) value = value-100.0;
2391 object->SetValue(detector,value);
2392 }
2393
2394 return object;
2395
2396}
2397//_____________________________________________________________________________
979b168f 2398TObject *AliTRDCalibraFit::CreatePadObjectGain(const TObjArray *vectorFit, Double_t scaleFitFactor, const AliTRDCalDet *detobject)
3a0f6479 2399{
55a288e5 2400 //
3a0f6479 2401 // It Creates the AliTRDCalPad object from AliTRDFitInfo
2402 // You need first to create the object for the detectors,
2403 // where the mean value is put.
2404 // This object has to be written in the database
55a288e5 2405 //
3a0f6479 2406
2407 // Create the DetObject
2408 AliTRDCalPad *object = new AliTRDCalPad("GainFactor","GainFactor (local variations)");
2409
2410 if(!vectorFit){
2411 for(Int_t k = 0; k < 540; k++){
2412 AliTRDCalROC *calROC = object->GetCalROC(k);
2413 Int_t nchannels = calROC->GetNchannels();
2414 for(Int_t ch = 0; ch < nchannels; ch++){
2415 calROC->SetValue(ch,1.0);
2416 }
2417 }
55a288e5 2418 }
3a0f6479 2419 else{
2420
2421 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2422 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2423 Int_t detector = -1;
2424 Float_t value = 0.0;
2425
2426 for (Int_t k = 0; k < loop; k++) {
2427 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2428 AliTRDCalROC *calROC = object->GetCalROC(detector);
2429 Float_t mean = detobject->GetValue(detector);
daa7dc79 2430 if(TMath::Abs(mean) <= 0.0000000001) continue;
3a0f6479 2431 Int_t rowMax = calROC->GetNrows();
2432 Int_t colMax = calROC->GetNcols();
2433 for (Int_t row = 0; row < rowMax; row++) {
2434 for (Int_t col = 0; col < colMax; col++) {
2435 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2436 if(value > 0) value = value*scaleFitFactor;
2437 calROC->SetValue(col,row,TMath::Abs(value)/mean);
2438 } // Col
2439 } // Row
2440 }
55a288e5 2441 }
2442
3a0f6479 2443 return object;
55a288e5 2444}
55a288e5 2445//_____________________________________________________________________________
979b168f 2446TObject *AliTRDCalibraFit::CreatePadObjectVdrift(const TObjArray *vectorFit, const AliTRDCalDet *detobject)
3a0f6479 2447{
55a288e5 2448 //
3a0f6479 2449 // It Creates the AliTRDCalPad object from AliTRDFitInfo
2450 // You need first to create the object for the detectors,
2451 // where the mean value is put.
2452 // This object has to be written in the database
55a288e5 2453 //
2454
3a0f6479 2455 // Create the DetObject
2456 AliTRDCalPad *object = new AliTRDCalPad("LocalVdrift","TRD drift velocities (local variations)");
2457
2458 if(!vectorFit){
2459 for(Int_t k = 0; k < 540; k++){
2460 AliTRDCalROC *calROC = object->GetCalROC(k);
2461 Int_t nchannels = calROC->GetNchannels();
2462 for(Int_t ch = 0; ch < nchannels; ch++){
2463 calROC->SetValue(ch,1.0);
2464 }
2465 }
55a288e5 2466 }
2467 else {
3a0f6479 2468
2469 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2470 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2471 Int_t detector = -1;
2472 Float_t value = 0.0;
2473
2474 for (Int_t k = 0; k < loop; k++) {
2475 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2476 AliTRDCalROC *calROC = object->GetCalROC(detector);
2477 Float_t mean = detobject->GetValue(detector);
2478 if(mean == 0) continue;
2479 Int_t rowMax = calROC->GetNrows();
2480 Int_t colMax = calROC->GetNcols();
2481 for (Int_t row = 0; row < rowMax; row++) {
2482 for (Int_t col = 0; col < colMax; col++) {
2483 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2484 calROC->SetValue(col,row,TMath::Abs(value)/mean);
2485 } // Col
2486 } // Row
2487 }
55a288e5 2488 }
3a0f6479 2489 return object;
55a288e5 2490
2491}
55a288e5 2492//_____________________________________________________________________________
979b168f 2493TObject *AliTRDCalibraFit::CreatePadObjectT0(const TObjArray *vectorFit, const AliTRDCalDet *detobject)
3a0f6479 2494{
55a288e5 2495 //
3a0f6479 2496 // It Creates the AliTRDCalPad object from AliTRDFitInfo2
2497 // You need first to create the object for the detectors,
2498 // where the mean value is put.
2499 // This object has to be written in the database
55a288e5 2500 //
3a0f6479 2501
2502 // Create the DetObject
2503 AliTRDCalPad *object = new AliTRDCalPad("LocalT0","T0 (local variations)");
2504
2505 if(!vectorFit){
2506 for(Int_t k = 0; k < 540; k++){
2507 AliTRDCalROC *calROC = object->GetCalROC(k);
2508 Int_t nchannels = calROC->GetNchannels();
2509 for(Int_t ch = 0; ch < nchannels; ch++){
2510 calROC->SetValue(ch,0.0);
2511 }
2512 }
55a288e5 2513 }
2514 else {
3a0f6479 2515
2516 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2517 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2518 Int_t detector = -1;
2519 Float_t value = 0.0;
2520
2521 for (Int_t k = 0; k < loop; k++) {
2522 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2523 AliTRDCalROC *calROC = object->GetCalROC(detector);
2524 Float_t min = detobject->GetValue(detector);
2525 Int_t rowMax = calROC->GetNrows();
2526 Int_t colMax = calROC->GetNcols();
2527 for (Int_t row = 0; row < rowMax; row++) {
2528 for (Int_t col = 0; col < colMax; col++) {
2529 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
64942b85 2530 // check successful
2531 if(value > 70.0) value = value - 100.0;
2532 //
3a0f6479 2533 calROC->SetValue(col,row,value-min);
2534 } // Col
2535 } // Row
2536 }
55a288e5 2537 }
3a0f6479 2538 return object;
55a288e5 2539
2540}
3a0f6479 2541//_____________________________________________________________________________
979b168f 2542TObject *AliTRDCalibraFit::CreatePadObjectPRF(const TObjArray *vectorFit)
3a0f6479 2543{
2544 //
2545 // It Creates the AliTRDCalPad object from AliTRDFitInfo
2546 // This object has to be written in the database
2547 //
2548
2549 // Create the DetObject
2550 AliTRDCalPad *object = new AliTRDCalPad("PRFWidth","PRFWidth");
2551
2552 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2553 if(loop != 540) AliInfo("The Vector Fit is not complete!");
2554 Int_t detector = -1;
2555 Float_t value = 0.0;
2556
2557 for (Int_t k = 0; k < loop; k++) {
2558 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2559 AliTRDCalROC *calROC = object->GetCalROC(detector);
2560 Int_t rowMax = calROC->GetNrows();
2561 Int_t colMax = calROC->GetNcols();
2562 for (Int_t row = 0; row < rowMax; row++) {
2563 for (Int_t col = 0; col < colMax; col++) {
2564 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[(Int_t)(col*rowMax+row)];
2565 calROC->SetValue(col,row,TMath::Abs(value));
2566 } // Col
2567 } // Row
2568 }
55a288e5 2569
3a0f6479 2570 return object;
2571
2572}
55a288e5 2573//_____________________________________________________________________________
979b168f 2574AliTRDCalDet *AliTRDCalibraFit::MakeOutliersStatDet(const TObjArray *vectorFit, const char *name, Double_t &mean)
3a0f6479 2575{
2576 //
2577 // It Creates the AliTRDCalDet object from AliTRDFitInfo
2578 // 0 successful fit 1 not successful fit
2579 // mean is the mean value over the successful fit
2580 // do not use it for t0: no meaning
2581 //
2582
2583 // Create the CalObject
2584 AliTRDCalDet *object = new AliTRDCalDet(name,name);
2585 mean = 0.0;
2586 Int_t count = 0;
2587
2588 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2589 if(loop != 540) {
2590 AliInfo("The Vector Fit is not complete! We initialise all outliers");
2591 for(Int_t k = 0; k < 540; k++){
2592 object->SetValue(k,1.0);
2593 }
2594 }
2595 Int_t detector = -1;
2596 Float_t value = 0.0;
2597
2598 for (Int_t k = 0; k < loop; k++) {
2599 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2600 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
2601 if(value <= 0) object->SetValue(detector,1.0);
2602 else {
2603 object->SetValue(detector,0.0);
2604 mean += value;
2605 count++;
2606 }
2607 }
2608 if(count > 0) mean /= count;
2609 return object;
2610}
2611//_____________________________________________________________________________
979b168f 2612TObject *AliTRDCalibraFit::MakeOutliersStatPad(const TObjArray *vectorFit, const char *name, Double_t &mean)
3a0f6479 2613{
2614 //
2615 // It Creates the AliTRDCalPad object from AliTRDFitInfo
2616 // 0 not successful fit 1 successful fit
2617 // mean mean value over the successful fit
2618 //
2619
2620 // Create the CalObject
2621 AliTRDCalPad *object = new AliTRDCalPad(name,name);
2622 mean = 0.0;
2623 Int_t count = 0;
2624
2625 Int_t loop = (Int_t) vectorFit->GetEntriesFast();
2626 if(loop != 540) {
2627 AliInfo("The Vector Fit is not complete! We initialise all outliers");
2628 for(Int_t k = 0; k < 540; k++){
2629 AliTRDCalROC *calROC = object->GetCalROC(k);
2630 Int_t nchannels = calROC->GetNchannels();
2631 for(Int_t ch = 0; ch < nchannels; ch++){
2632 calROC->SetValue(ch,1.0);
2633 }
2634 }
2635 }
2636 Int_t detector = -1;
2637 Float_t value = 0.0;
2638
2639 for (Int_t k = 0; k < loop; k++) {
2640 detector = ((AliTRDFitInfo *) vectorFit->At(k))->GetDetector();
2641 AliTRDCalROC *calROC = object->GetCalROC(detector);
2642 Int_t nchannels = calROC->GetNchannels();
2643 for (Int_t ch = 0; ch < nchannels; ch++) {
2644 value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[ch];
2645 if(value <= 0) calROC->SetValue(ch,1.0);
2646 else {
2647 calROC->SetValue(ch,0.0);
2648 mean += value;
2649 count++;
2650 }
2651 } // channels
2652 }
2653 if(count > 0) mean /= count;
2654 return object;
2655}
2656//_____________________________________________________________________________
2657void AliTRDCalibraFit::SetPeriodeFitPH(Int_t periodeFitPH)
55a288e5 2658{
2659 //
3a0f6479 2660 // Set FitPH if 1 then each detector will be fitted
55a288e5 2661 //
2662
3a0f6479 2663 if (periodeFitPH > 0) {
2664 fFitPHPeriode = periodeFitPH;
55a288e5 2665 }
2666 else {
3a0f6479 2667 AliInfo("periodeFitPH must be higher than 0!");
55a288e5 2668 }
2669
2670}
55a288e5 2671//_____________________________________________________________________________
2672void AliTRDCalibraFit::SetBeginFitCharge(Float_t beginFitCharge)
2673{
2674 //
2675 // The fit of the deposited charge distribution begins at
2676 // histo->Mean()/beginFitCharge
2677 // You can here set beginFitCharge
2678 //
2679
2680 if (beginFitCharge > 0) {
2681 fBeginFitCharge = beginFitCharge;
2682 }
2683 else {
2684 AliInfo("beginFitCharge must be strict positif!");
2685 }
2686
2687}
2688
2689//_____________________________________________________________________________
413153cb 2690void AliTRDCalibraFit::SetT0Shift0(Float_t t0Shift)
2691{
2692 //
2693 // The t0 calculated with the maximum positif slope is shift from t0Shift0
2694 // You can here set t0Shift0
2695 //
2696
2697 if (t0Shift > 0) {
2698 fT0Shift0 = t0Shift;
2699 }
2700 else {
2701 AliInfo("t0Shift0 must be strict positif!");
2702 }
2703
2704}
2705
2706//_____________________________________________________________________________
2707void AliTRDCalibraFit::SetT0Shift1(Float_t t0Shift)
55a288e5 2708{
2709 //
413153cb 2710 // The t0 calculated with the maximum of the amplification region is shift from t0Shift1
2711 // You can here set t0Shift1
55a288e5 2712 //
2713
2714 if (t0Shift > 0) {
413153cb 2715 fT0Shift1 = t0Shift;
55a288e5 2716 }
2717 else {
2718 AliInfo("t0Shift must be strict positif!");
2719 }
2720
2721}
2722
2723//_____________________________________________________________________________
2724void AliTRDCalibraFit::SetRangeFitPRF(Float_t rangeFitPRF)
2725{
2726 //
2727 // The fit of the PRF is from -rangeFitPRF to rangeFitPRF
2728 // You can here set rangeFitPRF
2729 //
2730
2731 if ((rangeFitPRF > 0) &&
2732 (rangeFitPRF <= 1.5)) {
2733 fRangeFitPRF = rangeFitPRF;
2734 }
2735 else {
2736 AliInfo("rangeFitPRF must be between 0 and 1.0");
2737 }
2738
2739}
2740
2741//_____________________________________________________________________________
3a0f6479 2742void AliTRDCalibraFit::SetMinEntries(Int_t minEntries)
55a288e5 2743{
2744 //
3a0f6479 2745 // Minimum entries for fitting
55a288e5 2746 //
2747
3a0f6479 2748 if (minEntries > 0) {
2749 fMinEntries = minEntries;
55a288e5 2750 }
2751 else {
3a0f6479 2752 AliInfo("fMinEntries must be >= 0.");
55a288e5 2753 }
2754
2755}
2756
55a288e5 2757//_____________________________________________________________________________
3a0f6479 2758void AliTRDCalibraFit::SetRebin(Short_t rebin)
2759{
55a288e5 2760 //
3a0f6479 2761 // Rebin with rebin time less bins the Ch histo
2762 // You can set here rebin that should divide the number of bins of CH histo
55a288e5 2763 //
55a288e5 2764
3a0f6479 2765 if (rebin > 0) {
2766 fRebin = rebin;
2767 AliInfo("You have to be sure that fRebin divides fNumberBinCharge used!");
2768 }
2769 else {
2770 AliInfo("You have to choose a positiv value!");
55a288e5 2771 }
2772
2773}
55a288e5 2774//_____________________________________________________________________________
3a0f6479 2775Bool_t AliTRDCalibraFit::FillVectorFit()
55a288e5 2776{
2777 //
3a0f6479 2778 // For the Fit functions fill the vector Fit
55a288e5 2779 //
2780
3a0f6479 2781 AliTRDFitInfo *fitInfo = new AliTRDFitInfo();
55a288e5 2782
3a0f6479 2783 Int_t ntotal = 1;
053767a4 2784 if (GetStack(fCountDet) == 2) {
3a0f6479 2785 ntotal = 1728;
55a288e5 2786 }
3a0f6479 2787 else {
2788 ntotal = 2304;
55a288e5 2789 }
2790
3a0f6479 2791 //printf("For the detector %d , ntotal %d and fCoefCH[0] %f\n",countdet,ntotal,fCoefCH[0]);
2792 Float_t *coef = new Float_t[ntotal];
2793 for (Int_t i = 0; i < ntotal; i++) {
2794 coef[i] = fCurrentCoefDetector[i];
55a288e5 2795 }
55a288e5 2796
3a0f6479 2797 Int_t detector = fCountDet;
2798 // Set
2799 fitInfo->SetCoef(coef);
2800 fitInfo->SetDetector(detector);
2801 fVectorFit.Add((TObject *) fitInfo);
55a288e5 2802
3a0f6479 2803 return kTRUE;
55a288e5 2804
55a288e5 2805}
55a288e5 2806//_____________________________________________________________________________
3a0f6479 2807Bool_t AliTRDCalibraFit::FillVectorFit2()
55a288e5 2808{
2809 //
3a0f6479 2810 // For the Fit functions fill the vector Fit
55a288e5 2811 //
2812
3a0f6479 2813 AliTRDFitInfo *fitInfo = new AliTRDFitInfo();
55a288e5 2814
2815 Int_t ntotal = 1;
053767a4 2816 if (GetStack(fCountDet) == 2) {
55a288e5 2817 ntotal = 1728;
2818 }
2819 else {
2820 ntotal = 2304;
2821 }
2822
2823 //printf("For the detector %d , ntotal %d and fCoefCH[0] %f\n",countdet,ntotal,fCoefCH[0]);
2824 Float_t *coef = new Float_t[ntotal];
2825 for (Int_t i = 0; i < ntotal; i++) {
3a0f6479 2826 coef[i] = fCurrentCoefDetector2[i];
55a288e5 2827 }
2828
3a0f6479 2829 Int_t detector = fCountDet;
55a288e5 2830 // Set
3a0f6479 2831 fitInfo->SetCoef(coef);
2832 fitInfo->SetDetector(detector);
2833 fVectorFit2.Add((TObject *) fitInfo);
55a288e5 2834
2835 return kTRUE;
2836
2837}
55a288e5 2838//____________Functions for initialising the AliTRDCalibraFit in the code_________
2839Bool_t AliTRDCalibraFit::InitFit(Int_t nbins, Int_t i)
2840{
2841 //
3a0f6479 2842 // Init the number of expected bins and fDect1[i] fDect2[i]
55a288e5 2843 //
2844
2845 gStyle->SetPalette(1);
2846 gStyle->SetOptStat(1111);
2847 gStyle->SetPadBorderMode(0);
2848 gStyle->SetCanvasColor(10);
2849 gStyle->SetPadLeftMargin(0.13);
2850 gStyle->SetPadRightMargin(0.01);
3a0f6479 2851
55a288e5 2852 // Mode groups of pads: the total number of bins!
3a0f6479 2853 CalculNumberOfBinsExpected(i);
55a288e5 2854
3a0f6479 2855 // Quick verification that we have the good pad calibration mode!
2856 if (fNumberOfBinsExpected != nbins) {
64942b85 2857 AliInfo(Form("It doesn't correspond to the mode of pad group calibration: expected %d and seen %d!",fNumberOfBinsExpected,nbins));
3a0f6479 2858 return kFALSE;
55a288e5 2859 }
3a0f6479 2860
55a288e5 2861 // Security for fDebug 3 and 4
3a0f6479 2862 if ((fDebugLevel >= 3) &&
55a288e5 2863 ((fDet[0] > 5) ||
2864 (fDet[1] > 4) ||
2865 (fDet[2] > 17))) {
2866 AliInfo("This detector doesn't exit!");
2867 return kFALSE;
2868 }
2869
3a0f6479 2870 // Determine fDet1 and fDet2 and set the fNfragZ and fNfragRphi for debug 3 and 4
2871 CalculDect1Dect2(i);
55a288e5 2872
3a0f6479 2873
2874 return kTRUE;
2875}
2876//____________Functions for initialising the AliTRDCalibraFit in the code_________
2877Bool_t AliTRDCalibraFit::InitFitCH()
2878{
2879 //
2880 // Init the fVectorFitCH for normalisation
2881 // Init the histo for debugging
2882 //
55a288e5 2883
3a0f6479 2884 gDirectory = gROOT;
2885
2886 fScaleFitFactor = 0.0;
f29cf84c 2887 if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
3a0f6479 2888 fCurrentCoefDetector = new Float_t[2304];
2889 for (Int_t k = 0; k < 2304; k++) {
2890 fCurrentCoefDetector[k] = 0.0;
55a288e5 2891 }
3a0f6479 2892 fVectorFit.SetName("gainfactorscoefficients");
55a288e5 2893
3a0f6479 2894 // fDebug == 0 nothing
2895 // fDebug == 1 and fFitVoir no histo
2896 if (fDebugLevel == 1) {
2897 if(!CheckFitVoir()) return kFALSE;
2898 }
2899 //Get the CalDet object
2900 if(fAccCDB){
2901 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
2902 if (!cal) {
2903 AliInfo("Could not get calibDB");
2904 return kFALSE;
55a288e5 2905 }
3a0f6479 2906 if(fCalDet) delete fCalDet;
2907 fCalDet = new AliTRDCalDet(*(cal->GetGainFactorDet()));
55a288e5 2908 }
3a0f6479 2909 else{
2910 Float_t devalue = 1.0;
2911 if(fCalDet) delete fCalDet;
2912 fCalDet = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)");
2913 for(Int_t k = 0; k < 540; k++){
2914 fCalDet->SetValue(k,devalue);
55a288e5 2915 }
3a0f6479 2916 }
2917 return kTRUE;
2918
2919}
2920//____________Functions for initialising the AliTRDCalibraFit in the code_________
2921Bool_t AliTRDCalibraFit::InitFitPH()
2922{
2923 //
2924 // Init the arrays of results
2925 // Init the histos for debugging
2926 //
55a288e5 2927
3a0f6479 2928 gDirectory = gROOT;
2929 fVectorFit.SetName("driftvelocitycoefficients");
2930 fVectorFit2.SetName("t0coefficients");
55a288e5 2931
f29cf84c 2932 if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
3a0f6479 2933 fCurrentCoefDetector = new Float_t[2304];
2934 for (Int_t k = 0; k < 2304; k++) {
2935 fCurrentCoefDetector[k] = 0.0;
2936 }
f29cf84c 2937 if( fCurrentCoefDetector2 ) delete [] fCurrentCoefDetector2;
3a0f6479 2938 fCurrentCoefDetector2 = new Float_t[2304];
2939 for (Int_t k = 0; k < 2304; k++) {
2940 fCurrentCoefDetector2[k] = 0.0;
2941 }
2942
2943 //fDebug == 0 nothing
2944 // fDebug == 1 and fFitVoir no histo
2945 if (fDebugLevel == 1) {
2946 if(!CheckFitVoir()) return kFALSE;
2947 }
2948 //Get the CalDet object
2949 if(fAccCDB){
2950 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
2951 if (!cal) {
2952 AliInfo("Could not get calibDB");
2953 return kFALSE;
55a288e5 2954 }
3a0f6479 2955 if(fCalDet) delete fCalDet;
2956 if(fCalDet2) delete fCalDet2;
2957 fCalDet = new AliTRDCalDet(*(cal->GetVdriftDet()));
2958 fCalDet2 = new AliTRDCalDet(*(cal->GetT0Det()));
2959 }
2960 else{
2961 Float_t devalue = 1.5;
2962 Float_t devalue2 = 0.0;
2963 if(fCalDet) delete fCalDet;
2964 if(fCalDet2) delete fCalDet2;
2965 fCalDet = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)");
2966 fCalDet2 = new AliTRDCalDet("ChamberT0","T0 (detector value)");
2967 for(Int_t k = 0; k < 540; k++){
2968 fCalDet->SetValue(k,devalue);
2969 fCalDet2->SetValue(k,devalue2);
55a288e5 2970 }
55a288e5 2971 }
55a288e5 2972 return kTRUE;
3a0f6479 2973}
2974//____________Functions for initialising the AliTRDCalibraFit in the code_________
2975Bool_t AliTRDCalibraFit::InitFitPRF()
2976{
2977 //
2978 // Init the calibration mode (Nz, Nrphi), the histograms for
2979 // debugging the fit methods if fDebug > 0,
2980 //
55a288e5 2981
3a0f6479 2982 gDirectory = gROOT;
2983 fVectorFit.SetName("prfwidthcoefficients");
2984
f29cf84c 2985 if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
3a0f6479 2986 fCurrentCoefDetector = new Float_t[2304];
2987 for (Int_t k = 0; k < 2304; k++) {
2988 fCurrentCoefDetector[k] = 0.0;
2989 }
2990
2991 // fDebug == 0 nothing
2992 // fDebug == 1 and fFitVoir no histo
2993 if (fDebugLevel == 1) {
2994 if(!CheckFitVoir()) return kFALSE;
2995 }
2996 return kTRUE;
2997}
2998//____________Functions for initialising the AliTRDCalibraFit in the code_________
2999Bool_t AliTRDCalibraFit::InitFitLinearFitter()
3000{
3001 //
3002 // Init the fCalDet, fVectorFit fCurrentCoefDetector
3003 //
3004
3005 gDirectory = gROOT;
3006
f29cf84c 3007 if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
3008 if( fCurrentCoefDetector2 ) delete [] fCurrentCoefDetector2;
3a0f6479 3009 fCurrentCoefDetector = new Float_t[2304];
3010 fCurrentCoefDetector2 = new Float_t[2304];
3011 for (Int_t k = 0; k < 2304; k++) {
3012 fCurrentCoefDetector[k] = 0.0;
3013 fCurrentCoefDetector2[k] = 0.0;
3014 }
3015
840ec79d 3016 if((!fCalDetVdriftUsed) || (!fCalDetExBUsed)) return kFALSE;
3017
3a0f6479 3018 return kTRUE;
55a288e5 3019}
55a288e5 3020//____________Functions for initialising the AliTRDCalibraFit in the code_________
a0bb5615 3021Bool_t AliTRDCalibraFit::InitFitExbAlt()
3022{
3023 //
3024 // Init the fCalDet, fVectorFit fCurrentCoefDetector
3025 //
3026
3027 gDirectory = gROOT;
3028
f29cf84c 3029 if( fCurrentCoefDetector2 ) delete [] fCurrentCoefDetector2;
3030 fCurrentCoefDetector2 = new Float_t[2304];
a0bb5615 3031 for (Int_t k = 0; k < 2304; k++) {
3032 fCurrentCoefDetector2[k] = 0.0;
3033 }
3034
3035 return kTRUE;
3036}
3037//____________Functions for initialising the AliTRDCalibraFit in the code_________
55a288e5 3038void AliTRDCalibraFit::InitfCountDetAndfCount(Int_t i)
3039{
3040 //
3041 // Init the current detector where we are fCountDet and the
3042 // next fCount for the functions Fit...
3043 //
3a0f6479 3044
55a288e5 3045 // Loop on the Xbins of ch!!
3a0f6479 3046 fCountDet = -1; // Current detector
3047 fCount = 0; // To find the next detector
55a288e5 3048
3049 // If fDebug >= 3
3a0f6479 3050 if (fDebugLevel >= 3) {
55a288e5 3051 // Set countdet to the detector
3a0f6479 3052 fCountDet = AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]);
55a288e5 3053 // Set counter to write at the end of the detector
3a0f6479 3054 fCount = fDect2;
3055 // Get the right calib objects
3056 SetCalROC(i);
3057 }
3058 if(fDebugLevel == 1) {
3059 fCountDet = 0;
3060 fCalibraMode->CalculXBins(fCountDet,i);
6aafa7ea 3061 if((fCalibraMode->GetNz(i)!=100) && (fCalibraMode->GetNrphi(i)!=100)){
3062 while(fCalibraMode->GetXbins(i) <=fFitVoir){
3063 fCountDet++;
3064 fCalibraMode->CalculXBins(fCountDet,i);
3065 //printf("GetXBins %d\n",fCalibraMode->GetXbins(i));
3066 }
3067 }
3068 else {
3a0f6479 3069 fCountDet++;
6aafa7ea 3070 }
3a0f6479 3071 fCount = fCalibraMode->GetXbins(i);
3072 fCountDet--;
3073 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
053767a4 3074 fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),i);
3075 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet)
3076 ,(Int_t) GetStack(fCountDet)
3077 ,(Int_t) GetSector(fCountDet),i);
55a288e5 3078 }
55a288e5 3079}
3a0f6479 3080//_______________________________________________________________________________
3081void AliTRDCalibraFit::CalculNumberOfBinsExpected(Int_t i)
3082{
3083 //
3084 // Calculate the number of bins expected (calibration groups)
3085 //
3086
3087 fNumberOfBinsExpected = 0;
64942b85 3088 // All
3089 if((fCalibraMode->GetNz(i) == 100) && (fCalibraMode->GetNrphi(i) == 100)){
3090 fNumberOfBinsExpected = 1;
3091 return;
3092 }
3093 // Per supermodule
3094 if((fCalibraMode->GetNz(i) == 10) && (fCalibraMode->GetNrphi(i) == 10)){
3095 fNumberOfBinsExpected = 18;
3096 return;
3097 }
3098 // More
3a0f6479 3099 fCalibraMode->ModePadCalibration(2,i);
3100 fCalibraMode->ModePadFragmentation(0,2,0,i);
3101 fCalibraMode->SetDetChamb2(i);
3102 if (fDebugLevel > 1) {
3103 AliInfo(Form("For the chamber 2: %d",fCalibraMode->GetDetChamb2(i)));
3104 }
3105 fNumberOfBinsExpected += 6 * 18 * fCalibraMode->GetDetChamb2(i);
3106 fCalibraMode->ModePadCalibration(0,i);
3107 fCalibraMode->ModePadFragmentation(0,0,0,i);
3108 fCalibraMode->SetDetChamb0(i);
3109 if (fDebugLevel > 1) {
3110 AliInfo(Form("For the other chamber 0: %d",fCalibraMode->GetDetChamb0(i)));
3111 }
3112 fNumberOfBinsExpected += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(i);
3113
3114}
3115//_______________________________________________________________________________
3116void AliTRDCalibraFit::CalculDect1Dect2(Int_t i)
3117{
3118 //
3119 // Calculate the range of fits
3120 //
3121
3122 fDect1 = -1;
3123 fDect2 = -1;
3124 if (fDebugLevel == 1) {
3125 fDect1 = fFitVoir;
3126 fDect2 = fDect1 +1;
3127 }
3128 if ((fDebugLevel == 2) || (fDebugLevel == 0)) {
3129 fDect1 = 0;
3130 fDect2 = fNumberOfBinsExpected;
3131 }
3132 if (fDebugLevel >= 3) {
3133 fCountDet = AliTRDgeometry::GetDetector(fDet[0],fDet[1],fDet[2]);
3134 fCalibraMode->CalculXBins(fCountDet,i);
3135 fDect1 = fCalibraMode->GetXbins(i);
3136 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
053767a4 3137 fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),i);
3138 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet)
3139 ,(Int_t) GetStack(fCountDet)
3140 ,(Int_t) GetSector(fCountDet),i);
3a0f6479 3141 // Set for the next detector
3142 fDect2 = fDect1 + fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i);
3143 }
3144}
3145//_______________________________________________________________________________
3146Bool_t AliTRDCalibraFit::CheckFitVoir()
3147{
3148 //
3149 // Check if fFitVoir is in the range
3150 //
3151
3152 if (fFitVoir < fNumberOfBinsExpected) {
3153 AliInfo(Form("We will see the fit of the object %d",fFitVoir));
3154 }
3155 else {
3156 AliInfo("fFitVoir is out of range of the histo!");
3157 return kFALSE;
3158 }
3159 return kTRUE;
3160}
55a288e5 3161//____________Functions for initialising the AliTRDCalibraFit in the code_________
3162void AliTRDCalibraFit::UpdatefCountDetAndfCount(Int_t idect, Int_t i)
3163{
3164 //
3165 // See if we are in a new detector and update the
3166 // variables fNfragZ and fNfragRphi if yes
3a0f6479 3167 // Will never happen for only one detector (3 and 4)
3168 // Doesn't matter for 2
3169 //
3170 if (fCount == idect) {
64942b85 3171 // On en est au detector (or first detector in the group)
3172 fCountDet += 1;
3173 AliDebug(2,Form("We are at the detector %d\n",fCountDet));
3174 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
3175 fCalibraMode->ModePadCalibration((Int_t) GetStack(fCountDet),i);
3176 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(fCountDet)
053767a4 3177 ,(Int_t) GetStack(fCountDet)
3178 ,(Int_t) GetSector(fCountDet),i);
64942b85 3179 // Set for the next detector
3180 fCount += fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i);
3181 // calib objects
3182 SetCalROC(i);
3183 }
55a288e5 3184}
55a288e5 3185//____________Functions for initialising the AliTRDCalibraFit in the code_________
3186void AliTRDCalibraFit::ReconstructFitRowMinRowMax(Int_t idect, Int_t i)
3187{
3188 //
3189 // Reconstruct the min pad row, max pad row, min pad col and
3190 // max pad col of the calibration group for the Fit functions
64942b85 3191 // idect is the calibration group inside the detector
55a288e5 3192 //
3a0f6479 3193 if (fDebugLevel != 1) {
3194 fCalibraMode->ReconstructionRowPadGroup((Int_t) (idect-(fCount-(fCalibraMode->GetNfragZ(i)*fCalibraMode->GetNfragRphi(i)))),i);
55a288e5 3