]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCConfMapTrack.cxx
Imported files from the existing L3 code directories (../src, ../comp,
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCConfMapTrack.cxx
CommitLineData
a6c02c85 1// @(#) $Id$
2
3// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no>
4//*-- Copyright &copy 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#if __GNUC__ >= 3
27using namespace std;
28#endif
29
30ClassImp(AliHLTTPCConfMapTrack)
31
32
33AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack()
34{
35 //Constructor
36 fChiSq[0] = 0.;
37 fChiSq[1] = 0.;
38}
39
40AliHLTTPCConfMapTrack::~AliHLTTPCConfMapTrack()
41{
42 //deconstructor
43}
44
45void AliHLTTPCConfMapTrack::DeleteCandidate()
46{
47 //Deletes this track by resetting all its parameters. Does not delete
48 //the object itself.
49
50 AliHLTTPCConfMapPoint *curHit = (AliHLTTPCConfMapPoint*)fFirstHit;
51 AliHLTTPCConfMapPoint *nextHit;
52
53 while(curHit != 0)
54 {
55 nextHit = (AliHLTTPCConfMapPoint*)curHit->GetNextTrackHit();
56 curHit->SetNextTrackHit(0);
57 curHit = nextHit;
58 }
59
60 UInt_t *hit_numbers = GetHitNumbers();
61 for(Int_t i=0; i<GetNHits(); i++)
62 {
63 //fHitNumbers[i] = 0;
64 hit_numbers[i]=0;
65 }
66
67 SetRadius(0.);
68 SetCenterX(0.);
69 SetCenterY(0.);
70
71 ComesFromMainVertex(false);
72
73 SetNHits(0);
74 SetCharge(0);
75 fChiSq[0] = 0.;
76 fChiSq[1] = 0.;
77}
78
79
80void AliHLTTPCConfMapTrack::SetProperties(Bool_t usage)
81{
82 //Set the hits to this track to 'usage'
83 for(StartLoop(); LoopDone(); GetNextHit())
84 {
85 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)fCurrentHit;
86 p->SetUsage(usage);
87 }
88 return;
89}
90
91void AliHLTTPCConfMapTrack::Reset()
92{
93 //Resets the fit parameters of this track.
94
95 //xy-plane
96 fs11Xy = 0;
97 fs12Xy = 0;
98 fs22Xy = 0;
99 fg1Xy = 0;
100 fg2Xy = 0;
101 fChiSq[0] = 0.;
102
103 //sz-plane
104 fs11Sz = 0;
105 fs12Sz = 0;
106 fs22Sz = 0;
107 fg1Sz = 0;
108 fg2Sz = 0;
109 fChiSq[1] = 0;
110 SetLength(0);
111 SetNHits(0);
112}
113
114void AliHLTTPCConfMapTrack::UpdateParam(AliHLTTPCConfMapPoint *thisHit)
115{
116 //Function to update fit parameters of track
117 //Also, it updates the hit pointers.
118
119
120 //Increment the number of hits assigned to this track:
121
122 //fNHits++;
123 Int_t nhits = GetNHits();
124 nhits++;
125 SetNHits(nhits); //SetNHits(nhits++);
126
127 //Set the hit pointers:
128 //if(fNHits == 1)
129 if(GetNHits()==1)
130 fFirstHit = thisHit;
131 else
132 ((AliHLTTPCConfMapPoint*)fLastHit)->SetNextTrackHit(thisHit);
133 fLastHit = thisHit;
134
135
136 fs11Xy = fs11Xy + thisHit->GetXYWeight() ;
137 fs12Xy = fs12Xy + thisHit->GetXYWeight() * thisHit->GetXprime() ;
138 fs22Xy = fs22Xy + thisHit->GetXYWeight() * pow((thisHit->GetXprime()),2) ;
139 fg1Xy = fg1Xy + thisHit->GetXYWeight() * thisHit->GetYprime() ;
140 fg2Xy = fg2Xy + thisHit->GetXYWeight() * thisHit->GetXprime() * thisHit->GetYprime() ;
141
142 fddXy = fs11Xy * fs22Xy - pow((fs12Xy),2) ;
143 if ( fddXy != 0 )
144 {
145 fa1Xy = ( fg1Xy * fs22Xy - fg2Xy * fs12Xy ) / fddXy ;
146 fa2Xy = ( fg2Xy * fs11Xy - fg1Xy * fs12Xy ) / fddXy ;
147 }
148
149 // Now in the sz plane
150 fs11Sz = fs11Sz + thisHit->GetZWeight() ;
151 fs12Sz = fs12Sz + thisHit->GetZWeight() * thisHit->GetS() ;
152 fs22Sz = fs22Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetS() ;
153 fg1Sz = fg1Sz + thisHit->GetZWeight() * thisHit->GetZ() ;
154 fg2Sz = fg2Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetZ() ;
155
156
157 fddSz = fs11Sz * fs22Sz - fs12Sz * fs12Sz ;
158 if ( fddSz != 0 ) {
159 fa1Sz = ( fg1Sz * fs22Sz - fg2Sz * fs12Sz ) / fddSz ;
160 fa2Sz = ( fg2Sz * fs11Sz - fg1Sz * fs12Sz ) / fddSz ;
161 }
162}
163
164
165void AliHLTTPCConfMapTrack::Fill(AliHLTTPCVertex *vertex,Double_t max_Dca)
166{
167 //Fill track variables with or without fit.
168
169 //fRadius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
170 Double_t radius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
171 SetRadius(radius);
172
173 //fPt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * fRadius);
174 Double_t pt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * GetRadius());
175 SetPt(pt);
176
177 if(GetPt() > max_Dca) //go for fit of helix in real space
178 {
179 AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
180 ComesFromMainVertex(AliHLTTPC::DoVertexFit());
181 fit->FitHelix();
182
183 //AliHLTTPCConfMapPoint *lHit = (AliHLTTPCConfMapPoint*)fLastHit;
184 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
185 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
186
187 UpdateToFirstPoint();
188
189 delete fit;
190 }
191 else if(GetPt() == 0)
192 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
193 "Found track with Pt=0!!!"<<ENDLOG;
194 else
195 {
196 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
197 "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
198 }
199}
200
201Int_t AliHLTTPCConfMapTrack::GetMCLabel()
202{
203 //For evaluation study.
204 //Returns the MCtrackID of the belonging clusters.
205 //If MCLabel < 0, means that track is fake.
206
207 return 0;
208 /*
209 Int_t num_of_clusters = GetNumberOfPoints();
210 S *s=new S[num_of_clusters];
211 Int_t i;
212 for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
213
214 Int_t lab=123456789;
215 for (i=0; i<num_of_clusters; i++) {
216 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
217 lab=fabs(c->fMCTrackID[0]);
218 Int_t j;
219 for (j=0; j<num_of_clusters; j++)
220 if (s[j].lab==lab || s[j].max==0) break;
221 s[j].lab=lab;
222 s[j].max++;
223 }
224
225 Int_t max=0;
226 for (i=0; i<num_of_clusters; i++)
227 if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
228
229 delete[] s;
230
231 for (i=0; i<num_of_clusters; i++) {
232 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
233 if (fabs(c->fMCTrackID[1]) == lab ||
234 fabs(c->fMCTrackID[2]) == lab ) max++;
235 }
236
237 //check if more than 10% of the clusters are incorrectly assigned (fake track):
238
239 if (1.-Float_t(max)/num_of_clusters > 0.10)
240 {
241 return -lab;
242 }
243 Int_t tail=Int_t(0.08*174);
244 if (num_of_clusters < tail) return lab;
245
246 max=0;
247 for (i=1; i<=tail; i++) {
248 AliHLTTPCConfMapPoint *c = (AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
249 if (lab == fabs(c->fMCTrackID[0]) ||
250 lab == fabs(c->fMCTrackID[1]) ||
251 lab == fabs(c->fMCTrackID[2])) max++;
252 }
253 if (max < Int_t(0.5*tail))
254 {
255 //printf("Wrong innermost clusters\n");
256 return -lab;
257 }
258 return lab;
259 */
260}
261