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