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