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