]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODTrack.cxx
Added possibility to invert the sign of the parametization
[u/mrichter/AliRoot.git] / STEER / 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"
df9db588 25#include "AliAODTrack.h"
26
27ClassImp(AliAODTrack)
28
29//______________________________________________________________________________
30AliAODTrack::AliAODTrack() :
4f6e22bd 31 AliVTrack(),
f43586f0 32 fRAtAbsorberEnd(0.),
1912763f 33 fChi2perNDF(-999.),
9333290e 34 fChi2MatchTrigger(0.),
6efb741f 35 fFlags(0),
df9db588 36 fLabel(-999),
1912763f 37 fITSMuonClusterMap(0),
9333290e 38 fFilterMap(0),
d999f2e6 39 fTPCClusterMap(),
40 fTPCSharedMap(),
02153d58 41 fID(-999),
9333290e 42 fCharge(-99),
e1c744ca 43 fType(kUndef),
9333290e 44 fCovMatrix(NULL),
7be1db84 45 fDetPid(NULL),
46 fProdVertex(NULL)
df9db588 47{
48 // default constructor
49
50 SetP();
51 SetPosition((Float_t*)NULL);
6c954176 52 SetXYAtDCA(-999., -999.);
53 SetPxPyPzAtDCA(-999., -999., -999.);
df9db588 54 SetPID((Float_t*)NULL);
55}
56
57//______________________________________________________________________________
02153d58 58AliAODTrack::AliAODTrack(Short_t id,
df9db588 59 Int_t label,
60 Double_t p[3],
61 Bool_t cartesian,
62 Double_t x[3],
63 Bool_t isDCA,
64 Double_t covMatrix[21],
65 Short_t charge,
66 UChar_t itsClusMap,
67 Double_t pid[10],
68 AliAODVertex *prodVertex,
1912763f 69 Bool_t usedForVtxFit,
dc825b15 70 Bool_t usedForPrimVtxFit,
ec40c484 71 AODTrk_t ttype,
862ce351 72 UInt_t selectInfo,
73 Float_t chi2perNDF) :
4f6e22bd 74 AliVTrack(),
f43586f0 75 fRAtAbsorberEnd(0.),
862ce351 76 fChi2perNDF(chi2perNDF),
9333290e 77 fChi2MatchTrigger(0.),
6efb741f 78 fFlags(0),
df9db588 79 fLabel(label),
6c954176 80 fITSMuonClusterMap(0),
9333290e 81 fFilterMap(selectInfo),
d999f2e6 82 fTPCClusterMap(),
83 fTPCSharedMap(),
02153d58 84 fID(id),
9333290e 85 fCharge(charge),
e1c744ca 86 fType(ttype),
9333290e 87 fCovMatrix(NULL),
7be1db84 88 fDetPid(NULL),
9333290e 89 fProdVertex(prodVertex)
df9db588 90{
91 // constructor
92
93 SetP(p, cartesian);
94 SetPosition(x, isDCA);
6c954176 95 SetXYAtDCA(-999., -999.);
96 SetPxPyPzAtDCA(-999., -999., -999.);
1912763f 97 SetUsedForVtxFit(usedForVtxFit);
dc825b15 98 SetUsedForPrimVtxFit(usedForPrimVtxFit);
df9db588 99 if(covMatrix) SetCovMatrix(covMatrix);
100 SetPID(pid);
6c954176 101 SetITSClusterMap(itsClusMap);
df9db588 102}
103
104//______________________________________________________________________________
02153d58 105AliAODTrack::AliAODTrack(Short_t id,
df9db588 106 Int_t label,
107 Float_t p[3],
108 Bool_t cartesian,
109 Float_t x[3],
110 Bool_t isDCA,
111 Float_t covMatrix[21],
112 Short_t charge,
113 UChar_t itsClusMap,
114 Float_t pid[10],
115 AliAODVertex *prodVertex,
1912763f 116 Bool_t usedForVtxFit,
dc825b15 117 Bool_t usedForPrimVtxFit,
ec40c484 118 AODTrk_t ttype,
862ce351 119 UInt_t selectInfo,
120 Float_t chi2perNDF) :
4f6e22bd 121 AliVTrack(),
f43586f0 122 fRAtAbsorberEnd(0.),
862ce351 123 fChi2perNDF(chi2perNDF),
9333290e 124 fChi2MatchTrigger(0.),
6efb741f 125 fFlags(0),
df9db588 126 fLabel(label),
6c954176 127 fITSMuonClusterMap(0),
9333290e 128 fFilterMap(selectInfo),
d999f2e6 129 fTPCClusterMap(),
130 fTPCSharedMap(),
02153d58 131 fID(id),
9333290e 132 fCharge(charge),
e1c744ca 133 fType(ttype),
9333290e 134 fCovMatrix(NULL),
7be1db84 135 fDetPid(NULL),
9333290e 136 fProdVertex(prodVertex)
df9db588 137{
138 // constructor
139
140 SetP(p, cartesian);
141 SetPosition(x, isDCA);
6c954176 142 SetXYAtDCA(-999., -999.);
143 SetPxPyPzAtDCA(-999., -999., -999.);
1912763f 144 SetUsedForVtxFit(usedForVtxFit);
dc825b15 145 SetUsedForPrimVtxFit(usedForPrimVtxFit);
df9db588 146 if(covMatrix) SetCovMatrix(covMatrix);
147 SetPID(pid);
6c954176 148 SetITSClusterMap(itsClusMap);
df9db588 149}
150
df9db588 151//______________________________________________________________________________
152AliAODTrack::~AliAODTrack()
153{
154 // destructor
155 delete fCovMatrix;
7450f8ab 156 delete fDetPid;
df9db588 157}
158
159
160//______________________________________________________________________________
161AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
4f6e22bd 162 AliVTrack(trk),
f43586f0 163 fRAtAbsorberEnd(trk.fRAtAbsorberEnd),
1912763f 164 fChi2perNDF(trk.fChi2perNDF),
9333290e 165 fChi2MatchTrigger(trk.fChi2MatchTrigger),
6efb741f 166 fFlags(trk.fFlags),
df9db588 167 fLabel(trk.fLabel),
1912763f 168 fITSMuonClusterMap(trk.fITSMuonClusterMap),
9333290e 169 fFilterMap(trk.fFilterMap),
d999f2e6 170 fTPCClusterMap(trk.fTPCClusterMap),
171 fTPCSharedMap(trk.fTPCSharedMap),
02153d58 172 fID(trk.fID),
9333290e 173 fCharge(trk.fCharge),
e1c744ca 174 fType(trk.fType),
9333290e 175 fCovMatrix(NULL),
7be1db84 176 fDetPid(NULL),
9333290e 177 fProdVertex(trk.fProdVertex)
df9db588 178{
179 // Copy constructor
180
181 trk.GetP(fMomentum);
182 trk.GetPosition(fPosition);
6c954176 183 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
184 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
1912763f 185 SetUsedForVtxFit(trk.GetUsedForVtxFit());
dc825b15 186 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
5d62ce04 187 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
7be1db84 188 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
df9db588 189 SetPID(trk.fPID);
df9db588 190}
191
192//______________________________________________________________________________
193AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
194{
195 // Assignment operator
196 if(this!=&trk) {
197
4f6e22bd 198 AliVTrack::operator=(trk);
df9db588 199
200 trk.GetP(fMomentum);
201 trk.GetPosition(fPosition);
202 trk.GetPID(fPID);
203
6c954176 204 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
205 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
206
f43586f0 207 fRAtAbsorberEnd = trk.fRAtAbsorberEnd;
208
1912763f 209 fChi2perNDF = trk.fChi2perNDF;
9333290e 210 fChi2MatchTrigger = trk.fChi2MatchTrigger;
df9db588 211
6efb741f 212 fFlags = trk.fFlags;
df9db588 213 fLabel = trk.fLabel;
214
9333290e 215 fITSMuonClusterMap = trk.fITSMuonClusterMap;
216 fFilterMap = trk.fFilterMap;
217
6efb741f 218 fID = trk.fID;
219
9333290e 220 fCharge = trk.fCharge;
221 fType = trk.fType;
222
df9db588 223 delete fCovMatrix;
5d62ce04 224 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
df9db588 225 else fCovMatrix=NULL;
226 fProdVertex = trk.fProdVertex;
227
1912763f 228 SetUsedForVtxFit(trk.GetUsedForVtxFit());
dc825b15 229 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
7be1db84 230
231 delete fDetPid;
232 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
233 else fDetPid=NULL;
df9db588 234 }
235
236 return *this;
237}
238
4697e4fb 239//______________________________________________________________________________
240Double_t AliAODTrack::M(AODTrkPID_t pid) const
241{
242 // Returns the mass.
9861edc0 243 // Masses for nuclei don't exist in the PDG tables, therefore they were put by hand.
4697e4fb 244
245 switch (pid) {
246
247 case kElectron :
9861edc0 248 return 0.000510999; //TDatabasePDG::Instance()->GetParticle(11/*::kElectron*/)->Mass();
4697e4fb 249 break;
250
251 case kMuon :
9861edc0 252 return 0.1056584; //TDatabasePDG::Instance()->GetParticle(13/*::kMuonMinus*/)->Mass();
4697e4fb 253 break;
254
255 case kPion :
9861edc0 256 return 0.13957; //TDatabasePDG::Instance()->GetParticle(211/*::kPiPlus*/)->Mass();
4697e4fb 257 break;
258
259 case kKaon :
9861edc0 260 return 0.4937; //TDatabasePDG::Instance()->GetParticle(321/*::kKPlus*/)->Mass();
4697e4fb 261 break;
262
263 case kProton :
9861edc0 264 return 0.9382720; //TDatabasePDG::Instance()->GetParticle(2212/*::kProton*/)->Mass();
4697e4fb 265 break;
266
267 case kDeuteron :
9861edc0 268 return 1.8756; //TDatabasePDG::Instance()->GetParticle(1000010020)->Mass();
4697e4fb 269 break;
270
271 case kTriton :
9861edc0 272 return 2.8089; //TDatabasePDG::Instance()->GetParticle(1000010030)->Mass();
4697e4fb 273 break;
274
275 case kHelium3 :
9861edc0 276 return 2.8084; //TDatabasePDG::Instance()->GetParticle(1000020030)->Mass();
4697e4fb 277 break;
278
279 case kAlpha :
9861edc0 280 return 3.7274; //TDatabasePDG::Instance()->GetParticle(1000020040)->Mass();
4697e4fb 281 break;
282
283 case kUnknown :
284 return -999.;
285 break;
286
287 default :
288 return -999.;
289 }
290}
291
292//______________________________________________________________________________
293Double_t AliAODTrack::E(AODTrkPID_t pid) const
294{
295 // Returns the energy of the particle of a given pid.
296
297 if (pid != kUnknown) { // particle was identified
298 Double_t m = M(pid);
299 return TMath::Sqrt(P()*P() + m*m);
300 } else { // pid unknown
301 return -999.;
302 }
303}
304
305//______________________________________________________________________________
306Double_t AliAODTrack::Y(AODTrkPID_t pid) const
307{
9861edc0 308 // Returns the rapidity of a particle of a given pid.
4697e4fb 309
310 if (pid != kUnknown) { // particle was identified
311 Double_t e = E(pid);
312 Double_t pz = Pz();
313 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
314 return 0.5*TMath::Log((e+pz)/(e-pz));
315 } else { // energy not known or equal to pz
316 return -999.;
317 }
318 } else { // pid unknown
319 return -999.;
320 }
321}
322
323//______________________________________________________________________________
324Double_t AliAODTrack::Y(Double_t m) const
325{
9861edc0 326 // Returns the rapidity of a particle of a given mass.
4697e4fb 327
328 if (m >= 0.) { // mass makes sense
329 Double_t e = E(m);
330 Double_t pz = Pz();
331 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
332 return 0.5*TMath::Log((e+pz)/(e-pz));
333 } else { // energy not known or equal to pz
334 return -999.;
335 }
336 } else { // pid unknown
337 return -999.;
338 }
339}
340
341//______________________________________________________________________________
342AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
343{
344 // Returns the most probable PID array element.
345
346 Int_t nPID = 10;
347 if (fPID) {
348 AODTrkPID_t loc = kUnknown;
349 Double_t max = 0.;
350 Bool_t allTheSame = kTRUE;
351
352 for (Int_t iPID = 0; iPID < nPID; iPID++) {
353 if (fPID[iPID] >= max) {
354 if (fPID[iPID] > max) {
355 allTheSame = kFALSE;
356 max = fPID[iPID];
357 loc = (AODTrkPID_t)iPID;
358 } else {
359 allTheSame = kTRUE;
360 }
361 }
362 }
363
364 return allTheSame ? kUnknown : loc;
365 } else {
366 return kUnknown;
367 }
368}
369
370//______________________________________________________________________________
371void AliAODTrack::ConvertAliPIDtoAODPID()
372{
373 // Converts AliPID array.
374 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
375 // Everything else has to be set to zero.
376
377 fPID[kDeuteron] = 0.;
8a1418dc 378 fPID[kTriton] = 0.;
379 fPID[kHelium3] = 0.;
380 fPID[kAlpha] = 0.;
381 fPID[kUnknown] = 0.;
4697e4fb 382
383 return;
384}
385
386
df9db588 387//______________________________________________________________________________
388template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
389{
8a1418dc 390 // Set the momentum
df9db588 391
392 if (p) {
393 if (cartesian) {
16b65f2a 394 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
0c5f89fb 395 Double_t pp = TMath::Sqrt(pt2 + p[2]*p[2]);
df9db588 396
16b65f2a 397 fMomentum[0] = TMath::Sqrt(pt2); // pt
b1a9edc8 398 fMomentum[1] = (pt2 != 0.) ? TMath::Pi()+TMath::ATan2(-p[1], -p[0]) : -999; // phi
0c5f89fb 399 fMomentum[2] = (pp != 0.) ? TMath::ACos(p[2] / pp) : -999.; // theta
df9db588 400 } else {
16b65f2a 401 fMomentum[0] = p[0]; // pt
df9db588 402 fMomentum[1] = p[1]; // phi
403 fMomentum[2] = p[2]; // theta
404 }
405 } else {
406 fMomentum[0] = -999.;
407 fMomentum[1] = -999.;
408 fMomentum[2] = -999.;
409 }
410}
411
412//______________________________________________________________________________
413template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
414{
415 // set the position
416
417 if (x) {
418 if (!dca) {
419 ResetBit(kIsDCA);
420
421 fPosition[0] = x[0];
422 fPosition[1] = x[1];
423 fPosition[2] = x[2];
424 } else {
425 SetBit(kIsDCA);
426 // don't know any better yet
427 fPosition[0] = -999.;
428 fPosition[1] = -999.;
429 fPosition[2] = -999.;
430 }
431 } else {
432 ResetBit(kIsDCA);
433
434 fPosition[0] = -999.;
435 fPosition[1] = -999.;
436 fPosition[2] = -999.;
437 }
438}
439
440//______________________________________________________________________________
441void AliAODTrack::SetDCA(Double_t d, Double_t z)
442{
443 // set the dca
444 fPosition[0] = d;
445 fPosition[1] = z;
446 fPosition[2] = 0.;
447 SetBit(kIsDCA);
448}
449
450//______________________________________________________________________________
451void AliAODTrack::Print(Option_t* /* option */) const
452{
453 // prints information about AliAODTrack
454
455 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
456 printf(" px = %f\n", Px());
457 printf(" py = %f\n", Py());
458 printf(" pz = %f\n", Pz());
459 printf(" pt = %f\n", Pt());
460 printf(" 1/pt = %f\n", OneOverPt());
461 printf(" theta = %f\n", Theta());
462 printf(" phi = %f\n", Phi());
1912763f 463 printf(" chi2/NDF = %f\n", Chi2perNDF());
df9db588 464 printf(" charge = %d\n", Charge());
df9db588 465}
466
2200238e 467//______________________________________________________________________________
468void AliAODTrack::SetMatchTrigger(Int_t matchTrig)
469{
470 // Set the MUON trigger information
8ac4fa64 471 switch(matchTrig){
e1c744ca 472 case 0: // 0 track does not match trigger
473 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
474 break;
475 case 1: // 1 track match but does not pass pt cut
476 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
477 break;
478 case 2: // 2 track match Low pt cut
479 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
480 break;
481 case 3: // 3 track match High pt cut
482 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
483 break;
484 default:
485 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
8ac4fa64 486 AliWarning(Form("unknown case for matchTrig: %d\n",matchTrig));
e1c744ca 487 }
488}
489
2200238e 490//______________________________________________________________________________
491Bool_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber, Int_t cathode) const
492{
493 // return kTRUE if the track fires the given tracking or trigger chamber.
494 // If the chamber is a trigger one:
495 // - if cathode = 0 or 1, the track matches the corresponding cathode
496 // - if cathode = -1, the track matches both cathodes
497
498 if (MuonChamber < 0) return kFALSE;
499
500 if (MuonChamber < 10) return TESTBIT(GetMUONClusterMap(), MuonChamber);
501
502 if (MuonChamber < 14) {
503
504 if (cathode < 0) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber) &&
505 TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+4);
506
507 if (cathode < 2) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+(1-cathode)*4);
508
e1c744ca 509 }
2200238e 510
511 return kFALSE;
e1c744ca 512}
513
2200238e 514//______________________________________________________________________________
515Bool_t AliAODTrack::MatchTriggerDigits() const
516{
517 // return kTRUE if the track matches a digit on both planes of at least 2 trigger chambers
6c954176 518
2200238e 519 Int_t nMatchedChambers = 0;
520 for (Int_t ich=10; ich<14; ich++) if (HitsMuonChamber(ich)) nMatchedChambers++;
521
522 return (nMatchedChambers >= 2);
e1c744ca 523}
c683ddc2 524