]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFtracker.cxx
removed dependence from libANALYSIS for track cuts
[u/mrichter/AliRoot.git] / TOF / AliTOFtracker.cxx
CommitLineData
596a855f 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 **************************************************************************/
0e46b9ae 15
16//--------------------------------------------------------------------//
17// //
18// AliTOFtracker Class //
19// Task: Perform association of the ESD tracks to TOF Clusters //
20// and Update ESD track with associated TOF Cluster parameters //
21// //
22// -- Authors : S. Arcelli, C. Zampolli (Bologna University and INFN) //
23// -- Contacts: Annalisa.De.Caro@cern.ch //
24// -- : Chiara.Zampolli@bo.infn.it //
25// -- : Silvia.Arcelli@bo.infn.it //
26// //
27//--------------------------------------------------------------------//
28
08048cd3 29#include <Rtypes.h>
30#include <TROOT.h>
571dda3d 31
5c7c93fa 32#include <TSeqCollection.h>
08048cd3 33#include <TClonesArray.h>
34#include <TGeoManager.h>
35#include <TTree.h>
36#include <TFile.h>
37#include <TH2F.h>
571dda3d 38
5c7c93fa 39#include "AliGeomManager.h"
0e46b9ae 40#include "AliESDtrack.h"
af885e0f 41#include "AliESDEvent.h"
d076c8d5 42#include "AliLog.h"
0e46b9ae 43#include "AliTrackPointArray.h"
5c7c93fa 44#include "AliCDBManager.h"
596a855f 45
5c7c93fa 46#include "AliTOFpidESD.h"
e0ddb533 47#include "AliTOFRecoParam.h"
3a646035 48#include "AliTOFReconstructor.h"
571dda3d 49#include "AliTOFcluster.h"
ba66add8 50#include "AliTOFGeometry.h"
571dda3d 51#include "AliTOFtracker.h"
0e46b9ae 52#include "AliTOFtrack.h"
571dda3d 53
0e46b9ae 54extern TGeoManager *gGeoManager;
d200609f 55extern TROOT *gROOT;
d4754572 56
596a855f 57ClassImp(AliTOFtracker)
58
74ea065c 59//_____________________________________________________________________________
e0ddb533 60AliTOFtracker::AliTOFtracker():
61 fRecoParam(0x0),
62 fGeom(0x0),
63 fPid(0x0),
58d8d9a3 64 fN(0),
65 fNseeds(0),
66 fNseedsTOF(0),
67 fngoodmatch(0),
68 fnbadmatch(0),
69 fnunmatch(0),
70 fnmatch(0),
9d802709 71 fTracks(new TClonesArray("AliTOFtrack")),
72 fSeeds(new TClonesArray("AliESDtrack")),
5664c6ed 73 fHDigClusMap(0x0),
74 fHDigNClus(0x0),
75 fHDigClusTime(0x0),
76 fHDigClusToT(0x0),
77 fHRecNClus(0x0),
78 fHRecDist(0x0),
79 fHRecSigYVsP(0x0),
80 fHRecSigZVsP(0x0),
81 fHRecSigYVsPWin(0x0),
82 fHRecSigZVsPWin(0x0),
83 fCalTree(0x0),
84 fIch(-1),
85 fToT(-1.),
86 fTime(-1.),
87 fExpTimePi(-1.),
88 fExpTimeKa(-1.),
89 fExpTimePr(-1.)
58d8d9a3 90 {
74ea065c 91 //AliTOFtracker main Ctor
e0ddb533 92
91219c0b 93 // Gettimg the geometry
ba66add8 94 fGeom= new AliTOFGeometry();
3a646035 95
e0ddb533 96 InitCheckHists();
3a646035 97
7aeeaf38 98}
5664c6ed 99//_____________________________________________________________________________
100AliTOFtracker::~AliTOFtracker() {
101 //
102 // Dtor
103 //
e0ddb533 104
5664c6ed 105 SaveCheckHists();
e0ddb533 106
5d456bcd 107 if(!(AliCDBManager::Instance()->GetCacheFlag())){
108 delete fRecoParam;
109 }
e0ddb533 110 delete fGeom;
111 delete fPid;
5664c6ed 112 delete fHDigClusMap;
113 delete fHDigNClus;
114 delete fHDigClusTime;
115 delete fHDigClusToT;
116 delete fHRecNClus;
117 delete fHRecDist;
118 delete fHRecSigYVsP;
119 delete fHRecSigZVsP;
120 delete fHRecSigYVsPWin;
121 delete fHRecSigZVsPWin;
122 delete fCalTree;
9d802709 123 if (fTracks){
124 fTracks->Delete();
125 delete fTracks;
126 fTracks=0x0;
127 }
128 if (fSeeds){
129 fSeeds->Delete();
130 delete fSeeds;
131 fSeeds=0x0;
132 }
133
5664c6ed 134}
74ea065c 135//_____________________________________________________________________________
af885e0f 136Int_t AliTOFtracker::PropagateBack(AliESDEvent* event) {
74ea065c 137 //
138 // Gets seeds from ESD event and Match with TOF Clusters
139 //
140
3a646035 141 // initialize RecoParam for current event
142
143 AliInfo("Initializing params for TOF... ");
144
145 fRecoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER...
90b234fe 146
3a646035 147 if (fRecoParam == 0x0) {
148 AliFatal("No Reco Param found for TOF!!!");
149 }
150 //fRecoParam->Dump();
a825d829 151 //if(fRecoParam->GetApplyPbPbCuts())fRecoParam=fRecoParam->GetPbPbparam();
90b234fe 152 //fRecoParam->PrintParameters();
153
3a646035 154 Double_t parPID[2];
155 parPID[0]=fRecoParam->GetTimeResolution();
156 parPID[1]=fRecoParam->GetTimeNSigma();
157 fPid=new AliTOFpidESD(parPID);
74ea065c 158
159 //Initialise some counters
160
161 fNseeds=0;
162 fNseedsTOF=0;
163 fngoodmatch=0;
164 fnbadmatch=0;
165 fnunmatch=0;
166 fnmatch=0;
167
168 Int_t ntrk=event->GetNumberOfTracks();
169 fNseeds = ntrk;
74ea065c 170 TClonesArray &aESDTrack = *fSeeds;
171
172
173 //Load ESD tracks into a local Array of ESD Seeds
174
175 for (Int_t i=0; i<fNseeds; i++) {
176 AliESDtrack *t=event->GetTrack(i);
177 new(aESDTrack[i]) AliESDtrack(*t);
178 }
179
180 //Prepare ESD tracks candidates for TOF Matching
181 CollectESD();
182
183 //First Step with Strict Matching Criterion
184 MatchTracks(kFALSE);
185
186 //Second Step with Looser Matching Criterion
187 MatchTracks(kTRUE);
188
8a06b2a0 189 AliInfo(Form("Number of matched tracks = %d (good = %d, bad = %d)",fnmatch,fngoodmatch,fnbadmatch));
74ea065c 190
191 //Update the matched ESD tracks
192
193 for (Int_t i=0; i<ntrk; i++) {
194 AliESDtrack *t=event->GetTrack(i);
195 AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
ff826920 196
af61c656 197 if ( (seed->GetStatus()&AliESDtrack::kTOFin)!=0 ) {
198 t->SetStatus(AliESDtrack::kTOFin);
199 //if(seed->GetTOFsignal()>0){
200 if ( (seed->GetStatus()&AliESDtrack::kTOFout)!=0 ) {
201 t->SetStatus(AliESDtrack::kTOFout);
202 t->SetTOFsignal(seed->GetTOFsignal());
203 t->SetTOFcluster(seed->GetTOFcluster());
204 t->SetTOFsignalToT(seed->GetTOFsignalToT());
205 t->SetTOFsignalRaw(seed->GetTOFsignalRaw());
206 t->SetTOFsignalDz(seed->GetTOFsignalDz());
46d7d82e 207 t->SetTOFsignalDx(seed->GetTOFsignalDx());
af61c656 208 t->SetTOFCalChannel(seed->GetTOFCalChannel());
209 Int_t tlab[3]; seed->GetTOFLabel(tlab);
210 t->SetTOFLabel(tlab);
211
e81ea7b6 212 Double_t alphaA = dynamic_cast<AliExternalTrackParam*>(t)->GetAlpha();
213 Double_t xA = dynamic_cast<AliExternalTrackParam*>(t)->GetX();
214 Double_t yA = dynamic_cast<AliExternalTrackParam*>(t)->GetY();
215 Double_t zA = dynamic_cast<AliExternalTrackParam*>(t)->GetZ();
216 Double_t p1A = dynamic_cast<AliExternalTrackParam*>(t)->GetSnp();
217 Double_t p2A = dynamic_cast<AliExternalTrackParam*>(t)->GetTgl();
218 Double_t p3A = dynamic_cast<AliExternalTrackParam*>(t)->GetSigned1Pt();
219 const Double_t *covA = dynamic_cast<AliExternalTrackParam*>(t)->GetCovariance();
220
221 // Make attention, please:
222 // AliESDtrack::fTOFInfo array does not be stored in the AliESDs.root file
223 // it is there only for a check during the reconstruction step.
224 Float_t info[10]; seed->GetTOFInfo(info);
24322e5c 225 t->SetTOFInfo(info);
e81ea7b6 226 AliDebug(3,Form(" distance=%f; residual in the pad reference frame: dX=%f, dZ=%f", info[0],info[1],info[2]));
227
228 // Check done:
229 // by calling the AliESDtrack::UpdateTrackParams,
230 // the current track parameters are changed
231 // and it could cause refit problems.
232 // We need to update only the following track parameters:
233 // the track length and expected times.
234 // Removed AliESDtrack::UpdateTrackParams call
235 // Called AliESDtrack::SetIntegratedTimes(...) and
236 // AliESDtrack::SetIntegratedLength() routines.
237 /*
238 AliTOFtrack *track = new AliTOFtrack(*seed);
239 t->UpdateTrackParams(track,AliESDtrack::kTOFout); // to be checked - AdC
240 delete track;
241 Double_t time[10]; t->GetIntegratedTimes(time);
242 */
243
244 Double_t time[10]; seed->GetIntegratedTimes(time);
245 t->SetIntegratedTimes(time);
246
247 Double_t length = seed->GetIntegratedLength();
248 t->SetIntegratedLength(length);
249
250 Double_t alphaB = dynamic_cast<AliExternalTrackParam*>(t)->GetAlpha();
251 Double_t xB = dynamic_cast<AliExternalTrackParam*>(t)->GetX();
252 Double_t yB = dynamic_cast<AliExternalTrackParam*>(t)->GetY();
253 Double_t zB = dynamic_cast<AliExternalTrackParam*>(t)->GetZ();
254 Double_t p1B = dynamic_cast<AliExternalTrackParam*>(t)->GetSnp();
255 Double_t p2B = dynamic_cast<AliExternalTrackParam*>(t)->GetTgl();
256 Double_t p3B = dynamic_cast<AliExternalTrackParam*>(t)->GetSigned1Pt();
257 const Double_t *covB = dynamic_cast<AliExternalTrackParam*>(t)->GetCovariance();
258 AliDebug(2,"Track params -now(before)-:");
259 AliDebug(2,Form(" X: %f(%f), Y: %f(%f), Z: %f(%f) --- alpha: %f(%f)",
260 xB,xA,
261 yB,yA,
262 zB,zA,
263 alphaB,alphaA));
264 AliDebug(2,Form(" p1: %f(%f), p2: %f(%f), p3: %f(%f)",
265 p1B,p1A,
266 p2B,p2A,
267 p3B,p3A));
268 AliDebug(2,Form(" cov1: %f(%f), cov2: %f(%f), cov3: %f(%f)"
269 " cov4: %f(%f), cov5: %f(%f), cov6: %f(%f)"
270 " cov7: %f(%f), cov8: %f(%f), cov9: %f(%f)"
271 " cov10: %f(%f), cov11: %f(%f), cov12: %f(%f)"
272 " cov13: %f(%f), cov14: %f(%f), cov15: %f(%f)",
273 covB[0],covA[0],
274 covB[1],covA[1],
275 covB[2],covA[2],
276 covB[3],covA[3],
277 covB[4],covA[4],
278 covB[5],covA[5],
279 covB[6],covA[6],
280 covB[7],covA[7],
281 covB[8],covA[8],
282 covB[9],covA[9],
283 covB[10],covA[10],
284 covB[11],covA[11],
285 covB[12],covA[12],
286 covB[13],covA[13],
287 covB[14],covA[14]
288 ));
289 AliDebug(3,Form(" TOF params: %6d %f %f %f %f %f %6d %3d %f %f %f %f %f %f",
af61c656 290 i,
291 t->GetTOFsignalRaw(),
292 t->GetTOFsignal(),
293 t->GetTOFsignalToT(),
294 t->GetTOFsignalDz(),
46d7d82e 295 t->GetTOFsignalDx(),
af61c656 296 t->GetTOFCalChannel(),
297 t->GetTOFcluster(),
298 t->GetIntegratedLength(),
299 time[0], time[1], time[2], time[3], time[4]
300 )
301 );
302 }
74ea065c 303 }
304 }
305
e0ddb533 306 //Handle Time Zero information
91219c0b 307
e0ddb533 308 Double_t timeZero=0.;
309 Double_t timeZeroMax=99999.;
310 Bool_t usetimeZero = fRecoParam->UseTimeZero();
311 Bool_t timeZeroFromT0 = fRecoParam->GetTimeZerofromT0();
312 Bool_t timeZeroFromTOF = fRecoParam->GetTimeZerofromTOF();
91219c0b 313
53884c34 314 AliDebug(2,Form("Use Time Zero?: %d",usetimeZero));
315 AliDebug(2,Form("Time Zero from T0? : %d",timeZeroFromT0));
316 AliDebug(2,Form("Time Zero From TOF? : %d",timeZeroFromTOF));
e0ddb533 317
318 if(usetimeZero){
319 if(timeZeroFromT0){
320 timeZero=GetTimeZerofromT0(event);
321 }
322 if(timeZeroFromTOF && (timeZero>timeZeroMax || !timeZeroFromT0)){
323 timeZero=GetTimeZerofromTOF(event);
324 }
325 }
326 AliDebug(2,Form("time Zero used in PID: %f",timeZero));
74ea065c 327 //Make TOF PID
e0ddb533 328 fPid->MakePID(event,timeZero);
74ea065c 329
9d802709 330 fSeeds->Clear();
331 fTracks->Clear();
74ea065c 332 return 0;
333
334}
335//_________________________________________________________________________
336void AliTOFtracker::CollectESD() {
337 //prepare the set of ESD tracks to be matched to clusters in TOF
5478df1f 338
339 Int_t seedsTOF1=0;
340 Int_t seedsTOF2=0;
74ea065c 341
74ea065c 342 TClonesArray &aTOFTrack = *fTracks;
343 for (Int_t i=0; i<fNseeds; i++) {
344
345 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
346 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
347
56da420e 348 AliTOFtrack *track = new AliTOFtrack(*t); // New
af61c656 349 Float_t x = (Float_t)track->GetX(); //New
350
351 // TRD 'good' tracks, already propagated at 371 cm
352 if ( ( (t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
353 ( x >= AliTOFGeometry::Rmin() ) ) {
354 if ( track->PropagateToInnerTOF() ) {
355
356 AliDebug(1,Form(" TRD propagated track till rho = %fcm."
357 " And then the track has been propagated till rho = %fcm.",
358 x, (Float_t)track->GetX()));
359
360 track->SetSeedIndex(i);
361 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
362 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
363 fNseedsTOF++;
364 seedsTOF1++;
365 }
74ea065c 366 delete track;
367 }
368
369 // Propagate the rest of TPCbp
74ea065c 370 else {
af61c656 371 if ( track->PropagateToInnerTOF() ) {
372
373 AliDebug(1,Form(" TPC propagated track till rho = %fcm."
374 " And then the track has been propagated till rho = %fcm.",
375 x, (Float_t)track->GetX()));
376
74ea065c 377 track->SetSeedIndex(i);
af61c656 378 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
74ea065c 379 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
380 fNseedsTOF++;
5478df1f 381 seedsTOF2++;
74ea065c 382 }
383 delete track;
384 }
385 }
386
8a06b2a0 387 AliInfo(Form("Number of TOF seeds = %d (Type 1 = %d, Type 2 = %d)",fNseedsTOF,seedsTOF1,seedsTOF2));
7b61cd9c 388
74ea065c 389 // Sort according uncertainties on track position
390 fTracks->Sort();
391
392}
393//_________________________________________________________________________
394void AliTOFtracker::MatchTracks( Bool_t mLastStep){
395
e0ddb533 396
397 // Parameters used/regulating the reconstruction
398
399 static Float_t corrLen=0.75;
400 static Float_t detDepth=15.3;
d01bf4f4 401 static Float_t padDepth=0.5;
e0ddb533 402
6819758a 403 const Float_t kSpeedOfLight= 2.99792458e-2; // speed of light [cm/ps]
404 const Float_t kTimeOffset = 32.; // time offset for tracking algorithm [ps]
405
ba66add8 406 Float_t dY=AliTOFGeometry::XPad();
407 Float_t dZ=AliTOFGeometry::ZPad();
e0ddb533 408
409 Float_t sensRadius = fRecoParam->GetSensRadius();
410 Float_t stepSize = fRecoParam->GetStepSize();
411 Float_t scaleFact = fRecoParam->GetWindowScaleFact();
412 Float_t dyMax=fRecoParam->GetWindowSizeMaxY();
413 Float_t dzMax=fRecoParam->GetWindowSizeMaxZ();
414 Float_t dCut=fRecoParam->GetDistanceCut();
ac359ffe 415 Double_t maxChi2=fRecoParam->GetMaxChi2TRD();
e0ddb533 416 Bool_t timeWalkCorr = fRecoParam->GetTimeWalkCorr();
a838421b 417 if(!mLastStep){
418 AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++ \n");
419 AliDebug(1,Form("TOF sens radius: %f",sensRadius));
420 AliDebug(1,Form("TOF step size: %f",stepSize));
421 AliDebug(1,Form("TOF Window scale factor: %f",scaleFact));
422 AliDebug(1,Form("TOF Window max dy: %f",dyMax));
423 AliDebug(1,Form("TOF Window max dz: %f",dzMax));
424 AliDebug(1,Form("TOF distance Cut: %f",dCut));
425 AliDebug(1,Form("TOF Max Chi2: %f",maxChi2));
426 AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr));
427 }
74ea065c 428
53884c34 429 //Match ESD tracks to clusters in TOF
a533f541 430
e0ddb533 431 // Get the number of propagation steps
e0ddb533 432 Int_t nSteps=(Int_t)(detDepth/stepSize);
7bf28302 433
434 //PH Arrays (moved outside of the loop)
435 Float_t * trackPos[4];
436 for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
128563f6 437 Int_t * clind = new Int_t[fN];
74ea065c 438
53884c34 439 // Some init
440 const Int_t kNfoundMax = 10000; // related to nSteps value
441 Int_t index[kNfoundMax];
442 Float_t dist[kNfoundMax];
443 Float_t distZ[kNfoundMax];
24322e5c 444 Float_t distY[kNfoundMax]; // delta(rhoXphi) // AdC
53884c34 445 Float_t cxpos[kNfoundMax];
446 Float_t crecL[kNfoundMax];
447 const Int_t kNclusterMax = 1000; // related to fN value
448 TGeoHMatrix global[kNclusterMax];
449
af61c656 450 //The matching loop
c0545837 451 for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) {
74ea065c 452
53884c34 453 for (Int_t ii=0; ii<kNfoundMax; ii++) {
454 index[ii] = -1;
455 dist[ii] = 9999.;
456 distZ[ii] = 9999.;
24322e5c 457 distY[ii] = 9999.;
53884c34 458 cxpos[ii] = 9999.;
459 crecL[ii] = 0.;
460 }
461 for (Int_t ii=0; ii<kNclusterMax; ii++)
462 global[ii] = 0x0;
463
c0545837 464 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed);
74ea065c 465 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
af61c656 466 //if ( t->GetTOFsignal()>0. ) continue;
467 if ( (t->GetStatus()&AliESDtrack::kTOFout)!=0 ) continue;
74ea065c 468 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
74ea065c 469
74ea065c 470 // Determine a window around the track
74ea065c 471 Double_t x,par[5];
472 trackTOFin->GetExternalParameters(x,par);
473 Double_t cov[15];
474 trackTOFin->GetExternalCovariance(cov);
6c94f330 475
53884c34 476 if (cov[0]<0. || cov[2]<0.) {
477 AliWarning(Form("Very strange track (%d)! At least one of its covariance matrix diagonal elements is negative!",iseed));
ecd795d8 478 //delete trackTOFin;
479 //continue;
53884c34 480 }
481
74ea065c 482 Double_t dphi=
e0ddb533 483 scaleFact*
ecd795d8 484 ((5*TMath::Sqrt(TMath::Abs(cov[0])) + 0.5*dY + 2.5*TMath::Abs(par[2]))/sensRadius);
74ea065c 485 Double_t dz=
e0ddb533 486 scaleFact*
ecd795d8 487 (5*TMath::Sqrt(TMath::Abs(cov[2])) + 0.5*dZ + 2.5*TMath::Abs(par[3]));
6c94f330 488
74ea065c 489 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
490 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
491 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
492 Double_t z=par[1];
493
c0545837 494 //upper limit on window's size.
495
e0ddb533 496 if(dz> dzMax) dz=dzMax;
497 if(dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
c0545837 498
499
74ea065c 500 Int_t nc=0;
7b61cd9c 501
74ea065c 502 // find the clusters in the window of the track
503
504 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
7b61cd9c 505
53884c34 506 if (nc>=kNclusterMax) {
507 AliWarning("No more matchable clusters can be stored! Please, increase the corresponding vectors size.");
508 break;
509 }
510
74ea065c 511 AliTOFcluster *c=fClusters[k];
512 if (c->GetZ() > z+dz) break;
513 if (c->IsUsed()) continue;
11c7ff68 514
17149e6b 515 if (!c->GetStatus()) {
53884c34 516 AliDebug(1,"Cluster in channel declared bad!");
517 continue; // skip bad channels as declared in OCDB
17149e6b 518 }
7b61cd9c 519
74ea065c 520 Double_t dph=TMath::Abs(c->GetPhi()-phi);
521 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
9b49e4c9 522 if (TMath::Abs(dph)>dphi) continue;
ba66add8 523
6c94f330 524 Double_t yc=(c->GetPhi() - trackTOFin->GetAlpha())*c->GetR();
525 Double_t p[2]={yc, c->GetZ()};
3c609b5c 526 Double_t cov2[3]= {dY*dY/12., 0., dZ*dZ/12.};
527 if (trackTOFin->AliExternalTrackParam::GetPredictedChi2(p,cov2) > maxChi2)continue;
6c94f330 528
128563f6 529 clind[nc] = k;
c0545837 530 Char_t path[100];
531 Int_t ind[5];
128563f6 532 ind[0]=c->GetDetInd(0);
533 ind[1]=c->GetDetInd(1);
534 ind[2]=c->GetDetInd(2);
535 ind[3]=c->GetDetInd(3);
536 ind[4]=c->GetDetInd(4);
c0545837 537 fGeom->GetVolumePath(ind,path);
538 gGeoManager->cd(path);
539 global[nc] = *gGeoManager->GetCurrentMatrix();
74ea065c 540 nc++;
541 }
542
53884c34 543 AliDebug(1,Form(" Number of matchable TOF clusters for the track number %d: %d",iseed,nc));
544
74ea065c 545 //start fine propagation
546
547 Int_t nStepsDone = 0;
548 for( Int_t istep=0; istep<nSteps; istep++){
549
ba66add8 550 Float_t xs=AliTOFGeometry::RinTOF()+istep*0.1;
551 Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
74ea065c 552
553 Bool_t skip=kFALSE;
554 Double_t ysect=trackTOFin->GetYat(xs,skip);
6c94f330 555 if (skip) break;
74ea065c 556 if (ysect > ymax) {
ba66add8 557 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
74ea065c 558 break;
559 }
560 } else if (ysect <-ymax) {
13c769b4 561 if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) {
74ea065c 562 break;
563 }
564 }
565
566 if(!trackTOFin->PropagateTo(xs)) {
567 break;
568 }
569
570 nStepsDone++;
571
572 // store the running point (Globalrf) - fine propagation
573
6c94f330 574 Double_t r[3];
575 trackTOFin->GetXYZ(r);
576 trackPos[0][istep]= (Float_t) r[0];
577 trackPos[1][istep]= (Float_t) r[1];
578 trackPos[2][istep]= (Float_t) r[2];
74ea065c 579 trackPos[3][istep]= trackTOFin->GetIntegratedLength();
580 }
581
582
583 Int_t nfound = 0;
d01bf4f4 584 Bool_t accept = kFALSE;
6819758a 585 Bool_t isInside = kFALSE;
74ea065c 586 for (Int_t istep=0; istep<nStepsDone; istep++) {
587
53884c34 588 if (nfound>=kNfoundMax) {
589 AliWarning("No more track positions can be stored! Please, increase the corresponding vectors size.");
590 break;
591 }
74ea065c 592
53884c34 593 Float_t ctrackPos[3];
ff826920 594 ctrackPos[0] = trackPos[0][istep];
595 ctrackPos[1] = trackPos[1][istep];
596 ctrackPos[2] = trackPos[2][istep];
74ea065c 597
598 //now see whether the track matches any of the TOF clusters
599
524da123 600 Float_t dist3d[3];
ff826920 601 accept = kFALSE;
602 for (Int_t i=0; i<nc; i++) {
524da123 603 isInside = fGeom->IsInsideThePad(global[i],ctrackPos,dist3d);
d01bf4f4 604
6819758a 605 if ( mLastStep ) {
606 Float_t yLoc = dist3d[1];
607 Float_t rLoc = TMath::Sqrt(dist3d[0]*dist3d[0]+dist3d[2]*dist3d[2]);
608 accept = (TMath::Abs(yLoc)<padDepth*0.5 && rLoc<dCut);
609 AliDebug(2," I am in the case mLastStep==kTRUE ");
d01bf4f4 610 }
ff826920 611 else {
d01bf4f4 612 accept = isInside;
613 }
ff826920 614 if (accept) {
6819758a 615
616 dist[nfound] = TMath::Sqrt(dist3d[0]*dist3d[0] +
617 dist3d[1]*dist3d[1] +
618 dist3d[2]*dist3d[2]);
53884c34 619 AliDebug(2,Form(" dist3dLoc[0] = %f, dist3dLoc[1] = %f, dist3dLoc[2] = %f ",
6819758a 620 dist3d[0],dist3d[1],dist3d[2]));
621 distZ[nfound] = dist3d[2]; // Z distance in the RF of the
622 // hit pad closest to the
623 // reconstructed track
24322e5c 624 distY[nfound] = dist3d[0]; // X distance in the RF of the
625 // hit pad closest to the
626 // reconstructed track
627 // It corresponds to Y coordinate
628 // in tracking RF
629
6819758a 630
24322e5c 631 AliDebug(2,Form(" dist3dLoc[0] = %f --- distY[%d] = %f",
632 dist3d[0],nfound,distY[nfound]));
53884c34 633 AliDebug(2,Form(" dist3dLoc[2] = %f --- distZ[%d] = %f",
6819758a 634 dist3d[2],nfound,distZ[nfound]));
635
24322e5c 636
ff826920 637 crecL[nfound] = trackPos[3][istep];
638 index[nfound] = clind[i]; // store cluster id
639 cxpos[nfound] = AliTOFGeometry::RinTOF()+istep*0.1; //store prop.radius
74ea065c 640 nfound++;
d01bf4f4 641 if(accept &&!mLastStep)break;
74ea065c 642 }//end if accept
524da123 643
74ea065c 644 } //end for on the clusters
d01bf4f4 645 if(accept &&!mLastStep)break;
74ea065c 646 } //end for on the steps
647
53884c34 648 AliDebug(1,Form(" Number of track points for the track number %d: %d",iseed,nfound));
9b49e4c9 649
650
74ea065c 651 if (nfound == 0 ) {
652 fnunmatch++;
7bf28302 653 delete trackTOFin;
74ea065c 654 continue;
655 }
656
657 fnmatch++;
658
659 // now choose the cluster to be matched with the track.
660
90b234fe 661 Int_t idclus=-1;
74ea065c 662 Float_t recL = 0.;
663 Float_t xpos=0.;
664 Float_t mindist=1000.;
e0ddb533 665 Float_t mindistZ=0.;
24322e5c 666 Float_t mindistY=0.;
74ea065c 667 for (Int_t iclus= 0; iclus<nfound;iclus++){
668 if (dist[iclus]< mindist){
669 mindist = dist[iclus];
6819758a 670 mindistZ = distZ[iclus]; // Z distance in the RF of the hit
671 // pad closest to the reconstructed
672 // track
24322e5c 673 mindistY = distY[iclus]; // Y distance in the RF of the hit
674 // pad closest to the reconstructed
675 // track
74ea065c 676 xpos = cxpos[iclus];
677 idclus =index[iclus];
e0ddb533 678 recL=crecL[iclus]+corrLen*0.5;
74ea065c 679 }
680 }
681
d01bf4f4 682
74ea065c 683 AliTOFcluster *c=fClusters[idclus];
6819758a 684 /*
685 Float_t tiltangle = AliTOFGeometry::GetAngles(c->GetDetInd(1),c->GetDetInd(2))*TMath::DegToRad();
686 Float_t localCheck=-mindistZ;
687 localCheck/=TMath::Cos(tiltangle); // Z (tracking/ALICE RF) component of
688 // the distance between the
689 // reconstructed track and the
690 // TOF closest cluster
691 */
692 AliDebug(2, Form("%7d %7d %10d %10d %10d %10d %7d",
32ead898 693 iseed,
3a646035 694 fnmatch-1,
32ead898 695 TMath::Abs(trackTOFin->GetLabel()),
696 c->GetLabel(0), c->GetLabel(1), c->GetLabel(2),
697 idclus)); // AdC
698
e0ddb533 699 c->Use();
74ea065c 700
701 // Track length correction for matching Step 2
702
703 if(mLastStep){
704 Float_t rc=TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ());
705 Float_t rt=TMath::Sqrt(trackPos[0][70]*trackPos[0][70]
706 +trackPos[1][70]*trackPos[1][70]
707 +trackPos[2][70]*trackPos[2][70]);
708 Float_t dlt=rc-rt;
709 recL=trackPos[3][70]+dlt;
710 }
711
712 if (
713 (c->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
714 ||
715 (c->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
716 ||
717 (c->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
718 ) {
719 fngoodmatch++;
d3c7bfac 720
6819758a 721 AliDebug(2,Form(" track label good %5d",trackTOFin->GetLabel()));
d3c7bfac 722
74ea065c 723 }
53884c34 724 else {
74ea065c 725 fnbadmatch++;
d3c7bfac 726
6819758a 727 AliDebug(2,Form(" track label bad %5d",trackTOFin->GetLabel()));
d3c7bfac 728
74ea065c 729 }
730
731 delete trackTOFin;
732
a533f541 733 // Store quantities to be used in the TOF Calibration
ba66add8 734 Float_t tToT=AliTOFGeometry::ToTBinWidth()*c->GetToT()*1E-3; // in ns
7aeeaf38 735 t->SetTOFsignalToT(tToT);
6819758a 736 Float_t rawTime=AliTOFGeometry::TdcBinWidth()*c->GetTDCRAW()+kTimeOffset; // RAW time,in ps
d321691a 737 t->SetTOFsignalRaw(rawTime);
738 t->SetTOFsignalDz(mindistZ);
46d7d82e 739 t->SetTOFsignalDx(mindistY);
6819758a 740
24322e5c 741 Float_t info[10] = {mindist,mindistY,mindistZ,
742 0.,0.,0.,0.,0.,0.,0.};
743 t->SetTOFInfo(info);
744 AliDebug(2,Form(" distance=%f; residual in the pad reference frame: dX=%f, dZ=%f", info[0],info[1],info[2]));
745
746
a533f541 747 Int_t ind[5];
748 ind[0]=c->GetDetInd(0);
749 ind[1]=c->GetDetInd(1);
750 ind[2]=c->GetDetInd(2);
751 ind[3]=c->GetDetInd(3);
752 ind[4]=c->GetDetInd(4);
ba66add8 753 Int_t calindex = AliTOFGeometry::GetIndex(ind);
a533f541 754 t->SetTOFCalChannel(calindex);
11c7ff68 755
756 // keep track of the track labels in the matched cluster
757 Int_t tlab[3];
758 tlab[0]=c->GetLabel(0);
759 tlab[1]=c->GetLabel(1);
760 tlab[2]=c->GetLabel(2);
6819758a 761 AliDebug(2,Form(" tdc time of the matched track %6d = ",c->GetTDC()));
762 Double_t tof=AliTOFGeometry::TdcBinWidth()*c->GetTDC()+kTimeOffset; // in ps
5478df1f 763 AliDebug(2,Form(" tof time of the matched track: %f = ",tof));
5478df1f 764 Double_t tofcorr=tof;
765 if(timeWalkCorr)tofcorr=CorrectTimeWalk(mindistZ,tof);
766 AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr));
767 //Set TOF time signal and pointer to the matched cluster
768 t->SetTOFsignal(tofcorr);
ee77ad87 769 t->SetTOFcluster(idclus); // pointing to the recPoints tree
5478df1f 770
6819758a 771 AliDebug(2,Form(" Setting TOF raw time: %f, z distance: %f corrected time: %f ",rawTime,mindistZ,tofcorr));
772
5478df1f 773 //Tracking info
6819758a 774 Double_t time[AliPID::kSPECIES]; t->GetIntegratedTimes(time); // in ps
74ea065c 775 Double_t mom=t->GetP();
53884c34 776 AliDebug(2,Form(" Momentum for track %d -> %f", iseed,mom));
777 for (Int_t j=0;j<AliPID::kSPECIES;j++) {
304864ab 778 Double_t mass=AliPID::ParticleMass(j);
6819758a 779 time[j]+=(recL-trackPos[3][0])/kSpeedOfLight*TMath::Sqrt(mom*mom+mass*mass)/mom;
74ea065c 780 }
781
782 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
783 trackTOFout->PropagateTo(xpos);
77a9ea9a 784
785 // Fill the track residual histograms.
786 FillResiduals(trackTOFout,c,kFALSE);
787
af61c656 788 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
74ea065c 789 t->SetIntegratedLength(recL);
790 t->SetIntegratedTimes(time);
11c7ff68 791 t->SetTOFLabel(tlab);
5478df1f 792
793
5664c6ed 794 // Fill Reco-QA histos for Reconstruction
795 fHRecNClus->Fill(nc);
796 fHRecDist->Fill(mindist);
797 fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0]));
798 fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2]));
e0ddb533 799 fHRecSigYVsPWin->Fill(mom,dphi*sensRadius);
5664c6ed 800 fHRecSigZVsPWin->Fill(mom,dz);
801
802 // Fill Tree for on-the-fly offline Calibration
803
53884c34 804 if ( !((t->GetStatus() & AliESDtrack::kTIME)==0 ) ) {
5664c6ed 805 fIch=calindex;
806 fToT=tToT;
5478df1f 807 fTime=rawTime;
5664c6ed 808 fExpTimePi=time[2];
809 fExpTimeKa=time[3];
810 fExpTimePr=time[4];
811 fCalTree->Fill();
812 }
74ea065c 813 delete trackTOFout;
814 }
7bf28302 815 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
128563f6 816 delete [] clind;
ba66add8 817
74ea065c 818}
819//_________________________________________________________________________
7b61cd9c 820Int_t AliTOFtracker::LoadClusters(TTree *cTree) {
74ea065c 821 //--------------------------------------------------------------------
822 //This function loads the TOF clusters
823 //--------------------------------------------------------------------
824
ba66add8 825 Int_t npadX = AliTOFGeometry::NpadX();
826 Int_t npadZ = AliTOFGeometry::NpadZ();
827 Int_t nStripA = AliTOFGeometry::NStripA();
828 Int_t nStripB = AliTOFGeometry::NStripB();
829 Int_t nStripC = AliTOFGeometry::NStripC();
5664c6ed 830
7b61cd9c 831 TBranch *branch=cTree->GetBranch("TOF");
74ea065c 832 if (!branch) {
7b61cd9c 833 AliError("can't get the branch with the TOF clusters !");
74ea065c 834 return 1;
835 }
836
9d802709 837 static TClonesArray dummy("AliTOFcluster",10000);
838 dummy.Clear();
839 TClonesArray *clusters=&dummy;
7b61cd9c 840 branch->SetAddress(&clusters);
74ea065c 841
7b61cd9c 842 cTree->GetEvent(0);
843 Int_t nc=clusters->GetEntriesFast();
5664c6ed 844 fHDigNClus->Fill(nc);
845
7b61cd9c 846 AliInfo(Form("Number of clusters: %d",nc));
74ea065c 847
7b61cd9c 848 for (Int_t i=0; i<nc; i++) {
849 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
16a2e36a 850//PH fClusters[i]=new AliTOFcluster(*c); fN++;
851 fClusters[i]=c; fN++;
5664c6ed 852
853 // Fill Digits QA histos
854
855 Int_t isector = c->GetDetInd(0);
856 Int_t iplate = c->GetDetInd(1);
857 Int_t istrip = c->GetDetInd(2);
858 Int_t ipadX = c->GetDetInd(4);
859 Int_t ipadZ = c->GetDetInd(3);
860
ba66add8 861 Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns
862 Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns
5664c6ed 863
864 Int_t stripOffset = 0;
865 switch (iplate) {
866 case 0:
867 stripOffset = 0;
868 break;
869 case 1:
870 stripOffset = nStripC;
871 break;
872 case 2:
873 stripOffset = nStripC+nStripB;
874 break;
875 case 3:
876 stripOffset = nStripC+nStripB+nStripA;
877 break;
878 case 4:
879 stripOffset = nStripC+nStripB+nStripA+nStripB;
880 break;
881 default:
882 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
883 break;
884 };
885 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
886 Int_t phiindex=npadX*isector+ipadX+1;
887 fHDigClusMap->Fill(zindex,phiindex);
888 fHDigClusTime->Fill(time);
889 fHDigClusToT->Fill(tot);
890
7b61cd9c 891 }
74ea065c 892
74ea065c 893
894 return 0;
895}
896//_________________________________________________________________________
897void AliTOFtracker::UnloadClusters() {
898 //--------------------------------------------------------------------
899 //This function unloads TOF clusters
900 //--------------------------------------------------------------------
7b61cd9c 901 for (Int_t i=0; i<fN; i++) {
16a2e36a 902//PH delete fClusters[i];
7b61cd9c 903 fClusters[i] = 0x0;
74ea065c 904 }
7b61cd9c 905 fN=0;
74ea065c 906}
907
908//_________________________________________________________________________
909Int_t AliTOFtracker::FindClusterIndex(Double_t z) const {
910 //--------------------------------------------------------------------
911 // This function returns the index of the nearest cluster
912 //--------------------------------------------------------------------
913 if (fN==0) return 0;
914 if (z <= fClusters[0]->GetZ()) return 0;
915 if (z > fClusters[fN-1]->GetZ()) return fN;
916 Int_t b=0, e=fN-1, m=(b+e)/2;
917 for (; b<e; m=(b+e)/2) {
918 if (z > fClusters[m]->GetZ()) b=m+1;
919 else e=m;
920 }
921 return m;
922}
d4754572 923
924//_________________________________________________________________________
925Bool_t AliTOFtracker::GetTrackPoint(Int_t index, AliTrackPoint& p) const
926{
927 // Get track space point with index i
928 // Coordinates are in the global system
929 AliTOFcluster *cl = fClusters[index];
930 Float_t xyz[3];
931 xyz[0] = cl->GetR()*TMath::Cos(cl->GetPhi());
932 xyz[1] = cl->GetR()*TMath::Sin(cl->GetPhi());
933 xyz[2] = cl->GetZ();
468f26c6 934 Float_t phiangle = (Int_t(cl->GetPhi()*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
935 Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
ba66add8 936 Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
468f26c6 937 Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
ba66add8 938 Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
939 Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
468f26c6 940 Float_t cov[6];
941 cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
942 cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
943 cov[2] = -cosphi*sinth*costh*sigmaz2;
944 cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
945 cov[4] = -sinphi*sinth*costh*sigmaz2;
946 cov[5] = costh*costh*sigmaz2;
947 p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
d4754572 948
949 // Detector numbering scheme
ba66add8 950 Int_t nSector = AliTOFGeometry::NSectors();
951 Int_t nPlate = AliTOFGeometry::NPlates();
952 Int_t nStripA = AliTOFGeometry::NStripA();
953 Int_t nStripB = AliTOFGeometry::NStripB();
954 Int_t nStripC = AliTOFGeometry::NStripC();
d4754572 955
956 Int_t isector = cl->GetDetInd(0);
957 if (isector >= nSector)
958 AliError(Form("Wrong sector number in TOF (%d) !",isector));
959 Int_t iplate = cl->GetDetInd(1);
960 if (iplate >= nPlate)
961 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
962 Int_t istrip = cl->GetDetInd(2);
963
964 Int_t stripOffset = 0;
965 switch (iplate) {
966 case 0:
967 stripOffset = 0;
968 break;
969 case 1:
970 stripOffset = nStripC;
971 break;
972 case 2:
973 stripOffset = nStripC+nStripB;
974 break;
975 case 3:
976 stripOffset = nStripC+nStripB+nStripA;
977 break;
978 case 4:
979 stripOffset = nStripC+nStripB+nStripA+nStripB;
980 break;
981 default:
982 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
983 break;
984 };
985
986 Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
987 stripOffset +
988 istrip;
ae079791 989 UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
d4754572 990 p.SetVolumeID((UShort_t)volid);
991 return kTRUE;
992}
5664c6ed 993//_________________________________________________________________________
994void AliTOFtracker::InitCheckHists() {
995
996 //Init histos for Digits/Reco QA and Calibration
997
998
0366f10f 999 TDirectory *dir = gDirectory;
1000 TFile *logFileTOF = 0;
1001
1002 TSeqCollection *list = gROOT->GetListOfFiles();
1003 int n = list->GetEntries();
1004 Bool_t isThere=kFALSE;
1005 for(int i=0; i<n; i++) {
1006 logFileTOF = (TFile*)list->At(i);
1007 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
1008 isThere=kTRUE;
1009 break;
1010 }
1011 }
1012
1013 if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
1014 logFileTOF->cd();
1015
5664c6ed 1016 fCalTree = new TTree("CalTree", "Tree for TOF calibration");
1017 fCalTree->Branch("TOFchannelindex",&fIch,"iTOFch/I");
1018 fCalTree->Branch("ToT",&fToT,"TOFToT/F");
1019 fCalTree->Branch("TOFtime",&fTime,"TOFtime/F");
1020 fCalTree->Branch("PionExpTime",&fExpTimePi,"PiExpTime/F");
1021 fCalTree->Branch("KaonExpTime",&fExpTimeKa,"KaExpTime/F");
1022 fCalTree->Branch("ProtonExpTime",&fExpTimePr,"PrExpTime/F");
1023
1024 //Digits "QA"
1025 fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);
1026 fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);
1027 fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);
1028 fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);
1029
1030 //Reco "QA"
1031 fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
1032 fHRecDist=new TH1F("TOFRec_Dist", "",50,0.5,10.5);
1033 fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
1034 fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
1035 fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
1036 fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
0366f10f 1037
1038 dir->cd();
1039
5664c6ed 1040}
1041
1042//_________________________________________________________________________
1043void AliTOFtracker::SaveCheckHists() {
1044
1045 //write histos for Digits/Reco QA and Calibration
1046
1047 TDirectory *dir = gDirectory;
5664c6ed 1048 TFile *logFileTOF = 0;
1049
1050 TSeqCollection *list = gROOT->GetListOfFiles();
d200609f 1051 int n = list->GetEntries();
5664c6ed 1052 Bool_t isThere=kFALSE;
d200609f 1053 for(int i=0; i<n; i++) {
5664c6ed 1054 logFileTOF = (TFile*)list->At(i);
1055 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
1056 isThere=kTRUE;
1057 break;
1058 }
1059 }
1060
0366f10f 1061 if(!isThere) {
1062 AliError(Form("File TOFQA.root not found!! not wring histograms...."));
1063 return;
1064 }
5664c6ed 1065 logFileTOF->cd();
1066 fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
1067 fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
1068 fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
1069 fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
1070 fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
1071 fHRecDist->Write(fHRecDist->GetName(), TObject::kOverwrite);
1072 fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
1073 fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
1074 fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
1075 fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
1076 fCalTree->Write(fCalTree->GetName(),TObject::kOverwrite);
1077 logFileTOF->Flush();
1078
1079 dir->cd();
1080 }
e0ddb533 1081//_________________________________________________________________________
1082Float_t AliTOFtracker::CorrectTimeWalk( Float_t dist, Float_t tof) {
1083
1084 //dummy, for the moment
1085 Float_t tofcorr=0.;
ba66add8 1086 if(dist<AliTOFGeometry::ZPad()*0.5){
e0ddb533 1087 tofcorr=tof;
1088 //place here the actual correction
1089 }else{
1090 tofcorr=tof;
1091 }
1092 return tofcorr;
1093}
1094//_________________________________________________________________________
af885e0f 1095Float_t AliTOFtracker::GetTimeZerofromT0(AliESDEvent *event) const {
e0ddb533 1096
1097 //Returns TimeZero as measured by T0 detector
1098
1099 return event->GetT0();
1100}
1101//_________________________________________________________________________
af885e0f 1102Float_t AliTOFtracker::GetTimeZerofromTOF(AliESDEvent * /*event*/) const {
e0ddb533 1103
1104 //dummy, for the moment. T0 algorithm using tracks on TOF
1105 {
1106 //place T0 algo here...
1107 }
1108 return 0.;
1109}
128563f6 1110//_________________________________________________________________________
1111
1112void AliTOFtracker::FillClusterArray(TObjArray* arr) const
1113{
1114 //
1115 // Returns the TOF cluster array
1116 //
1117
1118 if (fN==0)
1119 arr = 0x0;
1120 else
1121 for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);
1122
1123}
ff826920 1124//_________________________________________________________________________
1125