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()
50 AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack(const AliHLTTPCConfMapTrack&)
52 // dummy copy constructor
53 //HLTFatal("copy constructor untested");
56 AliHLTTPCConfMapTrack& AliHLTTPCConfMapTrack::operator=(const AliHLTTPCConfMapTrack&)
58 // dummy assignment operator
59 //HLTFatal("assignment operator untested");
63 AliHLTTPCConfMapTrack::~AliHLTTPCConfMapTrack()
68 void AliHLTTPCConfMapTrack::DeleteCandidate()
70 //Deletes this track by resetting all its parameters. Does not delete
73 AliHLTTPCConfMapPoint *curHit = (AliHLTTPCConfMapPoint*)fFirstHit;
74 AliHLTTPCConfMapPoint *nextHit;
78 nextHit = (AliHLTTPCConfMapPoint*)curHit->GetNextTrackHit();
79 curHit->SetNextTrackHit(0);
83 UInt_t *hit_numbers = GetHitNumbers();
84 for(Int_t i=0; i<GetNHits(); i++)
94 ComesFromMainVertex(false);
103 void AliHLTTPCConfMapTrack::SetProperties(Bool_t usage)
105 //Set the hits to this track to 'usage'
106 for(StartLoop(); LoopDone(); GetNextHit())
108 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)fCurrentHit;
114 void AliHLTTPCConfMapTrack::Reset()
116 //Resets the fit parameters of this track.
137 void AliHLTTPCConfMapTrack::UpdateParam(AliHLTTPCConfMapPoint *thisHit)
139 //Function to update fit parameters of track
140 //Also, it updates the hit pointers.
143 //Increment the number of hits assigned to this track:
146 Int_t nhits = GetNHits();
148 SetNHits(nhits); //SetNHits(nhits++);
150 //Set the hit pointers:
155 ((AliHLTTPCConfMapPoint*)fLastHit)->SetNextTrackHit(thisHit);
159 fs11Xy = fs11Xy + thisHit->GetXYWeight() ;
160 fs12Xy = fs12Xy + thisHit->GetXYWeight() * thisHit->GetXprime() ;
161 fs22Xy = fs22Xy + thisHit->GetXYWeight() * pow((thisHit->GetXprime()),2) ;
162 fg1Xy = fg1Xy + thisHit->GetXYWeight() * thisHit->GetYprime() ;
163 fg2Xy = fg2Xy + thisHit->GetXYWeight() * thisHit->GetXprime() * thisHit->GetYprime() ;
165 fddXy = fs11Xy * fs22Xy - pow((fs12Xy),2) ;
168 fa1Xy = ( fg1Xy * fs22Xy - fg2Xy * fs12Xy ) / fddXy ;
169 fa2Xy = ( fg2Xy * fs11Xy - fg1Xy * fs12Xy ) / fddXy ;
172 // Now in the sz plane
173 fs11Sz = fs11Sz + thisHit->GetZWeight() ;
174 fs12Sz = fs12Sz + thisHit->GetZWeight() * thisHit->GetS() ;
175 fs22Sz = fs22Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetS() ;
176 fg1Sz = fg1Sz + thisHit->GetZWeight() * thisHit->GetZ() ;
177 fg2Sz = fg2Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetZ() ;
180 fddSz = fs11Sz * fs22Sz - fs12Sz * fs12Sz ;
182 fa1Sz = ( fg1Sz * fs22Sz - fg2Sz * fs12Sz ) / fddSz ;
183 fa2Sz = ( fg2Sz * fs11Sz - fg1Sz * fs12Sz ) / fddSz ;
188 void AliHLTTPCConfMapTrack::Fill(AliHLTTPCVertex *vertex,Double_t max_Dca)
190 //Fill track variables with or without fit.
192 // #### -B0-CHANGE-START == JMT
193 // for straight line fit
194 if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
199 //go for fit of straight line in real space
200 AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
201 /* Matthias 13.12.2006
202 * the global variable AliHLTTPCS::fgDoVertexFit has never been used so far
203 * and has always been kTRUE.
204 * In order to remove the AliHLTTPC class (which is the old steering class for
205 * HLT (TPC) tracking) from the compilation, this function can not be activated
206 * again. We have to think about a more elegant way to specify the parameters
208 ComesFromMainVertex(AliHLTTPC::DoVertexFit());
210 ComesFromMainVertex(kTRUE);
211 fit->FitStraightLine();
213 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
214 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
216 UpdateToFirstPoint();
223 // #### -B0-UNCHANGED-START == JMT
224 //fRadius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
225 Double_t radius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
228 //fPt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * fRadius);
229 Double_t pt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * GetRadius());
232 if(GetPt() > max_Dca) //go for fit of helix in real space
234 AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
235 /* Matthias 13.12.2006
236 * the global variable AliHLTTPCS::fgDoVertexFit has never been used so far
237 * and has always been kTRUE.
238 * In order to remove the AliHLTTPC class (which is the old steering class for
239 * HLT (TPC) tracking) from the compilation, this function can not be activated
240 * again. We have to think about a more elegant way to specify the parameters
242 ComesFromMainVertex(AliHLTTPC::DoVertexFit());
244 ComesFromMainVertex(kTRUE);
247 //AliHLTTPCConfMapPoint *lHit = (AliHLTTPCConfMapPoint*)fLastHit;
248 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
249 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
251 UpdateToFirstPoint();
255 else if(GetPt() == 0)
257 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
258 "Found track with Pt=0!!!"<<ENDLOG;
262 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
263 "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
265 // #### -B0-UNCHANGED-END == JMT
267 // #### -B0-CHANGE-END == JMT
270 Int_t AliHLTTPCConfMapTrack::GetMCLabel()
272 //For evaluation study.
273 //Returns the MCtrackID of the belonging clusters.
274 //If MCLabel < 0, means that track is fake.
278 Int_t num_of_clusters = GetNumberOfPoints();
279 S *s=new S[num_of_clusters];
281 for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
284 for (i=0; i<num_of_clusters; i++) {
285 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
286 lab=fabs(c->fMCTrackID[0]);
288 for (j=0; j<num_of_clusters; j++)
289 if (s[j].lab==lab || s[j].max==0) break;
295 for (i=0; i<num_of_clusters; i++)
296 if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
300 for (i=0; i<num_of_clusters; i++) {
301 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
302 if (fabs(c->fMCTrackID[1]) == lab ||
303 fabs(c->fMCTrackID[2]) == lab ) max++;
306 //check if more than 10% of the clusters are incorrectly assigned (fake track):
308 if (1.-Float_t(max)/num_of_clusters > 0.10)
312 Int_t tail=Int_t(0.08*174);
313 if (num_of_clusters < tail) return lab;
316 for (i=1; i<=tail; i++) {
317 AliHLTTPCConfMapPoint *c = (AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
318 if (lab == fabs(c->fMCTrackID[0]) ||
319 lab == fabs(c->fMCTrackID[1]) ||
320 lab == fabs(c->fMCTrackID[2])) max++;
322 if (max < Int_t(0.5*tail))
324 //printf("Wrong innermost clusters\n");