]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliTracker.cxx
1bb700a6130acda082870540aeb468e771abdb82
[u/mrichter/AliRoot.git] / STEER / STEER / AliTracker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //               Implementation of the AliTracker class
20 //  that is the base for AliTPCtracker, AliITStrackerV2 and AliTRDtracker    
21 //        Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
22 //-------------------------------------------------------------------------
23
24 #include <TMath.h>
25 #include <TH1F.h>
26 #include <TGeoMatrix.h>
27
28 #include "AliTracker.h"
29 #include "AliGeomManager.h"
30 #include "AliCluster.h"
31 #include "AliKalmanTrack.h"
32 #include "AliGlobalQADataMaker.h"
33 #include "AliPoolsSet.h"
34
35 Bool_t AliTracker::fFillResiduals=kFALSE;
36 TObjArray **AliTracker::fResiduals=NULL;
37 AliRecoParam::EventSpecie_t AliTracker::fEventSpecie=AliRecoParam::kDefault;
38
39 ClassImp(AliTracker)
40
41 AliTracker::AliTracker():
42   AliTrackerBase(),
43   fEventInfo(NULL),
44   fPools(NULL)
45 {
46   //--------------------------------------------------------------------
47   // The default constructor.
48   //--------------------------------------------------------------------
49 }
50
51 //__________________________________________________________________________
52 AliTracker::AliTracker(const AliTracker &atr):
53   AliTrackerBase(atr),
54   fEventInfo(atr.fEventInfo),
55   fPools(atr.fPools)
56 {
57   //--------------------------------------------------------------------
58   // The default constructor.
59   //--------------------------------------------------------------------
60 }
61
62 //__________________________________________________________________________
63 void AliTracker::FillClusterArray(TObjArray* /*array*/) const
64 {
65   // Publishes all pointers to clusters known to the tracker into the
66   // passed object array.
67   // The ownership is not transfered - the caller is not expected to delete
68   // the clusters.
69
70   AliWarning("should be overriden by a sub-class.");
71 }
72
73 //__________________________________________________________________________
74 void AliTracker::CookLabel(AliKalmanTrack *t, Float_t wrong) const {
75   //--------------------------------------------------------------------
76   //This function "cooks" a track label. If label<0, this track is fake.
77   //--------------------------------------------------------------------
78   Int_t noc=t->GetNumberOfClusters();
79   if (noc<1) return;
80   Int_t *lb=new Int_t[noc];
81   Int_t *mx=new Int_t[noc];
82   AliCluster **clusters=new AliCluster*[noc];
83
84   Int_t i;
85   for (i=0; i<noc; i++) {
86      lb[i]=mx[i]=0;
87      Int_t index=t->GetClusterIndex(i);
88      clusters[i]=GetCluster(index);
89   }
90
91   Int_t lab=123456789;
92   for (i=0; i<noc; i++) {
93     AliCluster *c=clusters[i];
94     lab=TMath::Abs(c->GetLabel(0));
95     Int_t j;
96     for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
97     if (j<noc) {
98        lb[j]=lab;
99        (mx[j])++;
100     }
101   }
102
103   Int_t max=0;
104   for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
105     
106   for (i=0; i<noc; i++) {
107     AliCluster *c=clusters[i];
108     //if (TMath::Abs(c->GetLabel(1)) == lab ||
109     //    TMath::Abs(c->GetLabel(2)) == lab ) max++;
110     if (TMath::Abs(c->GetLabel(0)!=lab))
111         if (TMath::Abs(c->GetLabel(1)) == lab ||
112             TMath::Abs(c->GetLabel(2)) == lab ) max++;
113   }
114
115   if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
116   t->SetFakeRatio((1.- Float_t(max)/noc));
117   t->SetLabel(lab);
118
119   delete[] lb;
120   delete[] mx;
121   delete[] clusters;
122 }
123
124 //____________________________________________________________________________
125 void AliTracker::UseClusters(const AliKalmanTrack *t, Int_t from) const {
126   //------------------------------------------------------------------
127   //This function marks clusters associated with the track.
128   //------------------------------------------------------------------
129   Int_t noc=t->GetNumberOfClusters();
130   for (Int_t i=from; i<noc; i++) {
131      Int_t index=t->GetClusterIndex(i);
132      AliCluster *c=GetCluster(index); 
133      c->Use();   
134   }
135 }
136
137 void AliTracker::FillResiduals(const AliExternalTrackParam *t,
138                               Double_t *p, Double_t *cov, 
139                               UShort_t id, Bool_t updated) {
140   //
141   // This function fills the histograms of residuals 
142   // The array of these histos is external for this AliTracker class.
143   // Normally, this array belong to AliGlobalQADataMaker class.  
144   // 
145   if (!fFillResiduals) return; 
146   if (!fResiduals) return; 
147
148   const Double_t *residuals=t->GetResiduals(p,cov,updated);
149   if (!residuals) return;
150
151   TH1F *h=0;
152   Int_t esIndex = AliRecoParam::AConvert(fEventSpecie) ; 
153   AliGeomManager::ELayerID layer=AliGeomManager::VolUIDToLayer(id);
154   h=(TH1F*)fResiduals[esIndex]->At(2*layer-2);
155   if (h) h->Fill(residuals[0]);
156   h=(TH1F*)fResiduals[esIndex]->At(2*layer-1);
157   if (h) h->Fill(residuals[1]);
158
159   if (layer==5) {
160     if (p[1]<0) {  // SSD1 absolute residuals
161       h = (TH1F*)fResiduals[esIndex]->At(40);
162       if (h) h->Fill(t->GetY()-p[0]); //C side
163       h = (TH1F*)fResiduals[esIndex]->At(41);
164       if (h) h->Fill(t->GetZ()-p[1]);
165     } else {             
166       h = (TH1F*)fResiduals[esIndex]->At(42);
167       if (h) h->Fill(t->GetY()-p[0]); //A side
168       h = (TH1F*)fResiduals[esIndex]->At(43);
169       if (h) h->Fill(t->GetZ()-p[1]);
170     }           
171   }
172   if (layer==6) {  // SSD2 absolute residuals
173     if (p[1]<0) {
174       h = (TH1F*)fResiduals[esIndex]->At(44);
175       if (h) h->Fill(t->GetY()-p[0]); //C side
176       h = (TH1F*)fResiduals[esIndex]->At(45);
177       if (h) h->Fill(t->GetZ()-p[1]);
178     } else {
179       h = (TH1F*)fResiduals[esIndex]->At(46);
180       if (h) h->Fill(t->GetY()-p[0]); //A side
181       h = (TH1F*)fResiduals[esIndex]->At(47);
182       if (h) h->Fill(t->GetZ()-p[1]);
183     }
184   }
185
186 }
187
188 void AliTracker::FillResiduals(const AliExternalTrackParam *t,
189                                const AliCluster *c, Bool_t /*updated*/) {
190   //
191   // This function fills the histograms of residuals 
192   // The array of these histos is external for this AliTracker class.
193   // Normally, this array belong to AliGlobalQADataMaker class.  
194   // 
195   // For the moment, the residuals are absolute !
196   //
197
198   if (!fFillResiduals) return; 
199   if (!fResiduals) return; 
200
201   UShort_t id=c->GetVolumeId();
202   const TGeoHMatrix *matrixT2L=AliGeomManager::GetTracking2LocalMatrix(id);
203
204   // Position of the cluster in the tracking c.s.
205   Double_t clsTrk[3]={c->GetX(), c->GetY(), c->GetZ()};
206   // Position of the cluster in the local module c.s.
207   Double_t clsLoc[3]={0.,0.,0.};
208   matrixT2L->LocalToMaster(clsTrk,clsLoc);
209
210
211   // Position of the intersection point in the tracking c.s.
212   Double_t trkTrk[3]={t->GetX(),t->GetY(),t->GetZ()};
213   // Position of the intersection point in the local module c.s.
214   Double_t trkLoc[3]={0.,0.,0.};
215   matrixT2L->LocalToMaster(trkTrk,trkLoc);
216
217   Double_t residuals[2]={trkLoc[0]-clsLoc[0], trkLoc[2]-clsLoc[2]};
218
219   TH1F *h=0;
220   Int_t esIndex = AliRecoParam::AConvert(fEventSpecie) ; 
221   AliGeomManager::ELayerID layer=AliGeomManager::VolUIDToLayer(id);
222   h=(TH1F*)fResiduals[esIndex]->At(2*layer-2);
223   if (h) h->Fill(residuals[0]);
224   h=(TH1F*)fResiduals[esIndex]->At(2*layer-1);
225   if (h) h->Fill(residuals[1]);
226
227 }
228