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