Move sampling frequency to common params
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibra.cxx
CommitLineData
8ec526a4 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$ */
77566f2a 17
18/////////////////////////////////////////////////////////////////////////////////
19//
20// AliTRDCalibra
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.
24// It can be used for the calibration per chamber but also per group of pads and eventually per pad.
25// The user has to choose with the functions SetNz and SetNrphi the precision of the calibration.
26//Begin_Html
8ec526a4 27/*
28<br>
29<CENTER>
30<TABLE border=1>
31<TR><TD><center>Nz</center></TD><TD><center> 0 </center></TD><TD><center> 1 </center></TD><TD><center> 2 </center></TD><TD><center> 3 </center></TD><TD><center> 4 </center></TD></TR>
32<TR><TD><CENTER>group of row pads per detector</CENTER></TD><TD><CENTER>1</CENTER></TD><TD><CENTER>2</CENTER></TD><TD><CENTER>4</CENTER></TD><TD><CENTER>6(chamb2)<br> 8(others chambers)</CENTER></TD><TD><CENTER>12 (chamb2)<br> 16 (chamb0)</CENTER></TD></TR>
33<TR><TD><CENTER>row pads per group</CENTER></TD><TD><CENTER>12 (chamb2)<br> 16 (chamb0)</CENTER></TD><TD><CENTER>6 (chamb2)<br> 8 (chamb0)</CENTER></TD><TD><CENTER>3 (chamb2)<br> 4 (chamb0)</CENTER></TD><TD><CENTER>2</CENTER></TD><TD><CENTER>1</CENTER></TD></TR>
34<TR><TD><CENTER>~distance [cm]</CENTER></TD><TD><CENTER>106 (chamb2)<br> 130 (chamb0)</CENTER></TD><TD><CENTER>53 (chamb2)<br> 65 (chamb0)</CENTER></TD><TD><CENTER>26.5 (chamb2)<br> 32.5 (chamb0)</CENTER></TD><TD><CENTER>17 (chamb2)<br> 17 (chamb0)</CENTER></TD><TD><CENTER>9 (chamb2)<br> 9 (chamb0)</CENTER></TD></TR>
35<CAPTION>In the z direction</CAPTION>
36</TABLE>
37</CENTER>
38<CENTER>
39<br>
40<TABLE border=1>
41<TR><TD><center>Nrphi</center></TD><TD><center> 0 </center></TD><TD><center> 1 </center></TD><TD><center> 2 </center></TD><TD><center> 3 </center></TD><TD><center> 4 </center></TD><TD><center> 5 </center></TD><TD><center> 6 </center></TD></TR>
42<TR><TD><CENTER>group of col pads per detector</CENTER></TD><TD><CENTER>1</CENTER></TD><TD><CENTER>2</CENTER></TD><TD><CENTER>4</CENTER></TD><TD><CENTER>8</CENTER></TD><TD><CENTER>16</CENTER></TD><TD><center>36</center></TD><TD><center>144</center></TD></TR>
43<TR><TD><CENTER>col pads per group</CENTER></TD><TD><CENTER>144</CENTER></TD><TD><CENTER>72</CENTER></TD><TD><CENTER>36</CENTER></TD><TD><CENTER>18</CENTER></TD><TD><CENTER>9</CENTER></TD><TD><center>4</center></TD><TD><center>1</center></TD></TR>
44<TR><TD><CENTER>~distance [cm]</CENTER></TD><TD><CENTER>113.4</CENTER></TD><TD><CENTER>56.7</CENTER></TD><TD><CENTER>25.3</CENTER></TD><TD><CENTER>14.3</CENTER></TD><TD><CENTER>7.25</CENTER></TD><TD><center>3.2</center></TD><TD><center>0.8</center></TD></TR>
45<CAPTION>In the rphi direction</CAPTION>
46</TABLE>
47</CENTER>
48<br>
49*/
77566f2a 50//End_Html
51//
52// Fill histograms or vectors
53//----------------------------
54//
55// 2D Histograms (Histo2d) or vectors (Vector2d), then converted in Trees, will be filled
56// from RAW DATA in a run or from reconstructed TRD tracks during the offline tracking
57// in the function "FollowBackProlongation" (AliTRDtracker)
58// Per default the functions to fill are off.
59//
60//Begin_Html
8ec526a4 61/*
62Example of 2D histos for the relative gain (left) and the drift velocity (right) calibration of the sector 13 <br>
63<center>
64<img src="./gif/2dhisto.gif" width="600" height="350"><br>
65</center>
66*/
77566f2a 67//End_Html
68//
69// Fit the histograms to find the coefficients
70//---------------------------------------------
71//
72// These 2D histograms or vectors (first converted in 1D histos) will be fitted
73// if they have enough entries, otherwise the (default) value of the choosen database
74// will be put. For the relative gain calibration the resulted factors will be globally
75// normalized to the gain factors of the choosen database. It unables to precise
76// previous calibration procedure.
77// The function SetDebug enables the user to see:
78// _fDebug = 0: nothing, only the values are written in the tree if wanted
79// _fDebug = 1: a comparaison of the coefficients found and the default values
80// in the choosen database.
81// fCoef , histogram of the coefs as function of the calibration group number
82// fDelta , histogram of the relative difference of the coef with the default
83// value in the database as function of the calibration group number
84// fError , dirstribution of this relative difference
85// _fDebug = 2: only the fit of the choosen calibration group fFitVoir (SetFitVoir)
86// _fDebug = 3: The coefficients in the choosen detector fDet (SetDet) as function of the
87// pad row and col number
88// _fDebug = 4; The coeffcicients in the choosen detector fDet (SetDet) like in the 3 but with
89// also the comparaison histograms of the 1 for this detector
90//
91//Begin_Html
8ec526a4 92/*
93Example of fCoef for the relative gain calibration of the sector 13 <br>
94<center>
95<img src="./gif/coef.gif" width="400" height="460">
96</center><br>
97Example of fDelta (right) and fError (left) for the relative gain calibration of the sector 13 <br>
98<center>
99<img src="./gif/detlaerror.gif" width="550" height="380"><br>
100</center>
101*/
77566f2a 102//End_Html
8ec526a4 103//
77566f2a 104// Author:
105// R. Bailhache (R.Bailhache@gsi.de)
106//
107//////////////////////////////////////////////////////////////////////////////////////
108
8ec526a4 109#include <TTree.h>
110#include <TLine.h>
111#include <TH1I.h>
112#include <TStyle.h>
113#include <TProfile2D.h>
114#include <TFile.h>
115#include <TCanvas.h>
116#include <TGraphErrors.h>
117#include <TObjArray.h>
118#include <TChain.h>
119#include <TH1.h>
120#include <TH1I.h>
121#include <TH1F.h>
122#include <TF1.h>
123#include <TH2F.h>
124#include <TAxis.h>
125#include <TStopwatch.h>
126#include <TMath.h>
127#include <TLegend.h>
128#include <TDirectory.h>
129#include <TROOT.h>
130
131#include "AliLog.h"
132#include "AliCDBManager.h"
133#include "AliRun.h"
134#include "AliRunLoader.h"
135#include "AliLoader.h"
136#include "AliRawReaderFile.h"
137#include "AliRawReader.h"
77566f2a 138
139#include "AliTRDCalibra.h"
8ec526a4 140#include "AliTRDcalibDB.h"
141#include "AliTRDCommonParam.h"
142#include "AliTRDmcmTracklet.h"
143#include "AliTRDpadPlane.h"
144#include "AliTRDcluster.h"
145#include "AliTRDtrack.h"
146#include "AliTRDdigit.h"
147#include "AliTRDdigitsManager.h"
148#include "AliTRD.h"
149#include "AliTRDgeometry.h"
150#include "./Cal/AliTRDCalROC.h"
151#include "./Cal/AliTRDCalPad.h"
152#include "./Cal/AliTRDCalDet.h"
153#include "AliTRDrawData.h"
77566f2a 154
155ClassImp(AliTRDCalibra)
156
157AliTRDCalibra* AliTRDCalibra::fgInstance = 0;
158Bool_t AliTRDCalibra::fgTerminated = kFALSE;
159
160//_____________singleton implementation_________________________________________________
8ec526a4 161AliTRDCalibra *AliTRDCalibra::Instance()
77566f2a 162{
163 //
164 // Singleton implementation
165 //
166
8ec526a4 167 if (fgTerminated != kFALSE) {
77566f2a 168 return 0;
8ec526a4 169 }
77566f2a 170
8ec526a4 171 if (fgInstance == 0) {
77566f2a 172 fgInstance = new AliTRDCalibra();
8ec526a4 173 }
77566f2a 174
175 return fgInstance;
176
177}
178
179//______________________________________________________________________________________
180void AliTRDCalibra::Terminate()
181{
182 //
183 // Singleton implementation
184 // Deletes the instance of this class
185 //
186
187 fgTerminated = kTRUE;
188
189 if (fgInstance != 0) {
190 delete fgInstance;
191 fgInstance = 0;
192 }
193
194}
195
196//______________________________________________________________________________________
197AliTRDCalibra::AliTRDCalibra()
198 :TObject()
8ec526a4 199 ,fMITracking(kFALSE)
200 ,fMcmTracking(kFALSE)
201 ,fMcmCorrectAngle(kFALSE)
77566f2a 202 ,fCH2dOn(kFALSE)
203 ,fPH2dOn(kFALSE)
204 ,fPRF2dOn(kFALSE)
205 ,fHisto2d(kFALSE)
206 ,fVector2d(kFALSE)
207 ,fRelativeScale(0)
208 ,fCountRelativeScale(0)
209 ,fRelativeScaleAuto(kFALSE)
8ec526a4 210 ,fThresholdDigit(0)
77566f2a 211 ,fThresholdClusterPRF1(0.0)
212 ,fThresholdClusterPRF2(0.0)
213 ,fCenterOfflineCluster(kFALSE)
214 ,fTraMaxPad(kFALSE)
215 ,fWriteNameCoef(0)
216 ,fWriteName(0)
217 ,fFitPHOn(kFALSE)
218 ,fFitPHPeriode(0)
219 ,fBeginFitCharge(0.0)
220 ,fRangeFitPRF(0.0)
221 ,fMeanChargeOn(kFALSE)
222 ,fFitChargeBisOn(kFALSE)
223 ,fT0Shift(0.0)
8ec526a4 224 ,fAccCDB(kFALSE)
225 ,fNumberFit(0)
e5c60cc7 226 ,fNumberEnt(0)
8ec526a4 227 ,fStatisticMean(0.0)
77566f2a 228 ,fDebug(0)
229 ,fFitVoir(0)
230 ,fPRF(0)
231 ,fGain(0)
232 ,fT0(0)
233 ,fVdrift(0)
234 ,fVdriftDetector(0)
235 ,fVdriftPad(0x0)
236 ,fT0Detector(0)
237 ,fT0Pad(0x0)
238 ,fPRFDetector(0)
239 ,fPRFPad(0x0)
8ec526a4 240 ,fCoefCH(0x0)
77566f2a 241 ,fDetectorAliTRDtrack(kFALSE)
242 ,fChamberAliTRDtrack(-1)
8ec526a4 243 ,fDetectorPreviousTrack(-1)
77566f2a 244 ,fGoodTrack(kTRUE)
8ec526a4 245 ,fAmpTotal(0x0)
246 ,fPHPlace(0x0)
247 ,fPHValue(0x0)
77566f2a 248 ,fNumberClusters(0)
8ec526a4 249 ,fProcent(0.0)
250 ,fDifference(0)
251 ,fNumberTrack(0)
77566f2a 252 ,fDeltaPRF(0)
253 ,fErrorPRF(0)
254 ,fCoefPRFDB(0)
255 ,fTimeMax(0)
256 ,fSf(0.0)
8ec526a4 257 ,fScaleFitFactor(0.0)
77566f2a 258 ,fMinEntries(0)
259 ,fEntriesCurrent(0)
8ec526a4 260 ,fL3P0(0.0)
261 ,fL3P2(0.0)
262 ,fG3P2(0.0)
77566f2a 263 ,fVectorPH(0)
264 ,fPlaPH(0)
265 ,fNumberBinCharge(0)
266 ,fVectorCH(0)
267 ,fPlaCH(0)
268 ,fVectorFitCH(0)
269 ,fNumberBinPRF(0)
270 ,fVectorPRF(0)
271 ,fPlaPRF(0)
272 ,fPH2d(0x0)
273 ,fPRF2d(0x0)
274 ,fCH2d(0x0)
275 ,fRebin(0)
276{
277 //
278 // Default constructor
279 //
280
281 for (Int_t i = 0; i < 3; i++) {
282 fNz[i] = 0;
283 fNrphi[i] = 0;
284 }
285
286 for (Int_t k = 0; k < 3; k++) {
287 fNtotal[k] = 0;
8ec526a4 288 fDetChamb2[k] = 0;
289 fDetChamb0[k] = 0;
77566f2a 290 }
291
292 // Write
293 for (Int_t i = 0; i < 3; i++) {
294 fWriteCoef[i] = kFALSE;
295 fWrite[i] = kFALSE;
296 }
297
298 // Debug Mode
299 for (Int_t k = 0; k < 3; k++) {
300 fDet[k] = 0;
301 }
302
e5c60cc7 303 for (Int_t i = 0; i < 3; i++) {
77566f2a 304 fPhd[i] = 0.0;
305 }
77566f2a 306
307 // Init
308 Init();
309
310}
311
312//______________________________________________________________________________________
313AliTRDCalibra::AliTRDCalibra(const AliTRDCalibra &c)
314 :TObject(c)
8ec526a4 315 ,fMITracking(kFALSE)
316 ,fMcmTracking(kFALSE)
317 ,fMcmCorrectAngle(kFALSE)
77566f2a 318 ,fCH2dOn(kFALSE)
319 ,fPH2dOn(kFALSE)
320 ,fPRF2dOn(kFALSE)
321 ,fHisto2d(kFALSE)
322 ,fVector2d(kFALSE)
323 ,fRelativeScale(0)
324 ,fCountRelativeScale(0)
325 ,fRelativeScaleAuto(kFALSE)
8ec526a4 326 ,fThresholdDigit(0)
77566f2a 327 ,fThresholdClusterPRF1(0.0)
328 ,fThresholdClusterPRF2(0.0)
329 ,fCenterOfflineCluster(kFALSE)
330 ,fTraMaxPad(kFALSE)
331 ,fWriteNameCoef(0)
332 ,fWriteName(0)
333 ,fFitPHOn(kFALSE)
334 ,fFitPHPeriode(0)
335 ,fBeginFitCharge(0.0)
336 ,fRangeFitPRF(0.0)
337 ,fMeanChargeOn(kFALSE)
338 ,fFitChargeBisOn(kFALSE)
339 ,fT0Shift(0.0)
8ec526a4 340 ,fAccCDB(kFALSE)
341 ,fNumberFit(0)
e5c60cc7 342 ,fNumberEnt(0)
8ec526a4 343 ,fStatisticMean(0.0)
77566f2a 344 ,fDebug(0)
345 ,fFitVoir(0)
346 ,fPRF(0)
347 ,fGain(0)
348 ,fT0(0)
349 ,fVdrift(0)
350 ,fVdriftDetector(0)
351 ,fVdriftPad(0x0)
352 ,fT0Detector(0)
353 ,fT0Pad(0x0)
354 ,fPRFDetector(0)
355 ,fPRFPad(0x0)
8ec526a4 356 ,fCoefCH(0x0)
77566f2a 357 ,fDetectorAliTRDtrack(kFALSE)
358 ,fChamberAliTRDtrack(-1)
8ec526a4 359 ,fDetectorPreviousTrack(-1)
77566f2a 360 ,fGoodTrack(kTRUE)
8ec526a4 361 ,fAmpTotal(0x0)
362 ,fPHPlace(0x0)
363 ,fPHValue(0x0)
77566f2a 364 ,fNumberClusters(0)
8ec526a4 365 ,fProcent(0.0)
366 ,fDifference(0)
367 ,fNumberTrack(0)
77566f2a 368 ,fDeltaPRF(0)
369 ,fErrorPRF(0)
370 ,fCoefPRFDB(0)
371 ,fTimeMax(0)
372 ,fSf(0.0)
8ec526a4 373 ,fScaleFitFactor(0.0)
77566f2a 374 ,fMinEntries(0)
375 ,fEntriesCurrent(0)
8ec526a4 376 ,fL3P0(0.0)
377 ,fL3P2(0.0)
378 ,fG3P2(0.0)
77566f2a 379 ,fVectorPH(0)
380 ,fPlaPH(0)
381 ,fNumberBinCharge(0)
382 ,fVectorCH(0)
383 ,fPlaCH(0)
384 ,fVectorFitCH(0)
385 ,fNumberBinPRF(0)
386 ,fVectorPRF(0)
387 ,fPlaPRF(0)
388 ,fPH2d(0x0)
389 ,fPRF2d(0x0)
390 ,fCH2d(0x0)
391 ,fRebin(0)
392{
393 //
394 // Copy constructor
395 //
396
397}
398
399//____________________________________________________________________________________
400AliTRDCalibra::~AliTRDCalibra()
401{
402 //
403 // AliTRDCalibra destructor
404 //
405
406 ClearHistos();
407 ClearTree();
77566f2a 408
409}
410
411//_____________________________________________________________________________
412void AliTRDCalibra::Destroy()
413{
414 //
8ec526a4 415 // Delete instance
77566f2a 416 //
417
418 if (fgInstance) {
77566f2a 419 delete fgInstance;
420 fgInstance = 0x0;
421 }
8ec526a4 422
77566f2a 423}
424
425//_____________________________________________________________________________
426void AliTRDCalibra::ClearHistos()
427{
428 //
8ec526a4 429 // Delete the histos
77566f2a 430 //
431
8ec526a4 432 if (fPH2d) {
77566f2a 433 delete fPH2d;
8ec526a4 434 fPH2d = 0x0;
77566f2a 435 }
8ec526a4 436 if (fCH2d) {
77566f2a 437 delete fCH2d;
8ec526a4 438 fCH2d = 0x0;
77566f2a 439 }
8ec526a4 440 if (fPRF2d) {
77566f2a 441 delete fPRF2d;
442 fPRF2d = 0x0;
443 }
444
445}
446
447//_____________________________________________________________________________
448void AliTRDCalibra::ClearTree()
449{
450 //
8ec526a4 451 // Delete the trees
77566f2a 452 //
453
8ec526a4 454 if (fPRF) {
77566f2a 455 delete fPRF;
8ec526a4 456 fPRF = 0x0;
77566f2a 457 }
8ec526a4 458 if (fGain) {
77566f2a 459 delete fGain;
8ec526a4 460 fGain = 0x0;
77566f2a 461 }
8ec526a4 462 if (fT0) {
77566f2a 463 delete fT0;
8ec526a4 464 fT0 = 0x0;
77566f2a 465 }
8ec526a4 466 if (fVdrift) {
77566f2a 467 delete fVdrift;
468 fVdrift = 0x0;
469 }
470
471}
472
473//_____________________________________________________________________________
474void AliTRDCalibra::Init()
475{
476 //
477 // Init some default values
478 //
479
8ec526a4 480 // How to fill the 2D
481 fThresholdDigit = 5;
77566f2a 482 fThresholdClusterPRF1 = 2.0;
483 fThresholdClusterPRF2 = 20.0;
484
8ec526a4 485 // Store the Info
486 fNumberBinCharge = 100;
487 fNumberBinPRF = 20;
77566f2a 488
8ec526a4 489 // Write
490 fWriteName = "TRD.calibration.root";
491 fWriteNameCoef = "TRD.coefficient.root";
492
493 // Fit
494 fFitPHPeriode = 1;
495 fBeginFitCharge = 3.5;
496 fRangeFitPRF = 0.5;
497 fMinEntries = 800;
498 fT0Shift = 0.143397;
499
500 // Internal variables
501
502 // Fill the 2D histos in the offline tracking
503 fDetectorPreviousTrack = -1;
504 fChamberAliTRDtrack = -1;
505 fGoodTrack = kTRUE;
506
507 fProcent = 6.0;
508 fDifference = 17;
509 fNumberClusters = 18;
510 fNumberTrack = 0;
511 fNumberUsedCh[0] = 0;
512 fNumberUsedCh[1] = 0;
513 fNumberUsedPh[0] = 0;
514 fNumberUsedPh[1] = 0;
515
516 // Variables in the loop
517 for (Int_t k = 0; k < 4; k++) {
77566f2a 518 fChargeCoef[k] = 1.0;
519 fVdriftCoef[k] = 1.5;
8ec526a4 520 fT0Coef[k] = -1.0;
77566f2a 521 }
8ec526a4 522 for (Int_t i = 0; i < 2; i++) {
523 fPRFCoef[i] = -1.0;
77566f2a 524 }
525
8ec526a4 526 // Pad calibration
527 for (Int_t i = 0; i < 3; i++) {
528 fRowMin[i] = -1;
529 fRowMax[i] = -1;
530 fColMax[i] = -1;
531 fColMin[i] = -1;
532 fNnZ[i] = -1;
533 fNnRphi[i] = -1;
534 fNfragZ[i] = -1;
535 fNfragRphi[i] = -1;
536 fXbins[i] = -1;
537 }
538
539 // Local database to be changed
77566f2a 540 fRebin = 1;
541
542}
543
8ec526a4 544//____________Functions fit Online CH2d________________________________________
545Bool_t AliTRDCalibra::FitCHOnline(TH2I *ch)
77566f2a 546{
547 //
8ec526a4 548 // Fit the 1D histos, projections of the 2D ch on the Xaxis, for each
549 // calibration group normalized the resulted coefficients (to 1 normally)
550 // and write the results in a tree
77566f2a 551 //
77566f2a 552
8ec526a4 553 // Number of Xbins (detectors or groups of pads)
554 TAxis *xch = ch->GetXaxis();
555 Int_t nbins = xch->GetNbins();
556 TAxis *yph = ch->GetYaxis();
557 Int_t nybins = yph->GetNbins();
77566f2a 558 Double_t lowedge = xch->GetBinLowEdge(1);
8ec526a4 559 Double_t upedge = xch->GetBinUpEdge(xch->GetNbins());
560 if (!InitFit(nbins,lowedge,upedge,0)) {
77566f2a 561 return kFALSE;
562 }
8ec526a4 563 fStatisticMean = 0.0;
564 fNumberFit = 0;
e5c60cc7 565 fNumberEnt = 0;
77566f2a 566
8ec526a4 567 // For memory
568 if (fVectorCH) {
569 fVectorCH->Clear();
570 }
571 if (fPlaCH) {
572 fPlaCH->Clear();
77566f2a 573 }
77566f2a 574
8ec526a4 575 // Init fCountDet and fCount
576 InitfCountDetAndfCount(0);
577
578 // Beginning of the loop betwwen dect1 and dect2
579 for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) {
77566f2a 580
8ec526a4 581 TH1I *projch = (TH1I *) ch->ProjectionY("projch",idect+1,idect+1,(Option_t *)"e");
77566f2a 582 projch->SetDirectory(0);
583
8ec526a4 584 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
585 UpdatefCountDetAndfCount(idect,0);
77566f2a 586
8ec526a4 587 // Reconstruction of the row and pad group: rowmin, row max ...
588 ReconstructFitRowMinRowMax(idect, 0);
77566f2a 589
8ec526a4 590 // Number of entries for this calibration group
77566f2a 591 Double_t nentries = 0.0;
8ec526a4 592 for (Int_t k = 0; k < nybins; k++) {
77566f2a 593 nentries += ch->GetBinContent(ch->GetBin(idect+1,k+1));
594 }
e5c60cc7 595 if (nentries > 0) {
596 fNumberEnt++;
597 }
598
8ec526a4 599 // Rebin and statistic stuff
600 // Rebin
601 if (fRebin > 1) {
602 projch = ReBin((TH1I *) projch);
603 }
604 // This detector has not enough statistics or was off
605 if (nentries < fMinEntries) {
606 // Fill with the default infos
77566f2a 607 NotEnoughStatistic(idect,0);
8ec526a4 608 // Memory!!!
609 if (fDebug != 2) {
77566f2a 610 delete projch;
611 }
612 continue;
613 }
614
8ec526a4 615 // Statistics of the group fitted
616 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
617 fStatisticMean += nentries;
618 fNumberFit++;
77566f2a 619
8ec526a4 620 // Method Mean and fit
621 // idect is egal for fDebug = 0 and 2, only to fill the hist
622 FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
623 // Method fit bis
624 // idect is egal for fDebug = 0 and 2, only to fill the hist
625 if (fFitChargeBisOn) {
626 FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
77566f2a 627 }
628
8ec526a4 629 // Visualise the detector for fDebug 3 or 4
630 // Here is the reconstruction of the pad and row group is used!
631 if (fDebug >= 3) {
632 FillCoefChargeDB();
633 }
634 // Fill Infos Fit
77566f2a 635 FillInfosFit(idect,0);
636
8ec526a4 637 // Memory!!!
638 if (fDebug != 2) {
77566f2a 639 delete projch;
640 }
641
8ec526a4 642 } // Boucle object
77566f2a 643
8ec526a4 644 // Normierungcharge
645 if (fDebug != 2) {
646 NormierungCharge();
647 }
77566f2a 648
8ec526a4 649 // Error
650 if ((fDebug == 1) ||
651 (fDebug == 4)) {
652 ErrorCH();
653 }
77566f2a 654
8ec526a4 655 // Plot
656 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
657 if ((fDebug == 1) ||
658 (fDebug == 4)) {
77566f2a 659 PlotCH();
8ec526a4 660 }
661 if ((fDebug == 4) ||
662 (fDebug == 3)) {
77566f2a 663 PlotCHDB();
8ec526a4 664 }
77566f2a 665
8ec526a4 666 // Mean Statistic
667 if (fNumberFit > 0) {
668 AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean/fNumberFit));
669 fStatisticMean = fStatisticMean / fNumberFit;
77566f2a 670 }
671 else {
672 AliInfo("There is no fit!");
673 }
674
8ec526a4 675 // Write the things!
77566f2a 676 ConvertVectorFitCHTree();
8ec526a4 677 if (fWriteCoef[0]) {
77566f2a 678 WriteFitInfos(0);
679 }
8ec526a4 680
77566f2a 681 return kTRUE;
682
683}
77566f2a 684
8ec526a4 685//____________Functions fit Online CH2d________________________________________
77566f2a 686Bool_t AliTRDCalibra::FitCHOnline()
687{
688 //
8ec526a4 689 // Reconstruct a 1D histo from the vectorCH for each calibration group,
690 // fit the histo, normalized the resulted coefficients (to 1 normally)
691 // and write the results in a tree
77566f2a 692 //
693
8ec526a4 694 // Number of Xbins (detectors or groups of pads)
695 if (!InitFit(0,0,0,0)) {
77566f2a 696 return kFALSE;
697 }
8ec526a4 698 fStatisticMean = 0.0;
699 fNumberFit = 0;
e5c60cc7 700 fNumberEnt = 0;
77566f2a 701
8ec526a4 702 // Init fCountDet and fCount
703 InitfCountDetAndfCount(0);
77566f2a 704
8ec526a4 705 // Beginning of the loop between dect1 and dect2
706 for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) {
77566f2a 707
8ec526a4 708 // Search if the group is in the VectorCH
77566f2a 709 Int_t place = SearchInVector(idect,0);
710
8ec526a4 711 // Is in
712 TH1F *projch = 0x0;
77566f2a 713 TString name("CH");
714 name += idect;
8ec526a4 715 if (place != -1) {
716 // Variable
717 AliTRDCTInfo *fCHInfo = new AliTRDCTInfo();
718 // Retrieve
719 fCHInfo = ((AliTRDCTInfo *) fVectorCH->At(place));
720 projch = ConvertVectorCTHisto(fCHInfo,(const char *) name);
77566f2a 721 projch->SetDirectory(0);
722 delete fCHInfo;
723 }
724
8ec526a4 725 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
726 UpdatefCountDetAndfCount(idect,0);
77566f2a 727
8ec526a4 728 // Reconstruction of the row and pad group: rowmin, row max ...
729 ReconstructFitRowMinRowMax(idect,0);
77566f2a 730
8ec526a4 731 // Number of entries
77566f2a 732 Double_t nentries = 0.0;
9244c78b 733 if (projch) {
734 for (Int_t k = 0; k < fNumberBinCharge; k++) {
735 nentries += projch->GetBinContent(k+1);
736 }
77566f2a 737 }
e5c60cc7 738 if (nentries > 0) {
739 fNumberEnt++;
740 }
77566f2a 741
8ec526a4 742 // Rebin and statistic stuff
743 // Rebin
744 if ((fRebin > 1) &&
745 (place != -1)) {
746 projch = ReBin((TH1F *) projch);
747 }
77566f2a 748
8ec526a4 749 // This detector has not enough statistics or was not found in VectorCH
750 if ((place == -1) ||
751 ((place != -1) &&
752 (nentries < fMinEntries))) {
77566f2a 753
8ec526a4 754 // Fill with the default infos
77566f2a 755 NotEnoughStatistic(idect,0);
756
8ec526a4 757 // Memory!!!
758 if (fDebug != 2) {
77566f2a 759 delete projch;
760 }
761
762 continue;
8ec526a4 763
77566f2a 764 }
765
8ec526a4 766 // Statistic of the histos fitted
767 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
768 fNumberFit++;
769 fStatisticMean += nentries;
77566f2a 770
8ec526a4 771 // Method Mean and fit
772 // idect is egal for fDebug = 0 and 2, only to fill the hist
773 FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
77566f2a 774
8ec526a4 775 // Method fit bis
776 // idect is egal for fDebug = 0 and 2, only to fill the hist
777 if (fFitChargeBisOn) {
778 FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
77566f2a 779 }
780
8ec526a4 781 // Visualise the detector for fDebug 3 or 4
782 // Here is the reconstruction of the pad and row group is used!
783 if (fDebug >= 3) {
784 FillCoefChargeDB();
785 }
77566f2a 786
8ec526a4 787 // Fill Infos Fit
77566f2a 788 FillInfosFit(idect,0);
789
8ec526a4 790 // Memory!!!
791 if (fDebug != 2) {
77566f2a 792 delete projch;
793 }
77566f2a 794
8ec526a4 795 } // Boucle object
77566f2a 796
8ec526a4 797 // Normierungcharge
798 if (fDebug != 2) {
799 NormierungCharge();
800 }
77566f2a 801
8ec526a4 802 // Error
803 if ((fDebug == 1) ||
804 (fDebug == 4)) {
805 ErrorCH();
806 }
77566f2a 807
8ec526a4 808 // Plot
809 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
810 if ((fDebug == 1) ||
811 (fDebug == 4)){
77566f2a 812 PlotCH();
813 }
8ec526a4 814 if((fDebug == 4) ||
815 (fDebug == 3)){
77566f2a 816 PlotCHDB();
817 }
818
8ec526a4 819 // Mean Statistics
820 if (fNumberFit > 0) {
821 AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit));
822 fStatisticMean = fStatisticMean / fNumberFit;
77566f2a 823 }
824 else {
825 AliInfo("There is no fit!");
826 }
827
8ec526a4 828 // Write the things!
77566f2a 829 ConvertVectorFitCHTree();
8ec526a4 830 if (fWriteCoef[0]) {
77566f2a 831 WriteFitInfos(0);
832 }
8ec526a4 833
77566f2a 834 return kTRUE;
835
836}
77566f2a 837
8ec526a4 838//____________Functions fit Online CH2d________________________________________
77566f2a 839Bool_t AliTRDCalibra::FitCHOnline(TTree *tree)
840{
841 //
8ec526a4 842 // Look if the calibration group can be found in the tree, if yes take the
843 // histo, fit it, normalized the resulted coefficients (to 1 normally) and
844 // write the results in a tree
77566f2a 845 //
846
8ec526a4 847 // Number of Xbins (detectors or groups of pads)
848 if (!InitFit(0,0,0,0)) {
77566f2a 849 return kFALSE;
850 }
8ec526a4 851 fStatisticMean = 0.0;
852 fNumberFit = 0;
e5c60cc7 853 fNumberEnt = 0;
77566f2a 854
8ec526a4 855 // For memory
856 if (fVectorCH) {
857 fVectorCH->Clear();
77566f2a 858 }
8ec526a4 859 if (fPlaCH) {
860 fPlaCH->Clear();
77566f2a 861 }
8ec526a4 862
863 // Init fCountDet and fCount
864 InitfCountDetAndfCount(0);
865 TH1F *projch = 0x0;
77566f2a 866 tree->SetBranchAddress("histo",&projch);
8ec526a4 867 TObjArray *vectorplace = ConvertTreeVector(tree);
77566f2a 868
8ec526a4 869 // Beginning of the loop between dect1 and dect2
870 for (Int_t idect = fDect1[0]; idect < fDect2[0]; idect++) {
77566f2a 871
872 //Search if the group is in the VectorCH
873 Int_t place = SearchInTreeVector(vectorplace,idect);
874
8ec526a4 875 // Is in
876 if (place != -1) {
877 // Variable
77566f2a 878 tree->GetEntry(place);
879 }
880
8ec526a4 881 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
882 UpdatefCountDetAndfCount(idect,0);
77566f2a 883
8ec526a4 884 // Reconstruction of the row and pad group: rowmin, row max ...
885 ReconstructFitRowMinRowMax(idect,0);
77566f2a 886
8ec526a4 887 // Number of entries
77566f2a 888 Double_t nentries = 0.0;
9244c78b 889 if (projch) {
890 for (Int_t k = 0; k < projch->GetXaxis()->GetNbins(); k++) {
891 nentries += projch->GetBinContent(k+1);
892 }
e5c60cc7 893 }
894 if (nentries > 0) {
895 fNumberEnt++;
896 }
9244c78b 897
8ec526a4 898 // Rebin and statistic stuff
899 // Rebin
900 if ((fRebin > 1) &&
901 (place != -1)) {
902 projch = ReBin((TH1F *) projch);
903 }
904
905 // This detector has not enough statistics or was not found in VectorCH
906 if((place == -1) ||
907 ((place != -1) &&
908 (nentries < fMinEntries))) {
77566f2a 909
8ec526a4 910 // Fill with the default infos
77566f2a 911 NotEnoughStatistic(idect,0);
912
913 continue;
8ec526a4 914
77566f2a 915 }
916
8ec526a4 917 // Statistics of the group fitted
918 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
919 fNumberFit++;
920 fStatisticMean += nentries;
77566f2a 921
8ec526a4 922 // Method Mean and fit
923 // idect is egal for fDebug = 0 and 2, only to fill the hist
924 FitCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
77566f2a 925
8ec526a4 926 // Method fit bis
927 // idect is egal for fDebug = 0 and 2, only to fill the hist
928 if (fFitChargeBisOn) {
929 FitBisCH((TH1 *) projch,(Int_t) (idect-fDect1[0]));
77566f2a 930 }
77566f2a 931
8ec526a4 932 // Visualise the detector for fDebug 3 or 4
933 // Here is the reconstruction of the pad and row group is used!
934 if (fDebug >= 3) {
935 FillCoefChargeDB();
936 }
937
938 // Fill Infos Fit
77566f2a 939 FillInfosFit(idect,0);
77566f2a 940
8ec526a4 941 } // Boucle object
77566f2a 942
8ec526a4 943 // Normierungcharge
944 if (fDebug != 2) {
945 NormierungCharge();
946 }
77566f2a 947
8ec526a4 948 // Error
949 if ((fDebug == 1) ||
950 (fDebug == 4)) {
951 ErrorCH();
952 }
77566f2a 953
8ec526a4 954 // Plot
955 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
956 if ((fDebug == 1) ||
957 (fDebug == 4)){
77566f2a 958 PlotCH();
8ec526a4 959 }
960 if ((fDebug == 4) ||
961 (fDebug == 3)){
77566f2a 962 PlotCHDB();
8ec526a4 963 }
77566f2a 964
8ec526a4 965 // Mean Statistic
966 if (fNumberFit > 0) {
967 AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit));
968 fStatisticMean = fStatisticMean / fNumberFit;
77566f2a 969 }
970 else {
971 AliInfo("There is no fit!");
972 }
973
8ec526a4 974 // Write the things!
77566f2a 975 ConvertVectorFitCHTree();
8ec526a4 976 if (fWriteCoef[0]) {
77566f2a 977 WriteFitInfos(0);
978 }
8ec526a4 979
77566f2a 980 return kTRUE;
981
982}
77566f2a 983
8ec526a4 984//________________functions fit Online PH2d____________________________________
985Bool_t AliTRDCalibra::FitPHOnline(TProfile2D *ph)
77566f2a 986{
987 //
8ec526a4 988 // Take the 1D profiles (average pulse height), projections of the 2D PH
989 // on the Xaxis, for each calibration group
990 // Fit or use the slope of the average pulse height to reconstruct the
991 // drift velocity write the results in a tree
77566f2a 992 // A first calibration of T0 is also made using the same method (slope method)
993 //
994
8ec526a4 995 // Number of Xbins (detectors or groups of pads)
996 TAxis *xph = ph->GetXaxis();
997 TAxis *yph = ph->GetYaxis();
998 Int_t nbins = xph->GetNbins();
999 Int_t nybins = yph->GetNbins();
77566f2a 1000 Double_t lowedge = xph->GetBinLowEdge(1);
8ec526a4 1001 Double_t upedge = xph->GetBinUpEdge(xph->GetNbins());
1002 if (!InitFit(nbins,lowedge,upedge,1)) {
77566f2a 1003 return kFALSE;
1004 }
8ec526a4 1005 fStatisticMean = 0.0;
1006 fNumberFit = 0;
e5c60cc7 1007 fNumberEnt = 0;
77566f2a 1008
8ec526a4 1009 // For memory
1010 if (fVectorPH) {
1011 fVectorPH->Clear();
1012 }
1013 if (fPlaPH) {
1014 fPlaPH->Clear();
77566f2a 1015 }
77566f2a 1016
8ec526a4 1017 // Init fCountDet and fCount
1018 InitfCountDetAndfCount(1);
1019
1020 // Beginning of the loop
1021 for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) {
77566f2a 1022
8ec526a4 1023 TH1D *projph = (TH1D *) ph->ProjectionY("projph",idect+1,idect+1,(Option_t *) "e");
77566f2a 1024 projph->SetDirectory(0);
1025
8ec526a4 1026 // Number of entries for this calibration group
77566f2a 1027 Double_t nentries = 0;
8ec526a4 1028 for (Int_t k = 0; k < nybins; k++) {
1029 nentries += ph->GetBinEntries(ph->GetBin(idect+1,k+1));
77566f2a 1030 }
e5c60cc7 1031 if (nentries > 0) {
1032 fNumberEnt++;
1033 }
1034
8ec526a4 1035 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1036 UpdatefCountDetAndfCount(idect,1);
77566f2a 1037
8ec526a4 1038 // Reconstruction of the row and pad group: rowmin, row max ...
1039 ReconstructFitRowMinRowMax(idect,1);
77566f2a 1040
8ec526a4 1041 // Rebin and statistic stuff
1042 // This detector has not enough statistics or was off
1043 if (nentries < fMinEntries) {
77566f2a 1044
8ec526a4 1045 // Fill with the default values
77566f2a 1046 NotEnoughStatistic(idect,1);
1047
8ec526a4 1048 // Memory!!!
1049 if (fDebug != 2) {
77566f2a 1050 delete projph;
1051 }
1052
1053 continue;
8ec526a4 1054
77566f2a 1055 }
1056
8ec526a4 1057 // Statistics of the histos fitted
1058 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
1059 fNumberFit++;
1060 fStatisticMean += nentries;
77566f2a 1061
8ec526a4 1062 // Calcul of "real" coef
1063 CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
1064 CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
77566f2a 1065
8ec526a4 1066 // Method Mean and fit
1067 // idect is egal for fDebug = 0 and 2, only to fill the hist
1068 FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1]));
77566f2a 1069
8ec526a4 1070 // Method fit bis
1071 // idect is egal for fDebug = 0 and 2, only to fill the hist
1072 if (fFitPHOn) {
1073 FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1]));
77566f2a 1074 }
1075
8ec526a4 1076 // Visualise the detector for fDebug 3 or 4
1077 // Here is the reconstruction of the pad and row group is used!
1078 if (fDebug >= 3) {
77566f2a 1079 FillCoefVdriftDB();
1080 FillCoefT0DB();
1081 }
1082
8ec526a4 1083 // Fill the tree if end of a detector or only the pointer to the branch!!!
1084 FillInfosFit(idect,1);
77566f2a 1085
8ec526a4 1086 // Memory!!!
1087 if (fDebug != 2) {
77566f2a 1088 delete projph;
1089 }
1090
8ec526a4 1091 } // Boucle object
77566f2a 1092
8ec526a4 1093 // Error
1094 if ((fDebug == 1) ||
1095 (fDebug == 4)) {
77566f2a 1096 ErrorPH();
1097 ErrorT0();
1098 }
1099
8ec526a4 1100 // Plot
1101 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
1102 if ((fDebug == 1) ||
1103 (fDebug == 4)) {
77566f2a 1104 PlotPH();
1105 PlotT0();
8ec526a4 1106 }
1107 if ((fDebug == 4) ||
1108 (fDebug == 3)) {
77566f2a 1109 PlotPHDB();
1110 PlotT0DB();
8ec526a4 1111 }
77566f2a 1112
8ec526a4 1113 // Mean Statistic
1114 if (fNumberFit > 0) {
1115 AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit));
1116 fStatisticMean = fStatisticMean / fNumberFit;
77566f2a 1117 }
1118 else {
1119 AliInfo("There is no fit!");
1120 }
1121
8ec526a4 1122 // Write the things!
1123 if(fWriteCoef[1]) {
77566f2a 1124 WriteFitInfos(1);
1125 }
8ec526a4 1126
77566f2a 1127 return kTRUE;
1128
1129}
77566f2a 1130
8ec526a4 1131//____________Functions fit Online PH2d________________________________________
77566f2a 1132Bool_t AliTRDCalibra::FitPHOnline()
1133{
1134 //
8ec526a4 1135 // Reconstruct the average pulse height from the vectorPH for each
1136 // calibration group
1137 // Fit or use the slope of the average pulse height to reconstruct the
1138 // drift velocity write the results in a tree
77566f2a 1139 // A first calibration of T0 is also made using the same method (slope method)
1140 //
77566f2a 1141
8ec526a4 1142 // Number of Xbins (detectors or groups of pads)
1143 if (!InitFit(0,0,0,1)) {
77566f2a 1144 return kFALSE;
1145 }
8ec526a4 1146 fStatisticMean = 0.0;
1147 fNumberFit = 0;
e5c60cc7 1148 fNumberEnt = 0;
77566f2a 1149
8ec526a4 1150 // Init fCountDet and fCount
1151 InitfCountDetAndfCount(1);
77566f2a 1152
8ec526a4 1153 // Beginning of the loop
1154 for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) {
77566f2a 1155
8ec526a4 1156 // Search if the group is in the VectorCH
77566f2a 1157 Int_t place = SearchInVector(idect,1);
1158
8ec526a4 1159 // Is in
1160 TH1F *projph = 0x0;
77566f2a 1161 TString name("PH");
1162 name += idect;
8ec526a4 1163 if (place != -1) {
e5c60cc7 1164 //Entries
1165 fNumberEnt++;
8ec526a4 1166 // Variable
1167 AliTRDPInfo *fPHInfo = new AliTRDPInfo();
1168 // Retrieve
1169 fPHInfo = (AliTRDPInfo *) fVectorPH->At(place);
1170 projph = CorrectTheError((TGraphErrors *) ConvertVectorPHisto(fPHInfo,(const char *) name));
77566f2a 1171 projph->SetDirectory(0);
1172 delete fPHInfo;
1173 }
1174
8ec526a4 1175 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1176 UpdatefCountDetAndfCount(idect,1);
77566f2a 1177
8ec526a4 1178 // Reconstruction of the row and pad group: rowmin, row max ...
1179 ReconstructFitRowMinRowMax(idect,1);
77566f2a 1180
8ec526a4 1181 // Rebin and statistic stuff
1182 // This detector has not enough statistics or was off
1183 if ((place == -1) ||
1184 ((place != -1) &&
1185 (fEntriesCurrent < fMinEntries))) {
77566f2a 1186
8ec526a4 1187 // Fill with the default values
77566f2a 1188 NotEnoughStatistic(idect,1);
1189
8ec526a4 1190 // Memory!!!
1191 if (fDebug != 2) {
77566f2a 1192 delete projph;
1193 }
8ec526a4 1194
77566f2a 1195 continue;
8ec526a4 1196
77566f2a 1197 }
1198
8ec526a4 1199 // Statistic of the histos fitted
1200 AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent));
1201 fNumberFit++;
1202 fStatisticMean += fEntriesCurrent;
77566f2a 1203
8ec526a4 1204 // Calcul of "real" coef
1205 CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
1206 CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
77566f2a 1207
8ec526a4 1208 // Method Mean and fit
1209 // idect is egal for fDebug = 0 and 2, only to fill the hist
1210 FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1]));
77566f2a 1211
8ec526a4 1212 // Method fit bis
1213 // idect is egal for fDebug = 0 and 2, only to fill the hist
1214 if (fFitPHOn) {
1215 FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1]));
77566f2a 1216 }
1217
8ec526a4 1218 // Visualise the detector for fDebug 3 or 4
1219 // Here is the reconstruction of the pad and row group is used!
1220 if (fDebug >= 3) {
77566f2a 1221 FillCoefVdriftDB();
1222 FillCoefT0DB();
1223 }
1224
8ec526a4 1225 // Fill the tree if end of a detector or only the pointer to the branch!!!
77566f2a 1226 FillInfosFit(idect,1);
1227
8ec526a4 1228 // Memory!!!
1229 if (fDebug != 2) {
77566f2a 1230 delete projph;
1231 }
1232
8ec526a4 1233 } // Boucle object
77566f2a 1234
8ec526a4 1235 // Error
1236 if ((fDebug == 1) ||
1237 (fDebug == 4)) {
77566f2a 1238 ErrorPH();
1239 ErrorT0();
1240 }
1241
8ec526a4 1242 // Plot
1243 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
1244 if ((fDebug == 1) ||
1245 (fDebug == 4)) {
77566f2a 1246 PlotPH();
1247 PlotT0();
1248 }
8ec526a4 1249 if ((fDebug == 4) ||
1250 (fDebug == 3)) {
77566f2a 1251 PlotPHDB();
1252 PlotT0DB();
1253 }
1254
8ec526a4 1255 // Mean Statistic
1256 if (fNumberFit > 0) {
1257 AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit));
1258 fStatisticMean = fStatisticMean / fNumberFit;
77566f2a 1259 }
1260 else {
1261 AliInfo("There is no fit!");
1262 }
1263
8ec526a4 1264 // Write the things!
1265 if (fWriteCoef[1]) {
77566f2a 1266 WriteFitInfos(1);
1267 }
8ec526a4 1268
77566f2a 1269 return kTRUE;
1270
1271}
1272
8ec526a4 1273//____________Functions fit Online PH2d________________________________________
77566f2a 1274Bool_t AliTRDCalibra::FitPHOnline(TTree *tree)
1275{
1276 //
8ec526a4 1277 // Look if the calibration group can be found in the tree, if yes take the
1278 // histo, fit it, and write the results in a tree
77566f2a 1279 // A first calibration of T0 is also made using the same method (slope method)
1280 //
77566f2a 1281
8ec526a4 1282 // Number of Xbins (detectors or groups of pads)
1283 if (!InitFit(0,0,0,1)) {
77566f2a 1284 return kFALSE;
1285 }
8ec526a4 1286 fStatisticMean = 0.0;
1287 fNumberFit = 0;
e5c60cc7 1288 fNumberEnt = 0;
8ec526a4 1289
1290 // For memory
1291 if (fVectorPH) {
1292 fVectorPH->Clear();
77566f2a 1293 }
8ec526a4 1294 if (fPlaPH) {
1295 fPlaPH->Clear();
77566f2a 1296 }
1297
8ec526a4 1298 // Init fCountDet and fCount
1299 InitfCountDetAndfCount(1);
1300 TGraphErrors *projphtree = 0x0;
77566f2a 1301 tree->SetBranchAddress("histo",&projphtree);
8ec526a4 1302 TObjArray *vectorplace = ConvertTreeVector(tree);
77566f2a 1303
8ec526a4 1304 // Beginning of the loop
1305 for (Int_t idect = fDect1[1]; idect < fDect2[1]; idect++) {
77566f2a 1306
8ec526a4 1307 // Search if the group is in the VectorCH
77566f2a 1308 Int_t place = SearchInTreeVector(vectorplace,idect);
1309
1310 TH1F *projph = 0x0;
8ec526a4 1311 // Is in
1312 if (place != -1) {
e5c60cc7 1313 //Entries
1314 fNumberEnt++;
8ec526a4 1315 // Variable
77566f2a 1316 tree->GetEntry(place);
1317 projph = CorrectTheError(projphtree);
1318 }
1319
8ec526a4 1320 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1321 UpdatefCountDetAndfCount(idect,1);
77566f2a 1322
8ec526a4 1323 // Reconstruction of the row and pad group: rowmin, row max ...
1324 ReconstructFitRowMinRowMax(idect,1);
77566f2a 1325
8ec526a4 1326 // Rebin and statistic stuff
1327 // This detector has not enough statistics or was off
1328 if((place == -1) ||
1329 ((place != -1) &&
1330 (fEntriesCurrent < fMinEntries))) {
77566f2a 1331
8ec526a4 1332 // Fill with the default values
77566f2a 1333 NotEnoughStatistic(idect,1);
1334
8ec526a4 1335 // Memory!!!
1336 if (fDebug != 2) {
77566f2a 1337 delete projph;
1338 }
1339
1340 continue;
8ec526a4 1341
77566f2a 1342 }
1343
8ec526a4 1344 // Statistics of the histos fitted
1345 AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent));
1346 fNumberFit++;
1347 fStatisticMean += fEntriesCurrent;
77566f2a 1348
8ec526a4 1349 // Calcul of "real" coef
1350 CalculVdriftCoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
1351 CalculT0CoefMean(fCountDet[1],(Int_t) (idect - fDect1[1]));
77566f2a 1352
8ec526a4 1353 // Method Mean and fit
1354 // idect is egal for fDebug = 0 and 2, only to fill the hist
1355 FitPente((TH1 *) projph,(Int_t) (idect - fDect1[1]));
1356 // Method fit bis
1357 // idect is egal for fDebug = 0 and 2, only to fill the hist
1358 if (fFitPHOn) {
1359 FitPH((TH1 *) projph,(Int_t) (idect - fDect1[1]));
77566f2a 1360 }
1361
8ec526a4 1362 // Visualise the detector for fDebug 3 or 4
1363 // Here is the reconstruction of the pad and row group is used!
1364 if (fDebug >= 3) {
77566f2a 1365 FillCoefVdriftDB();
1366 FillCoefT0DB();
1367 }
1368
8ec526a4 1369 // Fill the tree if end of a detector or only the pointer to the branch!!!
77566f2a 1370 FillInfosFit(idect,1);
77566f2a 1371
8ec526a4 1372 // Memory!!!
1373 if (fDebug != 2) {
77566f2a 1374 delete projph;
1375 }
77566f2a 1376
8ec526a4 1377 } // Boucle object
77566f2a 1378
8ec526a4 1379 // Error
1380 if ((fDebug == 1) ||
1381 (fDebug == 4)) {
77566f2a 1382 ErrorPH();
1383 ErrorT0();
1384 }
1385
8ec526a4 1386 // Plot
1387 // 0 no plot, 1 and 4 error plot, 3 and 4 DB plot
1388 if ((fDebug == 1) ||
1389 (fDebug == 4)){
77566f2a 1390 PlotPH();
1391 PlotT0();
1392 }
8ec526a4 1393 if ((fDebug == 4) ||
1394 (fDebug == 3)){
77566f2a 1395 PlotPHDB();
1396 PlotT0DB();
1397 }
1398
8ec526a4 1399 // Mean Statistics
1400 if (fNumberFit > 0) {
1401 AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit));
1402 fStatisticMean = fStatisticMean / fNumberFit;
77566f2a 1403 }
1404 else {
1405 AliInfo("There is no fit!");
1406 }
1407
8ec526a4 1408 // Write the things!
1409 if (fWriteCoef[1]) {
77566f2a 1410 WriteFitInfos(1);
1411 }
8ec526a4 1412
77566f2a 1413 return kTRUE;
1414
1415}
77566f2a 1416
8ec526a4 1417//____________Functions fit Online PRF2d_______________________________________
1418Bool_t AliTRDCalibra::FitPRFOnline(TProfile2D *prf)
77566f2a 1419{
1420 //
8ec526a4 1421 // Take the 1D profiles (pad response function), projections of the 2D PRF
1422 // on the Xaxis, for each calibration group
1423 // Fit with a gaussian to reconstruct the sigma of the pad response function
1424 // write the results in a tree
77566f2a 1425 //
1426
8ec526a4 1427 // Number of Xbins (detectors or groups of pads)
1428 TAxis *xprf = prf->GetXaxis();
1429 TAxis *yprf = prf->GetYaxis();
1430 Int_t nybins = yprf->GetNbins();
1431 Int_t nbins = xprf->GetNbins();
77566f2a 1432 Double_t lowedge = xprf->GetBinLowEdge(1);
8ec526a4 1433 Double_t upedge = xprf->GetBinUpEdge(xprf->GetNbins());
1434 if (!InitFit(nbins,lowedge,upedge,2)) {
77566f2a 1435 return kFALSE;
1436 }
8ec526a4 1437 fStatisticMean = 0.0;
1438 fNumberFit = 0;
e5c60cc7 1439 fNumberEnt = 0;
77566f2a 1440
8ec526a4 1441 // For memory
1442 if (fVectorPRF) {
1443 fVectorPRF->Clear();
1444 }
1445 if (fPlaPRF) {
1446 fPlaPRF->Clear();
77566f2a 1447 }
77566f2a 1448
8ec526a4 1449 // Init fCountDet and fCount
1450 InitfCountDetAndfCount(2);
77566f2a 1451
8ec526a4 1452 // Beginning of the loop
1453 for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) {
77566f2a 1454
8ec526a4 1455 TH1D *projprf = (TH1D *) prf->ProjectionY("projprf",idect+1,idect+1,(Option_t *) "e");
77566f2a 1456 projprf->SetDirectory(0);
1457
8ec526a4 1458 // Number of entries for this calibration group
77566f2a 1459 Double_t nentries = 0;
8ec526a4 1460 for (Int_t k = 0; k < nybins; k++) {
1461 nentries += prf->GetBinEntries(prf->GetBin(idect+1,k+1));
77566f2a 1462 }
e5c60cc7 1463 if(nentries > 0) fNumberEnt++;
77566f2a 1464
8ec526a4 1465 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1466 UpdatefCountDetAndfCount(idect,2);
77566f2a 1467
8ec526a4 1468 // Reconstruction of the row and pad group: rowmin, row max ...
1469 ReconstructFitRowMinRowMax(idect,2);
77566f2a 1470
8ec526a4 1471 // Rebin and statistic stuff
1472 // This detector has not enough statistics or was off
1473 if (nentries < fMinEntries) {
77566f2a 1474
8ec526a4 1475 // Fill with the default values
77566f2a 1476 NotEnoughStatistic(idect,2);
1477
8ec526a4 1478 // Memory!
1479 if (fDebug != 2) {
77566f2a 1480 delete projprf;
1481 }
1482
1483 continue;
8ec526a4 1484
77566f2a 1485 }
1486
8ec526a4 1487 // Statistics of the histos fitted
1488 AliInfo(Form("For the group number %d there are %f stats",idect,nentries));
1489 fNumberFit++;
1490 fStatisticMean += nentries;
77566f2a 1491
8ec526a4 1492 // Calcul of "real" coef
1493 if ((fDebug == 1) ||
1494 (fDebug == 4)) {
1495 CalculPRFCoefMean(fCountDet[2],(Int_t) (idect - fDect1[2]));
77566f2a 1496 }
1497
8ec526a4 1498 // Method Mean and fit
1499 // idect is egal for fDebug = 0 and 2, only to fill the hist
1500 FitPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2]));
77566f2a 1501
8ec526a4 1502 // Visualise the detector for fDebug 3 or 4
1503 // Here is the reconstruction of the pad and row group is used!
1504 if (fDebug >= 3) {
1505 FillCoefPRFDB();
1506 }
77566f2a 1507
8ec526a4 1508 // Fill the tree if end of a detector or only the pointer to the branch!!!
77566f2a 1509 FillInfosFit(idect,2);
1510
8ec526a4 1511 // Memory!!!
1512 if (fDebug != 2) {
77566f2a 1513 delete projprf;
1514 }
1515
8ec526a4 1516 } // Boucle object
77566f2a 1517
8ec526a4 1518 // Error
1519 if ((fDebug == 1) ||
1520 (fDebug == 4)) {
1521 ErrorPRF();
1522 }
77566f2a 1523
8ec526a4 1524 // Plot
1525 // No plot, 1 and 4 error plot, 3 and 4 DB plot
1526 if ((fDebug == 1) ||
1527 (fDebug == 4)) {
77566f2a 1528 PlotPRF();
8ec526a4 1529 }
1530 if ((fDebug == 4) ||
1531 (fDebug == 3)){
77566f2a 1532 PlotPRFDB();
8ec526a4 1533 }
77566f2a 1534
8ec526a4 1535 // Mean Statistic
1536 if (fNumberFit > 0) {
1537 AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit));
1538 fStatisticMean = fStatisticMean / fNumberFit;
77566f2a 1539 }
1540 else {
1541 AliInfo("There is no fit!");
1542 }
1543
8ec526a4 1544 // Write the things!
1545 if (fWriteCoef[2]) {
77566f2a 1546 WriteFitInfos(2);
1547 }
8ec526a4 1548
77566f2a 1549 return kTRUE;
1550
1551}
77566f2a 1552
8ec526a4 1553//____________Functions fit Online PRF2d_______________________________________
77566f2a 1554Bool_t AliTRDCalibra::FitPRFOnline(TTree *tree)
1555{
1556 //
8ec526a4 1557 // Look if the calibration group can be found in the tree, if yes take
1558 // the histo, fit it, and write the results in a tree
77566f2a 1559 //
1560
8ec526a4 1561 // Number of Xbins (detectors or groups of pads)
1562 if (!InitFit(0,0,0,2)) {
77566f2a 1563 return kFALSE;
1564 }
8ec526a4 1565 fStatisticMean = 0.0;
1566 fNumberFit = 0;
e5c60cc7 1567 fNumberEnt = 0;
77566f2a 1568
8ec526a4 1569 // For memory
1570 if (fVectorPRF) {
1571 fVectorPRF->Clear();
1572 }
1573 if (fPlaPRF) {
1574 fPlaPRF->Clear();
77566f2a 1575 }
1576
8ec526a4 1577 // Init fCountDet and fCount
1578 InitfCountDetAndfCount(2);
1579 TGraphErrors *projprftree = 0x0;
77566f2a 1580 tree->SetBranchAddress("histo",&projprftree);
8ec526a4 1581 TObjArray *vectorplace = ConvertTreeVector(tree);
77566f2a 1582
8ec526a4 1583 // Beginning of the loop
1584 for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) {
77566f2a 1585
8ec526a4 1586 // Search if the group is in the VectorCH
77566f2a 1587 Int_t place = SearchInTreeVector(vectorplace,idect);
1588
8ec526a4 1589 // Is in
77566f2a 1590 TH1F *projprf = 0x0;
8ec526a4 1591 if (place != -1) {
e5c60cc7 1592 //Entries
1593 fNumberEnt++;
8ec526a4 1594 // Variable
77566f2a 1595 tree->GetEntry(place);
1596 projprf = CorrectTheError(projprftree);
1597 }
1598
8ec526a4 1599 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1600 UpdatefCountDetAndfCount(idect,2);
77566f2a 1601
8ec526a4 1602 // Reconstruction of the row and pad group: rowmin, row max ...
1603 ReconstructFitRowMinRowMax(idect,2);
77566f2a 1604
8ec526a4 1605 // Rebin and statistic stuff
1606 // This detector has not enough statistics or was off
1607 if ((place == -1) ||
1608 ((place != -1) &&
1609 (fEntriesCurrent < fMinEntries))) {
77566f2a 1610
8ec526a4 1611 // Fill with the default values
77566f2a 1612 NotEnoughStatistic(idect,2);
1613
8ec526a4 1614 // Memory!!!
1615 if (fDebug != 2) {
77566f2a 1616 delete projprf;
1617 }
1618
1619 continue;
8ec526a4 1620
77566f2a 1621 }
1622
8ec526a4 1623 // Statistics of the histos fitted
1624 AliInfo(Form("For the group number %d there are %d stats",idect,fEntriesCurrent));
1625 fNumberFit++;
1626 fStatisticMean += fEntriesCurrent;
77566f2a 1627
8ec526a4 1628 // Calcul of "real" coef
1629 if ((fDebug == 1) ||
1630 (fDebug == 4)){
1631 CalculPRFCoefMean(fCountDet[2],(Int_t) (idect - fDect1[2]));
1632 }
1633
1634 // Method Mean and fit
1635 // idect is egal for fDebug = 0 and 2, only to fill the hist
1636 FitPRF((TH1 *) projprf,(Int_t) (idect - fDect1[2]));
1637 // Visualise the detector for fDebug 3 or 4
1638 // Here is the reconstruction of the pad and row group is used!
1639 if (fDebug >= 3) {
1640 FillCoefPRFDB();
77566f2a 1641 }
8ec526a4 1642 // Fill the tree if end of a detector or only the pointer to the branch!!!
77566f2a 1643 FillInfosFit(idect,2);
77566f2a 1644
8ec526a4 1645 // Memory!!!
1646 if (fDebug != 2) {
77566f2a 1647 delete projprf;
1648 }
1649
8ec526a4 1650 } // Boucle object
77566f2a 1651
8ec526a4 1652 // Error
1653 if ((fDebug == 1) ||
1654 (fDebug == 4)) {
1655 ErrorPRF();
1656 }
77566f2a 1657
8ec526a4 1658 // Plot
1659 // No plot, 1 and 4 error plot, 3 and 4 DB plot
1660 if ((fDebug == 1) ||
1661 (fDebug == 4)){
77566f2a 1662 PlotPRF();
1663 }
8ec526a4 1664 if ((fDebug == 4) ||
1665 (fDebug == 3)){
77566f2a 1666 PlotPRFDB();
1667 }
1668
8ec526a4 1669 // Mean Statistics
1670 if (fNumberFit > 0) {
1671 AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit));
1672 fStatisticMean = fStatisticMean / fNumberFit;
77566f2a 1673 }
1674 else {
1675 AliInfo("There is no fit!");
1676 }
1677
8ec526a4 1678 // Write the things!
1679 if (fWriteCoef[2]) {
77566f2a 1680 WriteFitInfos(2);
1681 }
8ec526a4 1682
77566f2a 1683 return kTRUE;
1684
1685}
77566f2a 1686
8ec526a4 1687//____________Functions fit Online PRF2d_______________________________________
77566f2a 1688Bool_t AliTRDCalibra::FitPRFOnline()
1689{
1690 //
8ec526a4 1691 // Reconstruct the 1D histo (pad response function) from the vectorPRD for
1692 // each calibration group
1693 // Fit with a gaussian to reconstruct the sigma of the pad response function
1694 // write the results in a tree
77566f2a 1695 //
1696
8ec526a4 1697 // Number of Xbins (detectors or groups of pads)
1698 if (!InitFit(0,0,0,2)) {
77566f2a 1699 return kFALSE;
1700 }
8ec526a4 1701 fStatisticMean = 0.0;
1702 fNumberFit = 0;
e5c60cc7 1703 fNumberEnt = 0;
77566f2a 1704
8ec526a4 1705 // Init fCountDet and fCount
1706 InitfCountDetAndfCount(2);
77566f2a 1707
8ec526a4 1708 // Beginning of the loop
1709 for (Int_t idect = fDect1[2]; idect < fDect2[2]; idect++) {
77566f2a 1710
8ec526a4 1711 // Search if the group is in the VectorCH
77566f2a 1712 Int_t place = SearchInVector(idect,2);
1713
8ec526a4 1714 // Is in
1715 TH1F *projprf = 0x0;
77566f2a 1716 TString name("PRF");
1717 name += idect;
8ec526a4 1718 if (place != -1) {
e5c60cc7 1719 //Entries
1720 fNumberEnt++;
8ec526a4 1721 // Variable
1722 AliTRDPInfo *fPRFInfo = new AliTRDPInfo();
1723 // Retrieve
1724 fPRFInfo = (AliTRDPInfo *) fVectorPRF->At(place);
1725 projprf = CorrectTheError((TGraphErrors *) ConvertVectorPHisto(fPRFInfo,(const char *)name));
77566f2a 1726 projprf->SetDirectory(0);
1727 delete fPRFInfo;
1728 }
1729
8ec526a4 1730 // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
1731 UpdatefCountDetAndfCount(idect,2);
77566f2a 1732
8ec526a4 1733 // Reconstruction of the row and pad group: rowmin, row max ...
1734 ReconstructFitRowMinRowMax(idect,2);
77566f2a 1735
8ec526a4 1736 // Rebin and statistic stuff
1737 // This detector has not enough statistics or was off
1738 if ((place == -1) ||
1739 ((place != -1) &&
1740 (fEntriesCurrent < fMinEntries))) {
77566f2a 1741
8ec526a4 1742 // Fill with the default values
77566f2a 1743 NotEnoughStatistic(idect,2);
1744
8ec526a4 1745 // Memory
1746 if (fDebug != 2) {
77566f2a 1747 delete projprf;
1748 }
77566f2a 1749
1750 continue;
77566f2a 1751
8ec526a4 1752 }
77566f2a 1753
8ec526a4 1754 // Statistic of the histos fitted
1755 AliInfo(Form("For the group number %d there are %d stats", idect,fEntriesCurrent));
1756 fNumberFit++;
1757 fStatisticMean += fEntriesCurrent;
77566f2a 1758
8ec526a4 1759 // Calcul of "real" coef
1760 if ((fDebug == 1) ||
1761 (fDebug == 4)) {
1762 CalculPRFCoefMean(fCountDet[2],(Int_t) (idect-fDect1[2]));
1763 }
77566f2a 1764
8ec526a4 1765 // Method Mean and fit
1766 // idect is egal for fDebug = 0 and 2, only to fill the hist
1767 FitPRF((TH1 *) projprf,(Int_t) (idect-fDect1[2]));
1768 // Visualise the detector for fDebug 3 or 4
1769 // Here is the reconstruction of the pad and row group is used!
1770 if (fDebug >= 3) {
1771 FillCoefPRFDB();
77566f2a 1772 }
8ec526a4 1773 // Fill the tree if end of a detector or only the pointer to the branch!!!
77566f2a 1774 FillInfosFit(idect,2);
1775
8ec526a4 1776 // Memory!!!
1777 if (fDebug != 2) {
77566f2a 1778 delete projprf;
1779 }
1780
8ec526a4 1781 } // Boucle object
77566f2a 1782
8ec526a4 1783 // Error
1784 if ((fDebug == 1) ||
1785 (fDebug == 4)) {
1786 ErrorPRF();
1787 }
77566f2a 1788
8ec526a4 1789 // Plot
1790 // No plot, 1 and 4 error plot, 3 and 4 DB plot
1791 if ((fDebug == 1) ||
1792 (fDebug == 4)) {
77566f2a 1793 PlotPRF();
8ec526a4 1794 }
1795 if ((fDebug == 4) ||
1796 (fDebug == 3)) {
77566f2a 1797 PlotPRFDB();
8ec526a4 1798 }
77566f2a 1799
8ec526a4 1800 // Mean Statistics
1801 if (fNumberFit > 0) {
1802 AliInfo(Form("There is a mean statistic of: %d",(Int_t) fStatisticMean / fNumberFit));
77566f2a 1803 }
1804 else {
1805 AliInfo("There is no fit!");
1806 }
1807
8ec526a4 1808 // Write the things!
1809 if (fWriteCoef[2]) {
77566f2a 1810 WriteFitInfos(2);
1811 }
8ec526a4 1812
77566f2a 1813 return kTRUE;
1814
1815}
1816
8ec526a4 1817//____________Functions for initialising the AliTRDCalibra in the code_________
77566f2a 1818Bool_t AliTRDCalibra::Init2Dhistos()
1819{
8ec526a4 1820 //
1821 // For the offline tracking
1822 // This function will be called in the function AliReconstruction::Run()
1823 // Init the calibration mode (Nz, Nrphi), the 2D histograms if fHisto2d = kTRUE,
1824 //
77566f2a 1825
8ec526a4 1826 // DB Setting
1827 // Get cal
b43a3e17 1828 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
77566f2a 1829 if (!cal) {
1830 AliInfo("Could not get calibDB");
1831 return kFALSE;
1832 }
b43a3e17 1833 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
1834 if (!parCom) {
1835 AliInfo("Could not get CommonParam");
1836 return kFALSE;
1837 }
77566f2a 1838
77566f2a 1839 // Some parameters
8ec526a4 1840 fTimeMax = cal->GetNumberOfTimeBins();
b43a3e17 1841 fSf = parCom->GetSamplingFrequency();
8ec526a4 1842 if (fRelativeScaleAuto) {
1843 fRelativeScale = 0;
1844 }
1845 else {
1846 fRelativeScale = 20;
1847 }
77566f2a 1848
8ec526a4 1849 // Create the 2D histos corresponding to the pad groupCalibration mode
1850 if (fCH2dOn) {
77566f2a 1851
8ec526a4 1852 AliInfo(Form("The pad calibration mode for the relative gain calibration: Nz %d, and Nrphi %d"
1853 ,fNz[0]
1854 ,fNrphi[0]));
77566f2a 1855
8ec526a4 1856 // Calcul the number of Xbins
77566f2a 1857 fNtotal[0] = 0;
1858 ModePadCalibration(2,0);
1859 ModePadFragmentation(0,2,0,0);
8ec526a4 1860 fDetChamb2[0] = fNfragZ[0] * fNfragRphi[0];
1861 if (fDebug == 4) {
1862 AliInfo(Form("For the chamber 2: %d",fDetChamb2[0]));
77566f2a 1863 }
8ec526a4 1864 fNtotal[0] += 6 * 18 * fDetChamb2[0];
77566f2a 1865 ModePadCalibration(0,0);
1866 ModePadFragmentation(0,0,0,0);
8ec526a4 1867 fDetChamb0[0] = fNfragZ[0] * fNfragRphi[0];
1868 if (fDebug == 4) {
1869 AliInfo(Form("For the other chamber 0: %d",fDetChamb0[0]));
77566f2a 1870 }
8ec526a4 1871 fNtotal[0] += 6 * 4 * 18 * fDetChamb0[0];
1872 AliInfo(Form("Total number of Xbins: %d",fNtotal[0]));
77566f2a 1873
8ec526a4 1874 // Create the 2D histo
1875 if (fHisto2d) {
1876 CreateCH2d(fNtotal[0]);
1877 }
1878 if (fVector2d) {
1879 fVectorCH = new TObjArray();
1880 fPlaCH = new TObjArray();
1881 }
77566f2a 1882
8ec526a4 1883 // Variable
1884 fAmpTotal = new Float_t[TMath::Max(fDetChamb2[0],fDetChamb0[0])];
1885 for (Int_t k = 0; k < TMath::Max(fDetChamb2[0],fDetChamb0[0]); k++) {
1886 fAmpTotal[k] = 0.0;
77566f2a 1887 }
1888
77566f2a 1889 }
1890
8ec526a4 1891 if (fPH2dOn) {
1892
1893 AliInfo(Form("The pad calibration mode for the drift velocity calibration: Nz %d, and Nrphi %d"
1894 ,fNz[1]
1895 ,fNrphi[1]));
77566f2a 1896
8ec526a4 1897 // Calcul the number of Xbins
77566f2a 1898 fNtotal[1] = 0;
1899 ModePadCalibration(2,1);
1900 ModePadFragmentation(0,2,0,1);
8ec526a4 1901 fDetChamb2[1] = fNfragZ[1]*fNfragRphi[1];
1902 if (fDebug == 4) {
1903 AliInfo(Form("For the chamber 2: %d",fDetChamb2[1]));
77566f2a 1904 }
8ec526a4 1905 fNtotal[1] += 6 * 18 * fDetChamb2[1];
77566f2a 1906 ModePadCalibration(0,1);
1907 ModePadFragmentation(0,0,0,1);
8ec526a4 1908 fDetChamb0[1] = fNfragZ[1] * fNfragRphi[1];
1909 if (fDebug == 4) {
1910 AliInfo(Form("For the chamber 0: %d",fDetChamb0[1]));
77566f2a 1911 }
8ec526a4 1912 fNtotal[1] += 6 * 4 * 18 * fDetChamb0[1];
1913 AliInfo(Form("Total number of Xbins: %d",fNtotal[1]));
77566f2a 1914
8ec526a4 1915 // Create the 2D histo
1916 if (fHisto2d) {
1917 CreatePH2d(fNtotal[1]);
1918 }
1919 if (fVector2d) {
1920 fVectorPH = new TObjArray();
1921 fPlaPH = new TObjArray();
1922 }
77566f2a 1923
8ec526a4 1924 // Variable
1925 fPHPlace = new Short_t[fTimeMax];
1926 for (Int_t k = 0; k < fTimeMax; k++) {
1927 fPHPlace[k] = -1;
77566f2a 1928 }
8ec526a4 1929 fPHValue = new Float_t[fTimeMax];
1930 for (Int_t k = 0; k < fTimeMax; k++) {
1931 fPHValue[k] = -1.0;
1932 }
77566f2a 1933
1934 }
1935
8ec526a4 1936 if (fPRF2dOn) {
1937
1938 AliInfo(Form("The pad calibration mode for the PRF calibration: Nz %d, and Nrphi %d"
1939 ,fNz[2]
1940 ,fNrphi[2]));
77566f2a 1941
8ec526a4 1942 // Calcul the number of Xbins
77566f2a 1943 fNtotal[2] = 0;
1944 ModePadCalibration(2,2);
1945 ModePadFragmentation(0,2,0,2);
8ec526a4 1946 fDetChamb2[2] = fNfragZ[2] * fNfragRphi[2];
1947 if (fDebug == 4) {
1948 AliInfo(Form("For the chamber 2: %d",fDetChamb2[2]));
77566f2a 1949 }
8ec526a4 1950 fNtotal[2] += 6 * 18 * fDetChamb2[2];
77566f2a 1951 ModePadCalibration(0,2);
1952 ModePadFragmentation(0,0,0,2);
8ec526a4 1953 fDetChamb0[2] = fNfragZ[2] * fNfragRphi[2];
1954 if (fDebug == 4) {
1955 AliInfo(Form("For the chamber 0: %d",fDetChamb0[2]));
77566f2a 1956 }
8ec526a4 1957 fNtotal[2] += 6 * 4 * 18 * fDetChamb0[2];
1958 AliInfo(Form("Total number of Xbins: %d",fNtotal[2]));
77566f2a 1959
8ec526a4 1960 // Create the 2D histo
1961 if (fHisto2d) {
1962 CreatePRF2d(fNtotal[2]);
1963 }
1964 if (fVector2d) {
1965 fVectorPRF = new TObjArray();
1966 fPlaPRF = new TObjArray();
1967 }
77566f2a 1968
1969 }
1970
1971 return kTRUE;
1972
1973}
1974
8ec526a4 1975//____________Functions for filling the histos in the code_____________________
77566f2a 1976
8ec526a4 1977//____________Offine tracking in the AliTRDtracker_____________________________
1978Bool_t AliTRDCalibra::ResetTrack()
77566f2a 1979{
1980 //
8ec526a4 1981 // For the offline tracking
1982 // This function will be called in the function
1983 // AliTRDtracker::FollowBackPropagation() at the beginning
1984 // Reset the parameter to know we have a new TRD track
77566f2a 1985 //
1986
1987 fDetectorAliTRDtrack = kFALSE;
1988 return kTRUE;
77566f2a 1989
8ec526a4 1990}
77566f2a 1991
8ec526a4 1992//____________Offline tracking in the AliTRDtracker____________________________
77566f2a 1993Bool_t AliTRDCalibra::UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t)
1994{
1995 //
8ec526a4 1996 // For the offline tracking
1997 // This function will be called in the function
1998 // AliTRDtracker::FollowBackPropagation() in the loop over the clusters
1999 // of TRD tracks
2000 // Fill the 2D histos or the vectors with the info of the clusters at
2001 // the end of a detectors if the track is "good"
77566f2a 2002 //
2003
8ec526a4 2004 // Get the parameter object
77566f2a 2005 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
2006 if (!parCom) {
2007 AliInfo("Could not get CommonParam");
2008 return kFALSE;
2009 }
2010
2011 // Get the parameter object
2012 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
2013 if (!cal) {
2014 AliInfo("Could not get calibDB");
2015 return kFALSE;
2016 }
2017
8ec526a4 2018 // Localisation of the detector
77566f2a 2019 Int_t detector = cl->GetDetector();
8ec526a4 2020 Int_t chamber = GetChamber(detector);
2021 Int_t plane = GetPlane(detector);
77566f2a 2022
8ec526a4 2023 // Fill the infos for the previous clusters if not the same
2024 // detector anymore or if not the same track
2025 if (((detector != fDetectorPreviousTrack) || (!fDetectorAliTRDtrack)) &&
2026 (fDetectorPreviousTrack != -1)) {
2027
2028 fNumberTrack++;
77566f2a 2029
8ec526a4 2030 // If the same track, then look if the previous detector is in
2031 // the same plane, if yes: not a good track
2032 if (fDetectorAliTRDtrack &&
2033 (GetPlane(detector) <= GetPlane(fDetectorPreviousTrack))) {
77566f2a 2034 fGoodTrack = kFALSE;
2035 }
2036
8ec526a4 2037 // Fill only if the track doesn't touch a masked pad or doesn't
2038 // appear in the middle (fGoodTrack)
2039 if (fGoodTrack) {
77566f2a 2040
8ec526a4 2041 // Gain calibration
2042 if (fCH2dOn) {
77566f2a 2043 FillTheInfoOfTheTrackCH();
8ec526a4 2044 }
77566f2a 2045
8ec526a4 2046 // PH calibration
2047 if (fPH2dOn) {
77566f2a 2048 FillTheInfoOfTheTrackPH();
8ec526a4 2049 }
77566f2a 2050
8ec526a4 2051 } // if a good track
77566f2a 2052
8ec526a4 2053 ResetfVariables();
77566f2a 2054
8ec526a4 2055 } // Fill at the end the charge
77566f2a 2056
8ec526a4 2057 // Calcul the position of the detector
2058 if (detector != fDetectorPreviousTrack) {
2059 LocalisationDetectorXbins(detector);
77566f2a 2060 }
2061
8ec526a4 2062 // Reset the good track for the PRF
77566f2a 2063 Bool_t good = kTRUE;
2064
8ec526a4 2065 // Localisation of the cluster
2066 Double_t pos[3] = { 0.0, 0.0, 0.0 };
77566f2a 2067 pos[0] = cl->GetX();
2068 pos[1] = cl->GetY();
2069 pos[2] = cl->GetZ();
8ec526a4 2070 Int_t time = cl->GetLocalTimeBin();
2071
2072 // Reset the detector
2073 fDetectorPreviousTrack = detector;
2074 fDetectorAliTRDtrack = kTRUE;
2075
2076 // Position of the cluster
2077 AliTRDpadPlane *padplane = parCom->GetPadPlane(plane,chamber);
2078 Int_t row = padplane->GetPadRowNumber(pos[2]);
2079 Double_t offsetz = padplane->GetPadRowOffset(row,pos[2]);
2080 Double_t offsettilt = padplane->GetTiltOffset(offsetz);
2081 Int_t col = padplane->GetPadColNumber(pos[1] + offsettilt,offsetz);
2082
2083 // See if we are not near a masked pad
2084 if (!IsPadOn(detector,col,row)) {
2085 good = kFALSE;
77566f2a 2086 fGoodTrack = kFALSE;
2087 }
2088
8ec526a4 2089 if (col > 0) {
2090 if (!IsPadOn(detector,col-1,row)) {
77566f2a 2091 fGoodTrack = kFALSE;
8ec526a4 2092 good = kFALSE;
77566f2a 2093 }
2094 }
2095
8ec526a4 2096 if (col < 143) {
2097 if (!IsPadOn(detector,col+1,row)) {
77566f2a 2098 fGoodTrack = kFALSE;
8ec526a4 2099 good = kFALSE;
77566f2a 2100 }
2101 }
2102
8ec526a4 2103 // Row of the cluster and position in the pad groups
2104 Int_t posr[3] = { 0, 0, 0 };
2105 if ((fCH2dOn) && (fNnZ[0] != 0)) {
2106 posr[0] = (Int_t) row / fNnZ[0];
2107 }
2108 if ((fPH2dOn) && (fNnZ[1] != 0)) {
2109 posr[1] = (Int_t) row / fNnZ[1];
2110 }
2111 if ((fPRF2dOn) && (fNnZ[2] != 0)) {
2112 posr[2] = (Int_t) row / fNnZ[2];
2113 }
77566f2a 2114
8ec526a4 2115 // Col of the cluster and position in the pad groups
2116 Int_t posc[3] = { 0, 0, 0 };
2117 if ((fCH2dOn) && (fNnRphi[0] != 0)) {
2118 posc[0] = (Int_t) col / fNnRphi[0];
2119 }
2120 if ((fPH2dOn) && (fNnRphi[1] != 0)) {
2121 posc[1] = (Int_t) col / fNnRphi[1];
2122 }
2123 if ((fPRF2dOn) && (fNnRphi[2] != 0)) {
2124 posc[2] = (Int_t) col / fNnRphi[2];
2125 }
77566f2a 2126
8ec526a4 2127 // Charge in the cluster
2128 // For the moment take the abs
2129 Float_t q = TMath::Abs(cl->GetQ());
2130 Short_t *signals = cl->GetSignals();
77566f2a 2131
8ec526a4 2132 // Correction due to the track angle
2133 Float_t correction = 1.0;
77566f2a 2134 Float_t normalisation = 6.67;
8ec526a4 2135 if ((q >0) && (t->GetNdedx() > 0)) {
2136 correction = t->GetClusterdQdl((t->GetNdedx() - 1)) / (q * normalisation);
2137 }
2138
2139 // Fill the fAmpTotal with the charge
2140 if (fCH2dOn) {
2141 if (!fTraMaxPad){
2142 fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += q * correction;
2143 }
2144 else {
2145 fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += ((Float_t) signals[3]) * correction;
2146 }
77566f2a 2147 }
77566f2a 2148
8ec526a4 2149 // Fill the fPHPlace and value
2150 if (fPH2dOn) {
2151 fPHPlace[time] = posc[1]*fNfragZ[1]+posr[1];
2152 if (!fTraMaxPad) {
2153 fPHValue[time] = q * correction;
2154 }
2155 else {
2156 fPHValue[time] = ((Float_t) signals[3]) * correction;
2157 }
2158 }
77566f2a 2159
8ec526a4 2160 // Fill direct the PRF
2161 if ((fPRF2dOn) && (good)) {
77566f2a 2162
8ec526a4 2163 Float_t yminus = 0.0;
77566f2a 2164 Float_t xcenter = 0.0;
2165 Float_t ycenter = 0.0;
8ec526a4 2166 Float_t ymax = 0.0;
2167 Bool_t echec = kFALSE;
77566f2a 2168
8ec526a4 2169 if ((cl->From3pad()) && (!cl->IsUsed())) {
77566f2a 2170
8ec526a4 2171 // Center 3 balanced
2172 if ((((Float_t) signals[3]) > fThresholdClusterPRF2) &&
2173 (((Float_t) signals[2]) > fThresholdClusterPRF2) &&
2174 (((Float_t) signals[4]) > fThresholdClusterPRF2) &&
2175 (((Float_t) signals[1]) < fThresholdClusterPRF1) &&
2176 (((Float_t) signals[5]) < fThresholdClusterPRF1) &&
2177 (q * correction > 130.0)) {
2178 // Col correspond to signals[3]
2179 if (fCenterOfflineCluster) {
2180 xcenter = cl->GetCenter();
2181 }
2182 else {
2183 // Security of the denomiateur is 0
2184 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
2185 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
2186 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
2187 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
2188 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
2189 }
2190 else {
2191 xcenter = -100.0;
77566f2a 2192 }
77566f2a 2193 }
8ec526a4 2194 if ((xcenter > -0.5) && (xcenter < 0.5)) {
2195 ycenter = (Float_t) (((Float_t) signals[3])
2196 / (((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4]))));
2197 yminus = (Float_t) (((Float_t) signals[2])
2198 / (((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4]))));
2199 ymax = (Float_t) (((Float_t) signals[4])
2200 / (((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4]))));
2201 if ((ycenter > 0.485) &&
2202 (TMath::Abs(((Float_t) signals[2]) + ((Float_t) signals[3]) + (((Float_t) signals[4])) - q) < 8.0)) {
2203 echec = kTRUE;
2204 }
77566f2a 2205 }
2206 }
2207
8ec526a4 2208 // Fill only if it is in the drift region!
2209 if ((((Float_t) (((Float_t) time) / fSf)) > 0.3) && (echec)) {
2210 if (fHisto2d) {
2211 fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),xcenter,ycenter);
2212 if (xcenter < 0.0) {
2213 fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),-(xcenter+1.0),yminus);
2214 }
2215 if (xcenter > 0.0) {
2216 fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),1.0-xcenter,ymax);
2217 }
77566f2a 2218 }
8ec526a4 2219 if (fVector2d) {
2220 UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],xcenter,ycenter);
2221 if (xcenter < 0.0) {
2222 UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],-(xcenter+1.0),yminus);
2223 }
2224 if (xcenter > 0.0) {
2225 UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],1.0-xcenter,ymax);
2226 }
77566f2a 2227 }
8ec526a4 2228 } // If in the drift region
2229
2230 } // Cluster isole
2231
2232 } // PRF2dOn
77566f2a 2233
2234 return kTRUE;
2235
2236}
2237
8ec526a4 2238//____________Online trackling in AliTRDtrigger________________________________
2239Bool_t AliTRDCalibra::UpdateHistogramcm(AliTRDmcmTracklet *trk)
77566f2a 2240{
2241 //
8ec526a4 2242 // For the tracking
2243 // This function will be called in the function AliTRDtrigger::TestTracklet
2244 // before applying the pt cut on the tracklets
2245 // Fill the infos for the tracklets fTrkTest if the tracklets is "good"
77566f2a 2246 //
2247
8ec526a4 2248 // Localisation of the Xbins involved
2249 Int_t idect = trk->GetDetector();
2250 LocalisationDetectorXbins(idect);
77566f2a 2251
2252 // Get the parameter object
8ec526a4 2253 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
77566f2a 2254 if (!cal) {
2255 AliInfo("Could not get calibDB");
2256 return kFALSE;
2257 }
2258
8ec526a4 2259 // Reset
2260 ResetfVariables();
2261
2262 // Row of the tracklet and position in the pad groups
2263 Int_t row = trk->GetRow();
2264 Int_t posr[3] = { 0, 0, 0 };
2265 if ((fCH2dOn) && (fNnZ[0] != 0)) {
2266 posr[0] = (Int_t) row / fNnZ[0];
2267 }
2268 if ((fPH2dOn) && (fNnZ[1] != 0)) {
2269 posr[1] = (Int_t) row / fNnZ[1];
2270 }
2271 if ((fPRF2dOn) && (fNnZ[2] != 0)) {
2272 posr[2] = (Int_t) row / fNnZ[2];
2273 }
2274
2275 // Eventuelle correction due to track angle in z direction
77566f2a 2276 Float_t correction = 1.0;
8ec526a4 2277 if (fMcmCorrectAngle) {
2278 Float_t z = trk->GetRowz();
2279 Float_t r = trk->GetTime0();
2280 correction = r / TMath::Sqrt((r*r+z*z));
77566f2a 2281 }
8ec526a4 2282
2283 // Boucle sur les clusters
2284 // Condition on number of cluster: don't come from the middle of the detector
2285 if (trk->GetNclusters() >= fNumberClusters) {
2286
2287 for (Int_t icl = 0; icl < trk->GetNclusters(); icl++) {
2288
2289 Float_t amp[3] = { 0.0, 0.0, 0.0 };
2290 Int_t time = trk->GetClusterTime(icl);
2291 Int_t col = trk->GetClusterCol(icl);
77566f2a 2292
8ec526a4 2293 amp[0] = trk->GetClusterADC(icl)[0] * correction;
2294 amp[1] = trk->GetClusterADC(icl)[1] * correction;
2295 amp[2] = trk->GetClusterADC(icl)[2] * correction;
77566f2a 2296
8ec526a4 2297 if ((amp[0] < 0.0) ||
2298 (amp[1] < 0.0) ||
2299 (amp[2] < 0.0)) {
2300 continue;
2301 }
2302
2303 // Col of cluster and position in the pad groups
2304 Int_t posc[3] = { 0, 0, 0 };
2305 if ((fCH2dOn) && (fNnRphi[0] != 0)) {
2306 posc[0] = (Int_t) col / fNnRphi[0];
2307 }
2308 if ((fPH2dOn) && (fNnRphi[1] != 0)) {
2309 posc[1] = (Int_t) col / fNnRphi[1];
2310 }
2311 if ((fPRF2dOn) && (fNnRphi[2] != 0)) {
2312 posc[2] = (Int_t) col / fNnRphi[2];
2313 }
2314
2315 // See if we are not near a masked pad
77566f2a 2316 Bool_t good = kTRUE;
8ec526a4 2317 if (!IsPadOn(idect,col,row)) {
77566f2a 2318 fGoodTrack = kFALSE;
8ec526a4 2319 good = kFALSE;
77566f2a 2320 }
8ec526a4 2321
2322 if (col > 0) {
2323 if (!IsPadOn(idect,col-1,row)) {
77566f2a 2324 fGoodTrack = kFALSE;
8ec526a4 2325 good = kFALSE;
77566f2a 2326 }
2327 }
2328
8ec526a4 2329 if (col < 143) {
2330 if (!IsPadOn(idect,col+1,row)) {
77566f2a 2331 fGoodTrack = kFALSE;
8ec526a4 2332 good = kFALSE;
77566f2a 2333 }
2334 }
77566f2a 2335
8ec526a4 2336 // Total spectrum
2337 if (fPH2dOn) {
2338 fPHPlace[time] = posc[1] * fNfragZ[1] + posr[1];
77566f2a 2339 }
77566f2a 2340
8ec526a4 2341 if (!fTraMaxPad) {
2342 if (fCH2dOn) {
2343 fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += (Float_t) (amp[0]+amp[1]+amp[2]);
2344 }
2345 if (fPH2dOn) {
2346 fPHValue[time] = (Float_t) (amp[0]+amp[1]+amp[2]);
2347 }
2348 }
2349 else {
2350 if (fCH2dOn) {
2351 fAmpTotal[(Int_t) (posc[0]*fNfragZ[0]+posr[0])] += (Float_t) amp[1];
2352 }
2353 if (fPH2dOn) {
2354 fPHValue[time] = amp[1];
2355 }
77566f2a 2356 }
2357
8ec526a4 2358 // Fill PRF direct
2359 if (fPRF2dOn && good) {
2360 if ((amp[0] > fThresholdClusterPRF2) &&
2361 (amp[1] > fThresholdClusterPRF2) &&
2362 (amp[2] > fThresholdClusterPRF2) &&
2363 ((amp[0]+amp[1]+amp[2]) > 130.0)) {
2364 // Security of the denomiateur is 0
2365 if ((((Float_t) (((Float_t) amp[1]) * ((Float_t) amp[1])))
2366 / ((Float_t) (((Float_t) amp[0]) * ((Float_t) amp[2])))) != 1.0) {
2367 Float_t xcenter = 0.5 * (TMath::Log(amp[2] / amp[0]))
2368 / (TMath::Log((amp[1]*amp[1]) / (amp[0]*amp[2])));
2369 Float_t ycenter = amp[1] / (amp[0] + amp[1] + amp[2]);
2370 if ((xcenter > -0.5) &&
2371 (xcenter < 0.5) &&
2372 (ycenter > 0.485)) {
2373 Float_t yminus = amp[0] / (amp[0]+amp[1]+amp[2]);
2374 Float_t ymax = amp[2] / (amp[0]+amp[1]+amp[2]);
2375 // Fill only if it is in the drift region!
2376 if (((Float_t) time / fSf) > 0.3) {
2377 if (fHisto2d) {
2378 fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),xcenter,ycenter);
2379 if (xcenter < 0.0) {
2380 fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),-(xcenter+1.0),yminus);
2381 }
2382 if (xcenter > 0.0) {
2383 fPRF2d->Fill((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]+0.5),(1.0-xcenter),ymax);
2384 }
2385 }
2386 if (fVector2d) {
2387 UpdateVectorPRF((fXbins[2]+posc[2]*fNfragZ[2]+posr[2]),xcenter,ycenter);
2388 if (xcenter < 0.0) {
2389 UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],-(xcenter+1.0),yminus);
2390 }
2391 if (xcenter > 0.0) {
2392 UpdateVectorPRF(fXbins[2]+posc[2]*fNfragZ[2]+posr[2],(1.0-xcenter),ymax);
77566f2a 2393 }
77566f2a 2394 }
2395 }
2396 }
2397 }
2398 }
2399 }
2400
8ec526a4 2401 } // Boucle clusters
77566f2a 2402
8ec526a4 2403 // Fill the charge
2404 if (fCH2dOn && fGoodTrack) {
77566f2a 2405 FillTheInfoOfTheTrackCH();
8ec526a4 2406 }
77566f2a 2407
8ec526a4 2408 // PH calibration
2409 if (fPH2dOn && fGoodTrack) {
2410 FillTheInfoOfTheTrackPH();
2411 }
77566f2a 2412
8ec526a4 2413 } // Condition on number of clusters
2414
77566f2a 2415 return kTRUE;
2416
2417}
2418
8ec526a4 2419//____________Functions for seeing if the pad is really okey___________________
77566f2a 2420
8ec526a4 2421//_____________________________________________________________________________
2422Bool_t AliTRDCalibra::SetModeCalibrationFromTObject(TObject *object, Int_t i)
77566f2a 2423{
2424 //
8ec526a4 2425 // Set fNz[i] and fNrphi[i] of the AliTRDCalibra::Instance()
2426 // corresponding to the given TObject
77566f2a 2427 //
8ec526a4 2428
2429 const char *nametitle = object->GetTitle();
2430
2431 // Some patterns
2432 const Char_t *patternz0 = "Nz0";
2433 const Char_t *patternz1 = "Nz1";
2434 const Char_t *patternz2 = "Nz2";
2435 const Char_t *patternz3 = "Nz3";
2436 const Char_t *patternz4 = "Nz4";
2437 const Char_t *patternrphi0 = "Nrphi0";
2438 const Char_t *patternrphi1 = "Nrphi1";
2439 const Char_t *patternrphi2 = "Nrphi2";
2440 const Char_t *patternrphi3 = "Nrphi3";
2441 const Char_t *patternrphi4 = "Nrphi4";
2442 const Char_t *patternrphi5 = "Nrphi5";
2443 const Char_t *patternrphi6 = "Nrphi6";
2444
2445 UShort_t testz = 0;
2446 UShort_t testrphi = 0;
2447
2448 // Nz mode
2449 if (strstr(nametitle,patternz0)) {
2450 testz++;
2451 fNz[i] = 0;
2452 }
2453 if (strstr(nametitle,patternz1)) {
2454 testz++;
2455 fNz[i] = 1;
2456 }
2457 if (strstr(nametitle,patternz2)) {
2458 testz++;
2459 fNz[i] = 2;
2460 }
2461 if (strstr(nametitle,patternz3)) {
2462 testz++;
2463 fNz[i] = 3;
2464 }
2465 if (strstr(nametitle,patternz4)) {
2466 testz++;
2467 fNz[i] = 4;
2468 }
2469
2470 // Nrphi mode
2471 if (strstr(nametitle,patternrphi0)) {
2472 testrphi++;
2473 fNrphi[i] = 0;
2474 }
2475 if (strstr(nametitle,patternrphi1)) {
2476 testrphi++;
2477 fNrphi[i] = 1;
2478 }
2479 if (strstr(nametitle,patternrphi2)) {
2480 testrphi++;
2481 fNrphi[i] = 2;
2482 }
2483 if (strstr(nametitle,patternrphi3)) {
2484 testrphi++;
2485 fNrphi[i] = 3;
2486 }
2487 if (strstr(nametitle,patternrphi4)) {
2488 testrphi++;
2489 fNrphi[i] = 4;
2490 }
2491 if (strstr(nametitle,patternrphi5)) {
2492 testrphi++;
2493 fNrphi[i] = 5;
2494 }
2495 if (strstr(nametitle,patternrphi6)) {
2496 testrphi++;
2497 fNrphi[i] = 6;
2498 }
2499
2500 // Look if all is okey
2501 if ((testz == 1) &&
2502 (testrphi == 1)) {
2503 return kTRUE;
2504 }
2505 else {
2506 fNrphi[i] = 0;
2507 fNz[i] = 0;
2508 return kFALSE;
2509 }
77566f2a 2510
8ec526a4 2511}
2512
2513//_____________________________________________________________________________
2514Bool_t AliTRDCalibra::IsPadOn(Int_t detector, Int_t col, Int_t row) const
2515{
2516 //
2517 // Look in the choosen database if the pad is On.
2518 // If no the track will be "not good"
2519 //
77566f2a 2520
2521 // Get the parameter object
8ec526a4 2522 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
77566f2a 2523 if (!cal) {
2524 AliInfo("Could not get calibDB");
2525 return kFALSE;
2526 }
2527
8ec526a4 2528 if (!cal->IsChamberInstalled(detector) ||
2529 cal->IsChamberMasked(detector) ||
8ec526a4 2530 cal->IsPadMasked(detector,col,row)) {
77566f2a 2531 return kFALSE;
2532 }
8ec526a4 2533 else {
2534 return kTRUE;
2535 }
77566f2a 2536
2537}
2538
8ec526a4 2539//____________Functions for plotting the 2D____________________________________
77566f2a 2540
8ec526a4 2541//_____________________________________________________________________________
77566f2a 2542void AliTRDCalibra::Plot2d()
2543{
2544 //
2545 // Plot the 2D histos
2546 //
2547
8ec526a4 2548 if (fCH2dOn) {
2549 PlotCH2d();
2550 }
2551 if (fPH2dOn) {
2552 PlotPH2d();
2553 }
2554 if (fPRF2dOn) {
2555 PlotPRF2d();
2556 }
77566f2a 2557
2558}
77566f2a 2559
8ec526a4 2560//____________Writing the 2D___________________________________________________
2561
2562//_____________________________________________________________________________
77566f2a 2563Bool_t AliTRDCalibra::Write2d()
2564{
2565 //
8ec526a4 2566 // Write the 2D histograms or the vectors converted in trees in the file
2567 // "TRD.calibration.root"
77566f2a 2568 //
2569
2570 TFile *fout = TFile::Open(fWriteName,"RECREATE");
8ec526a4 2571 // Check if the file could be opened
77566f2a 2572 if (!fout || !fout->IsOpen()) {
2573 AliInfo("No File found!");
2574 return kFALSE;
2575 }
8ec526a4 2576 AliInfo(Form("Numbertrack: %d Numberusedch[0]: %d, Numberusedch[1]: %d Numberusedph[0]: %d, Numberusedph[1]: %d"
2577 ,fNumberTrack
2578 ,fNumberUsedCh[0]
2579 ,fNumberUsedCh[1]
2580 ,fNumberUsedPh[0]
2581 ,fNumberUsedPh[1]));
77566f2a 2582
2583 TStopwatch stopwatch;
2584 stopwatch.Start();
2585 AliInfo("Write2d");
8ec526a4 2586
2587 if ((fCH2dOn ) && (fWrite[0])) {
2588 if (fHisto2d) {
2589 fout->WriteTObject(fCH2d);
2590 }
2591 if (fVector2d) {
2592 TString name("Nz");
2593 name += fNz[0];
2594 name += "Nrphi";
2595 name += fNrphi[0];
2596 TTree *treeCH2d = ConvertVectorCTTreeHisto(fVectorCH,fPlaCH,"treeCH2d",(const char *) name);
77566f2a 2597 fout->WriteTObject(treeCH2d);
2598 }
2599 }
8ec526a4 2600 if ((fPH2dOn ) && (fWrite[1])) {
2601 if (fHisto2d) {
2602 fout->WriteTObject(fPH2d);
2603 }
2604 if (fVector2d) {
2605 TString name("Nz");
2606 name += fNz[1];
2607 name += "Nrphi";
2608 name += fNrphi[1];
2609 TTree *treePH2d = ConvertVectorPTreeHisto(fVectorPH,fPlaPH,"treePH2d",(const char *) name);
77566f2a 2610 fout->WriteTObject(treePH2d);
2611 }
2612 }
8ec526a4 2613 if ((fPRF2dOn ) && (fWrite[2])) {
2614 if (fHisto2d) {
2615 fout->WriteTObject(fPRF2d);
2616 }
2617 if (fVector2d) {
2618 TString name("Nz");
2619 name += fNz[2];
2620 name += "Nrphi";
2621 name += fNrphi[2];
2622 TTree *treePRF2d = ConvertVectorPTreeHisto(fVectorPRF,fPlaPRF,"treePRF2d",(const char *) name);
77566f2a 2623 fout->WriteTObject(treePRF2d);
2624 }
2625 }
2626
2627 fout->Close();
2628
8ec526a4 2629 AliInfo(Form("Execution time Write2d: R:%.2fs C:%.2fs"
2630 ,stopwatch.RealTime(),stopwatch.CpuTime()));
2631
77566f2a 2632 return kTRUE;
2633
2634}
8ec526a4 2635
2636//_____________________________________________________________________________
2637AliTRDCalDet *AliTRDCalibra::CreateDetObjectTree(TTree *tree, Int_t i)
77566f2a 2638{
2639 //
8ec526a4 2640 // It creates the AliTRDCalDet object from the tree of the coefficient
2641 // for the calibration i (i != 2)
77566f2a 2642 // It takes the mean value of the coefficients per detector
2643 // This object has to be written in the database
2644 //
2645
8ec526a4 2646 // Create the DetObject
77566f2a 2647 AliTRDCalDet *object = 0x0;
8ec526a4 2648 if (i == 0) {
2649 object = new AliTRDCalDet("ChamberGainFactor","GainFactor (detector value)");
2650 }
2651 if (i == 1) {
2652 object = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)");
2653 }
2654 else {
2655 object = new AliTRDCalDet("ChamberT0","T0 (detector value)");
2656 }
77566f2a 2657
8ec526a4 2658 // Read the Tree
2659 Int_t detector = -1;
77566f2a 2660 Float_t values[2304];
2661 tree->SetBranchAddress("detector",&detector);
8ec526a4 2662 if (i == 0) {
2663 tree->SetBranchAddress("gainPad",values);
2664 }
2665 if (i == 1) {
2666 tree->SetBranchAddress("vdrift" ,values);
2667 }
2668 if (i == 3) {
2669 tree->SetBranchAddress("t0" ,values);
2670 }
77566f2a 2671
8ec526a4 2672 // For calculating the mean
2673 Float_t mean = 0.0;
2674 Int_t nto = 0;
2675 Int_t numberofentries = tree->GetEntries();
77566f2a 2676
8ec526a4 2677 if (numberofentries != 540) {
2678 AliInfo("The tree is not complete");
2679 }
77566f2a 2680
8ec526a4 2681 for (Int_t det = 0; det < numberofentries; ++det) {
77566f2a 2682 tree->GetEntry(det);
8ec526a4 2683 if (GetChamber(detector) == 2) {
2684 nto = 1728;
2685 }
2686 else {
2687 nto = 2304;
2688 }
77566f2a 2689 mean = 0.0;
8ec526a4 2690 for (Int_t k = 0; k < nto; k++) {
2691 mean += TMath::Abs(values[k]) / nto;
2692 }
77566f2a 2693 object->SetValue(detector,mean);
2694 }
8ec526a4 2695
77566f2a 2696 return object;
8ec526a4 2697
77566f2a 2698}
8ec526a4 2699
2700//_____________________________________________________________________________
2701TObject *AliTRDCalibra::CreatePadObjectTree(TTree *tree, Int_t i
2702 , AliTRDCalDet *detobject)
77566f2a 2703{
2704 //
8ec526a4 2705 // It Creates the AliTRDCalPad object from the tree of the
2706 // coefficient for the calibration i (i != 2)
2707 // You need first to create the object for the detectors,
2708 // where the mean value is put.
77566f2a 2709 // This object has to be written in the database
2710 //
2711
8ec526a4 2712 // Create the DetObject
77566f2a 2713 AliTRDCalPad *object = 0x0;
8ec526a4 2714 if (i == 0) {
2715 object = new AliTRDCalPad("GainFactor","GainFactor (local variations)");
2716 }
2717 if (i == 1) {
2718 object = new AliTRDCalPad("LocalVdrift","TRD drift velocities (local variations)");
2719 }
2720 else {
2721 object = new AliTRDCalPad("LocalT0","T0 (local variations)");
2722 }
77566f2a 2723
8ec526a4 2724 // Read the Tree
2725 Int_t detector = -1;
77566f2a 2726 Float_t values[2304];
2727 tree->SetBranchAddress("detector",&detector);
8ec526a4 2728 if (i == 0) {
2729 tree->SetBranchAddress("gainPad",values);
2730 }
2731 if (i == 1) {
2732 tree->SetBranchAddress("vdrift" ,values);
2733 }
2734 if (i == 3) {
2735 tree->SetBranchAddress("t0" ,values);
2736 }
77566f2a 2737
8ec526a4 2738 // Variables
2739 Float_t mean = 0.0;
2740 Int_t numberofentries = tree->GetEntries();
77566f2a 2741
8ec526a4 2742 if (numberofentries != 540) {
2743 AliInfo("The tree is not complete");
2744 }
77566f2a 2745
8ec526a4 2746 for (Int_t det = 0; det < numberofentries; ++det) {
77566f2a 2747 tree->GetEntry(det);
2748 AliTRDCalROC *calROC = object->GetCalROC(detector);
2749 mean = detobject->GetValue(detector);
8ec526a4 2750 if (mean == 0) {
2751 continue;
2752 }
77566f2a 2753 Int_t rowMax = calROC->GetNrows();
2754 Int_t colMax = calROC->GetNcols();
8ec526a4 2755 for (Int_t row = 0; row < rowMax; ++row) {
2756 for (Int_t col = 0; col < colMax; ++col) {
e5c60cc7 2757
2758 calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])/mean);
2759
8ec526a4 2760 } // Col
2761 } // Row
77566f2a 2762 }
8ec526a4 2763
77566f2a 2764 return object;
8ec526a4 2765
77566f2a 2766}
8ec526a4 2767
2768//_____________________________________________________________________________
2769TObject *AliTRDCalibra::CreatePadObjectTree(TTree *tree)
77566f2a 2770{
2771 //
8ec526a4 2772 // It Creates the AliTRDCalPad object from the tree of the
2773 // coefficient for the calibration PRF (i = 2)
77566f2a 2774 // This object has to be written in the database
2775 //
2776
8ec526a4 2777 // Create the DetObject
77566f2a 2778 AliTRDCalPad *object = new AliTRDCalPad("PRFWidth","PRFWidth");
2779
8ec526a4 2780 // Read the Tree
2781 Int_t detector = -1;
77566f2a 2782 Float_t values[2304];
2783 tree->SetBranchAddress("detector",&detector);
8ec526a4 2784 tree->SetBranchAddress("width" ,values);
77566f2a 2785
8ec526a4 2786 // Variables
77566f2a 2787 Int_t numberofentries = tree->GetEntries();
2788
8ec526a4 2789 if (numberofentries != 540) {
2790 AliInfo("The tree is not complete");
2791 }
77566f2a 2792
8ec526a4 2793 for (Int_t det = 0; det < numberofentries; ++det) {
77566f2a 2794 tree->GetEntry(det);
2795 AliTRDCalROC *calROC = object->GetCalROC(detector);
2796 Int_t rowMax = calROC->GetNrows();
2797 Int_t colMax = calROC->GetNcols();
8ec526a4 2798 for (Int_t row = 0; row < rowMax; ++row) {
2799 for (Int_t col = 0; col < colMax; ++col) {
77566f2a 2800 calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)]));
8ec526a4 2801 } // Col
2802 } // Row
77566f2a 2803 }
8ec526a4 2804
77566f2a 2805 return object;
8ec526a4 2806
77566f2a 2807}
8ec526a4 2808
2809//_____________________________________________________________________________
2810void AliTRDCalibra::SetRelativeScale(Float_t RelativeScale)
77566f2a 2811{
2812 //
8ec526a4 2813 // Set the factor that will divide the deposited charge
2814 // to fit in the histo range [0,300]
77566f2a 2815 //
77566f2a 2816
8ec526a4 2817 if (RelativeScale > 0.0) {
2818 fRelativeScale = RelativeScale;
2819 }
2820 else {
2821 AliInfo("RelativeScale must be strict positif!");
2822 }
2823
2824}
2825
2826//_____________________________________________________________________________
2827void AliTRDCalibra::SetNz(Int_t i, Short_t Nz)
2828{
2829 //
2830 // Set the mode of calibration group in the z direction for the parameter i
2831 //
2832
2833 if ((Nz >= 0) &&
2834 (Nz < 5)) {
2835 fNz[i] = Nz;
2836 }
2837 else {
2838 AliInfo("You have to choose between 0 and 4");
2839 }
2840
2841}
2842
2843//_____________________________________________________________________________
2844void AliTRDCalibra::SetNrphi(Int_t i, Short_t Nrphi)
2845{
2846 //
2847 // Set the mode of calibration group in the rphi direction for the parameter i
2848 //
77566f2a 2849
8ec526a4 2850 if ((Nrphi >= 0) &&
2851 (Nrphi < 7)) {
2852 fNrphi[i] = Nrphi;
2853 }
2854 else {
2855 AliInfo("You have to choose between 0 and 6");
2856 }
2857
2858}
2859
2860//_____________________________________________________________________________
2861void AliTRDCalibra::SetPeriodeFitPH(Int_t periodeFitPH)
2862{
2863 //
2864 // Set FitPH if 1 then each detector will be fitted
2865 //
2866
2867 if (periodeFitPH > 0) {
2868 fFitPHPeriode = periodeFitPH;
2869 }
2870 else {
2871 AliInfo("periodeFitPH must be higher than 0!");
2872 }
2873
2874}
2875
2876//_____________________________________________________________________________
2877void AliTRDCalibra::SetBeginFitCharge(Float_t beginFitCharge)
2878{
2879 //
2880 // The fit of the deposited charge distribution begins at
2881 // histo->Mean()/beginFitCharge
2882 // You can here set beginFitCharge
2883 //
2884
2885 if (beginFitCharge > 0) {
2886 fBeginFitCharge = beginFitCharge;
2887 }
2888 else {
2889 AliInfo("beginFitCharge must be strict positif!");
2890 }
2891
2892}
2893
2894//_____________________________________________________________________________
2895void AliTRDCalibra::SetT0Shift(Float_t t0Shift)
2896{
2897 //
2898 // The t0 calculated with the maximum positif slope is shift from t0Shift
2899 // You can here set t0Shift
2900 //
2901
2902 if (t0Shift > 0) {
2903 fT0Shift = t0Shift;
2904 }
2905 else {
2906 AliInfo("t0Shift must be strict positif!");
2907 }
2908
2909}
2910
2911//_____________________________________________________________________________
2912void AliTRDCalibra::SetRangeFitPRF(Float_t rangeFitPRF)
2913{
2914 //
2915 // The fit of the PRF is from -rangeFitPRF to rangeFitPRF
2916 // You can here set rangeFitPRF
2917 //
2918
2919 if ((rangeFitPRF > 0) &&
2920 (rangeFitPRF <= 1.0)) {
2921 fRangeFitPRF = rangeFitPRF;
2922 }
2923 else {
2924 AliInfo("rangeFitPRF must be between 0 and 1.0");
2925 }
2926
2927}
2928
2929//_____________________________________________________________________________
2930void AliTRDCalibra::SetRebin(Short_t rebin)
2931{
2932 //
2933 // Rebin with rebin time less bins the Ch histo
2934 // You can set here rebin that should divide the number of bins of CH histo
2935 //
2936
2937 if (rebin > 0) {
2938 fRebin = rebin;
2939 AliInfo("You have to be sure that fRebin divides fNumberBinCharge used!");
2940 }
2941 else {
2942 AliInfo("You have to choose a positiv value!");
2943 }
2944
2945}
2946
2947//_____________________________________________________________________________
2948TTree *AliTRDCalibra::Sum2Trees(const Char_t *filename1
2949 , const Char_t *filename2
2950 , const Char_t *variablecali)
2951{
2952 //
2953 // It returns the sum of two trees with the name variablecali
2954 // in the files filenam1 and filename2 equivalent of merging two 2D histos
2955 // The name of the resulting tree is the same as the two input trees
2956 // variablecali can be treeCH2d, treePH2d or treePRF2d
2957 //
2958
2959 // Variables
2960 TChain *treeChain = new TChain(variablecali);
2961 TObjArray *vectorplace = new TObjArray();
2962 TObjArray *where = new TObjArray();
77566f2a 2963
8ec526a4 2964 // First tree
2965 // Take the tree
2966 TFile *file1 = new TFile(filename1,"READ");
77566f2a 2967 TTree *tree1 = (TTree *) file1->Get(variablecali);
8ec526a4 2968
2969 gDirectory = gROOT;
2970
2971 // Take the places
77566f2a 2972 vectorplace = ConvertTreeVector(tree1);
8ec526a4 2973
2974 // Say where it is in tree 1
2975 for (Int_t jui = 0; jui < (Int_t) vectorplace->GetEntriesFast(); jui++) {
2976 AliTRDPlace *placejui = new AliTRDPlace();
2977 placejui->SetPlace(jui);
2978 TObjArray *chainplace = new TObjArray();
2979 chainplace->Add((TObject *) placejui);
2980 where->Add((TObject *) chainplace);
77566f2a 2981 }
8ec526a4 2982
2983 // Add to the chain
77566f2a 2984 treeChain->Add(filename1);
2985 delete file1;
77566f2a 2986
8ec526a4 2987 // Second tree
2988 // Take the tree
2989 TFile *file2 = new TFile(filename2,"READ");
2990 TTree *tree2 = (TTree *) file2->Get(variablecali);
77566f2a 2991
8ec526a4 2992 gDirectory = gROOT;
77566f2a 2993
8ec526a4 2994 // Take the places
2995 TObjArray *vector2 = ConvertTreeVector(tree2);
77566f2a 2996 Int_t j = treeChain->GetEntries();
8ec526a4 2997
2998 for (Int_t jui = 0; jui < (Int_t) vector2->GetEntriesFast(); jui++) {
2999 // Search if already found
3000 Int_t place = SearchInTreeVector(vectorplace,((AliTRDPlace *) vector2->At(jui))->GetPlace());
3001 // Create a new element in the two std vectors
3002 if (place == -1) {
3003 AliTRDPlace *placejjui = new AliTRDPlace();
3004 placejjui->SetPlace((j+jui));
3005 TObjArray *chainplace = new TObjArray();
3006 chainplace->Add((TObject *) placejjui);
3007 vectorplace->Add((TObject *) (vector2->At(jui)));
3008 where->Add((TObject *) chainplace);
3009 }
3010 // Update the element at the place "place" in the std vector whereinthechain
77566f2a 3011 else {
8ec526a4 3012 AliTRDPlace *placejjui = new AliTRDPlace();
3013 placejjui->SetPlace((j+jui));
3014 TObjArray *chainplace = ((TObjArray *) where->At(place));
3015 chainplace->Add((TObject *) placejjui);
3016 where->AddAt((TObject *) chainplace,place);
77566f2a 3017 }
3018 }
8ec526a4 3019
3020 // Add to the Chain
77566f2a 3021 treeChain->Add(filename2);
3022 delete file2;
77566f2a 3023
8ec526a4 3024 // Take care of the profile
3025 const Char_t *pattern = "P";
77566f2a 3026 TTree *tree = 0x0;
3027
8ec526a4 3028 if (!strstr(variablecali,pattern)) {
3029
3030 // Ready to read the chain
77566f2a 3031 TH1F *his = 0x0;
3032 treeChain->SetBranchAddress("histo",&his);
8ec526a4 3033
3034 // Initialise the final tree
3035 Int_t group = -1;
77566f2a 3036 TH1F *histsum = 0x0;
3037
3038 tree = new TTree(variablecali,variablecali);
3039 tree->Branch("groupnumber",&group,"groupnumber/I");
3040 tree->Branch("histo","TH1F",&histsum,32000,0);
8ec526a4 3041
3042 // Init histsum
3043 if (treeChain->GetEntries() < 1) {
3044 return tree1;
3045 }
77566f2a 3046
8ec526a4 3047 for (Int_t h = 0; h < (Int_t) vectorplace->GetEntriesFast(); h++) {
3048 group = ((AliTRDPlace *) vectorplace->At(h))->GetPlace();
3049 TObjArray *chainplace = ((TObjArray *) where->At(h));
3050 treeChain->GetEntry(((AliTRDPlace *) chainplace->At(0))->GetPlace());
77566f2a 3051 //Init for the first time
8ec526a4 3052 if (h == 0) {
3053 histsum = new TH1F("","",his->GetXaxis()->GetNbins()
3054 ,his->GetXaxis()->GetBinLowEdge(1)
3055 ,his->GetXaxis()->GetBinUpEdge(his->GetXaxis()->GetNbins()));
3056 histsum->Sumw2();
77566f2a 3057 }
8ec526a4 3058 // Reset for each new group
77566f2a 3059 histsum->SetEntries(0.0);
8ec526a4 3060 for (Int_t l = 0; l <= histsum->GetXaxis()->GetNbins(); l++) {
77566f2a 3061 histsum->SetBinContent(l,0.0);
3062 histsum->SetBinError(l,0.0);
3063 }
3064 histsum->Add(his,1);
8ec526a4 3065 if ((Int_t) chainplace->GetEntriesFast() > 1) {
3066 for (Int_t s = 1; s < (Int_t) chainplace->GetEntriesFast(); s++) {
3067 treeChain->GetEntry(((AliTRDPlace *) chainplace->At(s))->GetPlace());
77566f2a 3068 histsum->Add(his,1);
3069 }
3070 }
3071 tree->Fill();
3072 }
8ec526a4 3073
77566f2a 3074 }
8ec526a4 3075 else {
3076
3077 // Ready to read the chain
77566f2a 3078 TGraphErrors *his = 0x0;
3079 treeChain->SetBranchAddress("histo",&his);
3080
8ec526a4 3081 // Initialise the final tree
3082 Int_t group = -1;
77566f2a 3083 TGraphErrors *histsum = 0x0;
8ec526a4 3084 Double_t *xref = 0x0;
77566f2a 3085
3086 tree = new TTree(variablecali,variablecali);
3087 tree->Branch("groupnumber",&group,"groupnumber/I");
3088 tree->Branch("histo","TGraphErrors",&histsum,32000,0);
8ec526a4 3089
3090 // Init histsum
3091 if (treeChain->GetEntries() < 1) {
3092 return tree1;
3093 }
3094
3095 for (Int_t h = 0; h < (Int_t) vectorplace->GetEntriesFast(); h++) {
3096
3097 group = ((AliTRDPlace *) vectorplace->At(h))->GetPlace();
3098 TObjArray *chainplace = ((TObjArray *) where->At(h));
3099 treeChain->GetEntry(((AliTRDPlace *) chainplace->At(0))->GetPlace());
77566f2a 3100 //Init or reset for a new group
3101 Int_t nbins = his->GetN();
3102 Double_t *x;
8ec526a4 3103 x = new Double_t[nbins];
77566f2a 3104 xref = his->GetX();
3105 Double_t *ex;
8ec526a4 3106 ex = new Double_t[nbins];
77566f2a 3107 Double_t *y;
8ec526a4 3108 y = new Double_t[nbins];
77566f2a 3109 Double_t *ey;
8ec526a4 3110 ey = new Double_t[nbins];
3111
3112 for (Int_t lo = 0; lo < nbins; lo++) {
3113 x[lo] = xref[lo];
77566f2a 3114 ex[lo] = 0.0;
3115 y[lo] = 0.0;
3116 ey[lo] = 0.0;
3117 }
3118 delete histsum;
3119 histsum = new TGraphErrors(nbins,x,y,ex,ey);
8ec526a4 3120
3121 // Add the first
77566f2a 3122 histsum = AddProfiles(his,histsum);
8ec526a4 3123 if ((Int_t) chainplace->GetEntriesFast() > 1) {
3124 for (Int_t s = 1; s < (Int_t) chainplace->GetEntriesFast(); s++) {
3125 treeChain->GetEntry(((AliTRDPlace *) chainplace->At(s))->GetPlace());
77566f2a 3126 histsum = AddProfiles(his,histsum);
3127 }
3128 }
8ec526a4 3129
77566f2a 3130 tree->Fill();
8ec526a4 3131
77566f2a 3132 }
8ec526a4 3133
77566f2a 3134 }
8ec526a4 3135
77566f2a 3136 return tree;
8ec526a4 3137
77566f2a 3138}
77566f2a 3139
8ec526a4 3140//____________Function fill 2D for the moment out of the code__________________
77566f2a 3141
8ec526a4 3142//____________Function fill 2D all objects from digits_________________________
3143Bool_t AliTRDCalibra::Create2DDiSimOnline(Int_t iev1, Int_t iev2)
77566f2a 3144{
3145 //
8ec526a4 3146 // Only for simulations, after the simulation, create the 2D histos
3147 // from the digits stored in the file "TRD.Digits.root"
77566f2a 3148 // Only for CH and PH
3149 //
77566f2a 3150
8ec526a4 3151 const Int_t kNplan = 6;
3152 const Int_t kNcham = 5;
77566f2a 3153
8ec526a4 3154 // RunLoader and so on
77566f2a 3155 if (gAlice) {
3156 delete gAlice->GetRunLoader();
3157 delete gAlice;
8ec526a4 3158 gAlice = 0;
77566f2a 3159 }
77566f2a 3160
8ec526a4 3161 AliRunLoader *rl = AliRunLoader::Open("galice.root");
77566f2a 3162 if (!rl) {
3163 return kFALSE;
3164 }
8ec526a4 3165
77566f2a 3166 rl->LoadgAlice();
3167 gAlice = rl->GetAliRun();
3168 if (!gAlice) {
3169 return kFALSE;
3170 }
3171
3172 // Import the Trees for the event nEvent in the file
3173 rl->LoadKinematics();
3174 rl->GetEvent(0);
3175 rl->LoadHeader();
3176