]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDCalibraFillHisto.cxx
Implementation of SetFirstRunGain, SetFirstRunGainLocal, SetFirstRunVdrift (Julian)
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFillHisto.cxx
CommitLineData
64942b85 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//**************************************************************************/
55a288e5 15
16/* $Id$ */
17
18/////////////////////////////////////////////////////////////////////////////////
170c35f1 19//
55a288e5 20// AliTRDCalibraFillHisto
21//
22// This class is for the TRD calibration of the relative gain factor, the drift velocity,
23// the time 0 and the pad response function. It fills histos or vectors.
24// It can be used for the calibration per chamber but also per group of pads and eventually per pad.
170c35f1 25// The user has to choose with the functions SetNz and SetNrphi the precision of the calibration (see AliTRDCalibraMode).
55a288e5 26// 2D Histograms (Histo2d) or vectors (Vector2d), then converted in Trees, will be filled
27// from RAW DATA in a run or from reconstructed TRD tracks during the offline tracking
28// in the function "FollowBackProlongation" (AliTRDtracker)
29// Per default the functions to fill are off.
30//
1785640c 31// Authors:
32// R. Bailhache (R.Bailhache@gsi.de, rbailhache@ikf.uni-frankfurt.de)
33// J. Book (jbook@ikf.uni-frankfurt.de)
55a288e5 34//
35//////////////////////////////////////////////////////////////////////////////////////
36
55a288e5 37#include <TProfile2D.h>
38#include <TProfile.h>
39#include <TFile.h>
55a288e5 40#include <TStyle.h>
41#include <TCanvas.h>
55a288e5 42#include <TObjArray.h>
d0569428 43#include <TObject.h>
55a288e5 44#include <TH1F.h>
45#include <TH2I.h>
46#include <TH2.h>
47#include <TStopwatch.h>
48#include <TMath.h>
49#include <TDirectory.h>
170c35f1 50#include <TTreeStream.h>
51#include <TVectorD.h>
6bbdc11a 52#include <TLinearFitter.h>
55a288e5 53
54#include "AliLog.h"
55a288e5 55
56#include "AliTRDCalibraFillHisto.h"
57#include "AliTRDCalibraMode.h"
58#include "AliTRDCalibraVector.h"
3a0f6479 59#include "AliTRDCalibraVdriftLinearFit.h"
55a288e5 60#include "AliTRDcalibDB.h"
61#include "AliTRDCommonParam.h"
55a288e5 62#include "AliTRDpadPlane.h"
63#include "AliTRDcluster.h"
bcb6fb78 64#include "AliTRDtrackV1.h"
3a0f6479 65#include "AliRawReader.h"
66#include "AliRawReaderDate.h"
f162af62 67#include "AliTRDgeometry.h"
d0569428 68#include "./Cal/AliTRDCalROC.h"
a2a4ec8e 69#include "./Cal/AliTRDCalPad.h"
d0569428 70#include "./Cal/AliTRDCalDet.h"
170c35f1 71
1785640c 72#include "AliTRDdigitsManager.h"
73#include "AliTRDdigitsParam.h"
74#include "AliTRDSignalIndex.h"
75#include "AliTRDarrayADC.h"
76
fd50bb14 77#include "AliTRDrawStream.h"
78
a2a4ec8e 79#include "AliCDBEntry.h"
80#include "AliCDBManager.h"
fd50bb14 81
170c35f1 82#ifdef ALI_DATE
83#include "event.h"
84#endif
55a288e5 85
3a0f6479 86
55a288e5 87ClassImp(AliTRDCalibraFillHisto)
88
89AliTRDCalibraFillHisto* AliTRDCalibraFillHisto::fgInstance = 0;
90Bool_t AliTRDCalibraFillHisto::fgTerminated = kFALSE;
91
92//_____________singleton implementation_________________________________________________
93AliTRDCalibraFillHisto *AliTRDCalibraFillHisto::Instance()
94{
95 //
96 // Singleton implementation
97 //
98
99 if (fgTerminated != kFALSE) {
100 return 0;
101 }
102
103 if (fgInstance == 0) {
104 fgInstance = new AliTRDCalibraFillHisto();
105 }
106
107 return fgInstance;
108
109}
110
111//______________________________________________________________________________________
112void AliTRDCalibraFillHisto::Terminate()
113{
114 //
115 // Singleton implementation
116 // Deletes the instance of this class
117 //
118
119 fgTerminated = kTRUE;
120
121 if (fgInstance != 0) {
122 delete fgInstance;
123 fgInstance = 0;
124 }
125
126}
3a0f6479 127
55a288e5 128//______________________________________________________________________________________
129AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
130 :TObject()
f162af62 131 ,fGeo(0)
01239968 132 ,fCalibDB(0)
64942b85 133 ,fIsHLT(kFALSE)
55a288e5 134 ,fCH2dOn(kFALSE)
135 ,fPH2dOn(kFALSE)
136 ,fPRF2dOn(kFALSE)
137 ,fHisto2d(kFALSE)
138 ,fVector2d(kFALSE)
170c35f1 139 ,fLinearFitterOn(kFALSE)
140 ,fLinearFitterDebugOn(kFALSE)
55a288e5 141 ,fRelativeScale(0)
170c35f1 142 ,fThresholdClusterPRF2(15.0)
b70c68da 143 ,fLimitChargeIntegration(kFALSE)
f9ed5395 144 ,fFillWithZero(kFALSE)
64942b85 145 ,fNormalizeNbOfCluster(kFALSE)
146 ,fMaxCluster(0)
147 ,fNbMaxCluster(0)
d085ba91 148 ,fFirstRunGain(0)
4c865c34 149 ,fVersionGainUsed(0)
150 ,fSubVersionGainUsed(0)
d085ba91 151 ,fFirstRunGainLocal(0)
a2a4ec8e 152 ,fVersionGainLocalUsed(0)
153 ,fSubVersionGainLocalUsed(0)
d085ba91 154 ,fFirstRunVdrift(0)
4c865c34 155 ,fVersionVdriftUsed(0)
156 ,fSubVersionVdriftUsed(0)
170c35f1 157 ,fCalibraMode(new AliTRDCalibraMode())
158 ,fDebugStreamer(0)
159 ,fDebugLevel(0)
55a288e5 160 ,fDetectorPreviousTrack(-1)
e4db522f 161 ,fMCMPrevious(-1)
162 ,fROBPrevious(-1)
64942b85 163 ,fNumberClusters(1)
bcb6fb78 164 ,fNumberClustersf(30)
6aafa7ea 165 ,fNumberClustersProcent(0.5)
166 ,fThresholdClustersDAQ(120.0)
167 ,fNumberRowDAQ(2)
168 ,fNumberColDAQ(4)
170c35f1 169 ,fProcent(6.0)
170 ,fDifference(17)
171 ,fNumberTrack(0)
172 ,fTimeMax(0)
173 ,fSf(10.0)
e526983e 174 ,fNumberBinCharge(50)
175 ,fNumberBinPRF(10)
176 ,fNgroupprf(3)
55a288e5 177 ,fAmpTotal(0x0)
178 ,fPHPlace(0x0)
179 ,fPHValue(0x0)
170c35f1 180 ,fGoodTracklet(kTRUE)
1ca79a00 181 ,fLinearFitterTracklet(0x0)
170c35f1 182 ,fEntriesCH(0x0)
183 ,fEntriesLinearFitter(0x0)
184 ,fCalibraVector(0x0)
55a288e5 185 ,fPH2d(0x0)
186 ,fPRF2d(0x0)
187 ,fCH2d(0x0)
d0569428 188 ,fLinearFitterArray(540)
3a0f6479 189 ,fLinearVdriftFit(0x0)
d0569428 190 ,fCalDetGain(0x0)
191 ,fCalROCGain(0x0)
55a288e5 192{
193 //
194 // Default constructor
195 //
196
170c35f1 197 //
198 // Init some default values
199 //
55a288e5 200
170c35f1 201 fNumberUsedCh[0] = 0;
202 fNumberUsedCh[1] = 0;
203 fNumberUsedPh[0] = 0;
204 fNumberUsedPh[1] = 0;
3a0f6479 205
f162af62 206 fGeo = new AliTRDgeometry();
01239968 207 fCalibDB = AliTRDcalibDB::Instance();
55a288e5 208}
f162af62 209
55a288e5 210//______________________________________________________________________________________
211AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
f162af62 212 :TObject(c)
213 ,fGeo(0)
01239968 214 ,fCalibDB(0)
64942b85 215 ,fIsHLT(c.fIsHLT)
f162af62 216 ,fCH2dOn(c.fCH2dOn)
217 ,fPH2dOn(c.fPH2dOn)
218 ,fPRF2dOn(c.fPRF2dOn)
219 ,fHisto2d(c.fHisto2d)
220 ,fVector2d(c.fVector2d)
221 ,fLinearFitterOn(c.fLinearFitterOn)
222 ,fLinearFitterDebugOn(c.fLinearFitterDebugOn)
223 ,fRelativeScale(c.fRelativeScale)
224 ,fThresholdClusterPRF2(c.fThresholdClusterPRF2)
b70c68da 225 ,fLimitChargeIntegration(c.fLimitChargeIntegration)
37b0cf5e 226 ,fFillWithZero(c.fFillWithZero)
64942b85 227 ,fNormalizeNbOfCluster(c.fNormalizeNbOfCluster)
228 ,fMaxCluster(c.fMaxCluster)
229 ,fNbMaxCluster(c.fNbMaxCluster)
d085ba91 230 ,fFirstRunGain(c.fFirstRunGain)
4c865c34 231 ,fVersionGainUsed(c.fVersionGainUsed)
232 ,fSubVersionGainUsed(c.fSubVersionGainUsed)
d085ba91 233 ,fFirstRunGainLocal(c.fFirstRunGainLocal)
a2a4ec8e 234 ,fVersionGainLocalUsed(c.fVersionGainLocalUsed)
235 ,fSubVersionGainLocalUsed(c.fSubVersionGainLocalUsed)
d085ba91 236 ,fFirstRunVdrift(c.fFirstRunVdrift)
4c865c34 237 ,fVersionVdriftUsed(c.fVersionVdriftUsed)
238 ,fSubVersionVdriftUsed(c.fSubVersionVdriftUsed)
f162af62 239 ,fCalibraMode(0x0)
240 ,fDebugStreamer(0)
241 ,fDebugLevel(c.fDebugLevel)
f162af62 242 ,fDetectorPreviousTrack(c.fDetectorPreviousTrack)
e4db522f 243 ,fMCMPrevious(c.fMCMPrevious)
244 ,fROBPrevious(c.fROBPrevious)
f162af62 245 ,fNumberClusters(c.fNumberClusters)
bcb6fb78 246 ,fNumberClustersf(c.fNumberClustersf)
6aafa7ea 247 ,fNumberClustersProcent(c.fNumberClustersProcent)
248 ,fThresholdClustersDAQ(c.fThresholdClustersDAQ)
249 ,fNumberRowDAQ(c.fNumberRowDAQ)
1785640c 250 ,fNumberColDAQ(c.fNumberColDAQ)
f162af62 251 ,fProcent(c.fProcent)
252 ,fDifference(c.fDifference)
253 ,fNumberTrack(c.fNumberTrack)
254 ,fTimeMax(c.fTimeMax)
255 ,fSf(c.fSf)
256 ,fNumberBinCharge(c.fNumberBinCharge)
257 ,fNumberBinPRF(c.fNumberBinPRF)
258 ,fNgroupprf(c.fNgroupprf)
3a0f6479 259 ,fAmpTotal(0x0)
260 ,fPHPlace(0x0)
261 ,fPHValue(0x0)
f162af62 262 ,fGoodTracklet(c.fGoodTracklet)
1ca79a00 263 ,fLinearFitterTracklet(0x0)
3a0f6479 264 ,fEntriesCH(0x0)
265 ,fEntriesLinearFitter(0x0)
f162af62 266 ,fCalibraVector(0x0)
267 ,fPH2d(0x0)
268 ,fPRF2d(0x0)
269 ,fCH2d(0x0)
d0569428 270 ,fLinearFitterArray(540)
3a0f6479 271 ,fLinearVdriftFit(0x0)
d0569428 272 ,fCalDetGain(0x0)
273 ,fCalROCGain(0x0)
55a288e5 274{
275 //
276 // Copy constructor
277 //
170c35f1 278 if(c.fCalibraMode) fCalibraMode = new AliTRDCalibraMode(*c.fCalibraMode);
279 if(c.fCalibraVector) fCalibraVector = new AliTRDCalibraVector(*c.fCalibraVector);
280 if(c.fPH2d) {
281 fPH2d = new TProfile2D(*c.fPH2d);
282 fPH2d->SetDirectory(0);
283 }
284 if(c.fPRF2d) {
285 fPRF2d = new TProfile2D(*c.fPRF2d);
286 fPRF2d->SetDirectory(0);
287 }
288 if(c.fCH2d) {
289 fCH2d = new TH2I(*c.fCH2d);
290 fCH2d->SetDirectory(0);
291 }
3a0f6479 292 if(c.fLinearVdriftFit){
293 fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit(*c.fLinearVdriftFit);
170c35f1 294 }
3a0f6479 295
d0569428 296 if(c.fCalDetGain) fCalDetGain = new AliTRDCalDet(*c.fCalDetGain);
d0569428 297 if(c.fCalROCGain) fCalROCGain = new AliTRDCalROC(*c.fCalROCGain);
d0569428 298
f162af62 299 if (fGeo) {
300 delete fGeo;
301 }
302 fGeo = new AliTRDgeometry();
01239968 303 fCalibDB = AliTRDcalibDB::Instance();
fdc15553 304
305 fNumberUsedCh[0] = 0;
306 fNumberUsedCh[1] = 0;
307 fNumberUsedPh[0] = 0;
308 fNumberUsedPh[1] = 0;
309
55a288e5 310}
f162af62 311
55a288e5 312//____________________________________________________________________________________
313AliTRDCalibraFillHisto::~AliTRDCalibraFillHisto()
314{
315 //
316 // AliTRDCalibraFillHisto destructor
317 //
318
319 ClearHistos();
170c35f1 320 if ( fDebugStreamer ) delete fDebugStreamer;
f162af62 321
d0569428 322 if ( fCalDetGain ) delete fCalDetGain;
d0569428 323 if ( fCalROCGain ) delete fCalROCGain;
d0569428 324
1ca79a00 325 if( fLinearFitterTracklet ) { delete fLinearFitterTracklet; }
326
327 delete [] fPHPlace;
328 delete [] fPHValue;
329 delete [] fEntriesCH;
330 delete [] fEntriesLinearFitter;
331 delete [] fAmpTotal;
332
333 for(Int_t idet=0; idet<AliTRDgeometry::kNdet; idet++){
334 TLinearFitter *f = (TLinearFitter*)fLinearFitterArray.At(idet);
335 if(f) { delete f;}
336 }
46c4871e 337 if(fLinearVdriftFit) delete fLinearVdriftFit;
f162af62 338 if (fGeo) {
339 delete fGeo;
340 }
55a288e5 341
342}
55a288e5 343//_____________________________________________________________________________
344void AliTRDCalibraFillHisto::Destroy()
345{
346 //
347 // Delete instance
348 //
349
350 if (fgInstance) {
351 delete fgInstance;
352 fgInstance = 0x0;
353 }
55a288e5 354}
bcb6fb78 355//_____________________________________________________________________________
356void AliTRDCalibraFillHisto::DestroyDebugStreamer()
357{
358 //
359 // Delete DebugStreamer
360 //
55a288e5 361
bcb6fb78 362 if ( fDebugStreamer ) delete fDebugStreamer;
64942b85 363 fDebugStreamer = 0x0;
bcb6fb78 364
365}
55a288e5 366//_____________________________________________________________________________
367void AliTRDCalibraFillHisto::ClearHistos()
368{
369 //
370 // Delete the histos
371 //
372
373 if (fPH2d) {
374 delete fPH2d;
375 fPH2d = 0x0;
376 }
377 if (fCH2d) {
378 delete fCH2d;
379 fCH2d = 0x0;
380 }
381 if (fPRF2d) {
382 delete fPRF2d;
383 fPRF2d = 0x0;
384 }
3a0f6479 385
55a288e5 386}
bcb6fb78 387//////////////////////////////////////////////////////////////////////////////////
388// calibration with AliTRDtrackV1: Init, Update
389//////////////////////////////////////////////////////////////////////////////////
55a288e5 390//____________Functions for initialising the AliTRDCalibraFillHisto in the code_________
9ff7be6d 391Bool_t AliTRDCalibraFillHisto::Init2Dhistos(Int_t nboftimebin)
55a288e5 392{
393 //
bcb6fb78 394 // Init the histograms and stuff to be filled
d0569428 395 //
396
55a288e5 397 // DB Setting
398 // Get cal
399 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
400 if (!cal) {
401 AliInfo("Could not get calibDB");
402 return kFALSE;
403 }
404 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
405 if (!parCom) {
406 AliInfo("Could not get CommonParam");
407 return kFALSE;
408 }
409
410 // Some parameters
9ff7be6d 411 if(nboftimebin > 0) fTimeMax = nboftimebin;
c698a3d9 412 else fTimeMax = cal->GetNumberOfTimeBinsDCS();
5496295d 413 if(fTimeMax <= 0) fTimeMax = 30;
09ea3770 414 printf("////////////////////////////////////////////\n");
415 printf("Number of time bins in calibration component %d\n",fTimeMax);
416 printf("////////////////////////////////////////////\n");
d95484e4 417 fSf = parCom->GetSamplingFrequency();
64942b85 418 if(!fNormalizeNbOfCluster) fRelativeScale = 20.0;
419 else fRelativeScale = 1.18;
d95484e4 420 fNumberClustersf = fTimeMax;
6aafa7ea 421 fNumberClusters = (Int_t)(fNumberClustersProcent*fTimeMax);
d0569428 422
1ca79a00 423 // Init linear fitter
424 if(!fLinearFitterTracklet) {
425 fLinearFitterTracklet = new TLinearFitter(2,"pol1");
64942b85 426 fLinearFitterTracklet->StoreData(kTRUE);
1ca79a00 427 }
170c35f1 428
3a0f6479 429 // Calcul Xbins Chambd0, Chamb2
0c349049 430 Int_t ntotal0 = CalculateTotalNumberOfBins(0);
431 Int_t ntotal1 = CalculateTotalNumberOfBins(1);
432 Int_t ntotal2 = CalculateTotalNumberOfBins(2);
3a0f6479 433
434 // If vector method On initialised all the stuff
435 if(fVector2d){
55a288e5 436 fCalibraVector = new AliTRDCalibraVector();
170c35f1 437 fCalibraVector->SetNumberBinCharge(fNumberBinCharge);
438 fCalibraVector->SetTimeMax(fTimeMax);
439 if(fNgroupprf != 0) {
440 fCalibraVector->SetNumberBinPRF(2*fNgroupprf*fNumberBinPRF);
441 fCalibraVector->SetPRFRange((Float_t)(3.0*fNgroupprf));
442 }
443 else {
444 fCalibraVector->SetNumberBinPRF(fNumberBinPRF);
445 fCalibraVector->SetPRFRange(1.5);
446 }
3a0f6479 447 for(Int_t k = 0; k < 3; k++){
448 fCalibraVector->SetDetCha0(k,fCalibraMode->GetDetChamb0(k));
449 fCalibraVector->SetDetCha2(k,fCalibraMode->GetDetChamb2(k));
450 }
e526983e 451 fCalibraVector->SetNzNrphi(0,fCalibraMode->GetNz(0),fCalibraMode->GetNrphi(0));
452 fCalibraVector->SetNzNrphi(1,fCalibraMode->GetNz(1),fCalibraMode->GetNrphi(1));
453 fCalibraVector->SetNzNrphi(2,fCalibraMode->GetNz(2),fCalibraMode->GetNrphi(2));
454 fCalibraVector->SetNbGroupPRF(fNgroupprf);
55a288e5 455 }
170c35f1 456
55a288e5 457 // Create the 2D histos corresponding to the pad groupCalibration mode
458 if (fCH2dOn) {
459
460 AliInfo(Form("The pad calibration mode for the relative gain calibration: Nz %d, and Nrphi %d"
461 ,fCalibraMode->GetNz(0)
462 ,fCalibraMode->GetNrphi(0)));
463
55a288e5 464 // Create the 2D histo
465 if (fHisto2d) {
0c349049 466 CreateCH2d(ntotal0);
55a288e5 467 }
55a288e5 468 // Variable
469 fAmpTotal = new Float_t[TMath::Max(fCalibraMode->GetDetChamb2(0),fCalibraMode->GetDetChamb0(0))];
470 for (Int_t k = 0; k < TMath::Max(fCalibraMode->GetDetChamb2(0),fCalibraMode->GetDetChamb0(0)); k++) {
471 fAmpTotal[k] = 0.0;
472 }
170c35f1 473 //Statistics
0c349049 474 fEntriesCH = new Int_t[ntotal0];
475 for(Int_t k = 0; k < ntotal0; k++){
170c35f1 476 fEntriesCH[k] = 0;
477 }
3a0f6479 478
55a288e5 479 }
55a288e5 480 if (fPH2dOn) {
481
482 AliInfo(Form("The pad calibration mode for the drift velocity calibration: Nz %d, and Nrphi %d"
483 ,fCalibraMode->GetNz(1)
484 ,fCalibraMode->GetNrphi(1)));
485
55a288e5 486 // Create the 2D histo
487 if (fHisto2d) {
0c349049 488 CreatePH2d(ntotal1);
55a288e5 489 }
55a288e5 490 // Variable
491 fPHPlace = new Short_t[fTimeMax];
492 for (Int_t k = 0; k < fTimeMax; k++) {
493 fPHPlace[k] = -1;
494 }
495 fPHValue = new Float_t[fTimeMax];
496 for (Int_t k = 0; k < fTimeMax; k++) {
497 fPHValue[k] = 0.0;
498 }
170c35f1 499 }
500 if (fLinearFitterOn) {
46c4871e 501 if(fLinearFitterDebugOn) {
502 fLinearFitterArray.SetName("ArrayLinearFitters");
503 fEntriesLinearFitter = new Int_t[540];
504 for(Int_t k = 0; k < 540; k++){
505 fEntriesLinearFitter[k] = 0;
506 }
170c35f1 507 }
3a0f6479 508 fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit();
55a288e5 509 }
510
511 if (fPRF2dOn) {
512
513 AliInfo(Form("The pad calibration mode for the PRF calibration: Nz %d, and Nrphi %d"
514 ,fCalibraMode->GetNz(2)
515 ,fCalibraMode->GetNrphi(2)));
55a288e5 516 // Create the 2D histo
517 if (fHisto2d) {
0c349049 518 CreatePRF2d(ntotal2);
55a288e5 519 }
55a288e5 520 }
521
522 return kTRUE;
523
a2a4ec8e 524}
525///////////////////////////////////////////////////////////////////////////////////////////////////////////////
526Bool_t AliTRDCalibraFillHisto::InitCalDet()
527{
528 //
529 // Init the Gain Cal Det
530 //
531
532 // DB Setting
533 // Get cal
d085ba91 534 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberGainFactor",fFirstRunGain,fVersionGainUsed,fSubVersionGainUsed);
3b0c1edc 535 if(!entry) {
536 AliError("No gain det calibration entry found");
537 return kFALSE;
538 }
539 AliTRDCalDet *calDet = (AliTRDCalDet *)entry->GetObject();
540 if(!calDet) {
541 AliError("No calDet gain found");
a2a4ec8e 542 return kFALSE;
a2a4ec8e 543 }
3b0c1edc 544
545
546 if( fCalDetGain ){
547 fCalDetGain->~AliTRDCalDet();
548 new(fCalDetGain) AliTRDCalDet(*(calDet));
549 }else fCalDetGain = new AliTRDCalDet(*(calDet));
550
a2a4ec8e 551
552 // title CH2d
553 TString name("Ver");
554 name += fVersionGainUsed;
555 name += "Subver";
556 name += fSubVersionGainUsed;
557 name += "Nz";
558 name += fCalibraMode->GetNz(0);
559 name += "Nrphi";
560 name += fCalibraMode->GetNrphi(0);
561
562 fCH2d->SetTitle(name);
563
564 // title PH2d
565 TString namee("Ver");
566 namee += fVersionVdriftUsed;
567 namee += "Subver";
568 namee += fSubVersionVdriftUsed;
569 namee += "Nz";
570 namee += fCalibraMode->GetNz(1);
571 namee += "Nrphi";
572 namee += fCalibraMode->GetNrphi(1);
573
574 fPH2d->SetTitle(namee);
575
576
577 return kTRUE;
578
579}
580///////////////////////////////////////////////////////////////////////////////////////////////////////////////
581Bool_t AliTRDCalibraFillHisto::InitCalPad(Int_t detector)
582{
583 //
584 // Init the Gain Cal Pad
585 //
586
587 // DB Setting
588 // Get cal
589 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/LocalGainFactor",AliCDBManager::Instance()->GetRun(),fVersionGainLocalUsed,fSubVersionGainLocalUsed);
3b0c1edc 590 if(!entry) {
591 AliError("No gain pad calibration entry found");
592 return kFALSE;
593 }
594 AliTRDCalPad *calPad = (AliTRDCalPad *)entry->GetObject();
595 if(!calPad) {
596 AliError("No calPad gain found");
597 return kFALSE;
598 }
599 AliTRDCalROC *calRoc = (AliTRDCalROC *)calPad->GetCalROC(detector);
600 if(!calRoc) {
601 AliError("No calRoc gain found");
602 return kFALSE;
603 }
a2a4ec8e 604
3b0c1edc 605 if( fCalROCGain ){
606 fCalROCGain->~AliTRDCalROC();
607 new(fCalROCGain) AliTRDCalROC(*(calRoc));
608 }else fCalROCGain = new AliTRDCalROC(*(calRoc));
a2a4ec8e 609
610
a2a4ec8e 611
3b0c1edc 612
a2a4ec8e 613
614 return kTRUE;
615
170c35f1 616}
55a288e5 617//____________Offline tracking in the AliTRDtracker____________________________
6bbdc11a 618Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
55a288e5 619{
620 //
bcb6fb78 621 // Use AliTRDtrackV1 for the calibration
55a288e5 622 //
623
bcb6fb78 624
625 const AliTRDseedV1 *tracklet = 0x0; // tracklet per plane
4aad967c 626 AliTRDcluster *cl = 0x0; // cluster attached now to the tracklet
1785640c 627 AliTRDcluster *cls = 0x0; // shared cluster attached now to the tracklet
4aad967c 628 Bool_t newtr = kTRUE; // new track
bcb6fb78 629
1ca79a00 630 // Get cal
01239968 631 // AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
632 /*
1ca79a00 633 if (!cal) {
634 AliInfo("Could not get calibDB");
635 return kFALSE;
636 }
01239968 637*/
638 if (!fCalibDB) {
639 AliInfo("Could not get calibDB");
640 return kFALSE;
641 }
642
bcb6fb78 643
644 ///////////////////////////
645 // loop over the tracklet
646 ///////////////////////////
647 for(Int_t itr = 0; itr < 6; itr++){
55a288e5 648
bcb6fb78 649 if(!(tracklet = t->GetTracklet(itr))) continue;
650 if(!tracklet->IsOK()) continue;
651 fNumberTrack++;
652 ResetfVariablestracklet();
653
654 //////////////////////////////////////////
655 // localisation of the tracklet and dqdl
656 //////////////////////////////////////////
053767a4 657 Int_t layer = tracklet->GetPlane();
bcb6fb78 658 Int_t ic = 0;
659 while(!(cl = tracklet->GetClusters(ic++))) continue;
660 Int_t detector = cl->GetDetector();
661 if (detector != fDetectorPreviousTrack) {
4aad967c 662 // if not a new track
663 if(!newtr){
664 // don't use the rest of this track if in the same plane
665 if (layer == GetLayer(fDetectorPreviousTrack)) {
666 //printf("bad tracklet, same layer for detector %d\n",detector);
667 break;
668 }
bcb6fb78 669 }
670 //Localise the detector bin
671 LocalisationDetectorXbins(detector);
bcb6fb78 672 // Get calib objects
a2a4ec8e 673 if(!fIsHLT) InitCalPad(detector);
674
bcb6fb78 675 // reset
676 fDetectorPreviousTrack = detector;
55a288e5 677 }
4aad967c 678 newtr = kFALSE;
55a288e5 679
bcb6fb78 680 ////////////////////////////
681 // loop over the clusters
682 ////////////////////////////
683 Int_t nbclusters = 0;
e3cf3d02 684 for(int jc=0; jc<AliTRDseedV1::kNtb; jc++){
7bce990c 685 if(!(cl = tracklet->GetClusters(jc))) continue;
bcb6fb78 686 nbclusters++;
687
688 // Store the info bis of the tracklet
689 Int_t row = cl->GetPadRow();
690 Int_t col = cl->GetPadCol();
d95484e4 691 CheckGoodTrackletV1(cl);
bcb6fb78 692 Int_t group[2] = {0,0};
693 if(fCH2dOn) group[0] = CalculateCalibrationGroup(0,row,col);
694 if(fPH2dOn) group[1] = CalculateCalibrationGroup(1,row,col);
1785640c 695 // Add the charge if shared cluster
696 cls = tracklet->GetClusters(jc+AliTRDseedV1::kNtb);
697 //
698 StoreInfoCHPHtrack(cl, tracklet->GetdQdl(jc),group,row,col,cls);
bcb6fb78 699 }
700
701 ////////////////////////////////////////
702 // Fill the stuffs if a good tracklet
703 ////////////////////////////////////////
704 if (fGoodTracklet) {
e526983e 705
bcb6fb78 706 // drift velocity unables to cut bad tracklets
707 Bool_t pass = FindP1TrackPHtrackletV1(tracklet, nbclusters);
708
e526983e 709 //printf("pass %d and nbclusters %d\n",pass,nbclusters);
710
55a288e5 711 // Gain calibration
712 if (fCH2dOn) {
bcb6fb78 713 FillTheInfoOfTheTrackCH(nbclusters);
55a288e5 714 }
bcb6fb78 715
55a288e5 716 // PH calibration
717 if (fPH2dOn) {
718 FillTheInfoOfTheTrackPH();
719 }
bcb6fb78 720
721 if(pass && fPRF2dOn) HandlePRFtrackletV1(tracklet,nbclusters);
722
723 } // if a good tracklet
bcb6fb78 724 }
4aad967c 725
55a288e5 726 return kTRUE;
727
728}
bcb6fb78 729///////////////////////////////////////////////////////////////////////////////////
730// Routine inside the update with AliTRDtrack
731///////////////////////////////////////////////////////////////////////////////////
732//____________Offine tracking in the AliTRDtracker_____________________________
bcb6fb78 733Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters)
170c35f1 734{
735 //
bcb6fb78 736 // Drift velocity calibration:
737 // Fit the clusters with a straight line
738 // From the slope find the drift velocity
170c35f1 739 //
740
bcb6fb78 741 ////////////////////////////////////////////////
742 //Number of points: if less than 3 return kFALSE
743 /////////////////////////////////////////////////
744 if(nbclusters <= 2) return kFALSE;
170c35f1 745
bcb6fb78 746 ////////////
747 //Variables
748 ////////////
bcb6fb78 749 // results of the linear fit
750 Double_t dydt = 0.0; // dydt tracklet after straight line fit
751 Double_t errorpar = 0.0; // error after straight line fit on dy/dt
752 Double_t pointError = 0.0; // error after straight line fit
753 // pad row problemes: avoid tracklet that cross pad rows, tilting angle in the constant
754 Int_t crossrow = 0; // if it crosses a pad row
755 Int_t rowp = -1; // if it crosses a pad row
756 Float_t tnt = tracklet->GetTilt(); // tan tiltingangle
1ca79a00 757 fLinearFitterTracklet->ClearPoints();
758
170c35f1 759
bcb6fb78 760 ///////////////////////////////////////////
761 // Take the parameters of the track
762 //////////////////////////////////////////
763 // take now the snp, tnp and tgl from the track
764 Double_t snp = tracklet->GetSnp(); // sin dy/dx at the end of the chamber
765 Double_t tnp = 0.0; // dy/dx at the end of the chamber
766 if( TMath::Abs(snp) < 1.){
60e55aee 767 tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp));
bcb6fb78 768 }
769 Double_t tgl = tracklet->GetTgl(); // dz/dl
770 Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl
771 // at the entrance
772 //Double_t tnp = tracklet->GetYref(1); // dy/dx at the entrance of the chamber
773 //Double_t tgl = tracklet->GetZref(1); // dz/dl at the entrance of the chamber
774 //Double_t dzdx = tgl; //*TMath::Sqrt(1+tnp*tnp); // dz/dx from dz/dl
775 // at the end with correction due to linear fit
776 //Double_t tnp = tracklet->GetYfit(1); // dy/dx at the end of the chamber after fit correction
777 //Double_t tgl = tracklet->GetZfit(1); // dz/dl at the end of the chamber after fit correction
778
779
780 ////////////////////////////
781 // loop over the clusters
782 ////////////////////////////
783 Int_t nbli = 0;
784 AliTRDcluster *cl = 0x0;
6aafa7ea 785 //////////////////////////////
786 // Check no shared clusters
787 //////////////////////////////
788 for(int icc=AliTRDseedV1::kNtb; icc<AliTRDseedV1::kNclusters; icc++){
3b0c1edc 789 cl = tracklet->GetClusters(icc);
790 if(cl) crossrow = 1;
6aafa7ea 791 }
792 //////////////////////////////////
793 // Loop clusters
794 //////////////////////////////////
e3cf3d02 795 for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
bcb6fb78 796 if(!(cl = tracklet->GetClusters(ic))) continue;
b70c68da 797 if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
bcb6fb78 798
799 Double_t ycluster = cl->GetY();
800 Int_t time = cl->GetPadTime();
801 Double_t timeis = time/fSf;
802 //See if cross two pad rows
803 Int_t row = cl->GetPadRow();
804 if(rowp==-1) rowp = row;
805 if(row != rowp) crossrow = 1;
806
1ca79a00 807 fLinearFitterTracklet->AddPoint(&timeis,ycluster,1);
bcb6fb78 808 nbli++;
170c35f1 809
1785640c 810
55a288e5 811 }
812
bcb6fb78 813 ////////////////////////////////////
814 // Do the straight line fit now
815 ///////////////////////////////////
1ca79a00 816 if(nbli <= 2){
817 fLinearFitterTracklet->ClearPoints();
818 return kFALSE;
819 }
bcb6fb78 820 TVectorD pars;
1ca79a00 821 fLinearFitterTracklet->Eval();
822 fLinearFitterTracklet->GetParameters(pars);
823 pointError = TMath::Sqrt(fLinearFitterTracklet->GetChisquare()/(nbli-2));
824 errorpar = fLinearFitterTracklet->GetParError(1)*pointError;
bcb6fb78 825 dydt = pars[1];
64942b85 826 //printf("chis %f, nbli %d, pointError %f, parError %f, errorpar %f\n",fLinearFitterTracklet->GetChisquare(),nbli,pointError,fLinearFitterTracklet->GetParError(1),errorpar);
1ca79a00 827 fLinearFitterTracklet->ClearPoints();
170c35f1 828
bcb6fb78 829 ////////////////////////////////
830 // Debug stuff
831 ///////////////////////////////
832
833
834 if(fDebugLevel > 0){
835 if ( !fDebugStreamer ) {
836 //debug stream
837 TDirectory *backup = gDirectory;
838 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
839 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
840 }
841
842
053767a4 843 Int_t layer = GetLayer(fDetectorPreviousTrack);
64942b85 844
bcb6fb78 845 (* fDebugStreamer) << "FindP1TrackPHtrackletV1"<<
846 //"snpright="<<snpright<<
64942b85 847 "nbli="<<nbli<<
bcb6fb78 848 "nbclusters="<<nbclusters<<
849 "detector="<<fDetectorPreviousTrack<<
053767a4 850 "layer="<<layer<<
bcb6fb78 851 "snp="<<snp<<
852 "tnp="<<tnp<<
853 "tgl="<<tgl<<
854 "tnt="<<tnt<<
855 "dydt="<<dydt<<
856 "dzdx="<<dzdx<<
857 "crossrow="<<crossrow<<
858 "errorpar="<<errorpar<<
859 "pointError="<<pointError<<
860 "\n";
861
170c35f1 862 }
863
bcb6fb78 864 /////////////////////////
865 // Cuts quality
866 ////////////////////////
c1105918 867
bcb6fb78 868 if(nbclusters < fNumberClusters) return kFALSE;
869 if(nbclusters > fNumberClustersf) return kFALSE;
64942b85 870 if(pointError >= 0.3) return kFALSE;
c1105918 871 if(crossrow == 1) return kTRUE;
170c35f1 872
bcb6fb78 873 ///////////////////////
874 // Fill
875 //////////////////////
170c35f1 876
bcb6fb78 877 if(fLinearFitterOn){
878 //Add to the linear fitter of the detector
879 if( TMath::Abs(snp) < 1.){
880 Double_t x = tnp-dzdx*tnt;
bcb6fb78 881 if(fLinearFitterDebugOn) {
46c4871e 882 (GetLinearFitter(fDetectorPreviousTrack,kTRUE))->AddPoint(&x,dydt);
883 fEntriesLinearFitter[fDetectorPreviousTrack]++;
bcb6fb78 884 }
46c4871e 885 fLinearVdriftFit->Update(fDetectorPreviousTrack,x,pars[1]);
bcb6fb78 886 }
170c35f1 887 }
888
889 return kTRUE;
170c35f1 890}
bcb6fb78 891//____________Offine tracking in the AliTRDtracker_____________________________
bcb6fb78 892Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters)
893{
894 //
895 // PRF width calibration
896 // Assume a Gaussian shape: determinate the position of the three pad clusters
897 // Fit with a straight line
898 // Take the fitted values for all the clusters (3 or 2 pad clusters)
899 // Fill the PRF as function of angle of the track
900 //
901 //
902
4aad967c 903 //printf("begin\n");
bcb6fb78 904 ///////////////////////////////////////////
905 // Take the parameters of the track
906 //////////////////////////////////////////
907 // take now the snp, tnp and tgl from the track
908 Double_t snp = tracklet->GetSnp(); // sin dy/dx at the end of the chamber
909 Double_t tnp = 0.0; // dy/dx at the end of the chamber
910 if( TMath::Abs(snp) < 1.){
60e55aee 911 tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp));
bcb6fb78 912 }
913 Double_t tgl = tracklet->GetTgl(); // dz/dl
914 Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl
915 // at the entrance
916 //Double_t tnp = tracklet->GetYref(1); // dy/dx at the entrance of the chamber
917 //Double_t tgl = tracklet->GetZref(1); // dz/dl at the entrance of the chamber
918 //Double_t dzdx = tgl; //*TMath::Sqrt(1+tnp*tnp); // dz/dx from dz/dl
919 // at the end with correction due to linear fit
920 //Double_t tnp = tracklet->GetYfit(1); // dy/dx at the end of the chamber after fit correction
921 //Double_t tgl = tracklet->GetZfit(1); // dz/dl at the end of the chamber after fit correction
922
923 ///////////////////////////////
924 // Calculate tnp group shift
925 ///////////////////////////////
926 Bool_t echec = kFALSE;
927 Double_t shift = 0.0;
928 //Calculate the shift in x coresponding to this tnp
929 if(fNgroupprf != 0.0){
930 shift = -3.0*(fNgroupprf-1)-1.5;
931 Double_t limithigh = -0.2*(fNgroupprf-1);
932 if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
933 else{
934 while(tnp > limithigh){
935 limithigh += 0.2;
936 shift += 3.0;
170c35f1 937 }
938 }
170c35f1 939 }
bcb6fb78 940 // do nothing if out of tnp range
4aad967c 941 //printf("echec %d\n",(Int_t)echec);
bcb6fb78 942 if(echec) return kFALSE;
3a0f6479 943
bcb6fb78 944 ///////////////////////
945 // Variables
946 //////////////////////
3a0f6479 947
bcb6fb78 948 Int_t nb3pc = 0; // number of three pads clusters used for fit
e3cf3d02 949 // to see the difference between the fit and the 3 pad clusters position
950 Double_t padPositions[AliTRDseedV1::kNtb];
951 memset(padPositions, 0, AliTRDseedV1::kNtb*sizeof(Double_t));
1ca79a00 952 fLinearFitterTracklet->ClearPoints();
953
4aad967c 954 //printf("loop clusters \n");
bcb6fb78 955 ////////////////////////////
956 // loop over the clusters
957 ////////////////////////////
958 AliTRDcluster *cl = 0x0;
e3cf3d02 959 for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
6cb3ebda 960 // reject shared clusters on pad row
e526983e 961 if((ic+AliTRDseedV1::kNtb) < AliTRDseedV1::kNclusters) {
35a82746 962 cl = tracklet->GetClusters(ic+AliTRDseedV1::kNtb);
963 if(cl) continue;
e526983e 964 }
35a82746 965 cl = tracklet->GetClusters(ic);
966 if(!cl) continue;
e526983e 967 Double_t time = cl->GetPadTime();
bcb6fb78 968 if((time<=7) || (time>=21)) continue;
969 Short_t *signals = cl->GetSignals();
970 Float_t xcenter = 0.0;
7bce990c 971 Bool_t echec1 = kTRUE;
e4db522f 972
bcb6fb78 973 /////////////////////////////////////////////////////////////
974 // Center 3 balanced: position with the center of the pad
975 /////////////////////////////////////////////////////////////
976 if ((((Float_t) signals[3]) > 0.0) &&
977 (((Float_t) signals[2]) > 0.0) &&
978 (((Float_t) signals[4]) > 0.0)) {
7bce990c 979 echec1 = kFALSE;
bcb6fb78 980 // Security if the denomiateur is 0
981 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
982 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
983 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
984 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
985 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
3a0f6479 986 }
bcb6fb78 987 else {
7bce990c 988 echec1 = kTRUE;
bcb6fb78 989 }
990 }
7bce990c 991 if(TMath::Abs(xcenter) > 0.5) echec1 = kTRUE;
992 if(echec1) continue;
e4db522f 993
bcb6fb78 994 ////////////////////////////////////////////////////////
7bce990c 995 //if no echec1: calculate with the position of the pad
bcb6fb78 996 // Position of the cluster
997 // fill the linear fitter
998 ///////////////////////////////////////////////////////
999 Double_t padPosition = xcenter + cl->GetPadCol();
1000 padPositions[ic] = padPosition;
1001 nb3pc++;
1ca79a00 1002 fLinearFitterTracklet->AddPoint(&time, padPosition,1);
e4db522f 1003
e4db522f 1004
bcb6fb78 1005 }//clusters loop
1006
4aad967c 1007 //printf("Fin loop clusters \n");
bcb6fb78 1008 //////////////////////////////
1009 // fit with a straight line
1010 /////////////////////////////
1ca79a00 1011 if(nb3pc < 3){
1ca79a00 1012 fLinearFitterTracklet->ClearPoints();
1ca79a00 1013 return kFALSE;
1014 }
1015 fLinearFitterTracklet->Eval();
bcb6fb78 1016 TVectorD line(2);
1ca79a00 1017 fLinearFitterTracklet->GetParameters(line);
bcb6fb78 1018 Float_t pointError = -1.0;
1ca79a00 1019 if( fLinearFitterTracklet->GetChisquare()>=0.0) {
1020 pointError = TMath::Sqrt( fLinearFitterTracklet->GetChisquare()/(nb3pc-2));
4aad967c 1021 }
1ca79a00 1022 fLinearFitterTracklet->ClearPoints();
1023
4aad967c 1024 //printf("PRF second loop \n");
bcb6fb78 1025 ////////////////////////////////////////////////
1026 // Fill the PRF: Second loop over clusters
1027 //////////////////////////////////////////////
e3cf3d02 1028 for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
6cb3ebda 1029 // reject shared clusters on pad row
3b0c1edc 1030 cl = tracklet->GetClusters(ic+AliTRDseedV1::kNtb);
1031 if(((ic+AliTRDseedV1::kNtb) < AliTRDseedV1::kNclusters) && (cl)) continue;
6cb3ebda 1032 //
3b0c1edc 1033 cl = tracklet->GetClusters(ic);
1034 if(!cl) continue;
162a3e73 1035
bcb6fb78 1036 Short_t *signals = cl->GetSignals(); // signal
e526983e 1037 Double_t time = cl->GetPadTime(); // time bin
bcb6fb78 1038 Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit
1039 Float_t padPos = cl->GetPadCol(); // middle pad
1040 Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit
1041 Float_t ycenter = 0.0; // relative center charge
1042 Float_t ymin = 0.0; // relative left charge
1043 Float_t ymax = 0.0; // relative right charge
162a3e73 1044
bcb6fb78 1045 ////////////////////////////////////////////////////////////////
1046 // Calculate ycenter, ymin and ymax even for two pad clusters
1047 ////////////////////////////////////////////////////////////////
1048 if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
1049 ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
1050 Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
1051 if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
1052 if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
1053 if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
3a0f6479 1054 }
1055
bcb6fb78 1056 /////////////////////////
1057 // Calibration group
1058 ////////////////////////
1059 Int_t rowcl = cl->GetPadRow(); // row of cluster
1060 Int_t colcl = cl->GetPadCol(); // col of cluster
1061 Int_t grouplocal = CalculateCalibrationGroup(2,rowcl,colcl); // calcul the corresponding group
1062 Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group
1063 Float_t xcl = cl->GetY(); // y cluster
1064 Float_t qcl = cl->GetQ(); // charge cluster
053767a4 1065 Int_t layer = GetLayer(fDetectorPreviousTrack); // layer
1066 Int_t stack = GetStack(fDetectorPreviousTrack); // stack
bcb6fb78 1067 Double_t xdiff = dpad; // reconstructed position constant
1068 Double_t x = dpad; // reconstructed position moved
1069 Float_t ep = pointError; // error of fit
1070 Float_t signal1 = (Float_t)signals[1]; // signal at the border
1071 Float_t signal3 = (Float_t)signals[3]; // signal
1072 Float_t signal2 = (Float_t)signals[2]; // signal
1073 Float_t signal4 = (Float_t)signals[4]; // signal
1074 Float_t signal5 = (Float_t)signals[5]; // signal at the border
1075
1ca79a00 1076
1077
bcb6fb78 1078 /////////////////////
1079 // Debug stuff
1080 ////////////////////
1081
1082 if(fDebugLevel > 0){
1083 if ( !fDebugStreamer ) {
1084 //debug stream
1085 TDirectory *backup = gDirectory;
1086 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
1087 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
1088 }
1089
1090 x = xdiff;
1091 Int_t type=0;
1092 Float_t y = ycenter;
1093 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1094 "caligroup="<<caligroup<<
1095 "detector="<<fDetectorPreviousTrack<<
053767a4 1096 "layer="<<layer<<
1097 "stack="<<stack<<
bcb6fb78 1098 "npoints="<<nbclusters<<
1099 "Np="<<nb3pc<<
1100 "ep="<<ep<<
1101 "type="<<type<<
1102 "snp="<<snp<<
1103 "tnp="<<tnp<<
1104 "tgl="<<tgl<<
1105 "dzdx="<<dzdx<<
1106 "padPos="<<padPos<<
1107 "padPosition="<<padPositions[ic]<<
1108 "padPosTracklet="<<padPosTracklet<<
1109 "x="<<x<<
1110 "y="<<y<<
1111 "xcl="<<xcl<<
1112 "qcl="<<qcl<<
1113 "signal1="<<signal1<<
1114 "signal2="<<signal2<<
1115 "signal3="<<signal3<<
1116 "signal4="<<signal4<<
1117 "signal5="<<signal5<<
1118 "time="<<time<<
1119 "\n";
1120 x=-(xdiff+1);
1121 y = ymin;
1122 type=-1;
1123 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1124 "caligroup="<<caligroup<<
1125 "detector="<<fDetectorPreviousTrack<<
053767a4 1126 "layer="<<layer<<
1127 "stack="<<stack<<
bcb6fb78 1128 "npoints="<<nbclusters<<
1129 "Np="<<nb3pc<<
1130 "ep="<<ep<<
1131 "type="<<type<<
1132 "snp="<<snp<<
1133 "tnp="<<tnp<<
1134 "tgl="<<tgl<<
1135 "dzdx="<<dzdx<<
1136 "padPos="<<padPos<<
1137 "padPosition="<<padPositions[ic]<<
1138 "padPosTracklet="<<padPosTracklet<<
1139 "x="<<x<<
1140 "y="<<y<<
1141 "xcl="<<xcl<<
1142 "qcl="<<qcl<<
1143 "signal1="<<signal1<<
1144 "signal2="<<signal2<<
1145 "signal3="<<signal3<<
1146 "signal4="<<signal4<<
1147 "signal5="<<signal5<<
1148 "time="<<time<<
1149 "\n";
1150 x=1-xdiff;
1151 y = ymax;
1152 type=1;
1153 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1154 "caligroup="<<caligroup<<
1155 "detector="<<fDetectorPreviousTrack<<
053767a4 1156 "layer="<<layer<<
1157 "stack="<<stack<<
bcb6fb78 1158 "npoints="<<nbclusters<<
1159 "Np="<<nb3pc<<
1160 "ep="<<ep<<
1161 "type="<<type<<
1162 "snp="<<snp<<
1163 "tnp="<<tnp<<
1164 "tgl="<<tgl<<
1165 "dzdx="<<dzdx<<
1166 "padPos="<<padPos<<
1167 "padPosition="<<padPositions[ic]<<
1168 "padPosTracklet="<<padPosTracklet<<
1169 "x="<<x<<
1170 "y="<<y<<
1171 "xcl="<<xcl<<
1172 "qcl="<<qcl<<
1173 "signal1="<<signal1<<
1174 "signal2="<<signal2<<
1175 "signal3="<<signal3<<
1176 "signal4="<<signal4<<
1177 "signal5="<<signal5<<
1178 "time="<<time<<
1179 "\n";
e4db522f 1180
bcb6fb78 1181 }
1182
1183 /////////////////////
1184 // Cuts quality
1185 /////////////////////
1186 if(nbclusters < fNumberClusters) continue;
1187 if(nbclusters > fNumberClustersf) continue;
1188 if(nb3pc <= 5) continue;
1189 if((time >= 21) || (time < 7)) continue;
1190 if(TMath::Abs(qcl) < 80) continue;
1191 if( TMath::Abs(snp) > 1.) continue;
1192
1193
1194 ////////////////////////
1195 // Fill the histos
1196 ///////////////////////
1197 if (fHisto2d) {
1198 if(TMath::Abs(dpad) < 1.5) {
1199 fPRF2d->Fill(shift+dpad,(caligroup+0.5),ycenter);
1200 fPRF2d->Fill(shift-dpad,(caligroup+0.5),ycenter);
1201 //printf("place %f, ycenter %f\n",(shift+dpad),ycenter);
e4db522f 1202 }
bcb6fb78 1203 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1204 fPRF2d->Fill(shift-(dpad+1.0),(caligroup+0.5),ymin);
1205 fPRF2d->Fill(shift+(dpad+1.0),(caligroup+0.5),ymin);
e4db522f 1206 }
bcb6fb78 1207 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1208 fPRF2d->Fill(shift+1.0-dpad,(caligroup+0.5),ymax);
1209 fPRF2d->Fill(shift-1.0+dpad,(caligroup+0.5),ymax);
e4db522f 1210 }
bcb6fb78 1211 }
1212 // vector method
1213 if (fVector2d) {
1214 if(TMath::Abs(dpad) < 1.5) {
1215 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+dpad,ycenter);
1216 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-dpad,ycenter);
1217 }
1218 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1219 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-(dpad+1.0),ymin);
1220 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+(dpad+1.0),ymin);
1221 }
1222 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1223 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+1.0-dpad,ymax);
1224 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-1.0+dpad,ymax);
170c35f1 1225 }
3a0f6479 1226 }
bcb6fb78 1227 } // second loop over clusters
1228
1229
1230 return kTRUE;
170c35f1 1231}
bcb6fb78 1232///////////////////////////////////////////////////////////////////////////////////////
1233// Pad row col stuff: see if masked or not
1234///////////////////////////////////////////////////////////////////////////////////////
1235//_____________________________________________________________________________
6bbdc11a 1236void AliTRDCalibraFillHisto::CheckGoodTrackletV1(const AliTRDcluster *cl)
d95484e4 1237{
1238 //
1239 // See if we are not near a masked pad
1240 //
1241
1242 if(cl->IsMasked()) fGoodTracklet = kFALSE;
1243
1244
1245}
1246//_____________________________________________________________________________
6bbdc11a 1247void AliTRDCalibraFillHisto::CheckGoodTrackletV0(const Int_t detector,const Int_t row,const Int_t col)
170c35f1 1248{
1249 //
bcb6fb78 1250 // See if we are not near a masked pad
170c35f1 1251 //
1252
bcb6fb78 1253 if (!IsPadOn(detector, col, row)) {
1254 fGoodTracklet = kFALSE;
1255 }
170c35f1 1256
bcb6fb78 1257 if (col > 0) {
1258 if (!IsPadOn(detector, col-1, row)) {
1259 fGoodTracklet = kFALSE;
1260 }
1261 }
170c35f1 1262
bcb6fb78 1263 if (col < 143) {
1264 if (!IsPadOn(detector, col+1, row)) {
1265 fGoodTracklet = kFALSE;
1266 }
1267 }
1268
170c35f1 1269}
bcb6fb78 1270//_____________________________________________________________________________
1271Bool_t AliTRDCalibraFillHisto::IsPadOn(Int_t detector, Int_t row, Int_t col) const
170c35f1 1272{
1273 //
bcb6fb78 1274 // Look in the choosen database if the pad is On.
1275 // If no the track will be "not good"
170c35f1 1276 //
170c35f1 1277
bcb6fb78 1278 // Get the parameter object
1279 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
1280 if (!cal) {
1281 AliInfo("Could not get calibDB");
1282 return kFALSE;
1283 }
1284
1285 if (!cal->IsChamberInstalled(detector) ||
1286 cal->IsChamberMasked(detector) ||
1287 cal->IsPadMasked(detector,col,row)) {
1288 return kFALSE;
1289 }
1290 else {
1291 return kTRUE;
1292 }
1293
170c35f1 1294}
bcb6fb78 1295///////////////////////////////////////////////////////////////////////////////////////
1296// Calibration groups: calculate the number of groups, localise...
1297////////////////////////////////////////////////////////////////////////////////////////
1298//_____________________________________________________________________________
1299Int_t AliTRDCalibraFillHisto::CalculateCalibrationGroup(Int_t i, Int_t row, Int_t col) const
170c35f1 1300{
1301 //
bcb6fb78 1302 // Calculate the calibration group number for i
170c35f1 1303 //
170c35f1 1304
bcb6fb78 1305 // Row of the cluster and position in the pad groups
1306 Int_t posr = 0;
1307 if (fCalibraMode->GetNnZ(i) != 0) {
1308 posr = (Int_t) row / fCalibraMode->GetNnZ(i);
1309 }
1310
1311
1312 // Col of the cluster and position in the pad groups
1313 Int_t posc = 0;
1314 if (fCalibraMode->GetNnRphi(i) != 0) {
1315 posc = (Int_t) col / fCalibraMode->GetNnRphi(i);
1316 }
170c35f1 1317
bcb6fb78 1318 return posc*fCalibraMode->GetNfragZ(i)+posr;
170c35f1 1319
1320}
bcb6fb78 1321//____________________________________________________________________________________
1322Int_t AliTRDCalibraFillHisto::CalculateTotalNumberOfBins(Int_t i)
170c35f1 1323{
3a0f6479 1324 //
bcb6fb78 1325 // Calculate the total number of calibration groups
3a0f6479 1326 //
1327
bcb6fb78 1328 Int_t ntotal = 0;
64942b85 1329
1330 // All together
1331 if((fCalibraMode->GetNz(i)==100) && (fCalibraMode->GetNrphi(i)==100)){
1332 ntotal = 1;
1333 AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i));
1334 return ntotal;
1335 }
1336
1337 // Per Supermodule
1338 if((fCalibraMode->GetNz(i)==10) && (fCalibraMode->GetNrphi(i)==10)){
1339 ntotal = 18;
1340 AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i));
1341 return ntotal;
1342 }
1343
1344 // More
bcb6fb78 1345 fCalibraMode->ModePadCalibration(2,i);
1346 fCalibraMode->ModePadFragmentation(0,2,0,i);
1347 fCalibraMode->SetDetChamb2(i);
1348 ntotal += 6 * 18 * fCalibraMode->GetDetChamb2(i);
1349 fCalibraMode->ModePadCalibration(0,i);
1350 fCalibraMode->ModePadFragmentation(0,0,0,i);
1351 fCalibraMode->SetDetChamb0(i);
1352 ntotal += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(i);
1353 AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i));
1354 return ntotal;
1355
1356}
1357//_____________________________________________________________________________
1358void AliTRDCalibraFillHisto::SetNz(Int_t i, Short_t Nz)
1359{
1360 //
1361 // Set the mode of calibration group in the z direction for the parameter i
1362 //
1363
1364 if ((Nz >= 0) &&
1365 (Nz < 5)) {
1366 fCalibraMode->SetNz(i, Nz);
1367 }
1368 else {
1369 AliInfo("You have to choose between 0 and 4");
55a288e5 1370 }
170c35f1 1371
bcb6fb78 1372}
1373//_____________________________________________________________________________
1374void AliTRDCalibraFillHisto::SetNrphi(Int_t i, Short_t Nrphi)
1375{
1376 //
1377 // Set the mode of calibration group in the rphi direction for the parameter i
1378 //
1379
1380 if ((Nrphi >= 0) &&
1381 (Nrphi < 7)) {
1382 fCalibraMode->SetNrphi(i ,Nrphi);
1383 }
1384 else {
1385 AliInfo("You have to choose between 0 and 6");
3a0f6479 1386 }
55a288e5 1387
bcb6fb78 1388}
64942b85 1389
1390//_____________________________________________________________________________
1391void AliTRDCalibraFillHisto::SetAllTogether(Int_t i)
1392{
1393 //
1394 // Set the mode of calibration group all together
1395 //
1396 if(fVector2d == kTRUE) {
1397 AliInfo("Can not work with the vector method");
1398 return;
1399 }
1400 fCalibraMode->SetAllTogether(i);
1401
1402}
1403
1404//_____________________________________________________________________________
1405void AliTRDCalibraFillHisto::SetPerSuperModule(Int_t i)
1406{
1407 //
1408 // Set the mode of calibration group per supermodule
1409 //
1410 if(fVector2d == kTRUE) {
1411 AliInfo("Can not work with the vector method");
1412 return;
1413 }
1414 fCalibraMode->SetPerSuperModule(i);
1415
1416}
1417
bcb6fb78 1418//____________Set the pad calibration variables for the detector_______________
1419Bool_t AliTRDCalibraFillHisto::LocalisationDetectorXbins(Int_t detector)
1420{
1421 //
1422 // For the detector calcul the first Xbins and set the number of row
1423 // and col pads per calibration groups, the number of calibration
1424 // groups in the detector.
1425 //
1426
1427 // first Xbins of the detector
1428 if (fCH2dOn) {
1429 fCalibraMode->CalculXBins(detector,0);
55a288e5 1430 }
bcb6fb78 1431 if (fPH2dOn) {
1432 fCalibraMode->CalculXBins(detector,1);
55a288e5 1433 }
170c35f1 1434 if (fPRF2dOn) {
bcb6fb78 1435 fCalibraMode->CalculXBins(detector,2);
55a288e5 1436 }
bcb6fb78 1437
1438 // fragmentation of idect
1439 for (Int_t i = 0; i < 3; i++) {
053767a4 1440 fCalibraMode->ModePadCalibration((Int_t) GetStack(detector),i);
1441 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(detector)
1442 , (Int_t) GetStack(detector)
bcb6fb78 1443 , (Int_t) GetSector(detector),i);
170c35f1 1444 }
55a288e5 1445
bcb6fb78 1446 return kTRUE;
1447
55a288e5 1448}
bcb6fb78 1449//_____________________________________________________________________________
1450void AliTRDCalibraFillHisto::SetNumberGroupsPRF(Short_t numberGroupsPRF)
55a288e5 1451{
1452 //
bcb6fb78 1453 // Should be between 0 and 6
55a288e5 1454 //
bcb6fb78 1455
1456 if ((numberGroupsPRF < 0) || (numberGroupsPRF > 6)) {
1457 AliInfo("The number of groups must be between 0 and 6!");
1458 }
1459 else {
1460 fNgroupprf = numberGroupsPRF;
1461 }
55a288e5 1462
bcb6fb78 1463}
1464///////////////////////////////////////////////////////////////////////////////////////////
1465// Per tracklet: store or reset the info, fill the histos with the info
1466//////////////////////////////////////////////////////////////////////////////////////////
1467//_____________________________________________________________________________
1785640c 1468void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col,const AliTRDcluster *cls)
bcb6fb78 1469{
1470 //
1471 // Store the infos in fAmpTotal, fPHPlace and fPHValue
1472 // Correct from the gain correction before
1785640c 1473 // cls is shared cluster if any
bcb6fb78 1474 //
1475
09ea3770 1476 //printf("StoreInfoCHPHtrack\n");
1477
bcb6fb78 1478 // time bin of the cluster not corrected
1479 Int_t time = cl->GetPadTime();
e526983e 1480 Float_t charge = TMath::Abs(cl->GetQ());
09ea3770 1481 if(cls) {
1482 charge += TMath::Abs(cls->GetQ());
1483 //printf("AliTRDCalibraFillHisto::Add the cluster charge");
1484 }
e526983e 1485
1486 //printf("Store::time %d, amplitude %f\n",time,dqdl);
1487
bcb6fb78 1488 //Correct for the gain coefficient used in the database for reconstruction
64942b85 1489 Float_t correctthegain = 1.0;
1490 if(fIsHLT) correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack);
1491 else correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack)*fCalROCGain->GetValue(col,row);
bcb6fb78 1492 Float_t correction = 1.0;
1493 Float_t normalisation = 6.67;
1494 // we divide with gain in AliTRDclusterizer::Transform...
1495 if( correctthegain > 0 ) normalisation /= correctthegain;
55a288e5 1496
55a288e5 1497
bcb6fb78 1498 // take dd/dl corrected from the angle of the track
1499 correction = dqdl / (normalisation);
1500
55a288e5 1501
bcb6fb78 1502 // Fill the fAmpTotal with the charge
b70c68da 1503 if (fCH2dOn) {
e526983e 1504 if((!fLimitChargeIntegration) || (cl->IsInChamber())) {
1505 //printf("Store::group %d, amplitude %f\n",group[0],correction);
1506 fAmpTotal[(Int_t) group[0]] += correction;
1507 }
bcb6fb78 1508 }
55a288e5 1509
bcb6fb78 1510 // Fill the fPHPlace and value
1511 if (fPH2dOn) {
1512 fPHPlace[time] = group[1];
e526983e 1513 fPHValue[time] = charge;
bcb6fb78 1514 }
1515
1516}
1517//____________Offine tracking in the AliTRDtracker_____________________________
1518void AliTRDCalibraFillHisto::ResetfVariablestracklet()
1519{
1520 //
1521 // Reset values per tracklet
1522 //
1523
1524 //Reset good tracklet
1525 fGoodTracklet = kTRUE;
1526
1527 // Reset the fPHValue
1528 if (fPH2dOn) {
1529 //Reset the fPHValue and fPHPlace
1530 for (Int_t k = 0; k < fTimeMax; k++) {
1531 fPHValue[k] = 0.0;
1532 fPHPlace[k] = -1;
55a288e5 1533 }
bcb6fb78 1534 }
55a288e5 1535
bcb6fb78 1536 // Reset the fAmpTotal where we put value
1537 if (fCH2dOn) {
1538 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
1539 fAmpTotal[k] = 0.0;
55a288e5 1540 }
55a288e5 1541 }
55a288e5 1542}
bcb6fb78 1543//____________Offine tracking in the AliTRDtracker_____________________________
1544void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters)
170c35f1 1545{
1546 //
bcb6fb78 1547 // For the offline tracking or mcm tracklets
1548 // This function will be called in the functions UpdateHistogram...
1549 // to fill the info of a track for the relativ gain calibration
170c35f1 1550 //
bcb6fb78 1551
1552 Int_t nb = 0; // Nombre de zones traversees
1553 Int_t fd = -1; // Premiere zone non nulle
1554 Float_t totalcharge = 0.0; // Total charge for the supermodule histo
170c35f1 1555
e526983e 1556 //printf("CH2d nbclusters %d, fNumberClusters %d, fNumberClustersf %d\n",nbclusters,fNumberClusters,fNumberClustersf);
1557
bcb6fb78 1558 if(nbclusters < fNumberClusters) return;
1559 if(nbclusters > fNumberClustersf) return;
64942b85 1560
1561
1562 // Normalize with the number of clusters
1563 Double_t normalizeCst = fRelativeScale;
1564 if(fNormalizeNbOfCluster) normalizeCst = normalizeCst*nbclusters;
e526983e 1565
1566 //printf("Number of groups in one detector %d\n",fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0));
bcb6fb78 1567
1568 // See if the track goes through different zones
1569 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
e526983e 1570 //printf("fAmpTotal %f for %d\n",fAmpTotal[k],k);
bcb6fb78 1571 if (fAmpTotal[k] > 0.0) {
1572 totalcharge += fAmpTotal[k];
1573 nb++;
1574 if (nb == 1) {
1575 fd = k;
1576 }
170c35f1 1577 }
170c35f1 1578 }
170c35f1 1579
e526983e 1580 //printf("CH2d: nb %d, fd %d, calibration group %d, amplitude %f, detector %d\n",nb,fd,fCalibraMode->GetXbins(0),fAmpTotal[fd]/normalizeCst,fDetectorPreviousTrack);
bcb6fb78 1581
1582 switch (nb)
1583 {
1584 case 1:
1585 fNumberUsedCh[0]++;
1586 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
1587 if (fHisto2d) {
64942b85 1588 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/normalizeCst);
1589 //fCH2d->Fill(fAmpTotal[fd]/normalizeCst,fCalibraMode->GetXbins(0)+fd+0.5);
bcb6fb78 1590 }
1591 if (fVector2d) {
64942b85 1592 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/normalizeCst);
bcb6fb78 1593 }
1594 break;
1595 case 2:
1596 if ((fAmpTotal[fd] > 0.0) &&
1597 (fAmpTotal[fd+1] > 0.0)) {
1598 // One of the two very big
1599 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) {
1600 if (fHisto2d) {
64942b85 1601 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/normalizeCst);
1602 //fCH2d->Fill(fAmpTotal[fd]/normalizeCst,fCalibraMode->GetXbins(0)+fd+0.5);
bcb6fb78 1603 }
1604 if (fVector2d) {
64942b85 1605 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/normalizeCst);
bcb6fb78 1606 }
1607 fNumberUsedCh[1]++;
1608 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
1609 }
1610 if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) {
1611 if (fHisto2d) {
64942b85 1612 FillCH2d(fCalibraMode->GetXbins(0)+fd+1,fAmpTotal[fd+1]/normalizeCst);
1613 //fCH2d->Fill(fAmpTotal[fd+1]/normalizeCst,fCalibraMode->GetXbins(0)+fd+1.5);
bcb6fb78 1614 }
1615 if (fVector2d) {
64942b85 1616 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+1,fAmpTotal[fd+1]/normalizeCst);
bcb6fb78 1617 }
1618 fNumberUsedCh[1]++;
1619 fEntriesCH[fCalibraMode->GetXbins(0)+fd+1]++;
1620 }
1621 }
1622 if (fCalibraMode->GetNfragZ(0) > 1) {
1623 if (fAmpTotal[fd] > 0.0) {
1624 if ((fd+fCalibraMode->GetNfragZ(0)) < (fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0))) {
1625 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > 0.0) {
1626 // One of the two very big
1627 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]) {
1628 if (fHisto2d) {
64942b85 1629 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/normalizeCst);
1630 //fCH2d->Fill(fAmpTotal[fd]/normalizeCst,fCalibraMode->GetXbins(0)+fd+0.5);
bcb6fb78 1631 }
1632 if (fVector2d) {
64942b85 1633 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/normalizeCst);
bcb6fb78 1634 }
1635 fNumberUsedCh[1]++;
1636 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
1637 }
1638 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > fProcent*fAmpTotal[fd]) {
1639 if (fHisto2d) {
64942b85 1640 FillCH2d(fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/normalizeCst);
1641 //fCH2d->Fill(fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/normalizeCst,fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)+0.5);
bcb6fb78 1642 }
1643 fNumberUsedCh[1]++;
1644 fEntriesCH[fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)]++;
1645 if (fVector2d) {
64942b85 1646 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/normalizeCst);
bcb6fb78 1647 }
1648 }
1649 }
1650 }
1651 }
1652 }
1653 break;
1654 default: break;
3d1ad7ac 1655 }
170c35f1 1656}
bcb6fb78 1657//____________Offine tracking in the AliTRDtracker_____________________________
1658void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
170c35f1 1659{
1660 //
bcb6fb78 1661 // For the offline tracking or mcm tracklets
1662 // This function will be called in the functions UpdateHistogram...
1663 // to fill the info of a track for the drift velocity calibration
170c35f1 1664 //
bcb6fb78 1665
1666 Int_t nb = 1; // Nombre de zones traversees 1, 2 ou plus de 3
1667 Int_t fd1 = -1; // Premiere zone non nulle
1668 Int_t fd2 = -1; // Deuxieme zone non nulle
1669 Int_t k1 = -1; // Debut de la premiere zone
1670 Int_t k2 = -1; // Debut de la seconde zone
1671 Int_t nbclusters = 0; // number of clusters
170c35f1 1672
170c35f1 1673
170c35f1 1674
bcb6fb78 1675 // See if the track goes through different zones
1676 for (Int_t k = 0; k < fTimeMax; k++) {
1677 if (fPHValue[k] > 0.0) {
1678 nbclusters++;
1679 if (fd1 == -1) {
1680 fd1 = fPHPlace[k];
1681 k1 = k;
1682 }
1683 if (fPHPlace[k] != fd1) {
1684 if (fd2 == -1) {
1685 k2 = k;
1686 fd2 = fPHPlace[k];
1687 nb = 2;
1688 }
1689 if (fPHPlace[k] != fd2) {
1690 nb = 3;
1691 }
1692 }
55a288e5 1693 }
1694 }
55a288e5 1695
64942b85 1696 // See if noise before and after
1697 if(fMaxCluster > 0) {
1698 if(fPHValue[0] > fMaxCluster) return;
1699 if(fTimeMax > fNbMaxCluster) {
1700 for(Int_t k = (fTimeMax-fNbMaxCluster); k < fTimeMax; k++){
1701 if(fPHValue[k] > fMaxCluster) return;
1702 }
1703 }
1704 }
1705
4aad967c 1706 //printf("nbclusters %d, low limit %d, high limit %d\n",nbclusters,fNumberClusters,fNumberClustersf);
1707
bcb6fb78 1708 if(nbclusters < fNumberClusters) return;
1709 if(nbclusters > fNumberClustersf) return;
3a0f6479 1710
bcb6fb78 1711 switch(nb)
1712 {
170c35f1 1713 case 1:
bcb6fb78 1714 fNumberUsedPh[0]++;
1715 for (Int_t i = 0; i < fTimeMax; i++) {
1716 if (fHisto2d) {
37b0cf5e 1717 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
1718 else {
1719 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
1720 }
bcb6fb78 1721 //printf("Fill the time bin %d with %f\n",i,fPHValue[i]);
1722 }
1723 if (fVector2d) {
37b0cf5e 1724 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
1725 else {
1726 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
1727 }
bcb6fb78 1728 }
55a288e5 1729 }
170c35f1 1730 break;
1731 case 2:
bcb6fb78 1732 if ((fd1 == fd2+1) ||
1733 (fd2 == fd1+1)) {
1734 // One of the two fast all the think
1735 if (k2 > (k1+fDifference)) {
1736 //we choose to fill the fd1 with all the values
1737 fNumberUsedPh[1]++;
1738 for (Int_t i = 0; i < fTimeMax; i++) {
1739 if (fHisto2d) {
37b0cf5e 1740 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
1741 else {
1742 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
1743 }
bcb6fb78 1744 }
1745 if (fVector2d) {
37b0cf5e 1746 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
1747 else {
1748 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
1749 }
bcb6fb78 1750 }
55a288e5 1751 }
55a288e5 1752 }
bcb6fb78 1753 if ((k2+fDifference) < fTimeMax) {
1754 //we choose to fill the fd2 with all the values
1755 fNumberUsedPh[1]++;
1756 for (Int_t i = 0; i < fTimeMax; i++) {
1757 if (fHisto2d) {
37b0cf5e 1758 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
1759 else {
1760 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
1761 }
bcb6fb78 1762 }
55a288e5 1763 if (fVector2d) {
37b0cf5e 1764 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
1765 else {
1766 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
1767 }
bcb6fb78 1768 }
55a288e5 1769 }
55a288e5 1770 }
1771 }
bcb6fb78 1772 // Two zones voisines sinon rien!
1773 if (fCalibraMode->GetNfragZ(1) > 1) {
1774 // Case 2
1775 if ((fd1+fCalibraMode->GetNfragZ(1)) < (fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1))) {
1776 if (fd2 == (fd1+fCalibraMode->GetNfragZ(1))) {
1777 // One of the two fast all the think
1778 if (k2 > (k1+fDifference)) {
1779 //we choose to fill the fd1 with all the values
1780 fNumberUsedPh[1]++;
1781 for (Int_t i = 0; i < fTimeMax; i++) {
55a288e5 1782 if (fHisto2d) {
37b0cf5e 1783 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
1784 else {
1785 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
1786 }
55a288e5 1787 }
1788 if (fVector2d) {
37b0cf5e 1789 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
1790 else {
1791 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
1792 }
55a288e5 1793 }
55a288e5 1794 }
bcb6fb78 1795 }
1796 if ((k2+fDifference) < fTimeMax) {
1797 //we choose to fill the fd2 with all the values
1798 fNumberUsedPh[1]++;
1799 for (Int_t i = 0; i < fTimeMax; i++) {
55a288e5 1800 if (fHisto2d) {
37b0cf5e 1801 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
1802 else {
1803 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
1804 }
170c35f1 1805 }
1806 if (fVector2d) {
37b0cf5e 1807 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
1808 else {
1809 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
1810 }
170c35f1 1811 }
55a288e5 1812 }
1813 }
1814 }
1815 }
170c35f1 1816 // Two zones voisines sinon rien!
1817 // Case 3
1818 if ((fd1 - fCalibraMode->GetNfragZ(1)) >= 0) {
1819 if (fd2 == (fd1 - fCalibraMode->GetNfragZ(1))) {
1820 // One of the two fast all the think
1821 if (k2 > (k1 + fDifference)) {
1822 //we choose to fill the fd1 with all the values
1823 fNumberUsedPh[1]++;
1824 for (Int_t i = 0; i < fTimeMax; i++) {
1825 if (fHisto2d) {
37b0cf5e 1826 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
1827 else {
1828 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
1829 }
170c35f1 1830 }
1831 if (fVector2d) {
37b0cf5e 1832 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
1833 else {
1834 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
1835 }
170c35f1 1836 }
55a288e5 1837 }
1838 }
170c35f1 1839 if ((k2+fDifference) < fTimeMax) {
1840 //we choose to fill the fd2 with all the values
1841 fNumberUsedPh[1]++;
1842 for (Int_t i = 0; i < fTimeMax; i++) {
1843 if (fHisto2d) {
37b0cf5e 1844 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
1845 else {
1846 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
1847 }
170c35f1 1848 }
1849 if (fVector2d) {
37b0cf5e 1850 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
1851 else {
1852 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
1853 }
170c35f1 1854 }
55a288e5 1855 }
1856 }
1857 }
1858 }
1859 }
170c35f1 1860 break;
1861 default: break;
1862 }
55a288e5 1863}
bcb6fb78 1864//////////////////////////////////////////////////////////////////////////////////////////
1865// DAQ process functions
1866/////////////////////////////////////////////////////////////////////////////////////////
1867//_____________________________________________________________________
8df1f8f5 1868Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliRawReader *rawReader)
fd50bb14 1869 { //main
1870 //
1871 // Event Processing loop - AliTRDrawStream
1872 //
1873 // 0 timebin problem
1874 // 1 no input
1875 // 2 input
1876 // Same algorithm as TestBeam but different reader
1877 //
1878
fd50bb14 1879 AliTRDrawStream *rawStream = new AliTRDrawStream(rawReader);
fd50bb14 1880
1881 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE);
1882 digitsManager->CreateArrays();
1883
1884 Int_t withInput = 1;
1885
1886 Double_t phvalue[16][144][36];
1887 for(Int_t k = 0; k < 36; k++){
1888 for(Int_t j = 0; j < 16; j++){
1889 for(Int_t c = 0; c < 144; c++){
1890 phvalue[j][c][k] = 0.0;
1891 }
1892 }
1893 }
1894
1895 fDetectorPreviousTrack = -1;
1896 fMCMPrevious = -1;
1897 fROBPrevious = -1;
1898
1899 Int_t nbtimebin = 0;
1900 Int_t baseline = 10;
1901
1902
1903 fTimeMax = 0;
1904
1905 Int_t det = 0;
1906 while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector
1907
1908 if (digitsManager->GetIndexes(det)->HasEntry()) {//QA
1909 // printf("there is ADC data on this chamber!\n");
1910
1911 AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod
1912 if (digits->HasData()) { //array
1913
1914 AliTRDSignalIndex *indexes = digitsManager->GetIndexes(det);
1915 if (indexes->IsAllocated() == kFALSE) {
1916 AliError("Indexes do not exist!");
1917 break;
1918 }
1919 Int_t iRow = 0;
1920 Int_t iCol = 0;
1921 indexes->ResetCounters();
1922
1923 while (indexes->NextRCIndex(iRow, iCol)) { //column,row
1924 //printf(" det %d \t row %d \t col %d \t digit\n",det,iRow,iCol);
1925 //while (rawStream->Next()) {
1926
1927 Int_t idetector = det; // current detector
1928 //Int_t imcm = rawStream->GetMCM(); // current MCM
1929 //Int_t irob = rawStream->GetROB(); // current ROB
1930
1931
1932 if((fDetectorPreviousTrack != idetector) && (fDetectorPreviousTrack != -1)) {
1933 // Fill
1934 withInput = TMath::Max(FillDAQ(phvalue),withInput);
1935
1936 // reset
1937 for(Int_t k = 0; k < 36; k++){
1938 for(Int_t j = 0; j < 16; j++){
1939 for(Int_t c = 0; c < 144; c++){
1940 phvalue[j][c][k] = 0.0;
1941 }
1942 }
1943 }
1944 }
1945
1946 fDetectorPreviousTrack = idetector;
1947 //fMCMPrevious = imcm;
1948 //fROBPrevious = irob;
1949
1950 // nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
1951 AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam();
1952 nbtimebin = digitParam->GetNTimeBins(det); // number of time bins read from data
1953 baseline = digitParam->GetADCbaseline(det); // baseline
1954
1955 if(nbtimebin == 0) return 0;
1956 if((fTimeMax != 0) && (nbtimebin != fTimeMax)) return 0;
1957 fTimeMax = nbtimebin;
1958
1959 fNumberClustersf = fTimeMax;
1960 fNumberClusters = (Int_t)(fNumberClustersProcent*fTimeMax);
1961
1962
1963 for(Int_t itime = 0; itime < nbtimebin; itime++) {
1964 // phvalue[row][col][itime] = signal[itime]-baseline;
1965 phvalue[iRow][iCol][itime] = (Short_t)(digits->GetData(iRow,iCol,itime) - baseline);
1966 /*if(phvalue[iRow][iCol][itime] >= 20) {
1967 printf("----------> phvalue[%d][%d][%d] %d baseline %d \n",
1968 iRow,
1969 iCol,
1970 itime,
1971 (Short_t)(digits->GetData(iRow,iCol,itime)),
1972 baseline);
1973 }*/
1974 }
1975
1976 }//column,row
1977
1978 // fill the last one
1979 if(fDetectorPreviousTrack != -1){
1980
1981 // Fill
1982 withInput = TMath::Max(FillDAQ(phvalue),withInput);
1983 // printf("\n ---> withinput %d\n\n",withInput);
1984 // reset
1985 for(Int_t k = 0; k < 36; k++){
1986 for(Int_t j = 0; j < 16; j++){
1987 for(Int_t c = 0; c < 144; c++){
1988 phvalue[j][c][k] = 0.0;
1989 }
1990 }
1991 }
1992 }
1993
1994 }//array
1995 }//QA
1996 digitsManager->ClearArrays(det);
1997 }//idetector
1998 delete digitsManager;
1999
2000 delete rawStream;
2001 return withInput;
2002 }//main
2003//_____________________________________________________________________
bcb6fb78 2004//////////////////////////////////////////////////////////////////////////////
2005// Routine inside the DAQ process
2006/////////////////////////////////////////////////////////////////////////////
2007//_______________________________________________________________________
bcb6fb78 2008Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
2009
2010 //
2011 // Look for the maximum by collapsing over the time
2012 // Sum over four pad col and two pad row
2013 //
2014
2015 Int_t used = 0;
2016
2017
2018 Int_t idect = fDetectorPreviousTrack;
d95484e4 2019 //printf("Enter Detector %d\n",fDetectorPreviousTrack);
bcb6fb78 2020 Double_t sum[36];
2021 for(Int_t tb = 0; tb < 36; tb++){
2022 sum[tb] = 0.0;
2023 }
2024
d95484e4 2025 //fGoodTracklet = kTRUE;
2026 //fDetectorPreviousTrack = 0;
bcb6fb78 2027
2028
2029 ///////////////////////////
2030 // look for maximum
2031 /////////////////////////
2032
2033 Int_t imaxRow = 0;
2034 Int_t imaxCol = 0;
2035 Double_t integralMax = -1;
2036
2037 for (Int_t ir = 1; ir <= 15; ir++)
2038 {
2039 for (Int_t ic = 2; ic <= 142; ic++)
2040 {
2041 Double_t integral = 0;
6aafa7ea 2042 for (Int_t ishiftR = 0; ishiftR < fNumberRowDAQ; ishiftR++)
bcb6fb78 2043 {
6aafa7ea 2044 for (Int_t ishiftC = -fNumberColDAQ; ishiftC < fNumberColDAQ; ishiftC++)
bcb6fb78 2045 {
2046 if (ir + ishiftR >= 1 && ir + ishiftR <= 16 &&
2047 ic + ishiftC >= 1 && ic + ishiftC <= 144)
2048 {
2049
2050 for(Int_t tb = 0; tb< fTimeMax; tb++){
2051 integral += phvalue[ir + ishiftR-1][ic + ishiftC-1][tb];
2052 }// addtb
2053 } //addsignal
2054 } //shiftC
2055 } // shiftR
bcb6fb78 2056 if (integralMax < integral)
2057 {
2058 imaxRow = ir;
2059 imaxCol = ic;
2060 integralMax = integral;
1785640c 2061
bcb6fb78 2062 } // check max integral
2063 } //ic
2064 } // ir
2065
1785640c 2066 // printf("imaxRow %d, imaxCol %d, fTimeMax %d, integralMax %f\n",imaxRow,imaxCol,fTimeMax, integralMax);
6aafa7ea 2067 //if((imaxRow == 0) || (imaxRow >= 15) || (imaxCol <= 3) || (imaxCol >= 140)) {
2068 // used=1;
2069 // return used;
2070 // }
1785640c 2071
6aafa7ea 2072 if(((imaxRow + fNumberRowDAQ) > 16) || (imaxRow == 0) || ((imaxCol - fNumberColDAQ) <= 1) || ((imaxCol + fNumberColDAQ) >= 144)) {
27b46d95 2073 used=1;
2074 return used;
2075 }
d95484e4 2076 //CheckGoodTrackletV0(fDetectorPreviousTrack,imaxRow,imaxCol);
2077 //if(!fGoodTracklet) used = 1;;
bcb6fb78 2078
2079 // /////////////////////////////////////////////////////
2080 // sum ober 2 row and 4 pad cols for each time bins
2081 // ////////////////////////////////////////////////////
2082
2083
1785640c 2084
6aafa7ea 2085 for (Int_t ishiftR = 0; ishiftR < fNumberRowDAQ; ishiftR++)
bcb6fb78 2086 {
6aafa7ea 2087 for (Int_t ishiftC = -fNumberColDAQ; ishiftC < fNumberColDAQ; ishiftC++)
bcb6fb78 2088 {
6aafa7ea 2089 if (imaxRow + ishiftR >= 1 && imaxRow + ishiftR <= 16 &&
2090 imaxCol + ishiftC >= 1 && imaxCol + ishiftC <= 144)
2091 {
2092 for(Int_t it = 0; it < fTimeMax; it++){
2093 sum[it] += phvalue[imaxRow + ishiftR-1][imaxCol + ishiftC-1][it];
2094 }
2095 }
2096 } // col shift
2097 }// row shift
bcb6fb78 2098
2099 Int_t nbcl = 0;
2100 Double_t sumcharge = 0.0;
2101 for(Int_t it = 0; it < fTimeMax; it++){
2102 sumcharge += sum[it];
1785640c 2103 if(sum[it] > fThresholdClustersDAQ) nbcl++;
bcb6fb78 2104 }
2105
2106
2107 /////////////////////////////////////////////////////////
2108 // Debug
2109 ////////////////////////////////////////////////////////
2110 if(fDebugLevel > 0){
2111 if ( !fDebugStreamer ) {
2112 //debug stream
2113 TDirectory *backup = gDirectory;
2114 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2115 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2116 }
2117
2118 Double_t amph0 = sum[0];
2119 Double_t amphlast = sum[fTimeMax-1];
2120 Double_t rms = TMath::RMS(fTimeMax,sum);
2121 Int_t goodtracklet = (Int_t) fGoodTracklet;
2122 for(Int_t it = 0; it < fTimeMax; it++){
2123 Double_t clustera = sum[it];
2124
2125 (* fDebugStreamer) << "FillDAQa"<<
2126 "ampTotal="<<sumcharge<<
2127 "row="<<imaxRow<<
2128 "col="<<imaxCol<<
2129 "detector="<<idect<<
2130 "amph0="<<amph0<<
2131 "amphlast="<<amphlast<<
2132 "goodtracklet="<<goodtracklet<<
2133 "clustera="<<clustera<<
2134 "it="<<it<<
2135 "rms="<<rms<<
6aafa7ea 2136 "nbcl="<<nbcl<<
bcb6fb78 2137 "\n";
2138 }
2139 }
2140
2141 ////////////////////////////////////////////////////////
2142 // fill
2143 ///////////////////////////////////////////////////////
6aafa7ea 2144 //printf("fNumberClusters %d, fNumberClustersf %d\n",fNumberClusters,fNumberClustersf);
bcb6fb78 2145 if(sum[0] > 100.0) used = 1;
2146 if(nbcl < fNumberClusters) used = 1;
2147 if(nbcl > fNumberClustersf) used = 1;
2148
2149 //if(fDetectorPreviousTrack == 15){
2150 // printf("rms %f and first time bin %f\n",TMath::RMS(fTimeMax,sum),sum[0]);
2151 //}
2152 //if((TMath::RMS(fTimeMax,sum) <= 10.0) && (sum[0] > 200.0)) return 1;
2153 if(used == 0){
2154 for(Int_t it = 0; it < fTimeMax; it++){
37b0cf5e 2155 if(fFillWithZero) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax);
2156 else{
1785640c 2157 if(sum[it] > 0.0) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax);
37b0cf5e 2158 }
1785640c 2159 //if(fFillWithZero) UpdateDAQ(0,0,0,it,sum[it],fTimeMax);
6aafa7ea 2160 //else{
1785640c 2161 // if(sum[it] > 0.0) UpdateDAQ(0,0,0,it,sum[it],fTimeMax);
2162 //}
bcb6fb78 2163 }
2164
2165
2166 //((TH2I *)GetCH2d()->Fill(sumcharge/30.0,fDetectorPreviousTrack));
2167 used = 2;
d95484e4 2168 //printf("Pass Detector %d\n",fDetectorPreviousTrack);
2169
bcb6fb78 2170 }
2171
2172 return used;
2173
2174}
2175//____________Online trackling in AliTRDtrigger________________________________
2176Bool_t AliTRDCalibraFillHisto::UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Float_t signal, Int_t nbtimebins)
2177{
2178 //
2179 // For the DAQ
2180 // Fill a simple average pulse height
2181 //
2182
2183
2184 ((TProfile2D *)GetPH2d(nbtimebins,fSf))->Fill((Float_t) timebin/fSf,det+0.5,(Float_t) signal);
2185
2186
2187 return kTRUE;
2188
2189}
2190//____________Write_____________________________________________________
2191//_____________________________________________________________________
2192void AliTRDCalibraFillHisto::Write2d(const Char_t *filename, Bool_t append)
2193{
2194 //
2195 // Write infos to file
2196 //
2197
2198 //For debugging
2199 if ( fDebugStreamer ) {
2200 delete fDebugStreamer;
2201 fDebugStreamer = 0x0;
2202 }
2203
2204 AliInfo(Form("Numbertrack: %d Numberusedch[0]: %d, Numberusedch[1]: %d Numberusedph[0]: %d, Numberusedph[1]: %d"
2205 ,fNumberTrack
2206 ,fNumberUsedCh[0]
2207 ,fNumberUsedCh[1]
2208 ,fNumberUsedPh[0]
2209 ,fNumberUsedPh[1]));
2210
2211 TDirectory *backup = gDirectory;
2212 TString option;
2213
2214 if ( append )
2215 option = "update";
2216 else
2217 option = "recreate";
2218
2219 TFile f(filename,option.Data());
2220
2221 TStopwatch stopwatch;
2222 stopwatch.Start();
2223 if(fVector2d) {
2224 f.WriteTObject(fCalibraVector);
2225 }
2226
2227 if (fCH2dOn ) {
2228 if (fHisto2d) {
2229 f.WriteTObject(fCH2d);
2230 }
2231 }
2232 if (fPH2dOn ) {
2233 if (fHisto2d) {
2234 f.WriteTObject(fPH2d);
2235 }
2236 }
2237 if (fPRF2dOn) {
2238 if (fHisto2d) {
2239 f.WriteTObject(fPRF2d);
2240 }
2241 }
2242 if(fLinearFitterOn){
46c4871e 2243 if(fLinearFitterDebugOn) AnalyseLinearFitter();
bcb6fb78 2244 f.WriteTObject(fLinearVdriftFit);
2245 }
2246
2247 f.Close();
2248
2249 if ( backup ) backup->cd();
2250
2251 AliInfo(Form("Execution time Write2d: R:%.2fs C:%.2fs"
2252 ,stopwatch.RealTime(),stopwatch.CpuTime()));
2253}
2254//////////////////////////////////////////////////////////////////////////////////////////////////////////////
2255// Stats stuff
2256//////////////////////////////////////////////////////////////////////////////////////////////////////////////
2257//___________________________________________probe the histos__________________________________________________
2258Double_t *AliTRDCalibraFillHisto::StatH(TH2 *h, Int_t i)
2259{
2260 //
2261 // Check the number of stats in h, 0 is TH2I 1 is TProfile2D
2262 // debug mode with 2 for TH2I and 3 for TProfile2D
2263 // It gives a pointer to a Double_t[7] with the info following...
2264 // [0] : number of calibration groups with entries
2265 // [1] : minimal number of entries found
2266 // [2] : calibration group number of the min
2267 // [3] : maximal number of entries found
2268 // [4] : calibration group number of the max
2269 // [5] : mean number of entries found
2270 // [6] : mean relative error
2271 //
2272
2273 Double_t *info = new Double_t[7];
2274
2275 // Number of Xbins (detectors or groups of pads)
2276 Int_t nbins = h->GetNbinsY(); //number of calibration groups
2277 Int_t nxbins = h->GetNbinsX(); //number of bins per histo
2278
2279 // Initialise
2280 Double_t nbwe = 0; //number of calibration groups with entries
2281 Double_t minentries = 0; //minimal number of entries found
2282 Double_t maxentries = 0; //maximal number of entries found
2283 Double_t placemin = 0; //calibration group number of the min
2284 Double_t placemax = -1; //calibration group number of the max
2285 Double_t meanstats = 0.0; //mean number of entries over the calibration group with at least ome entry
2286 Double_t meanrelativerror = 0.0; //mean relativ error in the TProfile2D
2287
2288 Double_t counter = 0;
2289
2290 //Debug
2291 TH1F *nbEntries = 0x0;//distribution of the number of entries
2292 TH1F *nbEntriesPerGroup = 0x0;//Number of entries per group
2293 TProfile *nbEntriesPerSp = 0x0;//Number of entries for one supermodule
2294
2295 // Beginning of the loop over the calibration groups
2296 for (Int_t idect = 0; idect < nbins; idect++) {
2297
2298 TH1I *projch = (TH1I *) h->ProjectionX("projch",idect+1,idect+1,(Option_t *)"e");
2299 projch->SetDirectory(0);
2300
2301 // Number of entries for this calibration group
2302 Double_t nentries = 0.0;
2303 if((i%2) == 0){
2304 for (Int_t k = 0; k < nxbins; k++) {
2305 nentries += h->GetBinContent(h->GetBin(k+1,idect+1));
3a0f6479 2306 }
bcb6fb78 2307 }
2308 else{
2309 for (Int_t k = 0; k < nxbins; k++) {
2310 nentries += ((TProfile2D *)h)->GetBinEntries(h->GetBin(k+1,idect+1));
2311 if(h->GetBinContent(h->GetBin(k+1,idect+1)) != 0) {
2312 meanrelativerror += (h->GetBinError(h->GetBin(k+1,idect+1))/(TMath::Abs(h->GetBinContent(h->GetBin(k+1,idect+1)))));
2313 counter++;
2314 }
2315 }
2316 }
2317
2318 //Debug
2319 if(i > 1){
35a82746 2320 if(nentries > 0){
2321 if(!((Bool_t)nbEntries)) nbEntries = new TH1F("Number of entries","Number of entries",100,(Int_t)nentries/2,nentries*2);
bcb6fb78 2322 nbEntries->SetDirectory(0);
35a82746 2323 nbEntries->Fill(nentries);
2324 if(!((Bool_t)nbEntriesPerGroup)) nbEntriesPerGroup = new TH1F("Number of entries per group","Number of entries per group",nbins,0,nbins);
bcb6fb78 2325 nbEntriesPerGroup->SetDirectory(0);
bcb6fb78 2326 nbEntriesPerGroup->Fill(idect+0.5,nentries);
35a82746 2327 if(!((Bool_t)nbEntriesPerSp)) nbEntriesPerSp = new TProfile("Number of entries per supermodule","Number of entries per supermodule",(Int_t)(nbins/18),0,(Int_t)(nbins/18));
2328 nbEntriesPerSp->SetDirectory(0);
bcb6fb78 2329 nbEntriesPerSp->Fill((idect%((Int_t)(nbins/18)))+0.5,nentries);
170c35f1 2330 }
2331 }
bcb6fb78 2332
2333 //min amd max
2334 if(nentries > maxentries){
2335 maxentries = nentries;
2336 placemax = idect;
2337 }
2338 if(idect == 0) {
2339 minentries = nentries;
2340 }
2341 if(nentries < minentries){
2342 minentries = nentries;
2343 placemin = idect;
2344 }
2345 //nbwe
2346 if(nentries > 0) {
2347 nbwe++;
2348 meanstats += nentries;
2349 }
2350 }//calibration groups loop
2351
2352 if(nbwe > 0) meanstats /= nbwe;
2353 if(counter > 0) meanrelativerror /= counter;
2354
2355 AliInfo(Form("There are %f calibration groups with entries",nbwe));
2356 AliInfo(Form("The minimum number of entries is %f for the group %f",minentries,placemin));
2357 AliInfo(Form("The maximum number of entries is %f for the group %f",maxentries,placemax));
2358 AliInfo(Form("The mean number of entries is %f",meanstats));
2359 if((i%2) == 1) AliInfo(Form("The mean relative error is %f",meanrelativerror));
2360
2361 info[0] = nbwe;
2362 info[1] = minentries;
2363 info[2] = placemin;
2364 info[3] = maxentries;
2365 info[4] = placemax;
2366 info[5] = meanstats;
2367 info[6] = meanrelativerror;
2368
35a82746 2369 if(nbEntries && nbEntriesPerSp && nbEntriesPerGroup){
bcb6fb78 2370 gStyle->SetPalette(1);
2371 gStyle->SetOptStat(1111);
2372 gStyle->SetPadBorderMode(0);
2373 gStyle->SetCanvasColor(10);
2374 gStyle->SetPadLeftMargin(0.13);
2375 gStyle->SetPadRightMargin(0.01);
2376 TCanvas *stat = new TCanvas("stat","",50,50,600,800);
2377 stat->Divide(2,1);
2378 stat->cd(1);
2379 nbEntries->Draw("");
2380 stat->cd(2);
2381 nbEntriesPerSp->SetStats(0);
2382 nbEntriesPerSp->Draw("");
2383 TCanvas *stat1 = new TCanvas("stat1","",50,50,600,800);
2384 stat1->cd();
2385 nbEntriesPerGroup->SetStats(0);
2386 nbEntriesPerGroup->Draw("");
2387 }
2388
2389 return info;
2390
2391}
2392//____________________________________________________________________________
2393Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberCH()
2394{
2395 //
2396 // Return a Int_t[4] with:
2397 // 0 Mean number of entries
2398 // 1 median of number of entries
2399 // 2 rms of number of entries
2400 // 3 number of group with entries
2401 //
2402
35a82746 2403 Double_t *stat = new Double_t[4];
bcb6fb78 2404 stat[3] = 0.0;
2405
2406 Int_t nbofgroups = CalculateTotalNumberOfBins(0);
35a82746 2407
2408 Double_t *weight = new Double_t[nbofgroups];
2409 Double_t *nonul = new Double_t[nbofgroups];
bcb6fb78 2410
2411 for(Int_t k = 0; k < nbofgroups; k++){
2412 if(fEntriesCH[k] > 0) {
2413 weight[k] = 1.0;
2414 nonul[(Int_t)stat[3]] = fEntriesCH[k];
2415 stat[3]++;
2416 }
2417 else weight[k] = 0.0;
170c35f1 2418 }
bcb6fb78 2419 stat[0] = TMath::Mean(nbofgroups,fEntriesCH,weight);
2420 stat[1] = TMath::Median(nbofgroups,fEntriesCH,weight);
2421 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
2422
35a82746 2423 delete [] weight;
2424 delete [] nonul;
2425
bcb6fb78 2426 return stat;
2427
170c35f1 2428}
bcb6fb78 2429//____________________________________________________________________________
2430Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberLinearFitter() const
55a288e5 2431{
2432 //
bcb6fb78 2433 // Return a Int_t[4] with:
2434 // 0 Mean number of entries
2435 // 1 median of number of entries
2436 // 2 rms of number of entries
2437 // 3 number of group with entries
55a288e5 2438 //
2439
bcb6fb78 2440 Double_t *stat = new Double_t[4];
2441 stat[3] = 0.0;
55a288e5 2442
bcb6fb78 2443 Int_t nbofgroups = 540;
2444 Double_t *weight = new Double_t[nbofgroups];
2445 Int_t *nonul = new Int_t[nbofgroups];
55a288e5 2446
bcb6fb78 2447 for(Int_t k = 0; k < nbofgroups; k++){
2448 if(fEntriesLinearFitter[k] > 0) {
2449 weight[k] = 1.0;
2450 nonul[(Int_t) stat[3]] = fEntriesLinearFitter[k];
2451 stat[3]++;
d0569428 2452 }
bcb6fb78 2453 else weight[k] = 0.0;
d0569428 2454 }
bcb6fb78 2455 stat[0] = TMath::Mean(nbofgroups,fEntriesLinearFitter,weight);
2456 stat[1] = TMath::Median(nbofgroups,fEntriesLinearFitter,weight);
2457 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
55a288e5 2458
35a82746 2459 delete [] weight;
2460 delete [] nonul;
2461
bcb6fb78 2462 return stat;
170c35f1 2463
bcb6fb78 2464}
2465//////////////////////////////////////////////////////////////////////////////////////
2466// Create Histos
2467//////////////////////////////////////////////////////////////////////////////////////
2468//_____________________________________________________________________________
2469void AliTRDCalibraFillHisto::CreatePRF2d(Int_t nn)
2470{
2471 //
2472 // Create the 2D histos: here we have 2*fNgroupprf bins in tnp of 0.2 amplitude each
2473 // If fNgroupprf is zero then no binning in tnp
2474 //
d0569428 2475
bcb6fb78 2476 TString name("Nz");
2477 name += fCalibraMode->GetNz(2);
2478 name += "Nrphi";
2479 name += fCalibraMode->GetNrphi(2);
2480 name += "Ngp";
2481 name += fNgroupprf;
d0569428 2482
bcb6fb78 2483 if(fNgroupprf != 0){
2484
2485 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
2486 ,2*fNgroupprf*fNumberBinPRF,-3.0*fNgroupprf,3.0*fNgroupprf,nn,0,nn);
2487 fPRF2d->SetYTitle("Det/pad groups");
2488 fPRF2d->SetXTitle("Position x/W [pad width units]");
2489 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
2490 fPRF2d->SetStats(0);
d0569428 2491 }
bcb6fb78 2492 else{
2493 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
2494 ,fNumberBinPRF,-1.5,1.5,nn,0,nn);
2495 fPRF2d->SetYTitle("Det/pad groups");
2496 fPRF2d->SetXTitle("Position x/W [pad width units]");
2497 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
2498 fPRF2d->SetStats(0);
d0569428 2499 }
d0569428 2500
2501}
bcb6fb78 2502
2503//_____________________________________________________________________________
2504void AliTRDCalibraFillHisto::CreatePH2d(Int_t nn)
d0569428 2505{
2506 //
bcb6fb78 2507 // Create the 2D histos
d0569428 2508 //
2509
4c865c34 2510 TString name("Ver");
2511 name += fVersionVdriftUsed;
2512 name += "Subver";
2513 name += fSubVersionVdriftUsed;
2514 name += "Nz";
bcb6fb78 2515 name += fCalibraMode->GetNz(1);
2516 name += "Nrphi";
2517 name += fCalibraMode->GetNrphi(1);
d0569428 2518
bcb6fb78 2519 fPH2d = new TProfile2D("PH2d",(const Char_t *) name
2520 ,fTimeMax,-0.5/fSf,(Float_t) (fTimeMax-0.5)/fSf
2521 ,nn,0,nn);
2522 fPH2d->SetYTitle("Det/pad groups");
2523 fPH2d->SetXTitle("time [#mus]");
2524 fPH2d->SetZTitle("<PH> [a.u.]");
2525 fPH2d->SetStats(0);
d0569428 2526
bcb6fb78 2527}
2528//_____________________________________________________________________________
2529void AliTRDCalibraFillHisto::CreateCH2d(Int_t nn)
2530{
2531 //
2532 // Create the 2D histos
2533 //
d0569428 2534
4c865c34 2535 TString name("Ver");
2536 name += fVersionGainUsed;
2537 name += "Subver";
2538 name += fSubVersionGainUsed;
2539 name += "Nz";
bcb6fb78 2540 name += fCalibraMode->GetNz(0);
2541 name += "Nrphi";
2542 name += fCalibraMode->GetNrphi(0);
4c865c34 2543
bcb6fb78 2544 fCH2d = new TH2I("CH2d",(const Char_t *) name
2545 ,fNumberBinCharge,0,300,nn,0,nn);
2546 fCH2d->SetYTitle("Det/pad groups");
2547 fCH2d->SetXTitle("charge deposit [a.u]");
2548 fCH2d->SetZTitle("counts");
2549 fCH2d->SetStats(0);
2550 fCH2d->Sumw2();
d0569428 2551
bcb6fb78 2552}
2553//////////////////////////////////////////////////////////////////////////////////
2554// Set relative scale
2555/////////////////////////////////////////////////////////////////////////////////
2556//_____________________________________________________________________________
2557void AliTRDCalibraFillHisto::SetRelativeScale(Float_t RelativeScale)
2558{
2559 //
2560 // Set the factor that will divide the deposited charge
2561 // to fit in the histo range [0,300]
2562 //
2563
2564 if (RelativeScale > 0.0) {
2565 fRelativeScale = RelativeScale;
2566 }
2567 else {
2568 AliInfo("RelativeScale must be strict positif!");
d0569428 2569 }
bcb6fb78 2570
2571}
2572//////////////////////////////////////////////////////////////////////////////////
2573// Quick way to fill a histo
2574//////////////////////////////////////////////////////////////////////////////////
2575//_____________________________________________________________________
2576void AliTRDCalibraFillHisto::FillCH2d(Int_t x, Float_t y)
2577{
2578 //
2579 // FillCH2d: Marian style
2580 //
2581
2582 //skip simply the value out of range
2583 if((y>=300.0) || (y<0.0)) return;
2584
2585 //Calcul the y place
2586 Int_t yplace = (Int_t) (fNumberBinCharge*y/300.0)+1;
2587 Int_t place = (fNumberBinCharge+2)*(x+1)+yplace;
d0569428 2588
bcb6fb78 2589 //Fill
2590 fCH2d->GetArray()[place]++;
2591
d0569428 2592}
bcb6fb78 2593
2594//////////////////////////////////////////////////////////////////////////////////
2595// Geometrical functions
2596///////////////////////////////////////////////////////////////////////////////////
d0569428 2597//_____________________________________________________________________________
053767a4 2598Int_t AliTRDCalibraFillHisto::GetLayer(Int_t d) const
d0569428 2599{
2600 //
053767a4 2601 // Reconstruct the layer number from the detector number
d0569428 2602 //
2603
2604 return ((Int_t) (d % 6));
2605
2606}
2607
2608//_____________________________________________________________________________
053767a4 2609Int_t AliTRDCalibraFillHisto::GetStack(Int_t d) const
d0569428 2610{
2611 //
053767a4 2612 // Reconstruct the stack number from the detector number
d0569428 2613 //
053767a4 2614 const Int_t kNlayer = 6;
d0569428 2615
053767a4 2616 return ((Int_t) (d % 30) / kNlayer);
d0569428 2617
2618}
2619
2620//_____________________________________________________________________________
2621Int_t AliTRDCalibraFillHisto::GetSector(Int_t d) const
2622{
2623 //
2624 // Reconstruct the sector number from the detector number
2625 //
2626 Int_t fg = 30;
2627
2628 return ((Int_t) (d / fg));
2629
2630}
bcb6fb78 2631///////////////////////////////////////////////////////////////////////////////////
2632// Getter functions for DAQ of the CH2d and the PH2d
2633//////////////////////////////////////////////////////////////////////////////////
d0569428 2634//_____________________________________________________________________
2635TProfile2D* AliTRDCalibraFillHisto::GetPH2d(Int_t nbtimebin, Float_t samplefrequency)
2636{
2637 //
2638 // return pointer to fPH2d TProfile2D
2639 // create a new TProfile2D if it doesn't exist allready
2640 //
2641 if ( fPH2d )
2642 return fPH2d;
2643
2644 // Some parameters
2645 fTimeMax = nbtimebin;
2646 fSf = samplefrequency;
2647
170c35f1 2648 CreatePH2d(540);
2649
2650 return fPH2d;
2651}
2652//_____________________________________________________________________
bcb6fb78 2653TH2I* AliTRDCalibraFillHisto::GetCH2d()
2654{
2655 //
2656 // return pointer to fCH2d TH2I
2657 // create a new TH2I if it doesn't exist allready
2658 //
2659 if ( fCH2d )
2660 return fCH2d;
2661
2662 CreateCH2d(540);
2663
2664 return fCH2d;
2665}
2666////////////////////////////////////////////////////////////////////////////////////////////
2667// Drift velocity calibration
2668///////////////////////////////////////////////////////////////////////////////////////////
2669//_____________________________________________________________________
170c35f1 2670TLinearFitter* AliTRDCalibraFillHisto::GetLinearFitter(Int_t detector, Bool_t force)
2671{
2672 //
2673 // return pointer to TLinearFitter Calibration
2674 // if force is true create a new TLinearFitter if it doesn't exist allready
2675 //
170c35f1 2676
d0569428 2677 if ((!force) || (fLinearFitterArray.UncheckedAt(detector))){
2678 return (TLinearFitter*)fLinearFitterArray.UncheckedAt(detector);
2679 }
2680
2681 // if we are forced and TLinearFitter doesn't yet exist create it
170c35f1 2682
d0569428 2683 // new TLinearFitter
2684 TLinearFitter *linearfitter = new TLinearFitter(2,"pol1");
2685 fLinearFitterArray.AddAt(linearfitter,detector);
2686 return linearfitter;
170c35f1 2687}
170c35f1 2688
3a0f6479 2689//____________________________________________________________________________
2690void AliTRDCalibraFillHisto::AnalyseLinearFitter()
2691{
2692 //
2693 // Analyse array of linear fitter because can not be written
2694 // Store two arrays: one with the param the other one with the error param + number of entries
2695 //
2696
2697 for(Int_t k = 0; k < 540; k++){
2698 TLinearFitter *linearfitter = GetLinearFitter(k);
2699 if((linearfitter!=0) && (fEntriesLinearFitter[k]>10)){
2700 TVectorD *par = new TVectorD(2);
2701 TVectorD pare = TVectorD(2);
2702 TVectorD *parE = new TVectorD(3);
c1105918 2703 if((linearfitter->EvalRobust(0.8)==0)) {
2704 //linearfitter->Eval();
2705 linearfitter->GetParameters(*par);
2706 //linearfitter->GetErrors(pare);
2707 //Float_t ppointError = TMath::Sqrt(TMath::Abs(linearfitter->GetChisquare())/fEntriesLinearFitter[k]);
2708 //(*parE)[0] = pare[0]*ppointError;
2709 //(*parE)[1] = pare[1]*ppointError;
2710
2711 (*parE)[0] = 0.0;
2712 (*parE)[1] = 0.0;
2713 (*parE)[2] = (Double_t) fEntriesLinearFitter[k];
2714 ((TObjArray *)fLinearVdriftFit->GetPArray())->AddAt(par,k);
2715 ((TObjArray *)fLinearVdriftFit->GetEArray())->AddAt(parE,k);
2716 }
3a0f6479 2717 }
2718 }
1f3c89d8 2719}
1785640c 2720
a2a4ec8e 2721
35a82746 2722