]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/src/AliL3ConfMapPoint.cxx
Only 1 file
[u/mrichter/AliRoot.git] / HLT / src / AliL3ConfMapPoint.cxx
1 // Author: Anders Vestbo <mailto:vestbo$fi.uib.no>
2 //*-- Copyright &copy ASV
3
4 #include <iostream.h>
5 #include <math.h>
6 #include "AliL3Logging.h"
7
8 #include "AliL3ConfMapPoint.h"
9 #include "AliL3SpacePointData.h"
10 #include "AliL3Vertex.h"
11 #include "AliL3ConfMapTrack.h"
12
13 //_____________________________________________________________
14 // AliL3ConfMapPoint
15 //
16 // Hit class for conformal mapper
17
18 ClassImp(AliL3ConfMapPoint)
19
20 AliL3ConfMapPoint::AliL3ConfMapPoint()
21 {
22   //Constructor
23   
24   SetUsage(false);
25   SetHitNumber(-1);
26   SetX(0);
27   SetY(0);
28   SetZ(0);
29   SetXerr(0);
30   SetYerr(0);
31   SetZerr(0);
32
33   SetPhi(0.);
34   SetEta(0.);
35   
36   SetXprime(0.);
37   SetYprime(0.);
38   SetXprimeerr(0.);
39   SetYprimeerr(0.);
40   SetIntPoint(0., 0., 0., 0., 0., 0.);
41   SetShiftedCoord();
42   SetMCTrackID(0,0,0);
43 }
44
45 AliL3ConfMapPoint::~AliL3ConfMapPoint()
46 {
47   // Destructor.
48   // Does nothing except destruct. 
49 }
50
51 Bool_t AliL3ConfMapPoint::ReadHits(AliL3SpacePointData* hits ){
52   SetHitNumber(hits->fID);
53   SetPadRow(hits->fPadRow);
54   Int_t slice = (hits->fID>>25) & 0x7f;
55   SetSector(slice);
56   SetX(hits->fX);
57   SetY(hits->fY);
58   SetZ(hits->fZ);
59   SetXerr(sqrt(hits->fXYErr));
60   SetYerr(sqrt(hits->fXYErr));
61   SetZerr(sqrt(hits->fZErr));
62   return kTRUE;
63 }
64
65 void AliL3ConfMapPoint::Setup(AliL3Vertex *vertex)
66 {
67   //Setup. Sets the vertex, conformal coordinates, and phi and eta of each hit.
68   
69   SetIntPoint(vertex->GetX(),    vertex->GetY(),    vertex->GetZ(),
70               vertex->GetXErr(), vertex->GetYErr(), vertex->GetZErr());
71   SetShiftedCoord();
72   SetConfCoord();
73   // The angles are set properly if they are set after the interaction point and the shifted coordinates
74   SetAngles();
75   //SetDist(0., 0.);
76   
77   return;
78 }
79
80 void AliL3ConfMapPoint::SetIntPoint(const Double_t in_x,const Double_t in_y, 
81                                const Double_t in_z,
82                                const Double_t in_x_err, const Double_t in_y_err, 
83                                const Double_t in_z_err)
84 {
85   // Defines a new interaction point. This point is needed to calculate
86   // the conformal coordinates.
87
88   SetXt(in_x);
89   SetYt(in_y);
90   SetZt(in_z);
91   SetXterr(in_x_err);
92   SetYterr(in_y_err);
93   SetZterr(in_z_err);
94
95   return;
96 }
97
98 void AliL3ConfMapPoint::SetAllCoord(const AliL3ConfMapPoint *preceding_hit)
99 {
100   // Sets the interaction point, the shifted coordinates, and the conformal mapping coordinates.
101   // These values are calculated from the interaction point of the given cluster which should be a
102   // already found cluster on the same track.
103
104   if (this == preceding_hit) {
105     SetIntPoint(preceding_hit->GetX(),    preceding_hit->GetY(),    preceding_hit->GetZ(),
106                 preceding_hit->GetXerr(), preceding_hit->GetYerr(), preceding_hit->GetZerr());
107   }
108
109   else {
110     SetIntPoint(preceding_hit->GetXt(),    preceding_hit->GetYt(),    preceding_hit->GetZt(),
111                 preceding_hit->GetXterr(), preceding_hit->GetYterr(), preceding_hit->GetZterr());
112   }
113
114   SetShiftedCoord();
115   SetConfCoord();
116
117   return;
118 }
119
120 void AliL3ConfMapPoint::SetShiftedCoord()
121 {
122   // Sets the coordinates with resepct to the given vertex point
123
124   SetXv(GetX() - fXt);
125   SetYv(GetY() - fYt);
126   SetZv(GetZ() - fZt);
127   /*
128   SetXverr(TMath::Sqrt(GetXerr()*GetXerr() + fXterr*fXterr));
129   SetYverr(TMath::Sqrt(GetYerr()*GetYerr() + fYterr*fYterr));
130   SetZverr(TMath::Sqrt(GetZerr()*GetZerr() + fZterr*fZterr));
131   */
132   return;
133 }
134
135 void AliL3ConfMapPoint::SetConfCoord()
136 {
137   // Calculates the conformal coordinates of one cluster.
138   // If the option "vertex_constraint" applies the interaction point is
139   // assumed to be at (0, 0, 0). Otherwise the function will use the
140   // interaction point specified by fXt and fYt.
141
142   Double_t r2;
143   Double_t xyErrorScale = 1;
144   Double_t szErrorScale = 1;
145
146   if ((r2 = fXv*fXv + fYv*fYv)) 
147     {
148       fXprime =  fXv / r2;
149       fYprime = -fYv / r2;
150       //  fXprimeerr = TMath::Sqrt(TMath::Power((-fXv * fXv +   fYv*fYv) * fXverr, 2) + TMath::Power( 2*fXv*fYv*fYverr, 2)) / TMath::Power(fXv*fXv + fYv*fYv, 2);
151       // fXprimeerr = TMath::Sqrt(TMath::Power((-fXv * fXv - 3*fYv*fYv) * fYverr, 2) + TMath::Power(-2*fXv*fYv*fXverr, 2)) / TMath::Power(fXv*fXv + fYv*fYv, 2);
152     
153       
154       //set weights:
155       //fWxy = r2*r2 / (TMath::Power(xyErrorScale,2)*(TMath::Power(xerr,2)+TMath::Power(yerr,2)));
156       fWxy = r2*r2 / ((xyErrorScale*xyErrorScale)*((xerr*xerr)+(yerr*yerr)));
157       s = 0; //track trajectory
158       //fWz = (Double_t)(1./TMath::Power(szErrorScale*zerr,2));
159       fWz = (Double_t)(1./(szErrorScale*zerr*zerr));
160     }
161   
162   else {
163     fXprime    = 0.;
164     fYprime    = 0.;
165     fXprimeerr = 0.;
166     fYprimeerr = 0.;
167     fWxy = 0;
168     fWz = 0;
169     s = 0;
170   }
171
172   return;
173 }
174
175 void AliL3ConfMapPoint::SetAngles()
176 {
177   // Calculates the angle phi and the pseudorapidity eta for each cluster.
178   /*
179   Double_t r = TMath::Sqrt(x*x + y*y);
180
181   fPhi = TMath::ATan2(y,x);
182   if(fPhi<0) fPhi = fPhi + 2*TMath::Pi();
183   fEta = 3.*z/(TMath::Abs(z)+2.*r);
184   return;
185   */
186   //  Double_t r3dim = TMath::Sqrt(fXv*fXv + fYv*fYv + fZv*fZv);
187   Double_t r3dim = sqrt(fXv*fXv + fYv*fYv + fZv*fZv);
188   //Double_t r2dim = TMath::Sqrt(fXv*fXv + fYv*fYv);
189
190   /*if (r2dim == 0.) {
191   // If r2dim == 0 the pseudorapidity eta cannot be calculated (division by zero)!
192   // This can only happen if the point is lying on the z-axis and this should never be possible.
193     cerr << "The pseudorapidity eta cannot be calculated (division by zero)! Set to 1.e-10." << endl;
194     r2dim = 1.e-10;
195   }
196
197   if (fXv == 0.) {
198     fPhi = (fYv > 0.) ? TMath::Pi() / 2. : - TMath::Pi() / 2.;
199   }
200
201   else {
202     fPhi = (fXv > 0.) ? TMath::ASin(fYv/r2dim) : TMath::Pi() - TMath::ASin(fYv/r2dim);
203   }
204
205   if (fPhi < 0.) {
206     fPhi += 2. * TMath::Pi();
207   }
208   */
209   //fPhi = TMath::ATan2(y,x);
210   fPhi = atan2(y,x);
211   //if(fPhi<0) fPhi = fPhi + 2*TMath::Pi();
212   
213   //fEta = 0.5 * TMath::Log((r3dim + fZv)/(r3dim - fZv));
214   fEta = 0.5 * log((r3dim + fZv)/(r3dim - fZv));
215   return;
216 }
217 /*
218 AliL3ConfMapTrack *AliL3ConfMapPoint::GetTrack(TClonesArray *tracks) const
219 {
220   // Returns the pointer to the track to which this hit belongs.
221   
222   return (AliL3ConfMapTrack*)tracks->At(this->GetTrackNumber());
223 }
224 */