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