]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AOD/AliAODTrack.cxx
merge
[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
086400fc 24#include <TVector3.h>
8ac4fa64 25#include "AliLog.h"
6dc40b1c 26#include "AliExternalTrackParam.h"
27#include "AliVVertex.h"
00a38d07 28#include "AliDetectorPID.h"
aab77ed0 29#include "AliAODEvent.h"
567624b5 30#include "AliAODHMPIDrings.h"
42fcc729 31#include "AliTOFHeader.h"
567624b5 32
33#include "AliAODTrack.h"
df9db588 34
35ClassImp(AliAODTrack)
36
37//______________________________________________________________________________
38AliAODTrack::AliAODTrack() :
4f6e22bd 39 AliVTrack(),
f43586f0 40 fRAtAbsorberEnd(0.),
1912763f 41 fChi2perNDF(-999.),
9333290e 42 fChi2MatchTrigger(0.),
76b98553 43 fPID(0),
6efb741f 44 fFlags(0),
df9db588 45 fLabel(-999),
a2c30af1 46 fTOFLabel(),
9b5c8b95 47 fTrackLength(0),
1912763f 48 fITSMuonClusterMap(0),
0a2dcc83 49 fMUONtrigHitsMapTrg(0),
50 fMUONtrigHitsMapTrk(0),
9333290e 51 fFilterMap(0),
bcabd0e4 52 fTPCFitMap(),
d999f2e6 53 fTPCClusterMap(),
54 fTPCSharedMap(),
3c01c166 55 fTPCnclsF(0),
820214a7 56 fTPCNCrossedRows(0),
02153d58 57 fID(-999),
9333290e 58 fCharge(-99),
e1c744ca 59 fType(kUndef),
76b98553 60 fPIDForTracking(AliPID::kPion),
a7d9ab9e 61 fCaloIndex(kEMCALNoMatch),
9333290e 62 fCovMatrix(NULL),
7be1db84 63 fDetPid(NULL),
00a38d07 64 fDetectorPID(NULL),
ed15417e 65 fProdVertex(NULL),
66 fTrackPhiOnEMCal(-999),
aab77ed0 67 fTrackEtaOnEMCal(-999),
a29b2a8a 68 fTrackPtOnEMCal(-999),
f7cc8591 69 fIsMuonGlobalTrack(kFALSE), // AU
539a5a59 70 fTPCsignalTuned(0),
a2c30af1 71 fTOFsignalTuned(99999),
f7cc8591 72 fMFTClusterPattern(0), // AU
aab77ed0 73 fAODEvent(NULL)
df9db588 74{
75 // default constructor
76
77 SetP();
78 SetPosition((Float_t*)NULL);
6c954176 79 SetXYAtDCA(-999., -999.);
80 SetPxPyPzAtDCA(-999., -999., -999.);
a2c30af1 81 for (Int_t i = 0; i < 3; i++) {fTOFLabel[i] = -1;}
df9db588 82}
83
84//______________________________________________________________________________
02153d58 85AliAODTrack::AliAODTrack(Short_t id,
df9db588 86 Int_t label,
87 Double_t p[3],
88 Bool_t cartesian,
89 Double_t x[3],
90 Bool_t isDCA,
91 Double_t covMatrix[21],
92 Short_t charge,
93 UChar_t itsClusMap,
df9db588 94 AliAODVertex *prodVertex,
1912763f 95 Bool_t usedForVtxFit,
dc825b15 96 Bool_t usedForPrimVtxFit,
ec40c484 97 AODTrk_t ttype,
862ce351 98 UInt_t selectInfo,
99 Float_t chi2perNDF) :
4f6e22bd 100 AliVTrack(),
f43586f0 101 fRAtAbsorberEnd(0.),
862ce351 102 fChi2perNDF(chi2perNDF),
9333290e 103 fChi2MatchTrigger(0.),
76b98553 104 fPID(0),
6efb741f 105 fFlags(0),
df9db588 106 fLabel(label),
a2c30af1 107 fTOFLabel(),
9b5c8b95 108 fTrackLength(0),
6c954176 109 fITSMuonClusterMap(0),
0a2dcc83 110 fMUONtrigHitsMapTrg(0),
111 fMUONtrigHitsMapTrk(0),
9333290e 112 fFilterMap(selectInfo),
bcabd0e4 113 fTPCFitMap(),
d999f2e6 114 fTPCClusterMap(),
115 fTPCSharedMap(),
3c01c166 116 fTPCnclsF(0),
820214a7 117 fTPCNCrossedRows(0),
02153d58 118 fID(id),
9333290e 119 fCharge(charge),
e1c744ca 120 fType(ttype),
76b98553 121 fPIDForTracking(AliPID::kPion),
a7d9ab9e 122 fCaloIndex(kEMCALNoMatch),
9333290e 123 fCovMatrix(NULL),
7be1db84 124 fDetPid(NULL),
00a38d07 125 fDetectorPID(NULL),
ed15417e 126 fProdVertex(prodVertex),
127 fTrackPhiOnEMCal(-999),
aab77ed0 128 fTrackEtaOnEMCal(-999),
a29b2a8a 129 fTrackPtOnEMCal(-999),
f7cc8591 130 fIsMuonGlobalTrack(kFALSE), // AU
539a5a59 131 fTPCsignalTuned(0),
a2c30af1 132 fTOFsignalTuned(99999),
f7cc8591 133 fMFTClusterPattern(0), // AU
aab77ed0 134 fAODEvent(NULL)
df9db588 135{
136 // constructor
137
138 SetP(p, cartesian);
139 SetPosition(x, isDCA);
6c954176 140 SetXYAtDCA(-999., -999.);
141 SetPxPyPzAtDCA(-999., -999., -999.);
1912763f 142 SetUsedForVtxFit(usedForVtxFit);
dc825b15 143 SetUsedForPrimVtxFit(usedForPrimVtxFit);
df9db588 144 if(covMatrix) SetCovMatrix(covMatrix);
6c954176 145 SetITSClusterMap(itsClusMap);
a2c30af1 146 for (Int_t i=0;i<3;i++) {fTOFLabel[i]=-1;}
df9db588 147}
148
149//______________________________________________________________________________
02153d58 150AliAODTrack::AliAODTrack(Short_t id,
df9db588 151 Int_t label,
152 Float_t p[3],
153 Bool_t cartesian,
154 Float_t x[3],
155 Bool_t isDCA,
156 Float_t covMatrix[21],
157 Short_t charge,
158 UChar_t itsClusMap,
df9db588 159 AliAODVertex *prodVertex,
1912763f 160 Bool_t usedForVtxFit,
dc825b15 161 Bool_t usedForPrimVtxFit,
ec40c484 162 AODTrk_t ttype,
862ce351 163 UInt_t selectInfo,
76b98553 164 Float_t chi2perNDF ) :
4f6e22bd 165 AliVTrack(),
f43586f0 166 fRAtAbsorberEnd(0.),
862ce351 167 fChi2perNDF(chi2perNDF),
9333290e 168 fChi2MatchTrigger(0.),
76b98553 169 fPID(0),
6efb741f 170 fFlags(0),
df9db588 171 fLabel(label),
a2c30af1 172 fTOFLabel(),
9b5c8b95 173 fTrackLength(0),
6c954176 174 fITSMuonClusterMap(0),
0a2dcc83 175 fMUONtrigHitsMapTrg(0),
176 fMUONtrigHitsMapTrk(0),
9333290e 177 fFilterMap(selectInfo),
bcabd0e4 178 fTPCFitMap(),
d999f2e6 179 fTPCClusterMap(),
180 fTPCSharedMap(),
3c01c166 181 fTPCnclsF(0),
820214a7 182 fTPCNCrossedRows(0),
02153d58 183 fID(id),
9333290e 184 fCharge(charge),
e1c744ca 185 fType(ttype),
76b98553 186 fPIDForTracking(AliPID::kPion),
a7d9ab9e 187 fCaloIndex(kEMCALNoMatch),
9333290e 188 fCovMatrix(NULL),
7be1db84 189 fDetPid(NULL),
00a38d07 190 fDetectorPID(NULL),
ed15417e 191 fProdVertex(prodVertex),
192 fTrackPhiOnEMCal(-999),
aab77ed0 193 fTrackEtaOnEMCal(-999),
a29b2a8a 194 fTrackPtOnEMCal(-999),
f7cc8591 195 fIsMuonGlobalTrack(kFALSE), // AU
539a5a59 196 fTPCsignalTuned(0),
a2c30af1 197 fTOFsignalTuned(99999),
f7cc8591 198 fMFTClusterPattern(0), // AU
aab77ed0 199 fAODEvent(NULL)
df9db588 200{
201 // constructor
202
203 SetP(p, cartesian);
204 SetPosition(x, isDCA);
6c954176 205 SetXYAtDCA(-999., -999.);
206 SetPxPyPzAtDCA(-999., -999., -999.);
1912763f 207 SetUsedForVtxFit(usedForVtxFit);
dc825b15 208 SetUsedForPrimVtxFit(usedForPrimVtxFit);
df9db588 209 if(covMatrix) SetCovMatrix(covMatrix);
6c954176 210 SetITSClusterMap(itsClusMap);
a2c30af1 211 for (Int_t i=0;i<3;i++) {fTOFLabel[i]=-1;}
df9db588 212}
213
df9db588 214//______________________________________________________________________________
215AliAODTrack::~AliAODTrack()
216{
217 // destructor
218 delete fCovMatrix;
7450f8ab 219 delete fDetPid;
00a38d07 220 delete fDetectorPID;
1b4891a7 221 if (fPID) {delete[] fPID; fPID = 0;}
df9db588 222}
223
224
225//______________________________________________________________________________
226AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
4f6e22bd 227 AliVTrack(trk),
f43586f0 228 fRAtAbsorberEnd(trk.fRAtAbsorberEnd),
1912763f 229 fChi2perNDF(trk.fChi2perNDF),
9333290e 230 fChi2MatchTrigger(trk.fChi2MatchTrigger),
76b98553 231 fPID(0),
6efb741f 232 fFlags(trk.fFlags),
df9db588 233 fLabel(trk.fLabel),
a2c30af1 234 fTOFLabel(),
9b5c8b95 235 fTrackLength(trk.fTrackLength),
1912763f 236 fITSMuonClusterMap(trk.fITSMuonClusterMap),
0a2dcc83 237 fMUONtrigHitsMapTrg(trk.fMUONtrigHitsMapTrg),
238 fMUONtrigHitsMapTrk(trk.fMUONtrigHitsMapTrk),
9333290e 239 fFilterMap(trk.fFilterMap),
bcabd0e4 240 fTPCFitMap(trk.fTPCFitMap),
d999f2e6 241 fTPCClusterMap(trk.fTPCClusterMap),
242 fTPCSharedMap(trk.fTPCSharedMap),
3c01c166 243 fTPCnclsF(trk.fTPCnclsF),
820214a7 244 fTPCNCrossedRows(trk.fTPCNCrossedRows),
02153d58 245 fID(trk.fID),
9333290e 246 fCharge(trk.fCharge),
e1c744ca 247 fType(trk.fType),
76b98553 248 fPIDForTracking(trk.fPIDForTracking),
a7d9ab9e 249 fCaloIndex(trk.fCaloIndex),
9333290e 250 fCovMatrix(NULL),
7be1db84 251 fDetPid(NULL),
00a38d07 252 fDetectorPID(NULL),
ed15417e 253 fProdVertex(trk.fProdVertex),
254 fTrackPhiOnEMCal(trk.fTrackPhiOnEMCal),
aab77ed0 255 fTrackEtaOnEMCal(trk.fTrackEtaOnEMCal),
a29b2a8a 256 fTrackPtOnEMCal(trk.fTrackPtOnEMCal),
f7cc8591 257 fIsMuonGlobalTrack(trk.fIsMuonGlobalTrack), // AU
539a5a59 258 fTPCsignalTuned(trk.fTPCsignalTuned),
a2c30af1 259 fTOFsignalTuned(trk.fTOFsignalTuned),
f7cc8591 260 fMFTClusterPattern(trk.fMFTClusterPattern), // AU
aab77ed0 261 fAODEvent(trk.fAODEvent)
df9db588 262{
263 // Copy constructor
264
265 trk.GetP(fMomentum);
266 trk.GetPosition(fPosition);
6c954176 267 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
268 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
1912763f 269 SetUsedForVtxFit(trk.GetUsedForVtxFit());
dc825b15 270 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
5d62ce04 271 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
7be1db84 272 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
df9db588 273 SetPID(trk.fPID);
00a38d07 274 if (trk.fDetectorPID) fDetectorPID = new AliDetectorPID(*trk.fDetectorPID);
a2c30af1 275 for (Int_t i = 0; i < 3; i++) {fTOFLabel[i] = trk.fTOFLabel[i];}
df9db588 276}
277
278//______________________________________________________________________________
279AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
280{
281 // Assignment operator
282 if(this!=&trk) {
283
4f6e22bd 284 AliVTrack::operator=(trk);
df9db588 285
286 trk.GetP(fMomentum);
287 trk.GetPosition(fPosition);
6c954176 288 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
289 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
05f9607e 290 fRAtAbsorberEnd = trk.fRAtAbsorberEnd;
291 fChi2perNDF = trk.fChi2perNDF;
292 fChi2MatchTrigger = trk.fChi2MatchTrigger;
76b98553 293 SetPID( trk.fPID );
05f9607e 294 fFlags = trk.fFlags;
295 fLabel = trk.fLabel;
9b5c8b95 296 fTrackLength = trk.fTrackLength;
9333290e 297 fITSMuonClusterMap = trk.fITSMuonClusterMap;
0a2dcc83 298 fMUONtrigHitsMapTrg = trk.fMUONtrigHitsMapTrg;
299 fMUONtrigHitsMapTrk = trk.fMUONtrigHitsMapTrk;
05f9607e 300 fFilterMap = trk.fFilterMap;
bcabd0e4 301 fTPCFitMap = trk.fTPCFitMap;
05f9607e 302 fTPCClusterMap = trk.fTPCClusterMap;
303 fTPCSharedMap = trk.fTPCSharedMap;
304 fTPCnclsF = trk.fTPCnclsF;
820214a7 305 fTPCNCrossedRows = trk.fTPCNCrossedRows;
05f9607e 306 fID = trk.fID;
307 fCharge = trk.fCharge;
308 fType = trk.fType;
76b98553 309 fPIDForTracking = trk.fPIDForTracking;
05f9607e 310 fCaloIndex = trk.fCaloIndex;
ed15417e 311 fTrackPhiOnEMCal = trk.fTrackPhiOnEMCal;
312 fTrackEtaOnEMCal = trk.fTrackEtaOnEMCal;
a29b2a8a 313 fTrackPtOnEMCal = trk.fTrackPtOnEMCal;
f7cc8591 314 fIsMuonGlobalTrack = trk.fIsMuonGlobalTrack; // AU
539a5a59 315 fTPCsignalTuned = trk.fTPCsignalTuned;
a2c30af1 316 fTOFsignalTuned = trk.fTOFsignalTuned;
f7cc8591 317 fMFTClusterPattern = trk.fMFTClusterPattern; // AU
318
df9db588 319 delete fCovMatrix;
5d62ce04 320 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
df9db588 321 else fCovMatrix=NULL;
df9db588 322
05f9607e 323
324 fProdVertex = trk.fProdVertex;
1912763f 325 SetUsedForVtxFit(trk.GetUsedForVtxFit());
dc825b15 326 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
7be1db84 327
00a38d07 328 //detector raw signals
7be1db84 329 delete fDetPid;
330 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
331 else fDetPid=NULL;
05f9607e 332
00a38d07 333 //calibrated PID cache
334 delete fDetectorPID;
335 fDetectorPID=0x0;
336 if (trk.fDetectorPID) fDetectorPID = new AliDetectorPID(*trk.fDetectorPID);
a2c30af1 337 for (Int_t i = 0; i < 3; i++) {fTOFLabel[i] = trk.fTOFLabel[i];}
df9db588 338 }
339
340 return *this;
341}
342
4697e4fb 343//______________________________________________________________________________
344Double_t AliAODTrack::M(AODTrkPID_t pid) const
345{
346 // Returns the mass.
9861edc0 347 // Masses for nuclei don't exist in the PDG tables, therefore they were put by hand.
4697e4fb 348
349 switch (pid) {
350
351 case kElectron :
9861edc0 352 return 0.000510999; //TDatabasePDG::Instance()->GetParticle(11/*::kElectron*/)->Mass();
4697e4fb 353 break;
354
355 case kMuon :
9861edc0 356 return 0.1056584; //TDatabasePDG::Instance()->GetParticle(13/*::kMuonMinus*/)->Mass();
4697e4fb 357 break;
358
359 case kPion :
9861edc0 360 return 0.13957; //TDatabasePDG::Instance()->GetParticle(211/*::kPiPlus*/)->Mass();
4697e4fb 361 break;
362
363 case kKaon :
9861edc0 364 return 0.4937; //TDatabasePDG::Instance()->GetParticle(321/*::kKPlus*/)->Mass();
4697e4fb 365 break;
366
367 case kProton :
9861edc0 368 return 0.9382720; //TDatabasePDG::Instance()->GetParticle(2212/*::kProton*/)->Mass();
4697e4fb 369 break;
370
371 case kDeuteron :
9861edc0 372 return 1.8756; //TDatabasePDG::Instance()->GetParticle(1000010020)->Mass();
4697e4fb 373 break;
374
375 case kTriton :
9861edc0 376 return 2.8089; //TDatabasePDG::Instance()->GetParticle(1000010030)->Mass();
4697e4fb 377 break;
378
379 case kHelium3 :
9861edc0 380 return 2.8084; //TDatabasePDG::Instance()->GetParticle(1000020030)->Mass();
4697e4fb 381 break;
382
383 case kAlpha :
9861edc0 384 return 3.7274; //TDatabasePDG::Instance()->GetParticle(1000020040)->Mass();
4697e4fb 385 break;
386
387 case kUnknown :
388 return -999.;
389 break;
390
391 default :
392 return -999.;
393 }
394}
395
396//______________________________________________________________________________
397Double_t AliAODTrack::E(AODTrkPID_t pid) const
398{
399 // Returns the energy of the particle of a given pid.
400
401 if (pid != kUnknown) { // particle was identified
402 Double_t m = M(pid);
403 return TMath::Sqrt(P()*P() + m*m);
404 } else { // pid unknown
405 return -999.;
406 }
407}
408
409//______________________________________________________________________________
410Double_t AliAODTrack::Y(AODTrkPID_t pid) const
411{
9861edc0 412 // Returns the rapidity of a particle of a given pid.
4697e4fb 413
414 if (pid != kUnknown) { // particle was identified
415 Double_t e = E(pid);
416 Double_t pz = Pz();
417 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
418 return 0.5*TMath::Log((e+pz)/(e-pz));
419 } else { // energy not known or equal to pz
420 return -999.;
421 }
422 } else { // pid unknown
423 return -999.;
424 }
425}
426
427//______________________________________________________________________________
428Double_t AliAODTrack::Y(Double_t m) const
429{
9861edc0 430 // Returns the rapidity of a particle of a given mass.
4697e4fb 431
432 if (m >= 0.) { // mass makes sense
433 Double_t e = E(m);
434 Double_t pz = Pz();
435 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
436 return 0.5*TMath::Log((e+pz)/(e-pz));
437 } else { // energy not known or equal to pz
438 return -999.;
439 }
440 } else { // pid unknown
441 return -999.;
442 }
443}
444
a2c30af1 445void AliAODTrack::SetTOFLabel(const Int_t *p) {
446 // Sets (in TOF)
447 for (Int_t i = 0; i < 3; i++) fTOFLabel[i]=p[i];
448}
449
450//_______________________________________________________________________
451void AliAODTrack::GetTOFLabel(Int_t *p) const {
452 // Gets (in TOF)
453 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
454}
455
4697e4fb 456//______________________________________________________________________________
457AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
458{
459 // Returns the most probable PID array element.
460
461 Int_t nPID = 10;
7ba6f91a 462 AODTrkPID_t loc = kUnknown;
7ba6f91a 463 Bool_t allTheSame = kTRUE;
76b98553 464 if (fPID) {
465 Double_t max = 0.;
466 for (Int_t iPID = 0; iPID < nPID; iPID++) {
467 if (fPID[iPID] >= max) {
468 if (fPID[iPID] > max) {
469 allTheSame = kFALSE;
470 max = fPID[iPID];
471 loc = (AODTrkPID_t)iPID;
472 } else {
473 allTheSame = kTRUE;
474 }
4697e4fb 475 }
476 }
4697e4fb 477 }
76b98553 478 return allTheSame ? AODTrkPID_t(GetPIDForTracking()) : loc;
4697e4fb 479}
480
481//______________________________________________________________________________
482void AliAODTrack::ConvertAliPIDtoAODPID()
483{
484 // Converts AliPID array.
485 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
486 // Everything else has to be set to zero.
76b98553 487 if (fPID) {
488 fPID[kDeuteron] = 0.;
489 fPID[kTriton] = 0.;
490 fPID[kHelium3] = 0.;
491 fPID[kAlpha] = 0.;
492 fPID[kUnknown] = 0.;
493 }
4697e4fb 494 return;
495}
496
497
df9db588 498//______________________________________________________________________________
cdd730d0 499template <typename T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
df9db588 500{
8a1418dc 501 // Set the momentum
df9db588 502
503 if (p) {
504 if (cartesian) {
16b65f2a 505 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
0c5f89fb 506 Double_t pp = TMath::Sqrt(pt2 + p[2]*p[2]);
df9db588 507
16b65f2a 508 fMomentum[0] = TMath::Sqrt(pt2); // pt
b1a9edc8 509 fMomentum[1] = (pt2 != 0.) ? TMath::Pi()+TMath::ATan2(-p[1], -p[0]) : -999; // phi
0c5f89fb 510 fMomentum[2] = (pp != 0.) ? TMath::ACos(p[2] / pp) : -999.; // theta
df9db588 511 } else {
16b65f2a 512 fMomentum[0] = p[0]; // pt
df9db588 513 fMomentum[1] = p[1]; // phi
514 fMomentum[2] = p[2]; // theta
515 }
516 } else {
517 fMomentum[0] = -999.;
518 fMomentum[1] = -999.;
519 fMomentum[2] = -999.;
520 }
521}
522
6e78367a 523/*
df9db588 524//______________________________________________________________________________
cdd730d0 525template <typename T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
df9db588 526{
527 // set the position
528
529 if (x) {
530 if (!dca) {
531 ResetBit(kIsDCA);
532
533 fPosition[0] = x[0];
534 fPosition[1] = x[1];
535 fPosition[2] = x[2];
536 } else {
537 SetBit(kIsDCA);
538 // don't know any better yet
539 fPosition[0] = -999.;
540 fPosition[1] = -999.;
541 fPosition[2] = -999.;
542 }
543 } else {
544 ResetBit(kIsDCA);
545
546 fPosition[0] = -999.;
547 fPosition[1] = -999.;
548 fPosition[2] = -999.;
549 }
550}
6e78367a 551*/
df9db588 552//______________________________________________________________________________
553void AliAODTrack::SetDCA(Double_t d, Double_t z)
554{
555 // set the dca
556 fPosition[0] = d;
557 fPosition[1] = z;
558 fPosition[2] = 0.;
559 SetBit(kIsDCA);
560}
561
562//______________________________________________________________________________
563void AliAODTrack::Print(Option_t* /* option */) const
564{
565 // prints information about AliAODTrack
566
567 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
568 printf(" px = %f\n", Px());
569 printf(" py = %f\n", Py());
570 printf(" pz = %f\n", Pz());
571 printf(" pt = %f\n", Pt());
572 printf(" 1/pt = %f\n", OneOverPt());
573 printf(" theta = %f\n", Theta());
574 printf(" phi = %f\n", Phi());
1912763f 575 printf(" chi2/NDF = %f\n", Chi2perNDF());
df9db588 576 printf(" charge = %d\n", Charge());
df9db588 577}
578
2200238e 579//______________________________________________________________________________
580void AliAODTrack::SetMatchTrigger(Int_t matchTrig)
581{
582 // Set the MUON trigger information
8ac4fa64 583 switch(matchTrig){
e1c744ca 584 case 0: // 0 track does not match trigger
585 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
586 break;
587 case 1: // 1 track match but does not pass pt cut
588 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
589 break;
590 case 2: // 2 track match Low pt cut
591 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
592 break;
593 case 3: // 3 track match High pt cut
594 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
595 break;
596 default:
597 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
8ac4fa64 598 AliWarning(Form("unknown case for matchTrig: %d\n",matchTrig));
e1c744ca 599 }
600}
601
2200238e 602//______________________________________________________________________________
603Bool_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber, Int_t cathode) const
604{
605 // return kTRUE if the track fires the given tracking or trigger chamber.
606 // If the chamber is a trigger one:
607 // - if cathode = 0 or 1, the track matches the corresponding cathode
608 // - if cathode = -1, the track matches both cathodes
609
610 if (MuonChamber < 0) return kFALSE;
611
612 if (MuonChamber < 10) return TESTBIT(GetMUONClusterMap(), MuonChamber);
613
614 if (MuonChamber < 14) {
615
616 if (cathode < 0) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber) &&
617 TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+4);
618
619 if (cathode < 2) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+(1-cathode)*4);
620
e1c744ca 621 }
2200238e 622
623 return kFALSE;
e1c744ca 624}
625
2200238e 626//______________________________________________________________________________
627Bool_t AliAODTrack::MatchTriggerDigits() const
628{
629 // return kTRUE if the track matches a digit on both planes of at least 2 trigger chambers
6c954176 630
2200238e 631 Int_t nMatchedChambers = 0;
632 for (Int_t ich=10; ich<14; ich++) if (HitsMuonChamber(ich)) nMatchedChambers++;
633
634 return (nMatchedChambers >= 2);
e1c744ca 635}
c683ddc2 636
6dc40b1c 637//______________________________________________________________________________
638Bool_t AliAODTrack::PropagateToDCA(const AliVVertex *vtx,
639 Double_t b, Double_t maxd, Double_t dz[2], Double_t covar[3])
640{
641 // compute impact parameters to the vertex vtx and their covariance matrix
642 // b is the Bz, needed to propagate correctly the track to vertex
643 // only the track parameters are update after the propagation (pos and mom),
644 // not the covariance matrix. This is OK for propagation over short distance
645 // inside the beam pipe.
646 // return kFALSE is something went wrong
647
95764f96 648 // allowed only for tracks inside the beam pipe
649 Float_t xstart2 = fPosition[0]*fPosition[0]+fPosition[1]*fPosition[1];
650 if(xstart2 > 3.*3.) { // outside beampipe radius
6dc40b1c 651 AliError("This method can be used only for propagation inside the beam pipe");
652 return kFALSE;
653 }
654
95764f96 655 // convert to AliExternalTrackParam
656 AliExternalTrackParam etp; etp.CopyFromVTrack(this);
657
658 // propagate
6dc40b1c 659 if(!etp.PropagateToDCA(vtx,b,maxd,dz,covar)) return kFALSE;
660
661 // update track position and momentum
662 Double_t mom[3];
663 etp.GetPxPyPz(mom);
664 SetP(mom,kTRUE);
665 etp.GetXYZ(mom);
666 SetPosition(mom,kFALSE);
667
668
669 return kTRUE;
670}
671
c8fe2783 672//______________________________________________________________________________
673Bool_t AliAODTrack::GetPxPyPz(Double_t p[3]) const
674{
675 //---------------------------------------------------------------------
676 // This function returns the global track momentum components
677 //---------------------------------------------------------------------
678 p[0]=Px(); p[1]=Py(); p[2]=Pz();
679 return kTRUE;
680}
9006fe9c 681
25f906db 682
683//_______________________________________________________________________
684Float_t AliAODTrack::GetTPCClusterInfo(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1, Int_t bitType ) const
9006fe9c 685{
686 //
25f906db 687 // TPC cluster information
9006fe9c 688 // type 0: get fraction of found/findable clusters with neighbourhood definition
689 // 1: findable clusters with neighbourhood definition
690 // 2: found clusters
25f906db 691 // bitType:
692 // 0 - all cluster used
693 // 1 - clusters used for the kalman update
9006fe9c 694 // definition of findable clusters:
695 // a cluster is defined as findable if there is another cluster
696 // within +- nNeighbours pad rows. The idea is to overcome threshold
697 // effects with a very simple algorithm.
698 //
25f906db 699
9006fe9c 700
701 Int_t found=0;
702 Int_t findable=0;
703 Int_t last=-nNeighbours;
25f906db 704 const TBits & clusterMap = (bitType%2==0) ? fTPCClusterMap : fTPCFitMap;
9006fe9c 705
25f906db 706 Int_t upperBound=clusterMap.GetNbits();
707 if (upperBound>row1) upperBound=row1;
708 for (Int_t i=row0; i<upperBound; ++i){
9006fe9c 709 //look to current row
25f906db 710 if (clusterMap[i]) {
9006fe9c 711 last=i;
712 ++found;
713 ++findable;
714 continue;
715 }
716 //look to nNeighbours before
717 if ((i-last)<=nNeighbours) {
718 ++findable;
719 continue;
720 }
721 //look to nNeighbours after
722 for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
25f906db 723 if (clusterMap[j]){
9006fe9c 724 ++findable;
725 break;
726 }
727 }
728 }
25f906db 729 if (type==2) return found;
9006fe9c 730 if (type==1) return findable;
731
732 if (type==0){
733 Float_t fraction=0;
25f906db 734 if (findable>0)
9006fe9c 735 fraction=(Float_t)found/(Float_t)findable;
25f906db 736 else
9006fe9c 737 fraction=0;
738 return fraction;
25f906db 739 }
9006fe9c 740 return 0; // undefined type - default value
741}
fd21ec8d 742
25f906db 743
fd21ec8d 744//______________________________________________________________________________
745Double_t AliAODTrack::GetTRDslice(Int_t plane, Int_t slice) const {
746 //
747 // return TRD Pid information
748 //
749 if (!fDetPid) return -1;
6736efd5 750 Double32_t *trdSlices=fDetPid->GetTRDslices();
fd21ec8d 751 if (!trdSlices) return -1;
752 if ((plane<0) || (plane>=kTRDnPlanes)) {
753 return -1.;
754 }
755
eb550f5c 756 Int_t ns=fDetPid->GetTRDnSlices();
fd21ec8d 757 if ((slice<-1) || (slice>=ns)) {
758 return -1.;
759 }
760
761 if(slice>=0) return trdSlices[plane*ns + slice];
762
763 // return average of the dEdx measurements
764 Double_t q=0.; Double32_t *s = &trdSlices[plane*ns];
765 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
766 return q/ns;
767}
768
99e9d5ec 769//______________________________________________________________________________
770UChar_t AliAODTrack::GetTRDntrackletsPID() const{
771 //
772 // return number of tracklets calculated from the slices
773 //
774 if(!fDetPid) return -1;
59a8e853 775 return fDetPid->GetTRDntrackletsPID();
776}
99e9d5ec 777
59a8e853 778//______________________________________________________________________________
779UChar_t AliAODTrack::GetTRDncls(Int_t layer) const {
780 //
781 // return number of TRD clusters
782 //
783 if(!fDetPid || layer > 5) return -1;
784 if(layer < 0) return fDetPid->GetTRDncls();
785 else return fDetPid->GetTRDncls(layer);
99e9d5ec 786}
787
fd21ec8d 788//______________________________________________________________________________
789Double_t AliAODTrack::GetTRDmomentum(Int_t plane, Double_t */*sp*/) const
790{
791 //Returns momentum estimation
792 // in TRD layer "plane".
793
794 if (!fDetPid) return -1;
c997f0f9 795 const Double_t *trdMomentum=fDetPid->GetTRDmomentum();
fd21ec8d 796
797 if (!trdMomentum) {
798 return -1.;
799 }
800 if ((plane<0) || (plane>=kTRDnPlanes)) {
801 return -1.;
802 }
803
804 return trdMomentum[plane];
805}
76e6ee6a 806
807//_______________________________________________________________________
1cecd6e3 808Int_t AliAODTrack::GetTOFBunchCrossing(Double_t b, Bool_t) const
76e6ee6a 809{
810 // Returns the number of bunch crossings after trigger (assuming 25ns spacing)
76e6ee6a 811 const double kSpacing = 25e3; // min interbanch spacing
812 const double kShift = 0;
3f2db92f 813 Int_t bcid = kTOFBCNA; // defualt one
a512bf97 814 if (!IsOn(kTOFout) || !IsOn(kESDpid)) return bcid; // no info
815 //
816 double tdif = GetTOFsignal();
817 if (IsOn(kTIME)) { // integrated time info is there
818 int pid = (int)GetMostProbablePID();
819 double ttimes[10];
fc9b31a7 820 GetIntegratedTimes(ttimes, pid>=AliPID::kSPECIES ? AliPID::kSPECIESC : AliPID::kSPECIES);
a512bf97 821 tdif -= ttimes[pid];
822 }
823 else { // assume integrated time info from TOF radius and momentum
824 const double kRTOF = 385.;
825 const double kCSpeed = 3.e-2; // cm/ps
826 double p = P();
827 if (p<0.001) p = 1.0;
828 double m = M();
829 double path = kRTOF; // mean TOF radius
830 if (TMath::Abs(b)>kAlmost0) { // account for curvature
831 double curv = Pt()/(b*kB2C);
832 if (curv>kAlmost0) {
833 double tgl = Pz()/Pt();
834 path = 2./curv*TMath::ASin(kRTOF*curv/2.)*TMath::Sqrt(1.+tgl*tgl);
835 }
836 }
837 tdif -= path/kCSpeed*TMath::Sqrt(1.+m*m/(p*p));
838 }
76e6ee6a 839 bcid = TMath::Nint((tdif - kShift)/kSpacing);
840 return bcid;
841}
086400fc 842
00a38d07 843void AliAODTrack::SetDetectorPID(const AliDetectorPID *pid)
844{
845 //
846 // Set the detector PID
847 //
848 if (fDetectorPID) delete fDetectorPID;
849 fDetectorPID=pid;
850
851}
852
567624b5 853//_____________________________________________________________________________
854Double_t AliAODTrack::GetHMPIDsignal() const
855{
856 if(fAODEvent->GetHMPIDringForTrackID(fID)) return fAODEvent->GetHMPIDringForTrackID(fID)->GetHmpSignal();
857 else return -999.;
858}
859
860//_____________________________________________________________________________
861Double_t AliAODTrack::GetHMPIDoccupancy() const
862{
863 if(fAODEvent->GetHMPIDringForTrackID(fID)) return fAODEvent->GetHMPIDringForTrackID(fID)->GetHmpOccupancy();
864 else return -999.;
865}
866
867//_____________________________________________________________________________
868Int_t AliAODTrack::GetHMPIDcluIdx() const
869{
870 if(fAODEvent->GetHMPIDringForTrackID(fID)) return fAODEvent->GetHMPIDringForTrackID(fID)->GetHmpCluIdx();
871 else return -999;
872}
873
874//_____________________________________________________________________________
875void AliAODTrack::GetHMPIDtrk(Float_t &x, Float_t &y, Float_t &th, Float_t &ph) const
876{
877 x = -999; y = -999.; th = -999.; ph = -999.;
878
879 const AliAODHMPIDrings *ring=fAODEvent->GetHMPIDringForTrackID(fID);
880 if(ring){
881 x = ring->GetHmpTrackX();
882 y = ring->GetHmpTrackY();
883 th = ring->GetHmpTrackTheta();
884 ph = ring->GetHmpTrackPhi();
885 }
886}
887
888//_____________________________________________________________________________
889void AliAODTrack::GetHMPIDmip(Float_t &x,Float_t &y,Int_t &q, Int_t &nph) const
890{
891 x = -999; y = -999.; q = -999; nph = -999;
892
893 const AliAODHMPIDrings *ring=fAODEvent->GetHMPIDringForTrackID(fID);
894 if(ring){
895 x = ring->GetHmpMipX();
896 y = ring->GetHmpMipY();
897 q = (Int_t)ring->GetHmpMipCharge();
898 nph = (Int_t)ring->GetHmpNumOfPhotonClusters();
899 }
900}
901
902//_____________________________________________________________________________
903Bool_t AliAODTrack::GetOuterHmpPxPyPz(Double_t *p) const
904{
905 if(fAODEvent->GetHMPIDringForTrackID(fID)) {fAODEvent->GetHMPIDringForTrackID(fID)->GetHmpMom(p); return kTRUE;}
906
907 else return kFALSE;
908}
086400fc 909//_____________________________________________________________________________
910Bool_t AliAODTrack::GetXYZAt(Double_t x, Double_t b, Double_t *r) const
911{
912 //---------------------------------------------------------------------
913 // This function returns the global track position extrapolated to
914 // the radial position "x" (cm) in the magnetic field "b" (kG)
915 //---------------------------------------------------------------------
916
917 //conversion of track parameter representation is
918 //based on the implementation of AliExternalTrackParam::Set(...)
919 //maybe some of this code can be moved to AliVTrack to avoid code duplication
086400fc 920 Double_t alpha=0.0;
921 Double_t radPos2 = fPosition[0]*fPosition[0]+fPosition[1]*fPosition[1];
922 Double_t radMax = 45.; // approximately ITS outer radius
923 if (radPos2 < radMax*radMax) { // inside the ITS
37f42322 924 alpha = fMomentum[1]; //TMath::ATan2(fMomentum[1],fMomentum[0]); // fMom is pt,phi,theta!
086400fc 925 } else { // outside the ITS
926 Float_t phiPos = TMath::Pi()+TMath::ATan2(-fPosition[1], -fPosition[0]);
927 alpha =
928 TMath::DegToRad()*(20*((((Int_t)(phiPos*TMath::RadToDeg()))/20))+10);
929 }
930 //
086400fc 931 // Get the vertex of origin and the momentum
932 TVector3 ver(fPosition[0],fPosition[1],fPosition[2]);
37f42322 933 TVector3 mom(Px(),Py(),Pz());
086400fc 934 //
086400fc 935 // Rotate to the local coordinate system
936 ver.RotateZ(-alpha);
937 mom.RotateZ(-alpha);
938
939 Double_t param0 = ver.Y();
940 Double_t param1 = ver.Z();
941 Double_t param2 = TMath::Sin(mom.Phi());
942 Double_t param3 = mom.Pz()/mom.Pt();
943 Double_t param4 = TMath::Sign(1/mom.Pt(),(Double_t)fCharge);
944
945 //calculate the propagated coordinates
946 //this is based on AliExternalTrackParam::GetXYZAt(Double_t x, Double_t b, Double_t *r)
947 Double_t dx=x-ver.X();
948 if(TMath::Abs(dx)<=kAlmost0) return GetXYZ(r);
949
950 Double_t f1=param2;
951 Double_t f2=f1 + dx*param4*b*kB2C;
952
953 if (TMath::Abs(f1) >= kAlmost1) return kFALSE;
954 if (TMath::Abs(f2) >= kAlmost1) return kFALSE;
955
956 Double_t r1=TMath::Sqrt((1.-f1)*(1.+f1)), r2=TMath::Sqrt((1.-f2)*(1.+f2));
957 r[0] = x;
958 r[1] = param0 + dx*(f1+f2)/(r1+r2);
959 r[2] = param1 + dx*(r2 + f2*(f1+f2)/(r1+r2))*param3;//Thanks to Andrea & Peter
086400fc 960 return Local2GlobalPosition(r,alpha);
961}
962
c8253dd9 963//_____________________________________________________________________________
964Bool_t AliAODTrack::GetXYZatR(Double_t xr,Double_t bz, Double_t *xyz, Double_t* alpSect) const
965{
966 // This method has 3 modes of behaviour
967 // 1) xyz[3] array is provided but alpSect pointer is 0: calculate the position of track intersection
968 // with circle of radius xr and fill it in xyz array
969 // 2) alpSect pointer is provided: find alpha of the sector where the track reaches local coordinate xr
970 // Note that in this case xr is NOT the radius but the local coordinate.
971 // If the xyz array is provided, it will be filled by track lab coordinates at local X in this sector
972 // 3) Neither alpSect nor xyz pointers are provided: just check if the track reaches radius xr
973 //
974 //
975 Double_t alpha=0.0;
976 Double_t radPos2 = fPosition[0]*fPosition[0]+fPosition[1]*fPosition[1];
977 Double_t radMax = 45.; // approximately ITS outer radius
978 if (radPos2 < radMax*radMax) { // inside the ITS
979 alpha = fMomentum[1]; //TMath::ATan2(fMomentum[1],fMomentum[0]); // fMom is pt,phi,theta!
980 } else { // outside the ITS
981 Float_t phiPos = TMath::Pi()+TMath::ATan2(-fPosition[1], -fPosition[0]);
982 alpha =
983 TMath::DegToRad()*(20*((((Int_t)(phiPos*TMath::RadToDeg()))/20))+10);
984 }
985 //
986 // Get the vertex of origin and the momentum
987 TVector3 ver(fPosition[0],fPosition[1],fPosition[2]);
988 TVector3 mom(Px(),Py(),Pz());
989 //
990 // Rotate to the local coordinate system
991 ver.RotateZ(-alpha);
992 mom.RotateZ(-alpha);
993 //
994 Double_t fx = ver.X();
995 Double_t fy = ver.Y();
996 Double_t fz = ver.Z();
997 Double_t sn = TMath::Sin(mom.Phi());
998 Double_t tgl = mom.Pz()/mom.Pt();
999 Double_t crv = TMath::Sign(1/mom.Pt(),(Double_t)fCharge)*bz*kB2C;
1000 //
1001 if ( (TMath::Abs(bz))<kAlmost0Field ) crv=0.;
1002 //
1003 // general circle parameterization:
1004 // x = (r0+tR)cos(phi0) - tR cos(t+phi0)
1005 // y = (r0+tR)sin(phi0) - tR sin(t+phi0)
1006 // where qb is the sign of the curvature, tR is the track's signed radius and r0
1007 // is the DCA of helix to origin
1008 //
1009 double tR = 1./crv; // track radius signed
1010 double cs = TMath::Sqrt((1-sn)*(1+sn));
1011 double x0 = fx - sn*tR; // helix center coordinates
1012 double y0 = fy + cs*tR;
1013 double phi0 = TMath::ATan2(y0,x0); // angle of PCA wrt to the origin
1014 if (tR<0) phi0 += TMath::Pi();
1015 if (phi0 > TMath::Pi()) phi0 -= 2.*TMath::Pi();
1016 else if (phi0 <-TMath::Pi()) phi0 += 2.*TMath::Pi();
1017 double cs0 = TMath::Cos(phi0);
1018 double sn0 = TMath::Sin(phi0);
1019 double r0 = x0*cs0 + y0*sn0 - tR; // DCA to origin
1020 double r2R = 1.+r0/tR;
1021 //
1022 //
1023 if (r2R<kAlmost0) return kFALSE; // helix is centered at the origin, no specific intersection with other concetric circle
1024 if (!xyz && !alpSect) return kTRUE;
1025 double xr2R = xr/tR;
1026 double r2Ri = 1./r2R;
1027 // the intersection cos(t) = [1 + (r0/tR+1)^2 - (r0/tR)^2]/[2(1+r0/tR)]
1028 double cosT = 0.5*(r2R + (1-xr2R*xr2R)*r2Ri);
1029 if ( TMath::Abs(cosT)>kAlmost1 ) {
1030 // printf("Does not reach : %f %f\n",r0,tR);
1031 return kFALSE; // track does not reach the radius xr
1032 }
1033 //
1034 double t = TMath::ACos(cosT);
1035 if (tR<0) t = -t;
1036 // intersection point
1037 double xyzi[3];
1038 xyzi[0] = x0 - tR*TMath::Cos(t+phi0);
1039 xyzi[1] = y0 - tR*TMath::Sin(t+phi0);
1040 if (xyz) { // if postition is requested, then z is needed:
1041 double t0 = TMath::ATan2(cs,-sn) - phi0;
1042 double z0 = fz - t0*tR*tgl;
1043 xyzi[2] = z0 + tR*t*tgl;
1044 }
1045 else xyzi[2] = 0;
1046 //
1047 Local2GlobalPosition(xyzi,alpha);
1048 //
1049 if (xyz) {
1050 xyz[0] = xyzi[0];
1051 xyz[1] = xyzi[1];
1052 xyz[2] = xyzi[2];
1053 }
1054 //
1055 if (alpSect) {
1056 double &alp = *alpSect;
1057 // determine the sector of crossing
1058 double phiPos = TMath::Pi()+TMath::ATan2(-xyzi[1],-xyzi[0]);
1059 int sect = ((Int_t)(phiPos*TMath::RadToDeg()))/20;
1060 alp = TMath::DegToRad()*(20*sect+10);
1061 double x2r,f1,f2,r1,r2,dx,dy2dx,yloc=0, ylocMax = xr*TMath::Tan(TMath::Pi()/18); // min max Y within sector at given X
1062 //
1063 while(1) {
1064 Double_t ca=TMath::Cos(alp-alpha), sa=TMath::Sin(alp-alpha);
1065 if ((cs*ca+sn*sa)<0) {
1066 AliDebug(1,Form("Rotation to target sector impossible: local cos(phi) would become %.2f",cs*ca+sn*sa));
1067 return kFALSE;
1068 }
1069 //
1070 f1 = sn*ca - cs*sa;
1071 if (TMath::Abs(f1) >= kAlmost1) {
1072 AliDebug(1,Form("Rotation to target sector impossible: local sin(phi) would become %.2f",f1));
1073 return kFALSE;
1074 }
1075 //
1076 double tmpX = fx*ca + fy*sa;
1077 double tmpY = -fx*sa + fy*ca;
1078 //
1079 // estimate Y at X=xr
1080 dx=xr-tmpX;
1081 x2r = crv*dx;
1082 f2=f1 + x2r;
1083 if (TMath::Abs(f2) >= kAlmost1) {
1084 AliDebug(1,Form("Propagation in target sector failed ! %.10e",f2));
1085 return kFALSE;
1086 }
1087 r1 = TMath::Sqrt((1.-f1)*(1.+f1));
1088 r2 = TMath::Sqrt((1.-f2)*(1.+f2));
1089 dy2dx = (f1+f2)/(r1+r2);
1090 yloc = tmpY + dx*dy2dx;
1091 if (yloc>ylocMax) {alp += 2*TMath::Pi()/18; sect++;}
1092 else if (yloc<-ylocMax) {alp -= 2*TMath::Pi()/18; sect--;}
1093 else break;
1094 if (alp >= TMath::Pi()) alp -= 2*TMath::Pi();
1095 else if (alp < -TMath::Pi()) alp += 2*TMath::Pi();
1096 // if (sect>=18) sect = 0;
1097 // if (sect<=0) sect = 17;
1098 }
1099 //
1100 // if alpha was requested, then recalculate the position at intersection in sector
1101 if (xyz) {
1102 xyz[0] = xr;
1103 xyz[1] = yloc;
1104 if (TMath::Abs(x2r)<0.05) xyz[2] = fz + dx*(r2 + f2*dy2dx)*tgl;
1105 else {
1106 // for small dx/R the linear apporximation of the arc by the segment is OK,
1107 // but at large dx/R the error is very large and leads to incorrect Z propagation
1108 // angle traversed delta = 2*asin(dist_start_end / R / 2), hence the arc is: R*deltaPhi
1109 // The dist_start_end is obtained from sqrt(dx^2+dy^2) = x/(r1+r2)*sqrt(2+f1*f2+r1*r2)
1110 // Similarly, the rotation angle in linear in dx only for dx<<R
1111 double chord = dx*TMath::Sqrt(1+dy2dx*dy2dx); // distance from old position to new one
1112 double rot = 2*TMath::ASin(0.5*chord*crv); // angular difference seen from the circle center
1113 xyz[2] = fz + rot/crv*tgl;
1114 }
1115 Local2GlobalPosition(xyz,alp);
1116 }
1117 }
1118 return kTRUE;
1119 //
1120}
086400fc 1121
74ca66e3 1122//_______________________________________________________
1123void AliAODTrack::GetITSdEdxSamples(Double_t s[4]) const
1124{
1125 // get ITS dedx samples
1126 if (!fDetPid) for (int i=4;i--;) s[i]=0;
1127 else for (int i=4;i--;) s[i] = fDetPid->GetITSdEdxSample(i);
1128}
76b98553 1129
1130//_____________________________________________
1131Double_t AliAODTrack::GetMassForTracking() const
1132{
10d99e43 1133 int pid = fPIDForTracking;
1134 if (pid<AliPID::kPion) pid = AliPID::kPion;
76b98553 1135 double m = AliPID::ParticleMass(fPIDForTracking);
1136 return (fPIDForTracking==AliPID::kHe3 || fPIDForTracking==AliPID::kAlpha) ? -m : m;
1137}
42fcc729 1138//_______________________________________________________
1139const AliTOFHeader* AliAODTrack::GetTOFHeader() const {
1140 return fAODEvent->GetTOFHeader();
1141}