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