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