]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUTrackHyp.cxx
Added loop for extraction of clusters really attached to its track.
[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 //__________________________________________________________________
59 AliITSUTrackHyp::AliITSUTrackHyp(const AliKalmanTrack &src)
60   : AliKalmanTrack(src)
61   , fNLayers(0)
62   , fITSLabel(0)
63   , fESDTrack(0)
64   , fWinner(0)
65   , fTPCSeed(0)
66   , fLayerSeeds(0)
67 {
68   // copy c-tor. from KalmanTrack
69   //
70 }
71
72 //__________________________________________________________________
73 AliITSUTrackHyp::AliITSUTrackHyp(const AliESDtrack &src)
74   : AliKalmanTrack()
75   , fNLayers(0)
76   , fITSLabel(0)
77   , fESDTrack(0)
78   , fWinner(0)
79   , fTPCSeed(0)
80   , fLayerSeeds(0)
81 {
82   // copy c-tor. from ESD track: take only kinematics, mass and time integral
83   AliExternalTrackParam::operator=((const AliExternalTrackParam&)src);
84   SetMass(src.GetMass());
85   if (src.IsOn(AliESDtrack::kTIME)) {
86     StartTimeIntegral();
87     SetIntegratedLength(src.GetIntegratedLength());
88     double times[AliPID::kSPECIES];
89     src.GetIntegratedTimes(times);
90     SetIntegratedTimes(times);
91   }
92   //
93 }
94
95 //__________________________________________________________________
96 void AliITSUTrackHyp::InitFrom(const AliITSUTrackHyp *src)
97 {
98   // copy initial params
99   fNLayers = src->fNLayers;
100   fITSLabel = src->fITSLabel;
101   fESDTrack = src->fESDTrack;
102   fWinner = src->fWinner;
103   fTPCSeed = src->fTPCSeed;
104   //
105 }
106
107 //__________________________________________________________________
108 AliITSUTrackHyp &AliITSUTrackHyp::operator=(const AliITSUTrackHyp &src)
109 {
110   // copy 
111   if (this == &src) return *this;
112   this->~AliITSUTrackHyp();
113   new(this) AliITSUTrackHyp(src);
114   return *this;
115   //
116 }
117
118 //__________________________________________________________________
119 AliITSUTrackHyp &AliITSUTrackHyp::operator=(const AliKalmanTrack &src)
120
121   // copy kinematics only
122   if (this == &src) return *this;
123   AliKalmanTrack::operator=(src);
124   return *this;
125   //
126 }
127
128 //__________________________________________________________________
129 AliITSUTrackHyp &AliITSUTrackHyp::operator=(const AliESDtrack &src)
130 {
131   // copy oparator from ESD track: take only kinematics, mass and time integral
132   AliExternalTrackParam::operator=((const AliExternalTrackParam&)src);
133   SetMass(src.GetMass());
134   if (src.IsOn(AliESDtrack::kTIME)) {
135     StartTimeIntegral();
136     SetIntegratedLength(src.GetIntegratedLength());
137     double times[AliPID::kSPECIES];
138     src.GetIntegratedTimes(times);
139     SetIntegratedTimes(times);
140   }
141   //
142   return *this;
143 }
144
145
146 //__________________________________________________________________
147 void AliITSUTrackHyp::Print(Option_t* opt) const
148 {
149   printf("Track Hyp.#%4d. NSeeds:",GetUniqueID());
150   TString opts = opt;
151   opts.ToLower();
152   Bool_t prSeeds = opts.Contains("l");
153   for (int i=0;i<fNLayers;i++) {
154     printf("Lr (%d) %3d ",i,GetNSeeds(i)); 
155     if (prSeeds) {
156       printf("\n");
157       for (int isd=0;isd<GetNSeeds(i);isd++) ((AliITSUSeed*)GetSeed(i,isd))->Print(opt);
158     }
159   }
160   if (!prSeeds) printf("\n");
161 }
162
163 //__________________________________________________________________
164 AliITSUSeed* AliITSUTrackHyp::GetWinner() const
165 {
166   // Get best candidate. TODO
167   return fWinner;
168 }
169
170 //__________________________________________________________________
171 AliITSUSeed* AliITSUTrackHyp::DefineWinner(int lr, int id)
172 {
173   // assign best candidate
174   int nsd = GetNSeeds(lr);
175   while ( id<nsd && ( !(fWinner=GetSeed(lr,id)) || fWinner->IsKilled() ) ) {id++; fWinner=0;}
176   if (!fWinner) {
177     //    AliInfo(Form("No winner candidates out of %d for %d",nsd,GetUniqueID()));
178     return 0;
179   }
180   UInt_t idESD = GetUniqueID(); // retain ESDtrackID
181   this->AliExternalTrackParam::operator=(*fWinner);
182   SetUniqueID(idESD);
183   SetChi2(fWinner->GetChi2GloNrm());
184   SetNumberOfClusters(fWinner->GetNLayersHit());
185   return fWinner;
186 }
187
188 //__________________________________________________________________
189 Double_t AliITSUTrackHyp::GetPredictedChi2(const AliCluster *cl) const
190 {
191   // calculate chi2 to cluster
192   Double_t p[2]={cl->GetY(), cl->GetZ()};
193   Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()};
194   return AliExternalTrackParam::GetPredictedChi2(p,cov);
195 }
196
197 //__________________________________________________________________
198 Bool_t AliITSUTrackHyp::PropagateTo(Double_t /*xr*/, Double_t /*x0*/, Double_t /*rho*/)
199 {
200   // NA
201   AliFatal("Not to be used");
202   return 0;
203 }
204
205 //__________________________________________________________________
206 Bool_t AliITSUTrackHyp::Update(const AliCluster* /*c*/, Double_t /*chi2*/, Int_t /*index*/)
207 {
208   // NA
209   AliFatal("Not to be used");
210   return kFALSE;
211 }
212
213 //__________________________________________________________________
214 Double_t AliITSUTrackHyp::Update(const AliCluster* cl)
215 {
216   // update with cluster
217   Double_t p[2]={cl->GetY(), cl->GetZ()};
218   Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()};
219   double chi2 = AliExternalTrackParam::GetPredictedChi2(p,cov);
220   if (!AliExternalTrackParam::Update(p,cov)) return -1;
221   SetChi2(GetChi2()+chi2);
222   return chi2;
223 }
224
225 //__________________________________________________________________
226 Int_t AliITSUTrackHyp::FetchClusterInfo(Int_t *clIDarr) const
227 {
228   // fill cl.id's in the array. The clusters of layer L will be set at slots
229   // clID[2L] (and clID[2L+1] if there is an extra cluster).
230   for (int i=fNLayers<<1;i--;) clIDarr[i]=-1;
231   return GetWinner() ? GetWinner()->FetchClusterInfo(clIDarr) : 0;
232 }
233
234 //__________________________________________________________________
235 Int_t AliITSUTrackHyp::GetNumberOfClusters() const
236 {
237   // This is a temporary (slow) way of accessing number of clusters
238   // TODO: add dedicated data members filled by winner
239   AliITSUSeed* seed = GetWinner();
240   int ncl = 0;
241   if (!seed) {
242     AliFatal("The winner is not set");
243     return ncl;
244   }
245   return seed->GetNClusters();
246   //
247 }
248
249 //__________________________________________________________________
250 Int_t AliITSUTrackHyp::GetClusterIndex(Int_t ind) const 
251 {
252   // This is a temporary (slow) way of accessing cluster index
253   // TODO: add dedicated data members filled by winner
254   AliITSUSeed* seed = GetWinner();
255   //  int ncl = 0;
256   if (!seed) {
257     AliFatal("The winner is not set");
258     return -1;
259   }
260   return seed->GetClusterIndex(ind);
261   //
262 }