]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/src/AliL3ConfMapTrack.cxx
Added Reset function
[u/mrichter/AliRoot.git] / HLT / src / AliL3ConfMapTrack.cxx
CommitLineData
108615fc 1
2//Author: Anders Strand Vestbo
3//Author: Uli Frankenfeld
4//Last Modified: 13.12.2000
5
6//____________________________________
7// AliL3ConfMapTrack
8//
9// Track class for conformal mapper
10
11#include "AliL3RootTypes.h"
12#include "AliL3Logging.h"
13#include "AliL3Vertex.h"
14#include "AliL3ConfMapPoint.h"
15#include "AliL3ConfMapFit.h"
16#include "AliL3ConfMapTrack.h"
17#include <math.h>
18
19ClassImp(AliL3ConfMapTrack)
20
21
22AliL3ConfMapTrack::AliL3ConfMapTrack()
23{
24 //Constructor
25
26 fChiSq[0] = 0.;
27 fChiSq[1] = 0.;
28
29}
30
31AliL3ConfMapTrack::~AliL3ConfMapTrack()
32{
33
34}
35
36void AliL3ConfMapTrack::DeleteCandidate()
37{
38 //Deletes this track by resetting all its parameters. Does not delete
39 //the object itself.
40
41 AliL3ConfMapPoint *curHit = (AliL3ConfMapPoint*)firstHit;
42 AliL3ConfMapPoint *nextHit;
43
44 while(curHit != 0)
45 {
46 nextHit = (AliL3ConfMapPoint*)curHit->nextTrackHit;
47 curHit->nextTrackHit = 0;
48 curHit = nextHit;
49 }
50
51 UInt_t *hit_numbers = GetHitNumbers();
52 for(Int_t i=0; i<GetNHits(); i++)
53 {
54 //fHitNumbers[i] = 0;
55 hit_numbers[i]=0;
56 }
57
58 SetRadius(0.);
59 SetCenterX(0.);
60 SetCenterY(0.);
61
62 ComesFromMainVertex(false);
63
64 SetNHits(0);
65 SetCharge(0);
66 fChiSq[0] = 0.;
67 fChiSq[1] = 0.;
68}
69
70
71void AliL3ConfMapTrack::SetProperties(Bool_t usage)
72{
73 //Set the hits to this track to 'usage'
74
75 for(StartLoop(); LoopDone(); GetNextHit())
76 {
77 AliL3ConfMapPoint *p = (AliL3ConfMapPoint*)currentHit;
78 p->SetUsage(usage);
79 }
80 return;
81}
82
83void AliL3ConfMapTrack::Reset()
84{
85 //Resets the fit parameters of this track.
86
87 //xy-plane
88 s11Xy = 0;
89 s12Xy = 0;
90 s22Xy = 0;
91 g1Xy = 0;
92 g2Xy = 0;
93 fChiSq[0] = 0.;
94
95 //sz-plane
96 s11Sz = 0;
97 s12Sz = 0;
98 s22Sz = 0;
99 g1Sz = 0;
100 g2Sz = 0;
101 fChiSq[1] = 0;
102 SetLength(0);
103
104
105}
106
107void AliL3ConfMapTrack::UpdateParam(AliL3ConfMapPoint *thisHit)
108{
109 //Function to update fit parameters of track
110 //Also, it updates the hit pointers.
111
112
113 //Increment the number of hits assigned to this track:
114
115 //fNHits++;
116 Int_t nhits = GetNHits();
117 nhits++;
118 SetNHits(nhits); //SetNHits(nhits++);
119
120 //Set the hit pointers:
121 //if(fNHits == 1)
122 if(GetNHits()==1)
123 firstHit = thisHit;
124 else
125 ((AliL3ConfMapPoint*)lastHit)->nextTrackHit = thisHit;
126 lastHit = thisHit;
127
128
129 s11Xy = s11Xy + thisHit->GetXYWeight() ;
130 s12Xy = s12Xy + thisHit->GetXYWeight() * thisHit->GetXprime() ;
131 s22Xy = s22Xy + thisHit->GetXYWeight() * pow((thisHit->GetXprime()),2) ;
132 g1Xy = g1Xy + thisHit->GetXYWeight() * thisHit->GetYprime() ;
133 g2Xy = g2Xy + thisHit->GetXYWeight() * thisHit->GetXprime() * thisHit->GetYprime() ;
134
135 ddXy = s11Xy * s22Xy - pow((s12Xy),2) ;
136 if ( ddXy != 0 )
137 {
138 a1Xy = ( g1Xy * s22Xy - g2Xy * s12Xy ) / ddXy ;
139 a2Xy = ( g2Xy * s11Xy - g1Xy * s12Xy ) / ddXy ;
140 }
141
142 // Now in the sz plane
143 s11Sz = s11Sz + thisHit->GetZWeight() ;
144 s12Sz = s12Sz + thisHit->GetZWeight() * thisHit->GetS() ;
145 s22Sz = s22Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetS() ;
146 g1Sz = g1Sz + thisHit->GetZWeight() * thisHit->GetZ() ;
147 g2Sz = g2Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetZ() ;
148
149
150 ddSz = s11Sz * s22Sz - s12Sz * s12Sz ;
151 if ( ddSz != 0 ) {
152 a1Sz = ( g1Sz * s22Sz - g2Sz * s12Sz ) / ddSz ;
153 a2Sz = ( g2Sz * s11Sz - g1Sz * s12Sz ) / ddSz ;
154 }
155
156}
157
158
159void AliL3ConfMapTrack::Fill(AliL3Vertex *vertex,Double_t max_Dca)
160{
161 //Fill track variables with or without fit.
162
163 //fRadius = sqrt(a2Xy*a2Xy+1)/(2*fabs(a1Xy));
164 Double_t radius = sqrt(a2Xy*a2Xy+1)/(2*fabs(a1Xy));
165 SetRadius(radius);
166
167 //fPt = (Double_t)(BFACT * bField * fRadius);
168 Double_t pt = (Double_t)(BFACT * bField * GetRadius());
169 SetPt(pt);
170
171 if(GetPt() > max_Dca) //go for fit of helix in real space
172 {
173 AliL3ConfMapFit *fit = new AliL3ConfMapFit(this,vertex);
174 fit->FitHelix();
175 UpdateToFirstPoint();
176
177 delete fit;
178 }
179 else if(GetPt() == 0)
180 LOG(AliL3Log::kError,"AliL3ConfMapTrack::Fill","Tracks")<<AliL3Log::kDec<<
181 "Found track with Pt=0!!!"<<ENDLOG;
182 else
183 {
184 LOG(AliL3Log::kError,"AliL3ConfMapTrack::Fill","Tracks")<<AliL3Log::kDec<<
185 "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
186 }
187
188}
189
190void AliL3ConfMapTrack::UpdateToFirstPoint()
191{
192 //Update track parameters to the innermost point on the track.
193 //Basically it justs calculates the intersection of the track, and a cylinder
194 //with radius = r(innermost point). Then the parameters are updated to this point.
195 //Should be called after the helixfit (in FillTracks).
196
197 //AliL3ConfMapPoint *lHit = (AliL3ConfMapPoint*)fPoints->Last();
198 AliL3ConfMapPoint *lHit = (AliL3ConfMapPoint*)lastHit;
199 Double_t radius = sqrt(lHit->GetX()*lHit->GetX()+lHit->GetY()*lHit->GetY());
200
201 //Get the track parameters
202
203 Double_t tPhi0 = GetPsi() + GetCharge() * 0.5 * pi / fabs(GetCharge()) ;
204 Double_t x0 = GetR0() * cos(GetPhi0()) ;
205 Double_t y0 = GetR0() * sin(GetPhi0()) ;
206 Double_t rc = fabs(GetPt()) / ( BFACT * bField ) ;
207 Double_t xc = x0 - rc * cos(tPhi0) ;
208 Double_t yc = y0 - rc * sin(tPhi0) ;
209
210 //Check helix and cylinder intersect
211
212 Double_t fac1 = xc*xc + yc*yc ;
213 Double_t sfac = sqrt( fac1 ) ;
214
215 if ( fabs(sfac-rc) > radius || fabs(sfac+rc) < radius ) {
216 LOG(AliL3Log::kError,"AliL3ConfMapTrack::UpdateToLastPoint","Tracks")<<AliL3Log::kDec<<
217 "Track does not intersect"<<ENDLOG;
218 return;
219 }
220
221 //Find intersection
222
223 Double_t fac2 = ( radius*radius + fac1 - rc*rc) / (2.00 * radius * sfac ) ;
224 Double_t phi = atan2(yc,xc) + GetCharge()*acos(fac2) ;
225 Double_t td = atan2(radius*sin(phi) - yc,radius*cos(phi) - xc) ;
226
227 //Intersection in z
228
229 if ( td < 0 ) td = td + 2. * pi ;
230 Double_t deltat = fmod((-GetCharge()*td + GetCharge()*tPhi0),2*pi) ;
231 if ( deltat < 0. ) deltat += 2. * pi ;
232 if ( deltat > 2.*pi ) deltat -= 2. * pi ;
233 Double_t z = GetZ0() + rc * GetTgl() * deltat ;
234
235
236 Double_t xExtra = radius * cos(phi) ;
237 Double_t yExtra = radius * sin(phi) ;
238
239 Double_t tPhi = atan2(yExtra-yc,xExtra-xc);
240
241 //if ( tPhi < 0 ) tPhi += 2. * M_PI ;
242
243 Double_t tPsi = tPhi - GetCharge() * 0.5 * pi / fabs(GetCharge()) ;
244 if ( tPsi > 2. * pi ) tPsi -= 2. * pi ;
245 if ( tPsi < 0. ) tPsi += 2. * pi ;
246
247 //And finally, update the track parameters
248
249 SetCenterX(xc);
250 SetCenterY(yc);
251 SetR0(radius);
252 SetPhi0(phi);
253 SetZ0(z);
254 SetPsi(tPsi);
255}
256
257Int_t AliL3ConfMapTrack::GetMCLabel()
258{
259 //For evaluation study.
260 //Returns the MCtrackID of the belonging clusters.
261 //If MCLabel < 0, means that track is fake.
262
263 return 0;
264 /*
265 Int_t num_of_clusters = GetNumberOfPoints();
266 S *s=new S[num_of_clusters];
267 Int_t i;
268 for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
269
270 Int_t lab=123456789;
271 for (i=0; i<num_of_clusters; i++) {
272 AliL3ConfMapPoint *c=(AliL3ConfMapPoint*)fPoints->UncheckedAt(i);
273 lab=fabs(c->fMCTrackID[0]);
274 Int_t j;
275 for (j=0; j<num_of_clusters; j++)
276 if (s[j].lab==lab || s[j].max==0) break;
277 s[j].lab=lab;
278 s[j].max++;
279 }
280
281 Int_t max=0;
282 for (i=0; i<num_of_clusters; i++)
283 if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
284
285 delete[] s;
286
287 for (i=0; i<num_of_clusters; i++) {
288 AliL3ConfMapPoint *c=(AliL3ConfMapPoint*)fPoints->UncheckedAt(i);
289 if (fabs(c->fMCTrackID[1]) == lab ||
290 fabs(c->fMCTrackID[2]) == lab ) max++;
291 }
292
293 //check if more than 10% of the clusters are incorrectly assigned (fake track):
294
295 if (1.-Float_t(max)/num_of_clusters > 0.10)
296 {
297 return -lab;
298 }
299 Int_t tail=Int_t(0.08*174);
300 if (num_of_clusters < tail) return lab;
301
302 max=0;
303 for (i=1; i<=tail; i++) {
304 AliL3ConfMapPoint *c = (AliL3ConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
305 if (lab == fabs(c->fMCTrackID[0]) ||
306 lab == fabs(c->fMCTrackID[1]) ||
307 lab == fabs(c->fMCTrackID[2])) max++;
308 }
309 if (max < Int_t(0.5*tail))
310 {
311 //printf("Wrong innermost clusters\n");
312 return -lab;
313 }
314 return lab;
315 */
316}
317