]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUTrackHyp.cxx
A skeleton of a comparison macro for pileup studies
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUTrackHyp.cxx
CommitLineData
716ccba7 1#include "AliITSUTrackHyp.h"
3e4e3c23 2#include "AliESDtrack.h"
3#include "AliCluster.h"
dd2117a2 4#include "AliITSUAux.h"
6cd80116 5#include <TString.h>
716ccba7 6
7ClassImp(AliITSUTrackHyp)
8
9
10
11//__________________________________________________________________
12AliITSUTrackHyp::AliITSUTrackHyp(Int_t nlr)
13: fNLayers(nlr)
dd2117a2 14 ,fITSLabel(0)
3e4e3c23 15 ,fESDTrack(0)
c03e4f8a 16 ,fWinner(0)
9cdcba2c 17 ,fTPCSeed(0)
716ccba7 18 ,fLayerSeeds(0)
19{
20 // def. c-tor
21 if (fNLayers>0) fLayerSeeds = new TObjArray[fNLayers];
22}
23
24//__________________________________________________________________
25AliITSUTrackHyp::~AliITSUTrackHyp()
26{
27 // d-tor
28 delete[] fLayerSeeds;
9cdcba2c 29 delete fTPCSeed;
716ccba7 30}
31
32//__________________________________________________________________
33AliITSUTrackHyp::AliITSUTrackHyp(const AliITSUTrackHyp &src)
3e4e3c23 34 : AliKalmanTrack(src)
716ccba7 35 , fNLayers(src.fNLayers)
a616242b 36 , fITSLabel(src.fITSLabel)
3e4e3c23 37 , fESDTrack(src.fESDTrack)
c03e4f8a 38 , fWinner(0)
9cdcba2c 39 , fTPCSeed(src.fTPCSeed)
716ccba7 40 , fLayerSeeds(0)
41{
c03e4f8a 42 // copy c-tor. Note: it is shallow
716ccba7 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 }
c03e4f8a 53 fWinner = src.fWinner;
716ccba7 54 }
55 //
56}
7ce7f445 57
58//__________________________________________________________________
59AliITSUTrackHyp::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//__________________________________________________________________
73AliITSUTrackHyp::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);
1d26da6d 84 SetMass(src.GetMassForTracking());
7ce7f445 85 if (src.IsOn(AliESDtrack::kTIME)) {
86 StartTimeIntegral();
87 SetIntegratedLength(src.GetIntegratedLength());
d4da4017 88 double times[AliPID::kSPECIESC];
fc9b31a7 89 src.GetIntegratedTimes(times,AliPID::kSPECIESC);
7ce7f445 90 SetIntegratedTimes(times);
91 }
92 //
93}
94
6cd80116 95//__________________________________________________________________
96void 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;
9cdcba2c 103 fTPCSeed = src->fTPCSeed;
6cd80116 104 //
105}
716ccba7 106
107//__________________________________________________________________
108AliITSUTrackHyp &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
7ce7f445 118//__________________________________________________________________
119AliITSUTrackHyp &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//__________________________________________________________________
129AliITSUTrackHyp &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);
1d26da6d 133 SetMass(src.GetMassForTracking());
7ce7f445 134 if (src.IsOn(AliESDtrack::kTIME)) {
135 StartTimeIntegral();
136 SetIntegratedLength(src.GetIntegratedLength());
d4da4017 137 double times[AliPID::kSPECIESC];
fc9b31a7 138 src.GetIntegratedTimes(times,AliPID::kSPECIESC);
7ce7f445 139 SetIntegratedTimes(times);
140 }
141 //
142 return *this;
143}
144
145
716ccba7 146//__________________________________________________________________
6cd80116 147void AliITSUTrackHyp::Print(Option_t* opt) const
716ccba7 148{
149 printf("Track Hyp.#%4d. NSeeds:",GetUniqueID());
6cd80116 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");
716ccba7 161}
3e4e3c23 162
163//__________________________________________________________________
164AliITSUSeed* AliITSUTrackHyp::GetWinner() const
165{
69e0f089 166 // Get best candidate. TODO
c03e4f8a 167 return fWinner;
3e4e3c23 168}
169
170//__________________________________________________________________
69e0f089 171AliITSUSeed* AliITSUTrackHyp::DefineWinner(int lr, int id)
3e4e3c23 172{
173 // assign best candidate
08419930 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
c03e4f8a 181 this->AliExternalTrackParam::operator=(*fWinner);
08419930 182 SetUniqueID(idESD);
c03e4f8a 183 SetChi2(fWinner->GetChi2GloNrm());
184 SetNumberOfClusters(fWinner->GetNLayersHit());
185 return fWinner;
3e4e3c23 186}
187
3e4e3c23 188//__________________________________________________________________
8b16dbae 189Double_t AliITSUTrackHyp::GetPredictedChi2(const AliCluster *cl) const
3e4e3c23 190{
8b16dbae 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);
3e4e3c23 195}
196
197//__________________________________________________________________
198Bool_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//__________________________________________________________________
206Bool_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}
8b16dbae 212
213//__________________________________________________________________
76390254 214Double_t AliITSUTrackHyp::Update(const AliCluster* cl)
8b16dbae 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);
76390254 220 if (!AliExternalTrackParam::Update(p,cov)) return -1;
8b16dbae 221 SetChi2(GetChi2()+chi2);
76390254 222 return chi2;
8b16dbae 223}
224
225//__________________________________________________________________
68a0f687 226Int_t AliITSUTrackHyp::FetchClusterInfo(Int_t *clIDarr) const
8b16dbae 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;
9cdcba2c 231 return GetWinner() ? GetWinner()->FetchClusterInfo(clIDarr) : 0;
8b16dbae 232}
e7d83d38 233
234//__________________________________________________________________
235Int_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//__________________________________________________________________
250Int_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();
80557052 255 // int ncl = 0;
e7d83d38 256 if (!seed) {
257 AliFatal("The winner is not set");
258 return -1;
259 }
260 return seed->GetClusterIndex(ind);
261 //
262}