CurrentTrack replaced by GetCurrentTrackNumber
[u/mrichter/AliRoot.git] / PMD / AliPMDUtility.cxx
CommitLineData
638f6e9b 1//-----------------------------------------------------//
2// //
3// //
4// Date : August 05 2003 //
5// //
6// Utility code for ALICE-PMD //
7// //
8//-----------------------------------------------------//
9
10#include "AliPMDUtility.h"
11#include "TMath.h"
12#include <stdio.h>
13
14ClassImp(AliPMDUtility)
15
16AliPMDUtility::AliPMDUtility()
17{
18 fPx = 0.;
19 fPy = 0.;
20 fPz = 0.;
21 fTheta = 0.;
22 fEta = 0.;
23 fPhi = 0.;
24}
25
26AliPMDUtility::AliPMDUtility(Float_t Px, Float_t Py, Float_t Pz)
27{
28 fPx = Px;
29 fPy = Py;
30 fPz = Pz;
31 fTheta = 0.;
32 fEta = 0.;
33 fPhi = 0.;
34}
35
36AliPMDUtility::~AliPMDUtility()
37{
38
39}
40
41void AliPMDUtility::SetPxPyPz(Float_t Px, Float_t Py, Float_t Pz)
42{
43 fPx = Px;
44 fPy = Py;
45 fPz = Pz;
46}
47
48void AliPMDUtility::SetXYZ(Float_t xPos, Float_t yPos, Float_t zPos)
49{
50 fPx = xPos;
51 fPy = yPos;
52 fPz = zPos;
53}
54void AliPMDUtility::CalculateEta()
55{
56 Float_t rpxpy, theta, eta;
57
58 rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
59 theta = TMath::ATan2(rpxpy,fPz);
60 eta = -TMath::Log(TMath::Tan(0.5*theta));
61 fTheta = theta;
62 fEta = eta;
63}
64void AliPMDUtility::CalculatePhi()
65{
66 Float_t pybypx, phi = 0., phi1;
67
68 if(fPx==0)
69 {
70 if(fPy>0) phi = 90.;
71 if(fPy<0) phi = 270.;
72 }
73 if(fPx != 0)
74 {
75 pybypx = fPy/fPx;
76 if(pybypx < 0) pybypx = - pybypx;
77 phi1 = TMath::ATan(pybypx)*180./3.14159;
78 if(fPx < 0 && fPy > 0) phi = 180 - phi1;
79 if(fPx < 0 && fPy < 0) phi = 180 + phi1;
80 if(fPx > 0 && fPy < 0) phi = 360 - phi1;
81 if(fPx > 0 && fPy > 0) phi = phi1;
82 }
83 phi = phi*3.14159/180.;
84
85 fPhi = phi;
86
87}
88void AliPMDUtility::CalculateEtaPhi()
89{
90 Float_t rpxpy, theta, eta;
91 Float_t pybypx, phi = 0., phi1;
92
93 rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
94 theta = TMath::ATan2(rpxpy,fPz);
95 eta = -TMath::Log(TMath::Tan(0.5*theta));
96
97 if(fPx==0)
98 {
99 if(fPy>0) phi = 90.;
100 if(fPy<0) phi = 270.;
101 }
102 if(fPx != 0)
103 {
104 pybypx = fPy/fPx;
105 if(pybypx < 0) pybypx = - pybypx;
106 phi1 = TMath::ATan(pybypx)*180./3.14159;
107 if(fPx < 0 && fPy > 0) phi = 180 - phi1;
108 if(fPx < 0 && fPy < 0) phi = 180 + phi1;
109 if(fPx > 0 && fPy < 0) phi = 360 - phi1;
110 if(fPx > 0 && fPy > 0) phi = phi1;
111 }
112 phi = phi*3.14159/180.;
113
114 fTheta = theta;
115 fEta = eta;
116 fPhi = phi;
117}
118Float_t AliPMDUtility::GetTheta() const
119{
120 return fTheta;
121}
122Float_t AliPMDUtility::GetEta() const
123{
124 return fEta;
125}
126Float_t AliPMDUtility::GetPhi() const
127{
128 return fPhi;
129}
130