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