2 // Original: AliHLTConfMapTrack.cxx,v 1.16 2005/06/14 10:55:21 cvetan
4 /**************************************************************************
5 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * Authors: Anders Vestbo *
8 * Matthias Richter <Matthias.Richter@ift.uib.no> *
9 * for The ALICE Off-line Project. *
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 **************************************************************************/
20 /** @file AliHLTTPCConfMapTrack.cxx
21 @author Anders Vestbo, maintained by Matthias Richter
23 @brief Track class for conformal mapper
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"
39 ClassImp(AliHLTTPCConfMapTrack)
42 AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack()
49 AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack(const AliHLTTPCConfMapTrack&)
51 // dummy copy constructor
52 //HLTFatal("copy constructor untested");
55 AliHLTTPCConfMapTrack& AliHLTTPCConfMapTrack::operator=(const AliHLTTPCConfMapTrack&)
57 // dummy assignment operator
58 //HLTFatal("assignment operator untested");
62 AliHLTTPCConfMapTrack::~AliHLTTPCConfMapTrack()
67 void AliHLTTPCConfMapTrack::DeleteCandidate()
69 //Deletes this track by resetting all its parameters. Does not delete
72 AliHLTTPCConfMapPoint *curHit = (AliHLTTPCConfMapPoint*)fFirstHit;
73 AliHLTTPCConfMapPoint *nextHit;
77 nextHit = (AliHLTTPCConfMapPoint*)curHit->GetNextTrackHit();
78 curHit->SetNextTrackHit(0);
82 UInt_t *hit_numbers = GetHitNumbers();
83 for(Int_t i=0; i<GetNHits(); i++)
93 ComesFromMainVertex(false);
102 void AliHLTTPCConfMapTrack::SetProperties(Bool_t usage)
104 //Set the hits to this track to 'usage'
105 for(StartLoop(); LoopDone(); GetNextHit())
107 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)fCurrentHit;
113 void AliHLTTPCConfMapTrack::Reset()
115 //Resets the fit parameters of this track.
136 void AliHLTTPCConfMapTrack::UpdateParam(AliHLTTPCConfMapPoint *thisHit)
138 //Function to update fit parameters of track
139 //Also, it updates the hit pointers.
142 //Increment the number of hits assigned to this track:
145 Int_t nhits = GetNHits();
147 SetNHits(nhits); //SetNHits(nhits++);
149 //Set the hit pointers:
154 ((AliHLTTPCConfMapPoint*)fLastHit)->SetNextTrackHit(thisHit);
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() ;
164 fddXy = fs11Xy * fs22Xy - pow((fs12Xy),2) ;
167 fa1Xy = ( fg1Xy * fs22Xy - fg2Xy * fs12Xy ) / fddXy ;
168 fa2Xy = ( fg2Xy * fs11Xy - fg1Xy * fs12Xy ) / fddXy ;
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() ;
179 fddSz = fs11Sz * fs22Sz - fs12Sz * fs12Sz ;
181 fa1Sz = ( fg1Sz * fs22Sz - fg2Sz * fs12Sz ) / fddSz ;
182 fa2Sz = ( fg2Sz * fs11Sz - fg1Sz * fs12Sz ) / fddSz ;
187 void AliHLTTPCConfMapTrack::Fill(AliHLTTPCVertex *vertex,Double_t max_Dca)
189 //Fill track variables with or without fit.
191 // #### -B0-CHANGE-START == JMT
192 // for straight line fit
193 if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
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
207 ComesFromMainVertex(AliHLTTPC::DoVertexFit());
209 ComesFromMainVertex(kTRUE);
210 fit->FitStraightLine();
212 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
213 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
215 UpdateToFirstPoint();
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));
227 //fPt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * fRadius);
228 Double_t pt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * GetRadius());
231 if(GetPt() > max_Dca) //go for fit of helix in real space
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
241 ComesFromMainVertex(AliHLTTPC::DoVertexFit());
243 ComesFromMainVertex(kTRUE);
246 //AliHLTTPCConfMapPoint *lHit = (AliHLTTPCConfMapPoint*)fLastHit;
247 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
248 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
250 UpdateToFirstPoint();
254 else if(GetPt() == 0)
256 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
257 "Found track with Pt=0!!!"<<ENDLOG;
261 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
262 "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
264 // #### -B0-UNCHANGED-END == JMT
266 // #### -B0-CHANGE-END == JMT
269 Int_t AliHLTTPCConfMapTrack::GetMCLabel()
271 //For evaluation study.
272 //Returns the MCtrackID of the belonging clusters.
273 //If MCLabel < 0, means that track is fake.
277 Int_t num_of_clusters = GetNumberOfPoints();
278 S *s=new S[num_of_clusters];
280 for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
283 for (i=0; i<num_of_clusters; i++) {
284 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
285 lab=fabs(c->fMCTrackID[0]);
287 for (j=0; j<num_of_clusters; j++)
288 if (s[j].lab==lab || s[j].max==0) break;
294 for (i=0; i<num_of_clusters; i++)
295 if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
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++;
305 //check if more than 10% of the clusters are incorrectly assigned (fake track):
307 if (1.-Float_t(max)/num_of_clusters > 0.10)
311 Int_t tail=Int_t(0.08*174);
312 if (num_of_clusters < tail) return lab;
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++;
321 if (max < Int_t(0.5*tail))
323 //printf("Wrong innermost clusters\n");