]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/src/AliL3ConfMapTrack.cxx
-Added protected copy constructors and assignment operators. -Public data members...
[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       UpdateToFirstPoint();
186       
187       delete fit;
188     }
189   else if(GetPt() == 0)
190     LOG(AliL3Log::kError,"AliL3ConfMapTrack::Fill","Tracks")<<AliL3Log::kDec<<
191       "Found track with Pt=0!!!"<<ENDLOG;
192   else
193     {
194       LOG(AliL3Log::kError,"AliL3ConfMapTrack::Fill","Tracks")<<AliL3Log::kDec<<
195         "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
196     }
197 }
198
199 Int_t AliL3ConfMapTrack::GetMCLabel()
200 {
201   //For evaluation study.
202   //Returns the MCtrackID of the belonging clusters.
203   //If MCLabel < 0, means that track is fake.
204
205   return 0;
206   /*
207   Int_t num_of_clusters = GetNumberOfPoints();
208   S *s=new S[num_of_clusters];
209   Int_t i;
210   for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
211   
212   Int_t lab=123456789;
213   for (i=0; i<num_of_clusters; i++) {
214     AliL3ConfMapPoint *c=(AliL3ConfMapPoint*)fPoints->UncheckedAt(i);
215     lab=fabs(c->fMCTrackID[0]);
216     Int_t j;
217     for (j=0; j<num_of_clusters; j++)
218       if (s[j].lab==lab || s[j].max==0) break;
219     s[j].lab=lab;
220     s[j].max++;
221   }
222   
223   Int_t max=0;
224   for (i=0; i<num_of_clusters; i++) 
225     if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
226     
227   delete[] s;
228   
229   for (i=0; i<num_of_clusters; i++) {
230     AliL3ConfMapPoint *c=(AliL3ConfMapPoint*)fPoints->UncheckedAt(i);
231     if (fabs(c->fMCTrackID[1]) == lab ||
232         fabs(c->fMCTrackID[2]) == lab ) max++;
233   }
234   
235   //check if more than 10% of the clusters are incorrectly assigned (fake track):
236   
237   if (1.-Float_t(max)/num_of_clusters > 0.10) 
238     {
239       return -lab;
240     }
241   Int_t tail=Int_t(0.08*174);
242   if (num_of_clusters < tail) return lab;
243   
244   max=0;
245   for (i=1; i<=tail; i++) {
246     AliL3ConfMapPoint *c = (AliL3ConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
247     if (lab == fabs(c->fMCTrackID[0]) ||
248         lab == fabs(c->fMCTrackID[1]) ||
249         lab == fabs(c->fMCTrackID[2])) max++;
250   }
251   if (max < Int_t(0.5*tail)) 
252     {
253       //printf("Wrong innermost clusters\n");
254       return -lab;
255     }
256   return lab;
257   */
258 }
259