]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCConfMapTrack.cxx
effC++ and warnings
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCConfMapTrack.cxx
1 // @(#) $Id$
2 // Original: AliHLTConfMapTrack.cxx,v 1.16 2005/06/14 10:55:21 cvetan 
3
4 /**************************************************************************
5  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6  *                                                                        *
7  * Authors: Anders Vestbo                                                 *
8  *          Matthias Richter <Matthias.Richter@ift.uib.no>                *
9  *          for The ALICE Off-line Project.                               *
10  *                                                                        *
11  * Permission to use, copy, modify and distribute this software and its   *
12  * documentation strictly for non-commercial purposes is hereby granted   *
13  * without fee, provided that the above copyright notice appears in all   *
14  * copies and that both the copyright notice and this permission notice   *
15  * appear in the supporting documentation. The authors make no claims     *
16  * about the suitability of this software for any purpose. It is          *
17  * provided "as is" without express or implied warranty.                  *
18  **************************************************************************/
19
20 /** @file   AliHLTTPCConfMapTrack.cxx
21     @author Anders Vestbo, maintained by Matthias Richter
22     @date   
23     @brief  Track class for conformal mapper
24 */
25
26 #include "AliHLTTPCRootTypes.h"
27 #include "AliHLTTPCLogging.h"
28 #include "AliHLTTPCVertex.h"
29 #include "AliHLTTPCConfMapPoint.h"
30 #include "AliHLTTPCConfMapFit.h"
31 #include "AliHLTTPCConfMapTrack.h"
32 #include "AliHLTTPCTransform.h"
33 //#include "AliHLTTPC.h"
34
35 #if __GNUC__ >= 3
36 using namespace std;
37 #endif
38
39 ClassImp(AliHLTTPCConfMapTrack)
40
41
42 AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack()
43 {
44   //Constructor
45   fChiSq[0] = 0.;
46   fChiSq[1] = 0.;
47 }
48
49 AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack(const AliHLTTPCConfMapTrack&)
50 {
51   // dummy copy constructor
52   //HLTFatal("copy constructor untested");
53 }
54
55 AliHLTTPCConfMapTrack& AliHLTTPCConfMapTrack::operator=(const AliHLTTPCConfMapTrack&)
56
57   // dummy assignment operator
58   //HLTFatal("assignment operator untested");
59   return *this;
60 }
61
62 AliHLTTPCConfMapTrack::~AliHLTTPCConfMapTrack()
63 {
64   //deconstructor
65 }
66
67 void AliHLTTPCConfMapTrack::DeleteCandidate()
68 {
69   //Deletes this track by resetting all its parameters. Does not delete
70   //the object itself.
71
72   AliHLTTPCConfMapPoint *curHit = (AliHLTTPCConfMapPoint*)fFirstHit;
73   AliHLTTPCConfMapPoint *nextHit;
74   
75   while(curHit != 0)
76     {
77       nextHit = (AliHLTTPCConfMapPoint*)curHit->GetNextTrackHit();
78       curHit->SetNextTrackHit(0);
79       curHit = nextHit;
80     }
81   
82   UInt_t *hit_numbers = GetHitNumbers();
83   for(Int_t i=0; i<GetNHits(); i++)
84     {
85       //fHitNumbers[i] = 0;
86       hit_numbers[i]=0;
87     }
88     
89   SetRadius(0.);
90   SetCenterX(0.);
91   SetCenterY(0.);
92   
93   ComesFromMainVertex(false);
94
95   SetNHits(0);
96   SetCharge(0);
97   fChiSq[0] = 0.;
98   fChiSq[1] = 0.;
99 }
100
101
102 void AliHLTTPCConfMapTrack::SetProperties(Bool_t usage)
103 {
104   //Set the hits to this track to 'usage'
105   for(StartLoop(); LoopDone(); GetNextHit())
106     {
107       AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)fCurrentHit;
108       p->SetUsage(usage);
109     }
110   return;
111 }
112
113 void AliHLTTPCConfMapTrack::Reset()
114 {
115   //Resets the fit parameters of this track.
116
117   //xy-plane
118   fs11Xy   = 0;
119   fs12Xy   = 0;
120   fs22Xy   = 0;
121   fg1Xy    = 0;
122   fg2Xy    = 0;
123   fChiSq[0]  = 0.;
124     
125   //sz-plane
126   fs11Sz = 0;
127   fs12Sz = 0;
128   fs22Sz = 0;
129   fg1Sz  = 0;
130   fg2Sz  = 0;
131   fChiSq[1] = 0; 
132   SetLength(0);
133   SetNHits(0);
134 }
135
136 void AliHLTTPCConfMapTrack::UpdateParam(AliHLTTPCConfMapPoint *thisHit)
137 {
138   //Function to update fit parameters of track
139   //Also, it updates the hit pointers.
140   
141
142   //Increment the number of hits assigned to this track:
143
144   //fNHits++;
145   Int_t nhits = GetNHits();
146   nhits++;
147   SetNHits(nhits); //SetNHits(nhits++);
148
149   //Set the hit pointers:
150   //if(fNHits == 1)
151   if(GetNHits()==1)  
152     fFirstHit = thisHit;
153   else
154     ((AliHLTTPCConfMapPoint*)fLastHit)->SetNextTrackHit(thisHit);
155   fLastHit = thisHit;
156
157   
158   fs11Xy = fs11Xy + thisHit->GetXYWeight() ;
159   fs12Xy = fs12Xy + thisHit->GetXYWeight() * thisHit->GetXprime() ;
160   fs22Xy = fs22Xy + thisHit->GetXYWeight() * pow((thisHit->GetXprime()),2) ;
161   fg1Xy  = fg1Xy  + thisHit->GetXYWeight() * thisHit->GetYprime() ;
162   fg2Xy  = fg2Xy  + thisHit->GetXYWeight() * thisHit->GetXprime() * thisHit->GetYprime() ;
163     
164   fddXy  = fs11Xy * fs22Xy - pow((fs12Xy),2) ;
165   if ( fddXy != 0 ) 
166     {
167       fa1Xy  = ( fg1Xy * fs22Xy - fg2Xy * fs12Xy ) / fddXy ;
168       fa2Xy  = ( fg2Xy * fs11Xy - fg1Xy * fs12Xy ) / fddXy ;
169     }
170
171   //     Now in the sz plane
172   fs11Sz = fs11Sz + thisHit->GetZWeight() ;
173   fs12Sz = fs12Sz + thisHit->GetZWeight() * thisHit->GetS() ;
174   fs22Sz = fs22Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetS() ;
175   fg1Sz  = fg1Sz  + thisHit->GetZWeight() * thisHit->GetZ() ;
176   fg2Sz  = fg2Sz  + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetZ() ;
177   
178         
179   fddSz  = fs11Sz * fs22Sz -  fs12Sz * fs12Sz ;
180   if ( fddSz != 0 ) {
181     fa1Sz  = ( fg1Sz * fs22Sz - fg2Sz * fs12Sz ) / fddSz ;
182     fa2Sz  = ( fg2Sz * fs11Sz - fg1Sz * fs12Sz ) / fddSz ;
183   }
184 }
185
186
187 void AliHLTTPCConfMapTrack::Fill(AliHLTTPCVertex *vertex,Double_t max_Dca)
188 {
189     //Fill track variables with or without fit.
190     
191 // #### -B0-CHANGE-START == JMT
192     // for straight line fit
193     if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
194
195         SetRadius(0.);  
196         SetPt(0.);
197         
198         //go for fit of straight line in real space
199         AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
200     /* Matthias 13.12.2006
201      * the global variable AliHLTTPCS::fgDoVertexFit has never been used so far
202      * and has always been kTRUE.
203      * In order to remove the AliHLTTPC class (which is the old steering class for
204      * HLT (TPC) tracking) from the compilation, this function can not be activated
205      * again. We have to think about a more elegant way to specify the parameters
206      * anyway. 
207         ComesFromMainVertex(AliHLTTPC::DoVertexFit());
208      */
209         ComesFromMainVertex(kTRUE);
210         fit->FitStraightLine();
211             
212         AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
213         SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
214         
215         UpdateToFirstPoint();
216         
217         delete fit;
218         
219     }
220     // for helix fit
221     else { 
222 // #### -B0-UNCHANGED-START == JMT
223         //fRadius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
224         Double_t radius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
225         SetRadius(radius);
226         
227         //fPt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * fRadius);
228         Double_t pt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * GetRadius());
229         SetPt(pt);
230         
231         if(GetPt() > max_Dca) //go for fit of helix in real space
232         {
233             AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
234     /* Matthias 13.12.2006
235      * the global variable AliHLTTPCS::fgDoVertexFit has never been used so far
236      * and has always been kTRUE.
237      * In order to remove the AliHLTTPC class (which is the old steering class for
238      * HLT (TPC) tracking) from the compilation, this function can not be activated
239      * again. We have to think about a more elegant way to specify the parameters
240      * anyway. 
241             ComesFromMainVertex(AliHLTTPC::DoVertexFit());
242      */
243             ComesFromMainVertex(kTRUE);
244             fit->FitHelix();
245             
246             //AliHLTTPCConfMapPoint *lHit = (AliHLTTPCConfMapPoint*)fLastHit;
247             AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
248             SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
249             
250             UpdateToFirstPoint();
251             
252             delete fit;
253         }
254         else if(GetPt() == 0) 
255         {
256             LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
257                 "Found track with Pt=0!!!"<<ENDLOG;
258         }
259         else
260         {
261             LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
262                 "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
263         }
264 // #### -B0-UNCHANGED-END == JMT
265     }
266 // #### -B0-CHANGE-END == JMT
267 }
268
269 Int_t AliHLTTPCConfMapTrack::GetMCLabel()
270 {
271   //For evaluation study.
272   //Returns the MCtrackID of the belonging clusters.
273   //If MCLabel < 0, means that track is fake.
274
275   return 0;
276   /*
277   Int_t num_of_clusters = GetNumberOfPoints();
278   S *s=new S[num_of_clusters];
279   Int_t i;
280   for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
281   
282   Int_t lab=123456789;
283   for (i=0; i<num_of_clusters; i++) {
284     AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
285     lab=fabs(c->fMCTrackID[0]);
286     Int_t j;
287     for (j=0; j<num_of_clusters; j++)
288       if (s[j].lab==lab || s[j].max==0) break;
289     s[j].lab=lab;
290     s[j].max++;
291   }
292   
293   Int_t max=0;
294   for (i=0; i<num_of_clusters; i++) 
295     if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
296     
297   delete[] s;
298   
299   for (i=0; i<num_of_clusters; i++) {
300     AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
301     if (fabs(c->fMCTrackID[1]) == lab ||
302         fabs(c->fMCTrackID[2]) == lab ) max++;
303   }
304   
305   //check if more than 10% of the clusters are incorrectly assigned (fake track):
306   
307   if (1.-Float_t(max)/num_of_clusters > 0.10) 
308     {
309       return -lab;
310     }
311   Int_t tail=Int_t(0.08*174);
312   if (num_of_clusters < tail) return lab;
313   
314   max=0;
315   for (i=1; i<=tail; i++) {
316     AliHLTTPCConfMapPoint *c = (AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
317     if (lab == fabs(c->fMCTrackID[0]) ||
318         lab == fabs(c->fMCTrackID[1]) ||
319         lab == fabs(c->fMCTrackID[2])) max++;
320   }
321   if (max < Int_t(0.5*tail)) 
322     {
323       //printf("Wrong innermost clusters\n");
324       return -lab;
325     }
326   return lab;
327   */
328 }
329