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