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