3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliL3StandardIncludes.h"
8 #include "AliL3Logging.h"
9 #include "AliL3Track.h"
10 #include "AliL3HoughTrack.h"
11 #include "AliL3Transform.h"
12 #include "AliL3HoughTransformerRow.h"
18 /** \class AliL3HoughTrack
20 //_____________________________________________________________
23 // Track class for Hough tracklets
28 ClassImp(AliL3HoughTrack)
31 AliL3HoughTrack::AliL3HoughTrack() : AliL3Track()
42 ComesFromMainVertex(kTRUE);
45 AliL3HoughTrack::~AliL3HoughTrack()
50 void AliL3HoughTrack::Set(AliL3Track *track)
52 //Basically copy constructor
53 AliL3HoughTrack *tpt = (AliL3HoughTrack*)track;
54 SetTrackParameters(tpt->GetKappa(),tpt->GetPsi(),tpt->GetWeight());
55 SetEtaIndex(tpt->GetEtaIndex());
56 SetEta(tpt->GetEta());
57 SetTgl(tpt->GetTgl());
58 SetPsi(tpt->GetPsi());
59 SetPterr(tpt->GetPterr());
60 SetTglerr(tpt->GetTglerr());
61 SetPsierr(tpt->GetPsierr());
62 SetCenterX(tpt->GetCenterX());
63 SetCenterY(tpt->GetCenterY());
64 SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
65 SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
66 SetCharge(tpt->GetCharge());
67 SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
68 SetSlice(tpt->GetSlice());
69 SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers());
70 SetMCid(tpt->GetMCid());
71 SetBinXY(tpt->GetBinX(),tpt->GetBinY(),tpt->GetSizeX(),tpt->GetSizeY());
72 SetSector(tpt->GetSector());
75 // fWeight = tpt->GetWeight();
76 // fDLine = tpt->GetDLine();
77 // fPsiLine = tpt->GetPsiLine();
78 // SetNHits(tpt->GetWeight());
79 // SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
83 Int_t AliL3HoughTrack::Compare(const AliL3Track *tpt) const
85 //Compare 2 hough tracks according to their weight
86 AliL3HoughTrack *track = (AliL3HoughTrack*)tpt;
87 if(track->GetWeight() < GetWeight()) return 1;
88 if(track->GetWeight() > GetWeight()) return -1;
92 void AliL3HoughTrack::SetEta(Double_t f)
94 //Set eta, and calculate fTanl, which is the tan of dipangle
97 Double_t theta = 2*atan(exp(-1.*fEta));
98 Double_t dipangle = AliL3Transform::PiHalf() - theta;
99 Double_t tgl = tan(dipangle);
103 void AliL3HoughTrack::UpdateToFirstRow()
105 //Update the track parameters to the point where track cross
108 //Get the crossing point with the first padrow:
110 if(!GetCrossingPoint(GetFirstRow(),xyz))
111 LOG(AliL3Log::kWarning,"AliL3HoughTrack::UpdateToFirstRow()","Track parameters")
112 <<AliL3Log::kDec<<"Track does not cross padrow "<<GetFirstRow()<<" centerx "
113 <<GetCenterX()<<" centery "<<GetCenterY()<<" Radius "<<GetRadius()<<" tgl "<<GetTgl()<<ENDLOG;
115 //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());
116 //printf("Before: first %f %f %f tgl %f center %f %f charge %d\n",GetFirstPointX(),GetFirstPointY(),GetFirstPointZ(),GetTgl(),GetCenterX(),GetCenterY(),GetCharge());
118 Double_t radius = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
120 //Get the track parameters
123 Double_t x0 = GetR0() * cos(GetPhi0()) ;
124 Double_t y0 = GetR0() * sin(GetPhi0()) ;
126 Double_t rc = GetRadius();//fabs(GetPt()) / AliL3Transform::GetBFieldValue();
127 Double_t tPhi0 = GetPsi() + GetCharge() * AliL3Transform::PiHalf() / abs(GetCharge()) ;
128 Double_t xc = GetCenterX();//x0 - rc * cos(tPhi0) ;
129 Double_t yc = GetCenterY();//y0 - rc * sin(tPhi0) ;
131 //Check helix and cylinder intersect
132 Double_t fac1 = xc*xc + yc*yc ;
133 Double_t sfac = sqrt( fac1 ) ;
135 if ( fabs(sfac-rc) > radius || fabs(sfac+rc) < radius ) {
136 LOG(AliL3Log::kError,"AliL3HoughTrack::UpdateToFirstRow","Tracks")<<AliL3Log::kDec<<
137 "Track does not intersect"<<ENDLOG;
142 Double_t fac2 = (radius*radius + fac1 - rc*rc) / (2.00 * radius * sfac ) ;
143 Double_t phi = atan2(yc,xc) + GetCharge()*acos(fac2) ;
144 Double_t td = atan2(radius*sin(phi) - yc,radius*cos(phi) - xc) ;
147 if ( td < 0 ) td = td + AliL3Transform::TwoPi();
148 Double_t deltat = fmod((-GetCharge()*td + GetCharge()*tPhi0),AliL3Transform::TwoPi());
149 if ( deltat < 0. ) deltat += AliL3Transform::TwoPi();
150 else if ( deltat > AliL3Transform::TwoPi() ) deltat -= AliL3Transform::TwoPi();
151 Double_t z = GetZ0() + rc * GetTgl() * deltat ;
153 Double_t xExtra = radius * cos(phi) ;
154 Double_t yExtra = radius * sin(phi) ;
156 Double_t tPhi = atan2(yExtra-yc,xExtra-xc);
158 //if ( tPhi < 0 ) tPhi += 2. * M_PI ;
159 Double_t tPsi = tPhi - GetCharge() * AliL3Transform::PiHalf() / abs(GetCharge()) ;
160 if ( tPsi > AliL3Transform::TwoPi() ) tPsi -= AliL3Transform::TwoPi() ;
161 else if ( tPsi < 0. ) tPsi += AliL3Transform::TwoPi();
163 //And finally, update the track parameters
168 SetFirstPoint(xyz[0],xyz[1],z);
169 //printf("After: first %f %f %f tgl %f center %f %f charge %d\n",GetFirstPointX(),GetFirstPointY(),GetFirstPointZ(),GetTgl(),GetCenterX(),GetCenterY(),GetCharge());
171 //printf("First point set %f %f %f\n",xyz[0],xyz[1],z);
173 //Also, set the coordinates of the point where track crosses last padrow:
174 GetCrossingPoint(GetLastRow(),xyz);
175 SetLastPoint(xyz[0],xyz[1],xyz[2]);
176 //printf("last point %f %f %f\n",xyz[0],xyz[1],xyz[2]);
179 void AliL3HoughTrack::SetTrackParameters(Double_t kappa,Double_t eangle,Int_t weight)
181 //Set track parameters - sort of ctor
185 Double_t pt = fabs(AliL3Transform::GetBFieldValue()/kappa);
187 Double_t radius = 1/fabs(kappa);
189 SetFirstPoint(0,0,0);
190 SetPsi(eangle); //Psi = emission angle when first point is vertex
191 SetPhi0(0); //not defined for vertex reference point
193 Double_t charge = -1.*kappa;
194 SetCharge((Int_t)copysign(1.,charge));
195 Double_t trackPhi0 = GetPsi() + charge*0.5*AliL3Transform::Pi()/fabs(charge);
196 Double_t xc = GetFirstPointX() - GetRadius() * cos(trackPhi0) ;
197 Double_t yc = GetFirstPointY() - GetRadius() * sin(trackPhi0) ;
200 SetNHits(1); //just for the trackarray IO
204 void AliL3HoughTrack::SetTrackParametersRow(Double_t alpha1,Double_t alpha2,Double_t eta,Int_t weight)
206 //Set track parameters for HoughTransformerRow
207 //This includes curvature,emission angle and eta
208 Double_t psi = atan((alpha1-alpha2)/(AliL3HoughTransformerRow::GetBeta1()-AliL3HoughTransformerRow::GetBeta2()));
209 Double_t kappa = 2.0*(alpha1*cos(psi)-AliL3HoughTransformerRow::GetBeta1()*sin(psi));
210 SetTrackParameters(kappa,psi,weight);
213 Double_t etaparam1 = AliL3HoughTransformerRow::GetEtaCalcParam1();
214 Double_t etaparam2 = AliL3HoughTransformerRow::GetEtaCalcParam2();
216 zovr = (etaparam1 - sqrt(etaparam1*etaparam1 - 4.*etaparam2*eta))/(2.*etaparam2);
218 zovr = -1.*(etaparam1 - sqrt(etaparam1*etaparam1 + 4.*etaparam2*eta))/(2.*etaparam2);
219 Double_t r = sqrt(1.+zovr*zovr);
220 Double_t exacteta = 0.5*log((1+zovr/r)/(1-zovr/r));
224 void AliL3HoughTrack::SetLineParameters(Double_t psi,Double_t D,Int_t weight,Int_t *rowrange,Int_t /*ref_row*/)
226 //Initialize a track piece, not yet a track
227 //Used in case of straight line transformation
229 //Transform line parameters to coordinate system of slice:
231 // D = D + fTransform->Row2X(ref_row)*cos(psi);
237 SetRowRange(rowrange[0],rowrange[1]);
241 void AliL3HoughTrack::SetBestMCid(Int_t mcid,Double_t mindist)
243 //Finds and set the closest mc label
244 if(mindist < fMinDist)
251 void AliL3HoughTrack::GetLineCrossingPoint(Int_t padrow,Float_t *xy)
253 //Returns the crossing point of the track with a given padrow
256 printf("AliL3HoughTrack::GetLineCrossingPoint : Track is not a line\n");
260 Float_t xhit = AliL3Transform::Row2X(padrow) - AliL3Transform::Row2X(GetFirstRow());
261 Float_t a = -1/tan(fPsiLine);
262 Float_t b = fDLine/sin(fPsiLine);
263 Float_t yhit = a*xhit + b;