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"
39 ClassImp(AliHLTTPCConfMapTrack)
42 AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack()
69 AliHLTTPCConfMapTrack::~AliHLTTPCConfMapTrack()
74 void AliHLTTPCConfMapTrack::DeleteCandidate()
76 //Deletes this track by resetting all its parameters. Does not delete
79 AliHLTTPCConfMapPoint *curHit = (AliHLTTPCConfMapPoint*)fFirstHit;
80 AliHLTTPCConfMapPoint *nextHit;
84 nextHit = (AliHLTTPCConfMapPoint*)curHit->GetNextTrackHit();
85 curHit->SetNextTrackHit(0);
89 UInt_t *hit_numbers = GetHitNumbers();
90 for(Int_t i=0; i<GetNHits(); i++)
100 ComesFromMainVertex(false);
109 void AliHLTTPCConfMapTrack::SetProperties(Bool_t usage)
111 //Set the hits to this track to 'usage'
112 for(StartLoop(); LoopDone(); GetNextHit())
114 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)fCurrentHit;
120 void AliHLTTPCConfMapTrack::Reset()
122 //Resets the fit parameters of this track.
143 void AliHLTTPCConfMapTrack::UpdateParam(AliHLTTPCConfMapPoint *thisHit)
145 //Function to update fit parameters of track
146 //Also, it updates the hit pointers.
149 //Increment the number of hits assigned to this track:
152 Int_t nhits = GetNHits();
154 SetNHits(nhits); //SetNHits(nhits++);
156 //Set the hit pointers:
161 ((AliHLTTPCConfMapPoint*)fLastHit)->SetNextTrackHit(thisHit);
165 fs11Xy = fs11Xy + thisHit->GetXYWeight() ;
166 fs12Xy = fs12Xy + thisHit->GetXYWeight() * thisHit->GetXprime() ;
167 fs22Xy = fs22Xy + thisHit->GetXYWeight() * pow((thisHit->GetXprime()),2) ;
168 fg1Xy = fg1Xy + thisHit->GetXYWeight() * thisHit->GetYprime() ;
169 fg2Xy = fg2Xy + thisHit->GetXYWeight() * thisHit->GetXprime() * thisHit->GetYprime() ;
171 fddXy = fs11Xy * fs22Xy - pow((fs12Xy),2) ;
174 fa1Xy = ( fg1Xy * fs22Xy - fg2Xy * fs12Xy ) / fddXy ;
175 fa2Xy = ( fg2Xy * fs11Xy - fg1Xy * fs12Xy ) / fddXy ;
178 // Now in the sz plane
179 fs11Sz = fs11Sz + thisHit->GetZWeight() ;
180 fs12Sz = fs12Sz + thisHit->GetZWeight() * thisHit->GetS() ;
181 fs22Sz = fs22Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetS() ;
182 fg1Sz = fg1Sz + thisHit->GetZWeight() * thisHit->GetZ() ;
183 fg2Sz = fg2Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetZ() ;
186 fddSz = fs11Sz * fs22Sz - fs12Sz * fs12Sz ;
188 fa1Sz = ( fg1Sz * fs22Sz - fg2Sz * fs12Sz ) / fddSz ;
189 fa2Sz = ( fg2Sz * fs11Sz - fg1Sz * fs12Sz ) / fddSz ;
194 void AliHLTTPCConfMapTrack::Fill(AliHLTTPCVertex *vertex,Double_t max_Dca)
196 //Fill track variables with or without fit.
198 // for straight line fit
199 if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
204 //go for fit of straight line in real space
205 AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
206 /* Matthias 13.12.2006
207 * the global variable AliHLTTPCS::fgDoVertexFit has never been used so far
208 * and has always been kTRUE.
209 * In order to remove the AliHLTTPC class (which is the old steering class for
210 * HLT (TPC) tracking) from the compilation, this function can not be activated
211 * again. We have to think about a more elegant way to specify the parameters
213 ComesFromMainVertex(AliHLTTPC::DoVertexFit());
215 ComesFromMainVertex(kTRUE);
216 fit->FitStraightLine();
218 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
219 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
221 UpdateToFirstPoint();
228 //fRadius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
229 Double_t radius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
232 //fPt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * fRadius);
233 Double_t pt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * GetRadius());
235 //Set Error here?????
237 if(GetPt() > max_Dca) //go for fit of helix 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);
252 //AliHLTTPCConfMapPoint *lHit = (AliHLTTPCConfMapPoint*)fLastHit;
253 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
254 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
256 UpdateToFirstPoint();
260 else if(GetPt() == 0)
262 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
263 "Found track with Pt=0!!!"<<ENDLOG;
267 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
268 "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
273 Int_t AliHLTTPCConfMapTrack::GetMCLabel()
275 //For evaluation study.
276 //Returns the MCtrackID of the belonging clusters.
277 //If MCLabel < 0, means that track is fake.
281 Int_t num_of_clusters = GetNumberOfPoints();
282 S *s=new S[num_of_clusters];
284 for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
287 for (i=0; i<num_of_clusters; i++) {
288 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
289 lab=fabs(c->fMCTrackID[0]);
291 for (j=0; j<num_of_clusters; j++)
292 if (s[j].lab==lab || s[j].max==0) break;
298 for (i=0; i<num_of_clusters; i++)
299 if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
303 for (i=0; i<num_of_clusters; i++) {
304 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
305 if (fabs(c->fMCTrackID[1]) == lab ||
306 fabs(c->fMCTrackID[2]) == lab ) max++;
309 //check if more than 10% of the clusters are incorrectly assigned (fake track):
311 if (1.-Float_t(max)/num_of_clusters > 0.10)
315 Int_t tail=Int_t(0.08*174);
316 if (num_of_clusters < tail) return lab;
319 for (i=1; i<=tail; i++) {
320 AliHLTTPCConfMapPoint *c = (AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
321 if (lab == fabs(c->fMCTrackID[0]) ||
322 lab == fabs(c->fMCTrackID[1]) ||
323 lab == fabs(c->fMCTrackID[2])) max++;
325 if (max < Int_t(0.5*tail))
327 //printf("Wrong innermost clusters\n");