]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/hough/AliL3HoughTrack.cxx
Coding violations...
[u/mrichter/AliRoot.git] / HLT / hough / AliL3HoughTrack.cxx
CommitLineData
3e87ef69 1// @(#) $Id$
b1886074 2
3// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
3e87ef69 4//*-- Copyright &copy ALICE HLT Group
d712b5b8 5
e06900d5 6#include "AliL3StandardIncludes.h"
d712b5b8 7
8#include "AliL3Logging.h"
de3c3890 9#include "AliL3Track.h"
d712b5b8 10#include "AliL3HoughTrack.h"
13a0c3d8 11#include "AliL3Transform.h"
d712b5b8 12
0bd0c1ef 13#if __GNUC__ == 3
e06900d5 14using namespace std;
15#endif
16
0bd0c1ef 17/** \class AliL3HoughTrack
18<pre>
b1886074 19//_____________________________________________________________
20// AliL3HoughTrack
21//
22// Track class for Hough tracklets
0bd0c1ef 23//
24</pre>
25*/
b1886074 26
d712b5b8 27ClassImp(AliL3HoughTrack)
28
29
de3c3890 30 AliL3HoughTrack::AliL3HoughTrack() : AliL3Track()
d712b5b8 31{
32 //Constructor
33
34 fWeight = 0;
35 fMinDist=0;
d712b5b8 36 fDLine = 0;
37 fPsiLine = 0;
38 fIsHelix = true;
39 fEtaIndex = -1;
208b54c5 40 fEta = 0;
de3c3890 41 ComesFromMainVertex(kTRUE);
d712b5b8 42}
43
d712b5b8 44AliL3HoughTrack::~AliL3HoughTrack()
45{
bd2f8772 46 //dtor
d712b5b8 47}
48
49void AliL3HoughTrack::Set(AliL3Track *track)
50{
bd2f8772 51 //Basically copy constructor
d712b5b8 52 AliL3HoughTrack *tpt = (AliL3HoughTrack*)track;
b46b53c1 53 SetTrackParameters(tpt->GetKappa(),tpt->GetPsi(),tpt->GetWeight());
d712b5b8 54 SetEtaIndex(tpt->GetEtaIndex());
55 SetEta(tpt->GetEta());
ae4d5136 56 SetTgl(tpt->GetTgl());
d712b5b8 57 SetPsi(tpt->GetPsi());
58 SetCenterX(tpt->GetCenterX());
59 SetCenterY(tpt->GetCenterY());
60 SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
61 SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
62 SetCharge(tpt->GetCharge());
63 SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
b1886074 64 SetSlice(tpt->GetSlice());
3e87ef69 65 SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers());
0bd0c1ef 66 SetMCid(tpt->GetMCid());
de3c3890 67 SetBinXY(tpt->GetBinX(),tpt->GetBinY(),tpt->GetSizeX(),tpt->GetSizeY());
68 SetSector(tpt->GetSector());
69 return;
70
71 fWeight = tpt->GetWeight();
72 fDLine = tpt->GetDLine();
73 fPsiLine = tpt->GetPsiLine();
74 SetNHits(tpt->GetWeight());
75 SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
76 fIsHelix = false;
d712b5b8 77}
78
79Int_t AliL3HoughTrack::Compare(const AliL3Track *tpt) const
80{
bd2f8772 81 //Compare 2 hough tracks according to their weight
d712b5b8 82 AliL3HoughTrack *track = (AliL3HoughTrack*)tpt;
83 if(track->GetWeight() < GetWeight()) return 1;
84 if(track->GetWeight() > GetWeight()) return -1;
85 return 0;
86}
87
88void AliL3HoughTrack::SetEta(Double_t f)
89{
b1886074 90 //Set eta, and calculate fTanl, which is the tan of dipangle
91
d712b5b8 92 fEta = f;
93 Double_t theta = 2*atan(exp(-1.*fEta));
5a31e9df 94 Double_t dipangle = AliL3Transform::PiHalf() - theta;
8b007a2d 95 Double_t tgl = tan(dipangle);
d712b5b8 96 SetTgl(tgl);
97}
98
d712b5b8 99void AliL3HoughTrack::UpdateToFirstRow()
100{
101 //Update the track parameters to the point where track cross
5a31e9df 102 //its first padrow.`
d712b5b8 103
104 //Get the crossing point with the first padrow:
105 Float_t xyz[3];
106 if(!GetCrossingPoint(GetFirstRow(),xyz))
107 LOG(AliL3Log::kWarning,"AliL3HoughTrack::UpdateToFirstRow()","Track parameters")
108 <<AliL3Log::kDec<<"Track does not cross padrow "<<GetFirstRow()<<" centerx "
109 <<GetCenterX()<<" centery "<<GetCenterY()<<" Radius "<<GetRadius()<<" tgl "<<GetTgl()<<ENDLOG;
110
8b007a2d 111 //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());
112 //printf("Before: first %f %f %f tgl %f center %f %f charge %d\n",GetFirstPointX(),GetFirstPointY(),GetFirstPointZ(),GetTgl(),GetCenterX(),GetCenterY(),GetCharge());
113
d712b5b8 114 Double_t radius = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
115
116 //Get the track parameters
b1886074 117
118 /*
119 Double_t x0 = GetR0() * cos(GetPhi0()) ;
120 Double_t y0 = GetR0() * sin(GetPhi0()) ;
121 */
5a31e9df 122 Double_t rc = GetRadius();//fabs(GetPt()) / AliL3Transform::GetBFieldValue();
123 Double_t tPhi0 = GetPsi() + GetCharge() * AliL3Transform::PiHalf() / abs(GetCharge()) ;
b1886074 124 Double_t xc = GetCenterX();//x0 - rc * cos(tPhi0) ;
125 Double_t yc = GetCenterY();//y0 - rc * sin(tPhi0) ;
d712b5b8 126
127 //Check helix and cylinder intersect
128 Double_t fac1 = xc*xc + yc*yc ;
129 Double_t sfac = sqrt( fac1 ) ;
b1886074 130
d712b5b8 131 if ( fabs(sfac-rc) > radius || fabs(sfac+rc) < radius ) {
132 LOG(AliL3Log::kError,"AliL3HoughTrack::UpdateToFirstRow","Tracks")<<AliL3Log::kDec<<
133 "Track does not intersect"<<ENDLOG;
134 return;
135 }
136
137 //Find intersection
b46b53c1 138 Double_t fac2 = (radius*radius + fac1 - rc*rc) / (2.00 * radius * sfac ) ;
d712b5b8 139 Double_t phi = atan2(yc,xc) + GetCharge()*acos(fac2) ;
140 Double_t td = atan2(radius*sin(phi) - yc,radius*cos(phi) - xc) ;
141
142 //Intersection in z
5a31e9df 143 if ( td < 0 ) td = td + AliL3Transform::TwoPi();
144 Double_t deltat = fmod((-GetCharge()*td + GetCharge()*tPhi0),AliL3Transform::TwoPi());
145 if ( deltat < 0. ) deltat += AliL3Transform::TwoPi();
146 else if ( deltat > AliL3Transform::TwoPi() ) deltat -= AliL3Transform::TwoPi();
d712b5b8 147 Double_t z = GetZ0() + rc * GetTgl() * deltat ;
8b007a2d 148
d712b5b8 149 Double_t xExtra = radius * cos(phi) ;
150 Double_t yExtra = radius * sin(phi) ;
151
152 Double_t tPhi = atan2(yExtra-yc,xExtra-xc);
153
154 //if ( tPhi < 0 ) tPhi += 2. * M_PI ;
5a31e9df 155 Double_t tPsi = tPhi - GetCharge() * AliL3Transform::PiHalf() / abs(GetCharge()) ;
156 if ( tPsi > AliL3Transform::TwoPi() ) tPsi -= AliL3Transform::TwoPi() ;
157 else if ( tPsi < 0. ) tPsi += AliL3Transform::TwoPi();
d712b5b8 158
159 //And finally, update the track parameters
d712b5b8 160 SetR0(radius);
161 SetPhi0(phi);
162 SetZ0(z);
163 SetPsi(tPsi);
164 SetFirstPoint(xyz[0],xyz[1],z);
8b007a2d 165 //printf("After: first %f %f %f tgl %f center %f %f charge %d\n",GetFirstPointX(),GetFirstPointY(),GetFirstPointZ(),GetTgl(),GetCenterX(),GetCenterY(),GetCharge());
166
167 //printf("First point set %f %f %f\n",xyz[0],xyz[1],z);
d712b5b8 168
169 //Also, set the coordinates of the point where track crosses last padrow:
170 GetCrossingPoint(GetLastRow(),xyz);
171 SetLastPoint(xyz[0],xyz[1],xyz[2]);
8b007a2d 172 //printf("last point %f %f %f\n",xyz[0],xyz[1],xyz[2]);
d712b5b8 173}
174
b46b53c1 175void AliL3HoughTrack::SetTrackParameters(Double_t kappa,Double_t eangle,Int_t weight)
d712b5b8 176{
bd2f8772 177 //Set track parameters - sort of ctor
d712b5b8 178 fWeight = weight;
179 fMinDist = 100000;
180 SetKappa(kappa);
5a31e9df 181 Double_t pt = fabs(AliL3Transform::GetBFieldValue()/kappa);
d712b5b8 182 SetPt(pt);
183 Double_t radius = 1/fabs(kappa);
184 SetRadius(radius);
185 SetFirstPoint(0,0,0);
b46b53c1 186 SetPsi(eangle); //Psi = emission angle when first point is vertex
187 SetPhi0(0); //not defined for vertex reference point
8b007a2d 188 SetR0(0);
d712b5b8 189 Double_t charge = -1.*kappa;
8b007a2d 190 SetCharge((Int_t)copysign(1.,charge));
26abc209 191 Double_t trackPhi0 = GetPsi() + charge*0.5*AliL3Transform::Pi()/fabs(charge);
8b007a2d 192 Double_t xc = GetFirstPointX() - GetRadius() * cos(trackPhi0) ;
193 Double_t yc = GetFirstPointY() - GetRadius() * sin(trackPhi0) ;
d712b5b8 194 SetCenterX(xc);
195 SetCenterY(yc);
242c143e 196 SetNHits(1); //just for the trackarray IO
d712b5b8 197 fIsHelix = true;
198}
199
dd7d3870 200void AliL3HoughTrack::SetLineParameters(Double_t psi,Double_t D,Int_t weight,Int_t *rowrange,Int_t /*ref_row*/)
d712b5b8 201{
202 //Initialize a track piece, not yet a track
203 //Used in case of straight line transformation
204
205 //Transform line parameters to coordinate system of slice:
206
3e87ef69 207 // D = D + fTransform->Row2X(ref_row)*cos(psi);
d712b5b8 208
209 fDLine = D;
210 fPsiLine = psi;
211 fWeight = weight;
3e87ef69 212 SetNHits(1);
d712b5b8 213 SetRowRange(rowrange[0],rowrange[1]);
214 fIsHelix = false;
d712b5b8 215}
216
bd2f8772 217void AliL3HoughTrack::SetBestMCid(Int_t mcid,Double_t mindist)
d712b5b8 218{
bd2f8772 219 //Finds and set the closest mc label
220 if(mindist < fMinDist)
d712b5b8 221 {
bd2f8772 222 fMinDist = mindist;
d712b5b8 223 SetMCid(mcid);
224 }
d712b5b8 225}
226
3e87ef69 227void AliL3HoughTrack::GetLineCrossingPoint(Int_t padrow,Float_t *xy)
d712b5b8 228{
bd2f8772 229 //Returns the crossing point of the track with a given padrow
d712b5b8 230 if(fIsHelix)
231 {
232 printf("AliL3HoughTrack::GetLineCrossingPoint : Track is not a line\n");
233 return;
234 }
235
3e87ef69 236 Float_t xhit = AliL3Transform::Row2X(padrow) - AliL3Transform::Row2X(GetFirstRow());
237 Float_t a = -1/tan(fPsiLine);
238 Float_t b = fDLine/sin(fPsiLine);
239 Float_t yhit = a*xhit + b;
d712b5b8 240 xy[0] = xhit;
241 xy[1] = yhit;
d712b5b8 242}