]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUTrackHyp.cxx
d977f3f32261b70461fb6f835b93a12d7ce084b7
[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
73   return fLayerSeeds[0].GetEntriesFast()>0 ? GetSeed(0,0) : 0;
74 }
75
76 //__________________________________________________________________
77 void AliITSUTrackHyp::DefineWinner(int lr, int id)
78 {
79   // assign best candidate
80   AliITSUSeed* winner = GetSeed(lr,id);
81   this->AliExternalTrackParam::operator=(*winner);
82   SetChi2(winner->GetChi2GloNrm());
83   SetNumberOfClusters(winner->GetNLayersHit());
84 }
85
86 //__________________________________________________________________
87 Double_t AliITSUTrackHyp::GetPredictedChi2(const AliCluster *cl) const
88 {
89   // calculate chi2 to cluster
90   Double_t p[2]={cl->GetY(), cl->GetZ()};
91   Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()};
92   return AliExternalTrackParam::GetPredictedChi2(p,cov);
93 }
94
95 //__________________________________________________________________
96 Bool_t AliITSUTrackHyp::PropagateTo(Double_t /*xr*/, Double_t /*x0*/, Double_t /*rho*/)
97 {
98   // NA
99   AliFatal("Not to be used");
100   return 0;
101 }
102
103 //__________________________________________________________________
104 Bool_t AliITSUTrackHyp::Update(const AliCluster* /*c*/, Double_t /*chi2*/, Int_t /*index*/)
105 {
106   // NA
107   AliFatal("Not to be used");
108   return kFALSE;
109 }
110
111 //__________________________________________________________________
112 Bool_t AliITSUTrackHyp::Update(const AliCluster* cl)
113 {
114   // update with cluster
115   Double_t p[2]={cl->GetY(), cl->GetZ()};
116   Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()};
117   double chi2 = AliExternalTrackParam::GetPredictedChi2(p,cov);
118   if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
119   SetChi2(GetChi2()+chi2);
120   return kTRUE;
121 }
122
123 //__________________________________________________________________
124 Int_t AliITSUTrackHyp::FetchClusterInfo(Int_t *clIDarr) const
125 {
126   // fill cl.id's in the array. The clusters of layer L will be set at slots
127   // clID[2L] (and clID[2L+1] if there is an extra cluster).
128   for (int i=fNLayers<<1;i--;) clIDarr[i]=-1;
129   AliITSUSeed* seed = GetWinner();
130   Int_t lr,ncl=0;
131   while(seed) {
132     int clID = seed->GetLrCluster(lr);
133     if (clID>=0) {
134       int slotLr = lr<<1;
135       clIDarr[ clIDarr[slotLr]<0 ? slotLr : slotLr+1 ] = clID;
136       ncl++;
137     }
138     seed = (AliITSUSeed*)seed->GetParent();
139   }
140   return ncl;
141 }