]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSglobalRecPoint.cxx
Inheritance from TObject. Automatic streamers.
[u/mrichter/AliRoot.git] / ITS / AliITSglobalRecPoint.cxx
1 #include <stdlib.h>
2 #include <iostream.h>
3
4 #include <TROOT.h>
5 #include <TMath.h>
6 #include <TString.h>
7
8 #include "AliITSglobalRecPoint.h"
9
10
11 ClassImp(AliITSglobalRecPoint)
12 //
13 //
14 //
15 AliITSglobalRecPoint::AliITSglobalRecPoint()
16 {
17         // Default constructor:
18         // sets to zero all members
19         fLayer = 0;
20         
21         fGX = fGSX = 0.0;
22         fGY = fGSY = 0.0;
23         fGZ = fGSZ = 0.0;
24         
25         fR2 = fR3 = fPhi = fTheta = 0.0;
26         
27         fLabel[0] = fLabel[1] = fLabel[2] = -1;
28         fKalmanLabel = 0;
29         fSign = 0;
30         fModule = 0;
31         fPosInModule = 0;
32         
33         fUsed = 0;
34 }
35 //
36 //
37 //
38 AliITSglobalRecPoint::AliITSglobalRecPoint(Double_t gx, Double_t gy, 
39         Double_t gz, Double_t gsx, Double_t gsy, Double_t gsz, Int_t l) : 
40         fGX(gx), fGY(gy), fGZ(gz), fGSX(gsx), fGSY(gsy), fGSZ(gsz), fLayer(l)
41 {
42         fR2 = TMath::Sqrt(fGX*fGX + fGY*fGY);
43         fR3 = TMath::Sqrt(fGX*fGX + fGY*fGY + fGZ*fGZ); 
44         fPhi = TMath::ATan2(fGY, fGX);
45         if (fPhi < 0.0) fPhi = 2.0 * TMath::Pi() + fPhi;
46         fTheta = TMath::ATan2(fR2, fGZ);
47         
48         fLabel[0] = fLabel[1] = fLabel[2] = -1;
49         fUsed = 0;
50         fKalmanLabel = 0;
51         fSign = 0;
52         fModule = 0;
53         fPosInModule = 0;
54 }
55 //
56 //
57 /*
58 Double_t AliITSglobalRecPoint::GetGlobalSigmaR2()
59 {       
60         // Square sigma of the 2-D radius:
61         // = X^2 * Sx^2 + Y^2 * Sy^2
62         
63         Double_t answer = fGX*fGX*fGSigmaX + fGY*fGY*fGSigmaY;
64         return answer / (fR2 * fR2);
65 }
66 //
67 //
68 //
69 Double_t AliITSglobalRecPoint::GetGlobalSigmaR3()
70 {
71         // Square sigma of the 3-D radius:
72         // = (X^2 * Sx^2 + Y^2 * Sy^2 + Z^2 * Sz^2) / R^2
73         // R in 3-D, r in 2-D
74         
75         Double_t answer = fGX*fGX*fGSigmaX + fGY*fGY*fGSigmaY + fGZ*fGZ*fGSigmaZ;
76         return answer / (fR3 * fR3);
77 }
78 //
79 //
80 //
81 Double_t AliITSglobalRecPoint::GetGlobalSigmaTheta()
82 {
83         // Square sigma of theta:
84         // = (Z^2 * (X^2 * Sx^2 + Y^2 * Sy^2) + r^4 * Sz^2) / (R^4 * r^2)
85         // R in 3-D, r in 2-D
86         
87         Double_t answer = fGZ*fGZ*(fGX*fGX*fGSigmaX + fGY*fGY*fGSigmaY) + fR2*fR2*fR2*fR2*fGSigmaZ;
88         return answer / (fR3*fR3*fR3*fR3*fR2*fR2);
89 }
90 //
91 //
92 //
93 Double_t AliITSglobalRecPoint::GetGlobalSigmaPhi()
94 {
95         // Square sigma of phi:
96         // = (Y^2 * Sx^2 + X^2 * Sy^2) / r^4
97         // R in 3-D, r in 2-D
98         
99         Double_t answer = fGY*fGY*fGSigmaX + fGX*fGX*fGSigmaY;
100         return answer / (fR2 * fR2 * fR2 * fR2);
101 }
102 //
103 //
104 //
105 Bool_t AliITSglobalRecPoint::SharesID(AliITSRecPoint* pt)
106 {
107         // Controls if there is a track index shared by two points
108         
109         Bool_t ok = kFALSE;
110         Int_t i, j;
111         for (i = 0; i < 3; i++) {
112                 if (fTracks[i] < 0) continue;
113                 for (j = 0; j < 3; j++) {
114                         if (pt->fTracks[j] < 0) continue;
115                         ok = ok || (fTracks[i] == pt->fTracks[j]);
116                 }
117         }
118         return ok;
119 }
120 */
121 //
122 //
123 Double_t AliITSglobalRecPoint::DPhi(AliITSglobalRecPoint *p)
124 {
125         // Absolute value of the difference
126         // between 'phi' coordinates of two points
127         // controlled in order to avoid that, for
128         // reasons of initial values, it come > 180. degrees
129         
130         Double_t phi = TMath::Abs(fPhi - p->fPhi);
131         if (phi > TMath::Pi())
132                 phi = 2.0 * TMath::Pi() - phi;
133         return phi;
134 }
135 //
136 //
137 //
138 Double_t AliITSglobalRecPoint::DTheta(AliITSglobalRecPoint *p)
139 {
140         // Absolute value of the difference
141         // between 'theta' coordinates of two points
142         
143         return TMath::Abs(fTheta - p->fTheta);
144 }
145 //
146 //
147 //
148 Int_t AliITSglobalRecPoint::Compare(const TObject *O) const
149 {
150         // Criterion for sorting:
151         // p1 < p2 if p1.phi < p2.phi;
152         
153         // Casting to convert the given argument to rec-point
154         AliITSglobalRecPoint *you = (AliITSglobalRecPoint*)O;
155         
156         // Comparation
157         if (fLayer < you->fLayer)
158                 return -1;
159         else if (fLayer > you->fLayer)
160                 return 1;
161         else {
162                 if (fPhi < you->fPhi)
163                         return -1;
164                 else if (fPhi > you->fPhi)
165                         return 1;
166                 else
167                         return 0;
168         }
169 }
170 //
171 //
172 //