]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/src/AliL3ConfMapTrack.cxx
195748ed48152c949af347a29e2542446b52ee3e
[u/mrichter/AliRoot.git] / HLT / src / AliL3ConfMapTrack.cxx
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 "AliL3StandardIncludes.h"
7
8 #include "AliL3RootTypes.h"
9 #include "AliL3Logging.h"
10 #include "AliL3Vertex.h"
11 #include "AliL3ConfMapPoint.h"
12 #include "AliL3ConfMapFit.h"
13 #include "AliL3ConfMapTrack.h"
14 #include "AliL3Transform.h"
15 #include "AliLevel3.h"
16
17 /** \class AliL3ConfMapTrack
18 <pre>
19 //_____________________________________________________________
20 // AliL3ConfMapTrack
21 //
22 // Track class for conformal mapper
23 </pre>
24 */
25
26 ClassImp(AliL3ConfMapTrack)
27
28
29 AliL3ConfMapTrack::AliL3ConfMapTrack()
30 {
31   //Constructor
32
33   fChiSq[0] = 0.;
34   fChiSq[1] = 0.;
35 }
36
37 AliL3ConfMapTrack::~AliL3ConfMapTrack()
38 {
39
40 }
41
42 void AliL3ConfMapTrack::DeleteCandidate()
43 {
44   //Deletes this track by resetting all its parameters. Does not delete
45   //the object itself.
46
47   AliL3ConfMapPoint *curHit = (AliL3ConfMapPoint*)firstHit;
48   AliL3ConfMapPoint *nextHit;
49   
50   while(curHit != 0)
51     {
52       nextHit = (AliL3ConfMapPoint*)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 AliL3ConfMapTrack::SetProperties(Bool_t usage)
78 {
79   //Set the hits to this track to 'usage'
80   
81   for(StartLoop(); LoopDone(); GetNextHit())
82     {
83       AliL3ConfMapPoint *p = (AliL3ConfMapPoint*)currentHit;
84       p->SetUsage(usage);
85     }
86   return;
87 }
88
89 void AliL3ConfMapTrack::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 AliL3ConfMapTrack::UpdateParam(AliL3ConfMapPoint *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     ((AliL3ConfMapPoint*)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 AliL3ConfMapTrack::Fill(AliL3Vertex *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)(AliL3Transform::GetBFieldValue() * fRadius);
172   Double_t pt = (Double_t)(AliL3Transform::GetBFieldValue() * GetRadius());
173   SetPt(pt);
174
175   if(GetPt() > max_Dca) //go for fit of helix in real space
176     {
177       AliL3ConfMapFit *fit = new AliL3ConfMapFit(this,vertex);
178       ComesFromMainVertex(AliLevel3::DoVertexFit());
179       fit->FitHelix();
180       
181       //AliL3ConfMapPoint *lHit = (AliL3ConfMapPoint*)lastHit;
182       AliL3ConfMapPoint *fHit = (AliL3ConfMapPoint*)firstHit;
183       SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
184       
185       if(AliLevel3::IsTracksAtFirstPoint())//Set the track fit parameter at the innermost most point
186         {
187           UpdateToFirstPoint();
188         }
189       
190       delete fit;
191     }
192   else if(GetPt() == 0)
193     LOG(AliL3Log::kError,"AliL3ConfMapTrack::Fill","Tracks")<<AliL3Log::kDec<<
194       "Found track with Pt=0!!!"<<ENDLOG;
195   else
196     {
197       LOG(AliL3Log::kError,"AliL3ConfMapTrack::Fill","Tracks")<<AliL3Log::kDec<<
198         "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
199     }
200 }
201
202 Int_t AliL3ConfMapTrack::GetMCLabel()
203 {
204   //For evaluation study.
205   //Returns the MCtrackID of the belonging clusters.
206   //If MCLabel < 0, means that track is fake.
207
208   return 0;
209   /*
210   Int_t num_of_clusters = GetNumberOfPoints();
211   S *s=new S[num_of_clusters];
212   Int_t i;
213   for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
214   
215   Int_t lab=123456789;
216   for (i=0; i<num_of_clusters; i++) {
217     AliL3ConfMapPoint *c=(AliL3ConfMapPoint*)fPoints->UncheckedAt(i);
218     lab=fabs(c->fMCTrackID[0]);
219     Int_t j;
220     for (j=0; j<num_of_clusters; j++)
221       if (s[j].lab==lab || s[j].max==0) break;
222     s[j].lab=lab;
223     s[j].max++;
224   }
225   
226   Int_t max=0;
227   for (i=0; i<num_of_clusters; i++) 
228     if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
229     
230   delete[] s;
231   
232   for (i=0; i<num_of_clusters; i++) {
233     AliL3ConfMapPoint *c=(AliL3ConfMapPoint*)fPoints->UncheckedAt(i);
234     if (fabs(c->fMCTrackID[1]) == lab ||
235         fabs(c->fMCTrackID[2]) == lab ) max++;
236   }
237   
238   //check if more than 10% of the clusters are incorrectly assigned (fake track):
239   
240   if (1.-Float_t(max)/num_of_clusters > 0.10) 
241     {
242       return -lab;
243     }
244   Int_t tail=Int_t(0.08*174);
245   if (num_of_clusters < tail) return lab;
246   
247   max=0;
248   for (i=1; i<=tail; i++) {
249     AliL3ConfMapPoint *c = (AliL3ConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
250     if (lab == fabs(c->fMCTrackID[0]) ||
251         lab == fabs(c->fMCTrackID[1]) ||
252         lab == fabs(c->fMCTrackID[2])) max++;
253   }
254   if (max < Int_t(0.5*tail)) 
255     {
256       //printf("Wrong innermost clusters\n");
257       return -lab;
258     }
259   return lab;
260   */
261 }
262