3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliL3StandardIncludes.h"
8 #include "AliL3RootTypes.h"
9 #include "AliL3Logging.h"
10 #include "AliL3Vertex.h"
11 #include "AliL3ConfMapPoint.h"
12 #include "AliL3ConfMapFit.h"
13 #include "AliL3ConfMapTrack.h"
14 #include "AliL3Transform.h"
15 #include "AliLevel3.h"
17 /** \class AliL3ConfMapTrack
19 //_____________________________________________________________
22 // Track class for conformal mapper
26 ClassImp(AliL3ConfMapTrack)
29 AliL3ConfMapTrack::AliL3ConfMapTrack()
37 AliL3ConfMapTrack::~AliL3ConfMapTrack()
42 void AliL3ConfMapTrack::DeleteCandidate()
44 //Deletes this track by resetting all its parameters. Does not delete
47 AliL3ConfMapPoint *curHit = (AliL3ConfMapPoint*)firstHit;
48 AliL3ConfMapPoint *nextHit;
52 nextHit = (AliL3ConfMapPoint*)curHit->nextTrackHit;
53 curHit->nextTrackHit = 0;
57 UInt_t *hit_numbers = GetHitNumbers();
58 for(Int_t i=0; i<GetNHits(); i++)
68 ComesFromMainVertex(false);
77 void AliL3ConfMapTrack::SetProperties(Bool_t usage)
79 //Set the hits to this track to 'usage'
81 for(StartLoop(); LoopDone(); GetNextHit())
83 AliL3ConfMapPoint *p = (AliL3ConfMapPoint*)currentHit;
89 void AliL3ConfMapTrack::Reset()
91 //Resets the fit parameters of this track.
112 void AliL3ConfMapTrack::UpdateParam(AliL3ConfMapPoint *thisHit)
114 //Function to update fit parameters of track
115 //Also, it updates the hit pointers.
118 //Increment the number of hits assigned to this track:
121 Int_t nhits = GetNHits();
123 SetNHits(nhits); //SetNHits(nhits++);
125 //Set the hit pointers:
130 ((AliL3ConfMapPoint*)lastHit)->nextTrackHit = thisHit;
134 s11Xy = s11Xy + thisHit->GetXYWeight() ;
135 s12Xy = s12Xy + thisHit->GetXYWeight() * thisHit->GetXprime() ;
136 s22Xy = s22Xy + thisHit->GetXYWeight() * pow((thisHit->GetXprime()),2) ;
137 g1Xy = g1Xy + thisHit->GetXYWeight() * thisHit->GetYprime() ;
138 g2Xy = g2Xy + thisHit->GetXYWeight() * thisHit->GetXprime() * thisHit->GetYprime() ;
140 ddXy = s11Xy * s22Xy - pow((s12Xy),2) ;
143 a1Xy = ( g1Xy * s22Xy - g2Xy * s12Xy ) / ddXy ;
144 a2Xy = ( g2Xy * s11Xy - g1Xy * s12Xy ) / ddXy ;
147 // Now in the sz plane
148 s11Sz = s11Sz + thisHit->GetZWeight() ;
149 s12Sz = s12Sz + thisHit->GetZWeight() * thisHit->GetS() ;
150 s22Sz = s22Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetS() ;
151 g1Sz = g1Sz + thisHit->GetZWeight() * thisHit->GetZ() ;
152 g2Sz = g2Sz + thisHit->GetZWeight() * thisHit->GetS() * thisHit->GetZ() ;
155 ddSz = s11Sz * s22Sz - s12Sz * s12Sz ;
157 a1Sz = ( g1Sz * s22Sz - g2Sz * s12Sz ) / ddSz ;
158 a2Sz = ( g2Sz * s11Sz - g1Sz * s12Sz ) / ddSz ;
163 void AliL3ConfMapTrack::Fill(AliL3Vertex *vertex,Double_t max_Dca)
165 //Fill track variables with or without fit.
167 //fRadius = sqrt(a2Xy*a2Xy+1)/(2*fabs(a1Xy));
168 Double_t radius = sqrt(a2Xy*a2Xy+1)/(2*fabs(a1Xy));
171 //fPt = (Double_t)(AliL3Transform::GetBFieldValue() * fRadius);
172 Double_t pt = (Double_t)(AliL3Transform::GetBFieldValue() * GetRadius());
175 if(GetPt() > max_Dca) //go for fit of helix in real space
177 AliL3ConfMapFit *fit = new AliL3ConfMapFit(this,vertex);
178 ComesFromMainVertex(AliLevel3::DoVertexFit());
181 //AliL3ConfMapPoint *lHit = (AliL3ConfMapPoint*)lastHit;
182 AliL3ConfMapPoint *fHit = (AliL3ConfMapPoint*)firstHit;
183 SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
185 UpdateToFirstPoint();
189 else if(GetPt() == 0)
190 LOG(AliL3Log::kError,"AliL3ConfMapTrack::Fill","Tracks")<<AliL3Log::kDec<<
191 "Found track with Pt=0!!!"<<ENDLOG;
194 LOG(AliL3Log::kError,"AliL3ConfMapTrack::Fill","Tracks")<<AliL3Log::kDec<<
195 "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
199 Int_t AliL3ConfMapTrack::GetMCLabel()
201 //For evaluation study.
202 //Returns the MCtrackID of the belonging clusters.
203 //If MCLabel < 0, means that track is fake.
207 Int_t num_of_clusters = GetNumberOfPoints();
208 S *s=new S[num_of_clusters];
210 for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
213 for (i=0; i<num_of_clusters; i++) {
214 AliL3ConfMapPoint *c=(AliL3ConfMapPoint*)fPoints->UncheckedAt(i);
215 lab=fabs(c->fMCTrackID[0]);
217 for (j=0; j<num_of_clusters; j++)
218 if (s[j].lab==lab || s[j].max==0) break;
224 for (i=0; i<num_of_clusters; i++)
225 if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
229 for (i=0; i<num_of_clusters; i++) {
230 AliL3ConfMapPoint *c=(AliL3ConfMapPoint*)fPoints->UncheckedAt(i);
231 if (fabs(c->fMCTrackID[1]) == lab ||
232 fabs(c->fMCTrackID[2]) == lab ) max++;
235 //check if more than 10% of the clusters are incorrectly assigned (fake track):
237 if (1.-Float_t(max)/num_of_clusters > 0.10)
241 Int_t tail=Int_t(0.08*174);
242 if (num_of_clusters < tail) return lab;
245 for (i=1; i<=tail; i++) {
246 AliL3ConfMapPoint *c = (AliL3ConfMapPoint*)fPoints->UncheckedAt(num_of_clusters-i);
247 if (lab == fabs(c->fMCTrackID[0]) ||
248 lab == fabs(c->fMCTrackID[1]) ||
249 lab == fabs(c->fMCTrackID[2])) max++;
251 if (max < Int_t(0.5*tail))
253 //printf("Wrong innermost clusters\n");