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