3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliL3StandardIncludes.h"
8 #include "AliL3Logging.h"
9 #include "AliL3HoughTrack.h"
10 #include "AliL3Transform.h"
16 //_____________________________________________________________
19 // Track class for Hough tracklets
21 ClassImp(AliL3HoughTrack)
24 AliL3HoughTrack::AliL3HoughTrack()
39 AliL3HoughTrack::~AliL3HoughTrack()
44 void AliL3HoughTrack::Set(AliL3Track *track)
47 AliL3HoughTrack *tpt = (AliL3HoughTrack*)track;
48 SetTrackParameters(tpt->GetKappa(),tpt->GetPsi(),tpt->GetWeight());
49 SetEtaIndex(tpt->GetEtaIndex());
50 SetEta(tpt->GetEta());
51 SetTgl(tpt->GetTgl());
52 SetPsi(tpt->GetPsi());
53 SetCenterX(tpt->GetCenterX());
54 SetCenterY(tpt->GetCenterY());
55 SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
56 SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
57 SetCharge(tpt->GetCharge());
58 SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
59 SetSlice(tpt->GetSlice());
60 SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers());
63 fWeight = tpt->GetWeight();
64 fDLine = tpt->GetDLine();
65 fPsiLine = tpt->GetPsiLine();
66 SetNHits(tpt->GetWeight());
67 SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
71 Int_t AliL3HoughTrack::Compare(const AliL3Track *tpt) const
73 AliL3HoughTrack *track = (AliL3HoughTrack*)tpt;
74 if(track->GetWeight() < GetWeight()) return 1;
75 if(track->GetWeight() > GetWeight()) return -1;
79 void AliL3HoughTrack::SetEta(Double_t f)
81 //Set eta, and calculate fTanl, which is the tan of dipangle
84 Double_t theta = 2*atan(exp(-1.*fEta));
85 Double_t dipangle = AliL3Transform::Pi()/2 - theta;
86 Double_t tgl = tan(dipangle);
91 void AliL3HoughTrack::UpdateToFirstRow()
93 //Update the track parameters to the point where track cross
96 //Get the crossing point with the first padrow:
98 if(!GetCrossingPoint(GetFirstRow(),xyz))
99 LOG(AliL3Log::kWarning,"AliL3HoughTrack::UpdateToFirstRow()","Track parameters")
100 <<AliL3Log::kDec<<"Track does not cross padrow "<<GetFirstRow()<<" centerx "
101 <<GetCenterX()<<" centery "<<GetCenterY()<<" Radius "<<GetRadius()<<" tgl "<<GetTgl()<<ENDLOG;
103 //printf("Track with eta %f tgl %f crosses at x %f y %f z %f on padrow %d\n",GetEta(),GetTgl(),xyz[0],xyz[1],xyz[2],GetFirstRow());
104 //printf("Before: first %f %f %f tgl %f center %f %f charge %d\n",GetFirstPointX(),GetFirstPointY(),GetFirstPointZ(),GetTgl(),GetCenterX(),GetCenterY(),GetCharge());
106 Double_t radius = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
108 //Get the track parameters
111 Double_t x0 = GetR0() * cos(GetPhi0()) ;
112 Double_t y0 = GetR0() * sin(GetPhi0()) ;
114 Double_t rc = GetRadius();//fabs(GetPt()) / ( BFACT * AliL3Transform::GetBField() ) ;
115 Double_t tPhi0 = GetPsi() + GetCharge() * 0.5 * pi / abs(GetCharge()) ;
116 Double_t xc = GetCenterX();//x0 - rc * cos(tPhi0) ;
117 Double_t yc = GetCenterY();//y0 - rc * sin(tPhi0) ;
119 //Check helix and cylinder intersect
120 Double_t fac1 = xc*xc + yc*yc ;
121 Double_t sfac = sqrt( fac1 ) ;
123 if ( fabs(sfac-rc) > radius || fabs(sfac+rc) < radius ) {
124 LOG(AliL3Log::kError,"AliL3HoughTrack::UpdateToFirstRow","Tracks")<<AliL3Log::kDec<<
125 "Track does not intersect"<<ENDLOG;
130 Double_t fac2 = (radius*radius + fac1 - rc*rc) / (2.00 * radius * sfac ) ;
131 Double_t phi = atan2(yc,xc) + GetCharge()*acos(fac2) ;
132 Double_t td = atan2(radius*sin(phi) - yc,radius*cos(phi) - xc) ;
135 if ( td < 0 ) td = td + 2. * pi ;
136 Double_t deltat = fmod((-GetCharge()*td + GetCharge()*tPhi0),2*pi) ;
137 if ( deltat < 0. ) deltat += 2. * pi ;
138 if ( deltat > 2.*pi ) deltat -= 2. * pi ;
139 Double_t z = GetZ0() + rc * GetTgl() * deltat ;
142 Double_t xExtra = radius * cos(phi) ;
143 Double_t yExtra = radius * sin(phi) ;
145 Double_t tPhi = atan2(yExtra-yc,xExtra-xc);
147 //if ( tPhi < 0 ) tPhi += 2. * M_PI ;
149 Double_t tPsi = tPhi - GetCharge() * 0.5 * pi / abs(GetCharge()) ;
150 if ( tPsi > 2. * pi ) tPsi -= 2. * pi ;
151 if ( tPsi < 0. ) tPsi += 2. * pi ;
153 //And finally, update the track parameters
158 SetFirstPoint(xyz[0],xyz[1],z);
159 //printf("After: first %f %f %f tgl %f center %f %f charge %d\n",GetFirstPointX(),GetFirstPointY(),GetFirstPointZ(),GetTgl(),GetCenterX(),GetCenterY(),GetCharge());
161 //printf("First point set %f %f %f\n",xyz[0],xyz[1],z);
163 //Also, set the coordinates of the point where track crosses last padrow:
164 GetCrossingPoint(GetLastRow(),xyz);
165 SetLastPoint(xyz[0],xyz[1],xyz[2]);
166 //printf("last point %f %f %f\n",xyz[0],xyz[1],xyz[2]);
169 void AliL3HoughTrack::SetTrackParameters(Double_t kappa,Double_t eangle,Int_t weight)
175 Double_t pt = fabs(BFACT*AliL3Transform::GetBField()/kappa);
177 Double_t radius = 1/fabs(kappa);
179 SetFirstPoint(0,0,0);
180 SetPsi(eangle); //Psi = emission angle when first point is vertex
181 SetPhi0(0); //not defined for vertex reference point
183 Double_t charge = -1.*kappa;
184 SetCharge((Int_t)copysign(1.,charge));
185 Double_t trackPhi0 = GetPsi() + charge*0.5*AliL3Transform::Pi()/fabs(charge);
186 Double_t xc = GetFirstPointX() - GetRadius() * cos(trackPhi0) ;
187 Double_t yc = GetFirstPointY() - GetRadius() * sin(trackPhi0) ;
190 SetNHits(1); //just for the trackarray IO
194 void AliL3HoughTrack::SetLineParameters(Double_t psi,Double_t D,Int_t weight,Int_t *rowrange,Int_t ref_row)
196 //Initialize a track piece, not yet a track
197 //Used in case of straight line transformation
199 //Transform line parameters to coordinate system of slice:
201 // D = D + fTransform->Row2X(ref_row)*cos(psi);
207 SetRowRange(rowrange[0],rowrange[1]);
212 void AliL3HoughTrack::SetBestMCid(Int_t mcid,Double_t min_dist)
215 if(min_dist < fMinDist)
223 void AliL3HoughTrack::GetLineCrossingPoint(Int_t padrow,Float_t *xy)
228 printf("AliL3HoughTrack::GetLineCrossingPoint : Track is not a line\n");
232 Float_t xhit = AliL3Transform::Row2X(padrow) - AliL3Transform::Row2X(GetFirstRow());
233 Float_t a = -1/tan(fPsiLine);
234 Float_t b = fDLine/sin(fPsiLine);
235 Float_t yhit = a*xhit + b;