]>
Commit | Line | Data |
---|---|---|
108615fc | 1 | |
2 | #include <math.h> | |
3 | ||
4 | #include "AliL3Transform.h" | |
5 | #include "AliL3Defs.h" | |
6 | #include "AliL3HoughTrack.h" | |
7 | ||
8 | ClassImp(AliL3HoughTrack) | |
9 | ||
10 | ||
11 | AliL3HoughTrack::AliL3HoughTrack() | |
12 | { | |
13 | //Constructor | |
14 | ||
15 | fWeight = 0; | |
16 | fMinDist=0; | |
17 | fTransform = new AliL3Transform(); | |
18 | fDLine = 0; | |
19 | fPsiLine = 0; | |
20 | fIsHelix = true; | |
21 | } | |
22 | ||
23 | ||
24 | AliL3HoughTrack::~AliL3HoughTrack() | |
25 | { | |
26 | //Destructor | |
27 | if(fTransform) | |
28 | delete fTransform; | |
29 | } | |
30 | ||
31 | void AliL3HoughTrack::Set(AliL3Track *track) | |
32 | { | |
33 | ||
34 | AliL3HoughTrack *tpt = (AliL3HoughTrack*)track; | |
35 | ||
36 | fWeight = tpt->GetWeight(); | |
37 | fDLine = tpt->GetDLine(); | |
38 | fPsiLine = tpt->GetPsiLine(); | |
39 | SetNHits(tpt->GetWeight()); | |
40 | SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow()); | |
41 | fIsHelix = false; | |
42 | ||
43 | ||
44 | } | |
45 | ||
46 | void AliL3HoughTrack::SetTrackParameters(Double_t kappa,Double_t phi,Int_t weight) | |
47 | { | |
48 | ||
49 | fWeight = weight; | |
50 | fMinDist = 100000; | |
51 | SetKappa(kappa); | |
52 | SetPhi0(phi); | |
53 | Double_t pt = fabs(BFACT*bField/kappa); | |
54 | SetPt(pt); | |
55 | Double_t radius = 1/fabs(kappa); | |
56 | SetRadius(radius); | |
57 | ||
58 | //set nhits for sorting. | |
59 | SetNHits(weight); | |
60 | ||
61 | SetCharge(copysign(1,kappa)); | |
62 | Double_t charge = -1.*kappa; | |
63 | Double_t trackPhi0 = GetPhi0() + charge*0.5*Pi/fabs(charge); | |
64 | ||
65 | //The first point on track is origo: | |
66 | Double_t x0=0; | |
67 | Double_t y0=0; | |
68 | ||
69 | Double_t xc = x0 - GetRadius() * cos(trackPhi0) ; | |
70 | Double_t yc = y0 - GetRadius() * sin(trackPhi0) ; | |
71 | SetCenterX(xc); | |
72 | SetCenterY(yc); | |
73 | fIsHelix = true; | |
74 | } | |
75 | ||
76 | void AliL3HoughTrack::SetLineParameters(Double_t psi,Double_t D,Int_t weight,Int_t *rowrange,Int_t ref_row) | |
77 | { | |
78 | //Initialize a track piece, not yet a track | |
79 | //Used in case of straight line transformation | |
80 | ||
81 | //Transform line parameters to coordinate system of slice: | |
82 | ||
83 | D = D + fTransform->Row2X(ref_row)*cos(psi); | |
84 | ||
85 | fDLine = D; | |
86 | fPsiLine = psi; | |
87 | fWeight = weight; | |
88 | SetNHits(weight); | |
89 | SetRowRange(rowrange[0],rowrange[1]); | |
90 | fIsHelix = false; | |
91 | ||
92 | } | |
93 | ||
94 | void AliL3HoughTrack::SetBestMCid(Int_t mcid,Double_t min_dist) | |
95 | { | |
96 | ||
97 | if(min_dist < fMinDist) | |
98 | { | |
99 | fMinDist = min_dist; | |
100 | SetMCid(mcid); | |
101 | } | |
102 | ||
103 | } | |
104 | ||
105 | void AliL3HoughTrack::GetLineCrossingPoint(Int_t padrow,Double_t *xy) | |
106 | { | |
107 | ||
108 | ||
109 | if(fIsHelix) | |
110 | { | |
111 | printf("AliL3HoughTrack::GetLineCrossingPoint : Track is not a line\n"); | |
112 | return; | |
113 | } | |
114 | ||
115 | Double_t xhit = fTransform->Row2X(padrow); | |
116 | Double_t a = -1/tan(fPsiLine); | |
117 | Double_t b = fDLine/sin(fPsiLine); | |
118 | ||
119 | Double_t yhit = a*xhit + b; | |
120 | xy[0] = xhit; | |
121 | xy[1] = yhit; | |
122 | ||
123 | } | |
124 | ||
125 | Double_t AliL3HoughTrack::GetCrossingAngle(Int_t padrow) | |
126 | { | |
127 | //Calculate the crossing angle between track and given padrow. | |
128 | ||
129 | if(!fIsHelix) | |
130 | { | |
131 | printf("AliL3HoughTrack::GetCrossingAngle : Track is not a helix\n"); | |
132 | return 0; | |
133 | } | |
134 | ||
135 | if(!IsLocal()) | |
136 | { | |
137 | printf("Track is not given in local coordinates\n"); | |
138 | return 0; | |
139 | } | |
140 | ||
141 | Float_t xyz[3]; | |
142 | if(!GetCrossingPoint(padrow,xyz)) | |
143 | printf("AliL3HoughTrack::GetCrossingPoint : Track does not cross line!!\n"); | |
144 | ||
145 | ||
146 | //Convert center of curvature to local coordinates: | |
147 | //Float_t xyz_coc[3] = {GetCenterX(),GetCenterY(),0}; | |
148 | //fTransform->Global2Local(xyz_coc,slice); | |
149 | ||
150 | //Take the dot product of the tangent vector of the track, and | |
151 | //vector perpendicular to the padrow. | |
152 | ||
153 | Double_t tangent[2]; | |
154 | //tangent[1] = (xyz[0] - xyz_coc[0])/GetRadius(); | |
155 | //tangent[0] = -1.*(xyz[1] - xyz_coc[1])/GetRadius(); | |
156 | tangent[1] = (xyz[0] - GetCenterX())/GetRadius(); | |
157 | tangent[0] = -1.*(xyz[1] - GetCenterY())/GetRadius(); | |
158 | ||
159 | Double_t perp_padrow[2] = {1,0}; //locally in slice | |
160 | ||
161 | Double_t cos_beta = fabs(tangent[0]*perp_padrow[0] + tangent[1]*perp_padrow[1]); | |
162 | return acos(cos_beta); | |
163 | ||
164 | } | |
165 | ||
166 | Bool_t AliL3HoughTrack::GetCrossingPoint(Int_t padrow,Float_t *xyz) | |
167 | { | |
168 | //Assumes the track is given in local coordinates | |
169 | ||
170 | if(!fIsHelix) | |
171 | { | |
172 | printf("AliL3HoughTrack::GetCrossingPoint : Track is not a helix\n"); | |
173 | return 0; | |
174 | } | |
175 | ||
176 | ||
177 | if(!IsLocal()) | |
178 | { | |
179 | printf("GetCrossingPoint: Track is given on global coordinates\n"); | |
180 | return false; | |
181 | } | |
182 | ||
183 | Double_t xHit = fTransform->Row2X(padrow); | |
184 | ||
185 | //xyz[0] = fTransform->Row2X(padrow); | |
186 | xyz[0] = xHit; | |
187 | Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX()); | |
188 | Double_t r2 = GetRadius()*GetRadius(); | |
189 | if(aa > r2) | |
190 | return false; | |
191 | ||
192 | Double_t aa2 = sqrt(r2 - aa); | |
193 | Double_t y1 = GetCenterY() + aa2; | |
194 | Double_t y2 = GetCenterY() - aa2; | |
195 | xyz[1] = y1; | |
196 | if(fabs(y2) < fabs(y1)) xyz[1] = y2; | |
197 | xyz[2] = 0; //only consider transverse plane | |
198 | ||
199 | return true; | |
200 | } | |
201 | ||
202 | ||
203 | Bool_t AliL3HoughTrack::GetCrossingPoint(Int_t slice,Int_t padrow,Float_t *xyz) | |
204 | { | |
205 | //Calculate the crossing point in transverse plane of this track and given | |
206 | //padrow (y = a*x + b). Point is given in local coordinates in slice. | |
207 | //Assumes the track is given in global coordinates. | |
208 | ||
209 | if(!fIsHelix) | |
210 | { | |
211 | printf("AliL3HoughTrack::GetCrossingPoint : Track is not a helix\n"); | |
212 | return 0; | |
213 | } | |
214 | ||
215 | ||
216 | if(IsLocal()) | |
217 | { | |
218 | printf("GetCrossingPoint: Track is given in local coordintes!!!\n"); | |
219 | return false; | |
220 | } | |
221 | ||
222 | Double_t padrowradii = fTransform->Row2X(padrow); | |
223 | ||
224 | ||
225 | Float_t rotation_angle = (slice*20)*ToRad; | |
226 | ||
227 | Float_t cs,sn; | |
228 | cs = cos(rotation_angle); | |
229 | sn = sin(rotation_angle); | |
230 | ||
231 | Double_t a = -1.*cs/sn; | |
232 | Double_t b = padrowradii/sn; | |
233 | ||
234 | Double_t ycPrime = GetCenterY() - b ; | |
235 | Double_t aa = ( 1. + a * a ) ; | |
236 | Double_t bb = -2. * ( GetCenterX() + a * ycPrime ) ; | |
237 | Double_t cc = ( GetCenterX() * GetCenterX() + ycPrime * ycPrime - GetRadius() * GetRadius() ) ; | |
238 | ||
239 | Double_t racine = bb * bb - 4. * aa * cc ; | |
240 | if ( racine < 0 ) return false ; | |
241 | Double_t rootRacine = sqrt(racine) ; | |
242 | ||
243 | Double_t oneOverA = 1./aa; | |
244 | // | |
245 | // First solution | |
246 | // | |
247 | Double_t x1 = 0.5 * oneOverA * ( -1. * bb + rootRacine ) ; | |
248 | Double_t y1 = a * x1 + b ; | |
249 | Double_t r1 = sqrt(x1*x1+y1*y1); | |
250 | // | |
251 | // Second solution | |
252 | // | |
253 | Double_t x2 = 0.5 * oneOverA * ( -1. * bb - rootRacine ) ; | |
254 | Double_t y2 = a * x2 + b ; | |
255 | Double_t r2 = sqrt(x2*x2+y2*y2); | |
256 | // | |
257 | // Choose close to (0,0) | |
258 | // | |
259 | Double_t xHit ; | |
260 | Double_t yHit ; | |
261 | if ( r1 < r2 ) { | |
262 | xHit = x1 ; | |
263 | yHit = y1 ; | |
264 | } | |
265 | else { | |
266 | xHit = x2 ; | |
267 | yHit = y2 ; | |
268 | } | |
269 | ||
270 | xyz[0] = xHit; | |
271 | xyz[1] = yHit; | |
272 | xyz[2] = 0; | |
273 | ||
274 | fTransform->Global2Local(xyz,slice); | |
275 | ||
276 | return true; | |
277 | } |