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