]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AOD/AliAODTrack.cxx
From Levente: Require z vertex within ± 10 cm and require ITS+TPC refit for tracks
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODTrack.cxx
CommitLineData
df9db588 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//-------------------------------------------------------------------------
4f6e22bd 19// AOD track implementation of AliVTrack
df9db588 20// Author: Markus Oldenburg, CERN
0c5f89fb 21// Markus.Oldenburg@cern.ch
df9db588 22//-------------------------------------------------------------------------
23
8ac4fa64 24#include "AliLog.h"
6dc40b1c 25#include "AliExternalTrackParam.h"
26#include "AliVVertex.h"
df9db588 27#include "AliAODTrack.h"
28
29ClassImp(AliAODTrack)
30
31//______________________________________________________________________________
32AliAODTrack::AliAODTrack() :
4f6e22bd 33 AliVTrack(),
f43586f0 34 fRAtAbsorberEnd(0.),
1912763f 35 fChi2perNDF(-999.),
9333290e 36 fChi2MatchTrigger(0.),
6efb741f 37 fFlags(0),
df9db588 38 fLabel(-999),
1912763f 39 fITSMuonClusterMap(0),
9333290e 40 fFilterMap(0),
d999f2e6 41 fTPCClusterMap(),
42 fTPCSharedMap(),
3c01c166 43 fTPCnclsF(0),
02153d58 44 fID(-999),
9333290e 45 fCharge(-99),
e1c744ca 46 fType(kUndef),
a7d9ab9e 47 fCaloIndex(kEMCALNoMatch),
9333290e 48 fCovMatrix(NULL),
7be1db84 49 fDetPid(NULL),
50 fProdVertex(NULL)
df9db588 51{
52 // default constructor
53
54 SetP();
55 SetPosition((Float_t*)NULL);
6c954176 56 SetXYAtDCA(-999., -999.);
57 SetPxPyPzAtDCA(-999., -999., -999.);
df9db588 58 SetPID((Float_t*)NULL);
59}
60
61//______________________________________________________________________________
02153d58 62AliAODTrack::AliAODTrack(Short_t id,
df9db588 63 Int_t label,
64 Double_t p[3],
65 Bool_t cartesian,
66 Double_t x[3],
67 Bool_t isDCA,
68 Double_t covMatrix[21],
69 Short_t charge,
70 UChar_t itsClusMap,
71 Double_t pid[10],
72 AliAODVertex *prodVertex,
1912763f 73 Bool_t usedForVtxFit,
dc825b15 74 Bool_t usedForPrimVtxFit,
ec40c484 75 AODTrk_t ttype,
862ce351 76 UInt_t selectInfo,
77 Float_t chi2perNDF) :
4f6e22bd 78 AliVTrack(),
f43586f0 79 fRAtAbsorberEnd(0.),
862ce351 80 fChi2perNDF(chi2perNDF),
9333290e 81 fChi2MatchTrigger(0.),
6efb741f 82 fFlags(0),
df9db588 83 fLabel(label),
6c954176 84 fITSMuonClusterMap(0),
9333290e 85 fFilterMap(selectInfo),
d999f2e6 86 fTPCClusterMap(),
87 fTPCSharedMap(),
3c01c166 88 fTPCnclsF(0),
02153d58 89 fID(id),
9333290e 90 fCharge(charge),
e1c744ca 91 fType(ttype),
a7d9ab9e 92 fCaloIndex(kEMCALNoMatch),
9333290e 93 fCovMatrix(NULL),
7be1db84 94 fDetPid(NULL),
9333290e 95 fProdVertex(prodVertex)
df9db588 96{
97 // constructor
98
99 SetP(p, cartesian);
100 SetPosition(x, isDCA);
6c954176 101 SetXYAtDCA(-999., -999.);
102 SetPxPyPzAtDCA(-999., -999., -999.);
1912763f 103 SetUsedForVtxFit(usedForVtxFit);
dc825b15 104 SetUsedForPrimVtxFit(usedForPrimVtxFit);
df9db588 105 if(covMatrix) SetCovMatrix(covMatrix);
106 SetPID(pid);
6c954176 107 SetITSClusterMap(itsClusMap);
df9db588 108}
109
110//______________________________________________________________________________
02153d58 111AliAODTrack::AliAODTrack(Short_t id,
df9db588 112 Int_t label,
113 Float_t p[3],
114 Bool_t cartesian,
115 Float_t x[3],
116 Bool_t isDCA,
117 Float_t covMatrix[21],
118 Short_t charge,
119 UChar_t itsClusMap,
120 Float_t pid[10],
121 AliAODVertex *prodVertex,
1912763f 122 Bool_t usedForVtxFit,
dc825b15 123 Bool_t usedForPrimVtxFit,
ec40c484 124 AODTrk_t ttype,
862ce351 125 UInt_t selectInfo,
126 Float_t chi2perNDF) :
4f6e22bd 127 AliVTrack(),
f43586f0 128 fRAtAbsorberEnd(0.),
862ce351 129 fChi2perNDF(chi2perNDF),
9333290e 130 fChi2MatchTrigger(0.),
6efb741f 131 fFlags(0),
df9db588 132 fLabel(label),
6c954176 133 fITSMuonClusterMap(0),
9333290e 134 fFilterMap(selectInfo),
d999f2e6 135 fTPCClusterMap(),
136 fTPCSharedMap(),
3c01c166 137 fTPCnclsF(0),
02153d58 138 fID(id),
9333290e 139 fCharge(charge),
e1c744ca 140 fType(ttype),
a7d9ab9e 141 fCaloIndex(kEMCALNoMatch),
9333290e 142 fCovMatrix(NULL),
7be1db84 143 fDetPid(NULL),
9333290e 144 fProdVertex(prodVertex)
df9db588 145{
146 // constructor
147
148 SetP(p, cartesian);
149 SetPosition(x, isDCA);
6c954176 150 SetXYAtDCA(-999., -999.);
151 SetPxPyPzAtDCA(-999., -999., -999.);
1912763f 152 SetUsedForVtxFit(usedForVtxFit);
dc825b15 153 SetUsedForPrimVtxFit(usedForPrimVtxFit);
df9db588 154 if(covMatrix) SetCovMatrix(covMatrix);
155 SetPID(pid);
6c954176 156 SetITSClusterMap(itsClusMap);
df9db588 157}
158
df9db588 159//______________________________________________________________________________
160AliAODTrack::~AliAODTrack()
161{
162 // destructor
163 delete fCovMatrix;
7450f8ab 164 delete fDetPid;
df9db588 165}
166
167
168//______________________________________________________________________________
169AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
4f6e22bd 170 AliVTrack(trk),
f43586f0 171 fRAtAbsorberEnd(trk.fRAtAbsorberEnd),
1912763f 172 fChi2perNDF(trk.fChi2perNDF),
9333290e 173 fChi2MatchTrigger(trk.fChi2MatchTrigger),
6efb741f 174 fFlags(trk.fFlags),
df9db588 175 fLabel(trk.fLabel),
1912763f 176 fITSMuonClusterMap(trk.fITSMuonClusterMap),
9333290e 177 fFilterMap(trk.fFilterMap),
d999f2e6 178 fTPCClusterMap(trk.fTPCClusterMap),
179 fTPCSharedMap(trk.fTPCSharedMap),
3c01c166 180 fTPCnclsF(trk.fTPCnclsF),
02153d58 181 fID(trk.fID),
9333290e 182 fCharge(trk.fCharge),
e1c744ca 183 fType(trk.fType),
a7d9ab9e 184 fCaloIndex(trk.fCaloIndex),
9333290e 185 fCovMatrix(NULL),
7be1db84 186 fDetPid(NULL),
9333290e 187 fProdVertex(trk.fProdVertex)
df9db588 188{
189 // Copy constructor
190
191 trk.GetP(fMomentum);
192 trk.GetPosition(fPosition);
6c954176 193 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
194 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
1912763f 195 SetUsedForVtxFit(trk.GetUsedForVtxFit());
dc825b15 196 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
5d62ce04 197 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
7be1db84 198 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
df9db588 199 SetPID(trk.fPID);
df9db588 200}
201
202//______________________________________________________________________________
203AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
204{
205 // Assignment operator
206 if(this!=&trk) {
207
4f6e22bd 208 AliVTrack::operator=(trk);
df9db588 209
210 trk.GetP(fMomentum);
211 trk.GetPosition(fPosition);
212 trk.GetPID(fPID);
213
6c954176 214 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
215 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
216
f43586f0 217 fRAtAbsorberEnd = trk.fRAtAbsorberEnd;
218
1912763f 219 fChi2perNDF = trk.fChi2perNDF;
9333290e 220 fChi2MatchTrigger = trk.fChi2MatchTrigger;
df9db588 221
6efb741f 222 fFlags = trk.fFlags;
df9db588 223 fLabel = trk.fLabel;
224
9333290e 225 fITSMuonClusterMap = trk.fITSMuonClusterMap;
226 fFilterMap = trk.fFilterMap;
227
6efb741f 228 fID = trk.fID;
229
9333290e 230 fCharge = trk.fCharge;
231 fType = trk.fType;
232
a7d9ab9e 233 fCaloIndex = trk.fCaloIndex;
234
df9db588 235 delete fCovMatrix;
5d62ce04 236 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
df9db588 237 else fCovMatrix=NULL;
238 fProdVertex = trk.fProdVertex;
239
1912763f 240 SetUsedForVtxFit(trk.GetUsedForVtxFit());
dc825b15 241 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
7be1db84 242
243 delete fDetPid;
244 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
245 else fDetPid=NULL;
df9db588 246 }
247
248 return *this;
249}
250
4697e4fb 251//______________________________________________________________________________
252Double_t AliAODTrack::M(AODTrkPID_t pid) const
253{
254 // Returns the mass.
9861edc0 255 // Masses for nuclei don't exist in the PDG tables, therefore they were put by hand.
4697e4fb 256
257 switch (pid) {
258
259 case kElectron :
9861edc0 260 return 0.000510999; //TDatabasePDG::Instance()->GetParticle(11/*::kElectron*/)->Mass();
4697e4fb 261 break;
262
263 case kMuon :
9861edc0 264 return 0.1056584; //TDatabasePDG::Instance()->GetParticle(13/*::kMuonMinus*/)->Mass();
4697e4fb 265 break;
266
267 case kPion :
9861edc0 268 return 0.13957; //TDatabasePDG::Instance()->GetParticle(211/*::kPiPlus*/)->Mass();
4697e4fb 269 break;
270
271 case kKaon :
9861edc0 272 return 0.4937; //TDatabasePDG::Instance()->GetParticle(321/*::kKPlus*/)->Mass();
4697e4fb 273 break;
274
275 case kProton :
9861edc0 276 return 0.9382720; //TDatabasePDG::Instance()->GetParticle(2212/*::kProton*/)->Mass();
4697e4fb 277 break;
278
279 case kDeuteron :
9861edc0 280 return 1.8756; //TDatabasePDG::Instance()->GetParticle(1000010020)->Mass();
4697e4fb 281 break;
282
283 case kTriton :
9861edc0 284 return 2.8089; //TDatabasePDG::Instance()->GetParticle(1000010030)->Mass();
4697e4fb 285 break;
286
287 case kHelium3 :
9861edc0 288 return 2.8084; //TDatabasePDG::Instance()->GetParticle(1000020030)->Mass();
4697e4fb 289 break;
290
291 case kAlpha :
9861edc0 292 return 3.7274; //TDatabasePDG::Instance()->GetParticle(1000020040)->Mass();
4697e4fb 293 break;
294
295 case kUnknown :
296 return -999.;
297 break;
298
299 default :
300 return -999.;
301 }
302}
303
304//______________________________________________________________________________
305Double_t AliAODTrack::E(AODTrkPID_t pid) const
306{
307 // Returns the energy of the particle of a given pid.
308
309 if (pid != kUnknown) { // particle was identified
310 Double_t m = M(pid);
311 return TMath::Sqrt(P()*P() + m*m);
312 } else { // pid unknown
313 return -999.;
314 }
315}
316
317//______________________________________________________________________________
318Double_t AliAODTrack::Y(AODTrkPID_t pid) const
319{
9861edc0 320 // Returns the rapidity of a particle of a given pid.
4697e4fb 321
322 if (pid != kUnknown) { // particle was identified
323 Double_t e = E(pid);
324 Double_t pz = Pz();
325 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
326 return 0.5*TMath::Log((e+pz)/(e-pz));
327 } else { // energy not known or equal to pz
328 return -999.;
329 }
330 } else { // pid unknown
331 return -999.;
332 }
333}
334
335//______________________________________________________________________________
336Double_t AliAODTrack::Y(Double_t m) const
337{
9861edc0 338 // Returns the rapidity of a particle of a given mass.
4697e4fb 339
340 if (m >= 0.) { // mass makes sense
341 Double_t e = E(m);
342 Double_t pz = Pz();
343 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
344 return 0.5*TMath::Log((e+pz)/(e-pz));
345 } else { // energy not known or equal to pz
346 return -999.;
347 }
348 } else { // pid unknown
349 return -999.;
350 }
351}
352
353//______________________________________________________________________________
354AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
355{
356 // Returns the most probable PID array element.
357
358 Int_t nPID = 10;
7ba6f91a 359 AODTrkPID_t loc = kUnknown;
360 Double_t max = 0.;
361 Bool_t allTheSame = kTRUE;
362
363 for (Int_t iPID = 0; iPID < nPID; iPID++) {
364 if (fPID[iPID] >= max) {
365 if (fPID[iPID] > max) {
366 allTheSame = kFALSE;
367 max = fPID[iPID];
368 loc = (AODTrkPID_t)iPID;
369 } else {
370 allTheSame = kTRUE;
4697e4fb 371 }
372 }
4697e4fb 373 }
7ba6f91a 374 return allTheSame ? kUnknown : loc;
4697e4fb 375}
376
377//______________________________________________________________________________
378void AliAODTrack::ConvertAliPIDtoAODPID()
379{
380 // Converts AliPID array.
381 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
382 // Everything else has to be set to zero.
383
384 fPID[kDeuteron] = 0.;
8a1418dc 385 fPID[kTriton] = 0.;
386 fPID[kHelium3] = 0.;
387 fPID[kAlpha] = 0.;
388 fPID[kUnknown] = 0.;
4697e4fb 389
390 return;
391}
392
393
df9db588 394//______________________________________________________________________________
395template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
396{
8a1418dc 397 // Set the momentum
df9db588 398
399 if (p) {
400 if (cartesian) {
16b65f2a 401 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
0c5f89fb 402 Double_t pp = TMath::Sqrt(pt2 + p[2]*p[2]);
df9db588 403
16b65f2a 404 fMomentum[0] = TMath::Sqrt(pt2); // pt
b1a9edc8 405 fMomentum[1] = (pt2 != 0.) ? TMath::Pi()+TMath::ATan2(-p[1], -p[0]) : -999; // phi
0c5f89fb 406 fMomentum[2] = (pp != 0.) ? TMath::ACos(p[2] / pp) : -999.; // theta
df9db588 407 } else {
16b65f2a 408 fMomentum[0] = p[0]; // pt
df9db588 409 fMomentum[1] = p[1]; // phi
410 fMomentum[2] = p[2]; // theta
411 }
412 } else {
413 fMomentum[0] = -999.;
414 fMomentum[1] = -999.;
415 fMomentum[2] = -999.;
416 }
417}
418
419//______________________________________________________________________________
420template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
421{
422 // set the position
423
424 if (x) {
425 if (!dca) {
426 ResetBit(kIsDCA);
427
428 fPosition[0] = x[0];
429 fPosition[1] = x[1];
430 fPosition[2] = x[2];
431 } else {
432 SetBit(kIsDCA);
433 // don't know any better yet
434 fPosition[0] = -999.;
435 fPosition[1] = -999.;
436 fPosition[2] = -999.;
437 }
438 } else {
439 ResetBit(kIsDCA);
440
441 fPosition[0] = -999.;
442 fPosition[1] = -999.;
443 fPosition[2] = -999.;
444 }
445}
446
447//______________________________________________________________________________
448void AliAODTrack::SetDCA(Double_t d, Double_t z)
449{
450 // set the dca
451 fPosition[0] = d;
452 fPosition[1] = z;
453 fPosition[2] = 0.;
454 SetBit(kIsDCA);
455}
456
457//______________________________________________________________________________
458void AliAODTrack::Print(Option_t* /* option */) const
459{
460 // prints information about AliAODTrack
461
462 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
463 printf(" px = %f\n", Px());
464 printf(" py = %f\n", Py());
465 printf(" pz = %f\n", Pz());
466 printf(" pt = %f\n", Pt());
467 printf(" 1/pt = %f\n", OneOverPt());
468 printf(" theta = %f\n", Theta());
469 printf(" phi = %f\n", Phi());
1912763f 470 printf(" chi2/NDF = %f\n", Chi2perNDF());
df9db588 471 printf(" charge = %d\n", Charge());
df9db588 472}
473
2200238e 474//______________________________________________________________________________
475void AliAODTrack::SetMatchTrigger(Int_t matchTrig)
476{
477 // Set the MUON trigger information
8ac4fa64 478 switch(matchTrig){
e1c744ca 479 case 0: // 0 track does not match trigger
480 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
481 break;
482 case 1: // 1 track match but does not pass pt cut
483 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
484 break;
485 case 2: // 2 track match Low pt cut
486 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
487 break;
488 case 3: // 3 track match High pt cut
489 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
490 break;
491 default:
492 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
8ac4fa64 493 AliWarning(Form("unknown case for matchTrig: %d\n",matchTrig));
e1c744ca 494 }
495}
496
2200238e 497//______________________________________________________________________________
498Bool_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber, Int_t cathode) const
499{
500 // return kTRUE if the track fires the given tracking or trigger chamber.
501 // If the chamber is a trigger one:
502 // - if cathode = 0 or 1, the track matches the corresponding cathode
503 // - if cathode = -1, the track matches both cathodes
504
505 if (MuonChamber < 0) return kFALSE;
506
507 if (MuonChamber < 10) return TESTBIT(GetMUONClusterMap(), MuonChamber);
508
509 if (MuonChamber < 14) {
510
511 if (cathode < 0) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber) &&
512 TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+4);
513
514 if (cathode < 2) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+(1-cathode)*4);
515
e1c744ca 516 }
2200238e 517
518 return kFALSE;
e1c744ca 519}
520
2200238e 521//______________________________________________________________________________
522Bool_t AliAODTrack::MatchTriggerDigits() const
523{
524 // return kTRUE if the track matches a digit on both planes of at least 2 trigger chambers
6c954176 525
2200238e 526 Int_t nMatchedChambers = 0;
527 for (Int_t ich=10; ich<14; ich++) if (HitsMuonChamber(ich)) nMatchedChambers++;
528
529 return (nMatchedChambers >= 2);
e1c744ca 530}
c683ddc2 531
6dc40b1c 532//______________________________________________________________________________
533Bool_t AliAODTrack::PropagateToDCA(const AliVVertex *vtx,
534 Double_t b, Double_t maxd, Double_t dz[2], Double_t covar[3])
535{
536 // compute impact parameters to the vertex vtx and their covariance matrix
537 // b is the Bz, needed to propagate correctly the track to vertex
538 // only the track parameters are update after the propagation (pos and mom),
539 // not the covariance matrix. This is OK for propagation over short distance
540 // inside the beam pipe.
541 // return kFALSE is something went wrong
542
543 // convert to AliExternalTrackParam
544 AliExternalTrackParam etp(this);
545
546 Float_t xstart = etp.GetX();
547 if(xstart>3.) {
548 AliError("This method can be used only for propagation inside the beam pipe");
549 return kFALSE;
550 }
551
552 if(!etp.PropagateToDCA(vtx,b,maxd,dz,covar)) return kFALSE;
553
554 // update track position and momentum
555 Double_t mom[3];
556 etp.GetPxPyPz(mom);
557 SetP(mom,kTRUE);
558 etp.GetXYZ(mom);
559 SetPosition(mom,kFALSE);
560
561
562 return kTRUE;
563}
564
c8fe2783 565//______________________________________________________________________________
566Bool_t AliAODTrack::GetPxPyPz(Double_t p[3]) const
567{
568 //---------------------------------------------------------------------
569 // This function returns the global track momentum components
570 //---------------------------------------------------------------------
571 p[0]=Px(); p[1]=Py(); p[2]=Pz();
572 return kTRUE;
573}
9006fe9c 574
575//______________________________________________________________________________
576Float_t AliAODTrack::GetTPCClusterInfo(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1) const
577{
578 //
579 // TPC cluster information
580 // type 0: get fraction of found/findable clusters with neighbourhood definition
581 // 1: findable clusters with neighbourhood definition
582 // 2: found clusters
583 //
584 // definition of findable clusters:
585 // a cluster is defined as findable if there is another cluster
586 // within +- nNeighbours pad rows. The idea is to overcome threshold
587 // effects with a very simple algorithm.
588 //
589
590 if (type==2) return fTPCClusterMap.CountBits();
591
592 Int_t found=0;
593 Int_t findable=0;
594 Int_t last=-nNeighbours;
595
596 for (Int_t i=row0; i<row1; ++i){
597 //look to current row
598 if (fTPCClusterMap[i]) {
599 last=i;
600 ++found;
601 ++findable;
602 continue;
603 }
604 //look to nNeighbours before
605 if ((i-last)<=nNeighbours) {
606 ++findable;
607 continue;
608 }
609 //look to nNeighbours after
610 for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
611 if (fTPCClusterMap[j]){
612 ++findable;
613 break;
614 }
615 }
616 }
617 if (type==1) return findable;
618
619 if (type==0){
620 Float_t fraction=0;
621 if (findable>0)
622 fraction=(Float_t)found/(Float_t)findable;
623 else
624 fraction=0;
625 return fraction;
626 }
627 return 0; // undefined type - default value
628}
fd21ec8d 629
630//______________________________________________________________________________
631Double_t AliAODTrack::GetTRDslice(Int_t plane, Int_t slice) const {
632 //
633 // return TRD Pid information
634 //
635 if (!fDetPid) return -1;
636 Double32_t *trdSlices=fDetPid->GetTRDsignal();
637 if (!trdSlices) return -1;
638 if ((plane<0) || (plane>=kTRDnPlanes)) {
639 return -1.;
640 }
641
99e9d5ec 642 Int_t ns=fDetPid->GetTRDnSlices()/kTRDnPlanes;
fd21ec8d 643 if ((slice<-1) || (slice>=ns)) {
644 return -1.;
645 }
646
647 if(slice>=0) return trdSlices[plane*ns + slice];
648
649 // return average of the dEdx measurements
650 Double_t q=0.; Double32_t *s = &trdSlices[plane*ns];
651 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
652 return q/ns;
653}
654
99e9d5ec 655//______________________________________________________________________________
656UChar_t AliAODTrack::GetTRDntrackletsPID() const{
657 //
658 // return number of tracklets calculated from the slices
659 //
660 if(!fDetPid) return -1;
661
662 Int_t ntracklets = 0, // Number of tracklets / track
663 nSlicesTracklet = fDetPid->GetTRDnSlices()/kTRDnPlanes, // Number of slices per tracklet
664 nSlicesNonZero = 0; // Number of slices containing a dE/dx measurement
665 for(Int_t ily = 0; ily < kTRDnPlanes; ily++){
666 // a tracklet is found if it has at least one slice containing a dE/dx measurement
667 nSlicesNonZero = 0;
668 for(Int_t islice = 0; islice < nSlicesTracklet; islice++){
669 if(fDetPid->GetTRDsignal()[nSlicesTracklet * ily + islice] > 0.01) nSlicesNonZero++;
670 }
671 if(nSlicesNonZero) ntracklets++;
672 }
673 return ntracklets;
674}
675
fd21ec8d 676//______________________________________________________________________________
677Double_t AliAODTrack::GetTRDmomentum(Int_t plane, Double_t */*sp*/) const
678{
679 //Returns momentum estimation
680 // in TRD layer "plane".
681
682 if (!fDetPid) return -1;
683 Float_t *trdMomentum=fDetPid->GetTRDmomentum();
684
685 if (!trdMomentum) {
686 return -1.;
687 }
688 if ((plane<0) || (plane>=kTRDnPlanes)) {
689 return -1.;
690 }
691
692 return trdMomentum[plane];
693}
76e6ee6a 694
695//_______________________________________________________________________
a512bf97 696Int_t AliAODTrack::GetTOFBunchCrossing(Double_t b) const
76e6ee6a 697{
698 // Returns the number of bunch crossings after trigger (assuming 25ns spacing)
76e6ee6a 699 const double kSpacing = 25e3; // min interbanch spacing
700 const double kShift = 0;
3f2db92f 701 Int_t bcid = kTOFBCNA; // defualt one
a512bf97 702 if (!IsOn(kTOFout) || !IsOn(kESDpid)) return bcid; // no info
703 //
704 double tdif = GetTOFsignal();
705 if (IsOn(kTIME)) { // integrated time info is there
706 int pid = (int)GetMostProbablePID();
707 double ttimes[10];
708 GetIntegratedTimes(ttimes);
709 tdif -= ttimes[pid];
710 }
711 else { // assume integrated time info from TOF radius and momentum
712 const double kRTOF = 385.;
713 const double kCSpeed = 3.e-2; // cm/ps
714 double p = P();
715 if (p<0.001) p = 1.0;
716 double m = M();
717 double path = kRTOF; // mean TOF radius
718 if (TMath::Abs(b)>kAlmost0) { // account for curvature
719 double curv = Pt()/(b*kB2C);
720 if (curv>kAlmost0) {
721 double tgl = Pz()/Pt();
722 path = 2./curv*TMath::ASin(kRTOF*curv/2.)*TMath::Sqrt(1.+tgl*tgl);
723 }
724 }
725 tdif -= path/kCSpeed*TMath::Sqrt(1.+m*m/(p*p));
726 }
76e6ee6a 727 bcid = TMath::Nint((tdif - kShift)/kSpacing);
728 return bcid;
729}