3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliHLTTPCStandardIncludes.h"
8 #include "AliHLTTPCRootTypes.h"
9 #include "AliHLTTPCLogging.h"
10 #include "AliHLTTPCVertex.h"
11 #include "AliHLTTPCConfMapPoint.h"
12 #include "AliHLTTPCConfMapFit.h"
13 #include "AliHLTTPCConfMapTrack.h"
14 #include "AliHLTTPCTransform.h"
15 #include "AliHLTTPC.h"
17 /** \class AliHLTTPCConfMapTrack
19 //_____________________________________________________________
20 // AliHLTTPCConfMapTrack
22 // Track class for conformal mapper
30 ClassImp(AliHLTTPCConfMapTrack)
33 AliHLTTPCConfMapTrack::AliHLTTPCConfMapTrack()
40 AliHLTTPCConfMapTrack::~AliHLTTPCConfMapTrack()
45 void AliHLTTPCConfMapTrack::DeleteCandidate()
47 //Deletes this track by resetting all its parameters. Does not delete
50 AliHLTTPCConfMapPoint *curHit = (AliHLTTPCConfMapPoint*)fFirstHit;
51 AliHLTTPCConfMapPoint *nextHit;
55 nextHit = (AliHLTTPCConfMapPoint*)curHit->GetNextTrackHit();
56 curHit->SetNextTrackHit(0);
60 UInt_t *hit_numbers = GetHitNumbers();
61 for(Int_t i=0; i<GetNHits(); i++)
71 ComesFromMainVertex(false);
80 void AliHLTTPCConfMapTrack::SetProperties(Bool_t usage)
82 //Set the hits to this track to 'usage'
83 for(StartLoop(); LoopDone(); GetNextHit())
85 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)fCurrentHit;
91 void AliHLTTPCConfMapTrack::Reset()
93 //Resets the fit parameters of this track.
114 void AliHLTTPCConfMapTrack::UpdateParam(AliHLTTPCConfMapPoint *thisHit)
116 //Function to update fit parameters of track
117 //Also, it updates the hit pointers.
120 //Increment the number of hits assigned to this track:
123 Int_t nhits = GetNHits();
125 SetNHits(nhits); //SetNHits(nhits++);
127 //Set the hit pointers:
132 ((AliHLTTPCConfMapPoint*)fLastHit)->SetNextTrackHit(thisHit);
136 fs11Xy = fs11Xy + thisHit->GetXYWeight() ;
137 fs12Xy = fs12Xy + thisHit->GetXYWeight() * thisHit->GetXprime() ;
138 fs22Xy = fs22Xy + thisHit->GetXYWeight() * pow((thisHit->GetXprime()),2) ;
139 fg1Xy = fg1Xy + thisHit->GetXYWeight() * thisHit->GetYprime() ;
140 fg2Xy = fg2Xy + thisHit->GetXYWeight() * thisHit->GetXprime() * thisHit->GetYprime() ;
142 fddXy = fs11Xy * fs22Xy - pow((fs12Xy),2) ;
145 fa1Xy = ( fg1Xy * fs22Xy - fg2Xy * fs12Xy ) / fddXy ;
146 fa2Xy = ( fg2Xy * fs11Xy - fg1Xy * fs12Xy ) / fddXy ;
149 // Now in the sz plane
150 fs11Sz = fs11Sz + thisHit->GetZWeight() ;
151 fs12Sz = fs12Sz + thisHit->GetZWeight() * thisHit->GetS() ;
152 fs22Sz = fs22Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetS() ;
153 fg1Sz = fg1Sz + thisHit->GetZWeight() * thisHit->GetZ() ;
154 fg2Sz = fg2Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetZ() ;
157 fddSz = fs11Sz * fs22Sz - fs12Sz * fs12Sz ;
159 fa1Sz = ( fg1Sz * fs22Sz - fg2Sz * fs12Sz ) / fddSz ;
160 fa2Sz = ( fg2Sz * fs11Sz - fg1Sz * fs12Sz ) / fddSz ;
165 void AliHLTTPCConfMapTrack::Fill(AliHLTTPCVertex *vertex,Double_t max_Dca)
167 //Fill track variables with or without fit.
169 //fRadius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
170 Double_t radius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
173 //fPt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * fRadius);
174 Double_t pt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * GetRadius());
177 if(GetPt() > max_Dca) //go for fit of helix in real space
179 AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
180 ComesFromMainVertex(AliHLTTPC::DoVertexFit());
183 //AliHLTTPCConfMapPoint *lHit = (AliHLTTPCConfMapPoint*)fLastHit;
184 AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
185 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
187 UpdateToFirstPoint();
191 else if(GetPt() == 0)
192 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
193 "Found track with Pt=0!!!"<<ENDLOG;
196 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
197 "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
201 Int_t AliHLTTPCConfMapTrack::GetMCLabel()
203 //For evaluation study.
204 //Returns the MCtrackID of the belonging clusters.
205 //If MCLabel < 0, means that track is fake.
209 Int_t num_of_clusters = GetNumberOfPoints();
210 S *s=new S[num_of_clusters];
212 for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
215 for (i=0; i<num_of_clusters; i++) {
216 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
217 lab=fabs(c->fMCTrackID[0]);
219 for (j=0; j<num_of_clusters; j++)
220 if (s[j].lab==lab || s[j].max==0) break;
226 for (i=0; i<num_of_clusters; i++)
227 if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
231 for (i=0; i<num_of_clusters; i++) {
232 AliHLTTPCConfMapPoint *c=(AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(i);
233 if (fabs(c->fMCTrackID[1]) == lab ||
234 fabs(c->fMCTrackID[2]) == lab ) max++;
237 //check if more than 10% of the clusters are incorrectly assigned (fake track):
239 if (1.-Float_t(max)/num_of_clusters > 0.10)
243 Int_t tail=Int_t(0.08*174);
244 if (num_of_clusters < tail) return lab;
247 for (i=1; i<=tail; i++) {
248 AliHLTTPCConfMapPoint *c = (AliHLTTPCConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
249 if (lab == fabs(c->fMCTrackID[0]) ||
250 lab == fabs(c->fMCTrackID[1]) ||
251 lab == fabs(c->fMCTrackID[2])) max++;
253 if (max < Int_t(0.5*tail))
255 //printf("Wrong innermost clusters\n");