4 #include "AliL3Transform.h"
6 #include "AliL3HoughTrack.h"
8 ClassImp(AliL3HoughTrack)
11 AliL3HoughTrack::AliL3HoughTrack()
17 fTransform = new AliL3Transform();
24 AliL3HoughTrack::~AliL3HoughTrack()
31 void AliL3HoughTrack::Set(AliL3Track *track)
34 AliL3HoughTrack *tpt = (AliL3HoughTrack*)track;
36 fWeight = tpt->GetWeight();
37 fDLine = tpt->GetDLine();
38 fPsiLine = tpt->GetPsiLine();
39 SetNHits(tpt->GetWeight());
40 SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
46 void AliL3HoughTrack::SetTrackParameters(Double_t kappa,Double_t phi,Int_t weight)
53 Double_t pt = fabs(BFACT*bField/kappa);
55 Double_t radius = 1/fabs(kappa);
58 //set nhits for sorting.
61 SetCharge(copysign(1,kappa));
62 Double_t charge = -1.*kappa;
63 Double_t trackPhi0 = GetPhi0() + charge*0.5*Pi/fabs(charge);
65 //The first point on track is origo:
69 Double_t xc = x0 - GetRadius() * cos(trackPhi0) ;
70 Double_t yc = y0 - GetRadius() * sin(trackPhi0) ;
76 void AliL3HoughTrack::SetLineParameters(Double_t psi,Double_t D,Int_t weight,Int_t *rowrange,Int_t ref_row)
78 //Initialize a track piece, not yet a track
79 //Used in case of straight line transformation
81 //Transform line parameters to coordinate system of slice:
83 D = D + fTransform->Row2X(ref_row)*cos(psi);
89 SetRowRange(rowrange[0],rowrange[1]);
94 void AliL3HoughTrack::SetBestMCid(Int_t mcid,Double_t min_dist)
97 if(min_dist < fMinDist)
105 void AliL3HoughTrack::GetLineCrossingPoint(Int_t padrow,Double_t *xy)
111 printf("AliL3HoughTrack::GetLineCrossingPoint : Track is not a line\n");
115 Double_t xhit = fTransform->Row2X(padrow);
116 Double_t a = -1/tan(fPsiLine);
117 Double_t b = fDLine/sin(fPsiLine);
119 Double_t yhit = a*xhit + b;
125 Double_t AliL3HoughTrack::GetCrossingAngle(Int_t padrow)
127 //Calculate the crossing angle between track and given padrow.
131 printf("AliL3HoughTrack::GetCrossingAngle : Track is not a helix\n");
137 printf("Track is not given in local coordinates\n");
142 if(!GetCrossingPoint(padrow,xyz))
143 printf("AliL3HoughTrack::GetCrossingPoint : Track does not cross line!!\n");
146 //Convert center of curvature to local coordinates:
147 //Float_t xyz_coc[3] = {GetCenterX(),GetCenterY(),0};
148 //fTransform->Global2Local(xyz_coc,slice);
150 //Take the dot product of the tangent vector of the track, and
151 //vector perpendicular to the padrow.
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();
159 Double_t perp_padrow[2] = {1,0}; //locally in slice
161 Double_t cos_beta = fabs(tangent[0]*perp_padrow[0] + tangent[1]*perp_padrow[1]);
162 return acos(cos_beta);
166 Bool_t AliL3HoughTrack::GetCrossingPoint(Int_t padrow,Float_t *xyz)
168 //Assumes the track is given in local coordinates
172 printf("AliL3HoughTrack::GetCrossingPoint : Track is not a helix\n");
179 printf("GetCrossingPoint: Track is given on global coordinates\n");
183 Double_t xHit = fTransform->Row2X(padrow);
185 //xyz[0] = fTransform->Row2X(padrow);
187 Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX());
188 Double_t r2 = GetRadius()*GetRadius();
192 Double_t aa2 = sqrt(r2 - aa);
193 Double_t y1 = GetCenterY() + aa2;
194 Double_t y2 = GetCenterY() - aa2;
196 if(fabs(y2) < fabs(y1)) xyz[1] = y2;
197 xyz[2] = 0; //only consider transverse plane
203 Bool_t AliL3HoughTrack::GetCrossingPoint(Int_t slice,Int_t padrow,Float_t *xyz)
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.
211 printf("AliL3HoughTrack::GetCrossingPoint : Track is not a helix\n");
218 printf("GetCrossingPoint: Track is given in local coordintes!!!\n");
222 Double_t padrowradii = fTransform->Row2X(padrow);
225 Float_t rotation_angle = (slice*20)*ToRad;
228 cs = cos(rotation_angle);
229 sn = sin(rotation_angle);
231 Double_t a = -1.*cs/sn;
232 Double_t b = padrowradii/sn;
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() ) ;
239 Double_t racine = bb * bb - 4. * aa * cc ;
240 if ( racine < 0 ) return false ;
241 Double_t rootRacine = sqrt(racine) ;
243 Double_t oneOverA = 1./aa;
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);
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);
257 // Choose close to (0,0)
274 fTransform->Global2Local(xyz,slice);