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