]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUTrackHyp.cxx
1) fix in the AliITSUTrackerGlo for track hypothesis w/o winner
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUTrackHyp.cxx
1 #include "AliITSUTrackHyp.h"
2 #include "AliESDtrack.h"
3 #include "AliCluster.h"
4 #include "AliITSUAux.h"
5
6 ClassImp(AliITSUTrackHyp)
7
8
9
10 //__________________________________________________________________
11 AliITSUTrackHyp::AliITSUTrackHyp(Int_t nlr) 
12 : fNLayers(nlr)
13   ,fITSLabel(0)
14   ,fESDTrack(0)
15   ,fLayerSeeds(0)
16 {
17   // def. c-tor
18   if (fNLayers>0) fLayerSeeds = new TObjArray[fNLayers];
19 }
20
21 //__________________________________________________________________
22 AliITSUTrackHyp::~AliITSUTrackHyp() 
23 {
24   // d-tor
25   delete[] fLayerSeeds;
26 }
27
28 //__________________________________________________________________
29 AliITSUTrackHyp::AliITSUTrackHyp(const AliITSUTrackHyp &src)
30   : AliKalmanTrack(src)
31   , fNLayers(src.fNLayers)
32   , fITSLabel(src.fITSLabel)
33   , fESDTrack(src.fESDTrack)
34   , fLayerSeeds(0)
35 {
36   // copy c-tor
37   if (fNLayers>0) {
38     fLayerSeeds = new TObjArray[fNLayers];
39     for (int ilr=fNLayers;ilr--;) {
40       int ns = src.GetNSeeds(ilr);
41       for (int isd=0;isd<ns;isd++) {
42         AliITSUSeed* sd = src.GetSeed(ilr,isd);
43         if (sd->IsKilled()) continue;
44         AddSeed(sd,ilr);
45       }      
46     }
47   }
48   //
49 }
50
51 //__________________________________________________________________
52 AliITSUTrackHyp &AliITSUTrackHyp::operator=(const AliITSUTrackHyp &src)
53 {
54   // copy 
55   if (this == &src) return *this;
56   this->~AliITSUTrackHyp();
57   new(this) AliITSUTrackHyp(src);
58   return *this;
59   //
60 }
61
62 //__________________________________________________________________
63 void AliITSUTrackHyp::Print(Option_t* ) const
64 {
65   printf("Track Hyp.#%4d. NSeeds:",GetUniqueID());
66   for (int i=0;i<fNLayers;i++) printf(" (%d) %3d",i,GetNSeeds(i)); printf("\n");
67 }
68
69 //__________________________________________________________________
70 AliITSUSeed* AliITSUTrackHyp::GetWinner() const
71 {
72   // Get best candidate. TODO
73   return fLayerSeeds[0].GetEntriesFast()>0 ? GetSeed(0,0) : 0;
74 }
75
76 //__________________________________________________________________
77 AliITSUSeed* AliITSUTrackHyp::DefineWinner(int lr, int id)
78 {
79   // assign best candidate
80   if (GetNSeeds(lr)<=id) return 0;
81   AliITSUSeed* winner = GetSeed(lr,id);
82   this->AliExternalTrackParam::operator=(*winner);
83   SetChi2(winner->GetChi2GloNrm());
84   SetNumberOfClusters(winner->GetNLayersHit());
85   return winner;
86 }
87
88 //__________________________________________________________________
89 Double_t AliITSUTrackHyp::GetPredictedChi2(const AliCluster *cl) const
90 {
91   // calculate chi2 to cluster
92   Double_t p[2]={cl->GetY(), cl->GetZ()};
93   Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()};
94   return AliExternalTrackParam::GetPredictedChi2(p,cov);
95 }
96
97 //__________________________________________________________________
98 Bool_t AliITSUTrackHyp::PropagateTo(Double_t /*xr*/, Double_t /*x0*/, Double_t /*rho*/)
99 {
100   // NA
101   AliFatal("Not to be used");
102   return 0;
103 }
104
105 //__________________________________________________________________
106 Bool_t AliITSUTrackHyp::Update(const AliCluster* /*c*/, Double_t /*chi2*/, Int_t /*index*/)
107 {
108   // NA
109   AliFatal("Not to be used");
110   return kFALSE;
111 }
112
113 //__________________________________________________________________
114 Bool_t AliITSUTrackHyp::Update(const AliCluster* cl)
115 {
116   // update with cluster
117   Double_t p[2]={cl->GetY(), cl->GetZ()};
118   Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()};
119   double chi2 = AliExternalTrackParam::GetPredictedChi2(p,cov);
120   if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
121   SetChi2(GetChi2()+chi2);
122   return kTRUE;
123 }
124
125 //__________________________________________________________________
126 Int_t AliITSUTrackHyp::FetchClusterInfo(Int_t *clIDarr) const
127 {
128   // fill cl.id's in the array. The clusters of layer L will be set at slots
129   // clID[2L] (and clID[2L+1] if there is an extra cluster).
130   for (int i=fNLayers<<1;i--;) clIDarr[i]=-1;
131   Int_t lr,ncl=0;
132   AliITSUSeed* seed = GetWinner();
133   if (!seed) {
134     AliFatal("The winner is not set");
135     return ncl;
136   }
137   while(seed) {
138     int clID = seed->GetLrCluster(lr);
139     if (clID>=0) {
140       int slotLr = lr<<1;
141       clIDarr[ clIDarr[slotLr]<0 ? slotLr : slotLr+1 ] = clID;
142       ncl++;
143     }
144     seed = (AliITSUSeed*)seed->GetParent();
145   }
146   return ncl;
147 }
148
149 //__________________________________________________________________
150 Int_t AliITSUTrackHyp::GetNumberOfClusters() const
151 {
152   // This is a temporary (slow) way of accessing number of clusters
153   // TODO: add dedicated data members filled by winner
154   AliITSUSeed* seed = GetWinner();
155   int ncl = 0;
156   if (!seed) {
157     AliFatal("The winner is not set");
158     return ncl;
159   }
160   return seed->GetNClusters();
161   //
162 }
163
164 //__________________________________________________________________
165 Int_t AliITSUTrackHyp::GetClusterIndex(Int_t ind) const 
166 {
167   // This is a temporary (slow) way of accessing cluster index
168   // TODO: add dedicated data members filled by winner
169   AliITSUSeed* seed = GetWinner();
170   int ncl = 0;
171   if (!seed) {
172     AliFatal("The winner is not set");
173     return -1;
174   }
175   return seed->GetClusterIndex(ind);
176   //
177 }