]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSclusterTable.cxx
Accomodation for the new coordinate system: oposite sign of the track curvature ...
[u/mrichter/AliRoot.git] / ITS / AliITSclusterTable.cxx
CommitLineData
13918578 1/**************************************************************************
2 * Copyright(c) 1998-2003, 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//////////////////////////////////////////////////////////////////////////
17// Class used to simplify some operations with clusters. //
18// -Function FillArray fills an array wich contains, for each //
19// ITS module, an array with the indices of all the clusters detected //
20// by the module. The indices correspond to the cluster indices in class//
21// AliITSlayer of AliITStrackerV2. //
22// This function is used in AliITStrackerSA::FindTracks. //
23// -Function FillArrayLabel fills an array wich contains, for each //
24// particle label, and for each layer, the information on clusters: //
25// 0 if there is no cluster, 1 if there is a cluster with this label. //
26// This function is used to define trackable tracks. //
27///////////////////////////////////////////////////////////////////////////
28
29
30#include "AliITSclusterTable.h"
31#include "AliITSclusterV2.h"
32#include "AliITSgeom.h"
33#include "AliITStrackerSA.h"
34#include<TBranch.h>
35#include<TClonesArray.h>
36#include<TTree.h>
37ClassImp(AliITSclusterTable)
38
39//__________________________________________________________
40AliITSclusterTable::AliITSclusterTable(){
41// Default constructor
42 fDet=0;
43 fNCl = 0;
44 fLbl=0;
45 fGeom = 0;
46 fTracker = 0;
47}
48
49//__________________________________________________________
50AliITSclusterTable::AliITSclusterTable(AliITSgeom* geom, AliITStrackerSA* tracker) {
51// Standard constructor
52 fDet=0;
53 Int_t nm = geom->GetIndexMax();
54 fNCl = new Int_t[nm];
55 for(Int_t i=0;i<nm;i++){fNCl[i]=0;}
56 fLbl=0;
57 fGeom = geom;
58 fTracker = tracker;
59}
60
61//______________________________________________________________________
62AliITSclusterTable::AliITSclusterTable(const AliITSclusterTable &tab) :
63 TObject(tab) {
64 // Copy constructor
65 // Copies are not allowed. The method is protected to avoid misuse.
66 Error("AliITSclusterTable","Copy constructor not allowed\n");
67}
68
69//______________________________________________________________________
70AliITSclusterTable& AliITSclusterTable::operator=(const
71 AliITSclusterTable& /* tab */){
72 // Assignment operator
73 // Assignment is not allowed. The method is protected to avoid misuse.
74 Error("= operator","Assignment operator not allowed\n");
75 return *this;
76}
77
78//__________________________________________________________
79AliITSclusterTable::~AliITSclusterTable(){
80// Destructor
81 Int_t nm = fGeom->GetIndexMax();
82 if(fDet){
83 for (Int_t i=0; i<nm; i++){
84 delete fDet[i];
85 }
86 delete fDet;
87 }
88 /* if(fLbl){
89 for (Int_t i=0; i<nm; i++){
90 delete fLbl[i];
91 }
92 delete fLbl;
93 }*/
94 if (fLbl)delete [] fLbl;
95 if (fNCl)delete [] fNCl;
96}
97
98//__________________________________________________________
99
100void AliITSclusterTable::FillArray(TTree* clusterTree,Int_t evnumber){
101
102 //
103 Int_t nm = fGeom->GetIndexMax();
104 fDet = new TArrayI*[nm];
105 fTracker->SetEventNumber(evnumber);
106 fTracker->LoadClusters(clusterTree);
107
108 TArrayI** vect = new TArrayI*[fGeom->GetNlayers()];
109
037efb75 110 Int_t * firstmod = new Int_t[fGeom->GetNlayers()+1];
13918578 111 firstmod[fGeom->GetNlayers()]=fGeom->GetIndexMax(); // upper limit
112 for(Int_t nlayer=0;nlayer<fGeom->GetNlayers();nlayer++){
113 firstmod[nlayer] = fGeom->GetModuleIndex(nlayer+1,1,1);
114 Int_t ncl = fTracker->GetNumberOfClustersLayer(nlayer);
115 vect[nlayer]=new TArrayI(ncl);
116 for(Int_t j=0;j<ncl;j++){
117 AliITSclusterV2* cl = fTracker->GetClusterLayer(nlayer,j);
118 vect[nlayer]->AddAt(cl->GetDetectorIndex()+firstmod[nlayer],j);
119 }
120 }
121
122 TBranch *brancht=(TBranch*)clusterTree->GetBranch("Clusters");
123 if(!brancht) Warning("FillArray","No cluster branch");
124 TClonesArray* clus = new TClonesArray("AliITSclusterV2",10000);
125 brancht->SetAddress(&clus);
126
127
128 for(Int_t mod=0;mod<nm;mod++){
129 Int_t nc=0;
130 clusterTree->GetEvent(mod);
131 Int_t ncl = clus->GetEntries();
132 fDet[mod] = new TArrayI(ncl);
133 fNCl[mod]= ncl;
134 Int_t nlr = FindIndex(fGeom->GetNlayers(),firstmod,mod);
135 if(nlr<0){
136 Fatal("FillArray","Wrong module number %d . Limits: %d , %d",mod,firstmod[0],firstmod[fGeom->GetNlayers()+1]);
137 return;
138 }
139 else {
140 for(Int_t n=0;n<vect[nlr]->GetSize();n++){
141 Int_t mm=vect[nlr]->At(n);
142 if(mm==mod) {fDet[mod]->AddAt(n,nc); nc+=1; }
143 }
144 }
145 }
146
147
148 fTracker->UnloadClusters();
149
150 for(Int_t n=0;n<fGeom->GetNlayers();n++)delete vect[n];
151 delete vect;
037efb75 152 delete [] firstmod;
13918578 153}
154
155//_________________________________________________________________
6ba216a4 156void AliITSclusterTable::FillArrayLabel(Int_t numberofparticles,TTree* clusterTree,Int_t evnumber){
13918578 157 //
158
159
160 fLbl = new TArrayI*[numberofparticles];
161 fTracker->SetEventNumber(evnumber);
162 fTracker->LoadClusters(clusterTree);
163 const Int_t knm =fGeom->GetNlayers();
164 for(Int_t nlab=0;nlab<numberofparticles;nlab++){
165 fLbl[nlab] = new TArrayI(knm);
037efb75 166 Int_t * nn = new Int_t[knm];
167 for(Int_t i=0;i<knm;i++)nn[i]=0;
13918578 168 for(Int_t nlayer=0;nlayer<knm;nlayer++){
169 Int_t ncl = fTracker->GetNumberOfClustersLayer(nlayer);
170 while(ncl--){
171 AliITSclusterV2* cl = fTracker->GetClusterLayer(nlayer,ncl);
172 if(cl->IsUsed()==1) continue;
173 if(cl->GetLabel(0)==nlab || cl->GetLabel(1)==nlab || cl->GetLabel(2)==nlab){
174 nn[nlayer]+=1;
175 cl->Use();
176 break;
177 }
178 }
179 fLbl[nlab]->AddAt(nn[nlayer],nlayer);
180 }
037efb75 181 delete [] nn;
13918578 182 }
183
184 fTracker->UnloadClusters();
185}
186
187//_______________________________________________________________
188Int_t AliITSclusterTable::ThisParticleIsTrackable(Int_t label,Int_t numberofpoints){
189
190 //Returns 1 if particle with label "label" is trackable.
191
192 Int_t nb=0;
193 for(Int_t i=0;i<fGeom->GetNlayers();i++){
194 Int_t ncl = fLbl[label]->At(i);
195 if(ncl>0) nb++;
196 }
197 if(nb>=numberofpoints) return 1;
198 else return 0;
199
200}
201
202//_______________________________________________________________
203Int_t AliITSclusterTable::FindIndex(Int_t ndim, Int_t *ptr, Int_t value){
204// ptr[ndim+1] is an array of integers
205// ndim is its dimension minus 1
206// value is a number such as: ptr[0]<=value < ptr[ndim]
207// if ptr[i]<=value<ptr[i+1] the index i is returned; -1 if out of bounds
208 Int_t retval = -1;
209 for(Int_t k=0;k<ndim;k++){
210 if(value>=ptr[k] && value <ptr[k+1]){
211 retval = k;
212 break;
213 }
214 }
215 return retval;
216}