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