2 // Original: AliHLTConfMapTrack.cxx,v 1.16 2005/06/14 10:55:21 cvetan
4 /**************************************************************************
5 * This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
8 * Primary Authors: Anders Vestbo, maintained by *
9 * Matthias Richter <Matthias.Richter@ift.uib.no> *
10 * for The ALICE HLT Project. *
12 * Permission to use, copy, modify and distribute this software and its *
13 * documentation strictly for non-commercial purposes is hereby granted *
14 * without fee, provided that the above copyright notice appears in all *
15 * copies and that both the copyright notice and this permission notice *
16 * appear in the supporting documentation. The authors make no claims *
17 * about the suitability of this software for any purpose. It is *
18 * provided "as is" without express or implied warranty. *
19 **************************************************************************/
21 /** @file AliHLTTPCConfMapTrack.cxx
22 @author Anders Vestbo, maintained by Matthias Richter
24 @brief Track class for conformal mapper
27 #include "AliHLTTPCRootTypes.h"
28 #include "AliHLTTPCLogging.h"
29 #include "AliHLTTPCVertex.h"
30 #include "AliHLTTPCConfMapPoint.h"
31 #include "AliHLTTPCConfMapFit.h"
32 #include "AliHLTTPCConfMapTrack.h"
33 #include "AliHLTTPCTransform.h"
34 //#include "AliHLTTPC.h"
40 ClassImp(AliHLTTPCConfMapTrack)
43 AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack()
70 AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack(const AliHLTTPCConfMapTrack&)
92 // dummy copy constructor
93 //HLTFatal("copy constructor untested");
96 AliHLTTPCConfMapTrack& AliHLTTPCConfMapTrack::operator=(const AliHLTTPCConfMapTrack&)
98 // dummy assignment operator
99 //HLTFatal("assignment operator untested");
103 AliHLTTPCConfMapTrack::~AliHLTTPCConfMapTrack()
108 void AliHLTTPCConfMapTrack::DeleteCandidate()
110 //Deletes this track by resetting all its parameters. Does not delete
113 AliHLTTPCConfMapPoint *curHit = (AliHLTTPCConfMapPoint*)fFirstHit;
114 AliHLTTPCConfMapPoint *nextHit;
118 nextHit = (AliHLTTPCConfMapPoint*)curHit->GetNextTrackHit();
119 curHit->SetNextTrackHit(0);
123 UInt_t *hit_numbers = GetHitNumbers();
124 for(Int_t i=0; i<GetNHits(); i++)
126 //fHitNumbers[i] = 0;
134 ComesFromMainVertex(false);
143 void AliHLTTPCConfMapTrack::SetProperties(Bool_t usage)
145 //Set the hits to this track to 'usage'
146 for(StartLoop(); LoopDone(); GetNextHit())
148 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)fCurrentHit;
154 void AliHLTTPCConfMapTrack::Reset()
156 //Resets the fit parameters of this track.
177 void AliHLTTPCConfMapTrack::UpdateParam(AliHLTTPCConfMapPoint *thisHit)
179 //Function to update fit parameters of track
180 //Also, it updates the hit pointers.
183 //Increment the number of hits assigned to this track:
186 Int_t nhits = GetNHits();
188 SetNHits(nhits); //SetNHits(nhits++);
190 //Set the hit pointers:
195 ((AliHLTTPCConfMapPoint*)fLastHit)->SetNextTrackHit(thisHit);
199 fs11Xy = fs11Xy + thisHit->GetXYWeight() ;
200 fs12Xy = fs12Xy + thisHit->GetXYWeight() * thisHit->GetXprime() ;
201 fs22Xy = fs22Xy + thisHit->GetXYWeight() * pow((thisHit->GetXprime()),2) ;
202 fg1Xy = fg1Xy + thisHit->GetXYWeight() * thisHit->GetYprime() ;
203 fg2Xy = fg2Xy + thisHit->GetXYWeight() * thisHit->GetXprime() * thisHit->GetYprime() ;
205 fddXy = fs11Xy * fs22Xy - pow((fs12Xy),2) ;
208 fa1Xy = ( fg1Xy * fs22Xy - fg2Xy * fs12Xy ) / fddXy ;
209 fa2Xy = ( fg2Xy * fs11Xy - fg1Xy * fs12Xy ) / fddXy ;
212 // Now in the sz plane
213 fs11Sz = fs11Sz + thisHit->GetZWeight() ;
214 fs12Sz = fs12Sz + thisHit->GetZWeight() * thisHit->GetS() ;
215 fs22Sz = fs22Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetS() ;
216 fg1Sz = fg1Sz + thisHit->GetZWeight() * thisHit->GetZ() ;
217 fg2Sz = fg2Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetZ() ;
220 fddSz = fs11Sz * fs22Sz - fs12Sz * fs12Sz ;
222 fa1Sz = ( fg1Sz * fs22Sz - fg2Sz * fs12Sz ) / fddSz ;
223 fa2Sz = ( fg2Sz * fs11Sz - fg1Sz * fs12Sz ) / fddSz ;
228 void AliHLTTPCConfMapTrack::Fill(AliHLTTPCVertex *vertex,Double_t max_Dca)
230 //Fill track variables with or without fit.
232 // for straight line fit
233 if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
238 //go for fit of straight line in real space
239 AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
240 /* Matthias 13.12.2006
241 * the global variable AliHLTTPCS::fgDoVertexFit has never been used so far
242 * and has always been kTRUE.
243 * In order to remove the AliHLTTPC class (which is the old steering class for
244 * HLT (TPC) tracking) from the compilation, this function can not be activated
245 * again. We have to think about a more elegant way to specify the parameters
247 ComesFromMainVertex(AliHLTTPC::DoVertexFit());
249 ComesFromMainVertex(kTRUE);
250 fit->FitStraightLine();
252 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
253 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
255 UpdateToFirstPoint();
262 //fRadius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
263 Double_t radius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
266 //fPt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * fRadius);
267 Double_t pt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * GetRadius());
270 if(GetPt() > max_Dca) //go for fit of helix in real space
272 AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
273 /* Matthias 13.12.2006
274 * the global variable AliHLTTPCS::fgDoVertexFit has never been used so far
275 * and has always been kTRUE.
276 * In order to remove the AliHLTTPC class (which is the old steering class for
277 * HLT (TPC) tracking) from the compilation, this function can not be activated
278 * again. We have to think about a more elegant way to specify the parameters
280 ComesFromMainVertex(AliHLTTPC::DoVertexFit());
282 ComesFromMainVertex(kTRUE);
285 //AliHLTTPCConfMapPoint *lHit = (AliHLTTPCConfMapPoint*)fLastHit;
286 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
287 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
289 UpdateToFirstPoint();
293 else if(GetPt() == 0)
295 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
296 "Found track with Pt=0!!!"<<ENDLOG;
300 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
301 "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
306 Int_t AliHLTTPCConfMapTrack::GetMCLabel()
308 //For evaluation study.
309 //Returns the MCtrackID of the belonging clusters.
310 //If MCLabel < 0, means that track is fake.
314 Int_t num_of_clusters = GetNumberOfPoints();
315 S *s=new S[num_of_clusters];
317 for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
320 for (i=0; i<num_of_clusters; i++) {
321 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
322 lab=fabs(c->fMCTrackID[0]);
324 for (j=0; j<num_of_clusters; j++)
325 if (s[j].lab==lab || s[j].max==0) break;
331 for (i=0; i<num_of_clusters; i++)
332 if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
336 for (i=0; i<num_of_clusters; i++) {
337 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
338 if (fabs(c->fMCTrackID[1]) == lab ||
339 fabs(c->fMCTrackID[2]) == lab ) max++;
342 //check if more than 10% of the clusters are incorrectly assigned (fake track):
344 if (1.-Float_t(max)/num_of_clusters > 0.10)
348 Int_t tail=Int_t(0.08*174);
349 if (num_of_clusters < tail) return lab;
352 for (i=1; i<=tail; i++) {
353 AliHLTTPCConfMapPoint *c = (AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
354 if (lab == fabs(c->fMCTrackID[0]) ||
355 lab == fabs(c->fMCTrackID[1]) ||
356 lab == fabs(c->fMCTrackID[2])) max++;
358 if (max < Int_t(0.5*tail))
360 //printf("Wrong innermost clusters\n");