1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 // -Function FillArrayCoorAngles fills arrays wich contains, for each //
28 // layer, the global coordinates, errors on x,y,z and angles lambda //
29 // and phi for each cluster //
30 ///////////////////////////////////////////////////////////////////////////
34 #include "AliITSclusterTable.h"
35 #include "AliITSclusterV2.h"
36 #include "AliITSgeom.h"
37 #include "AliITStrackerSA.h"
39 #include<TClonesArray.h>
41 ClassImp(AliITSclusterTable)
42 //__________________________________________________________
43 AliITSclusterTable::AliITSclusterTable(){
44 // Default constructor
58 for(Int_t i=0;i<3;i++){fPrimaryVertex[i]=0;}
61 //__________________________________________________________
62 AliITSclusterTable::AliITSclusterTable(AliITSgeom* geom, AliITStrackerSA* tracker,Double_t* primaryVertex) {
63 // Standard constructor
65 Int_t nm = geom->GetIndexMax();
67 for(Int_t i=0;i<nm;i++){fNCl[i]=0;}
71 for(Int_t i=0;i<3;i++){fPrimaryVertex[i]=primaryVertex[i];}
81 //______________________________________________________________________
82 AliITSclusterTable::AliITSclusterTable(const AliITSclusterTable &tab) :
85 // Copies are not allowed. The method is protected to avoid misuse.
86 Error("AliITSclusterTable","Copy constructor not allowed\n");
89 //______________________________________________________________________
90 AliITSclusterTable& AliITSclusterTable::operator=(const
91 AliITSclusterTable& /* tab */){
92 // Assignment operator
93 // Assignment is not allowed. The method is protected to avoid misuse.
94 Error("= operator","Assignment operator not allowed\n");
98 //__________________________________________________________
99 AliITSclusterTable::~AliITSclusterTable(){
101 Int_t nm = fGeom->GetIndexMax();
103 for (Int_t i=0; i<nm; i++){
108 if (fLbl)delete [] fLbl; // memory leak!
109 if (fNCl)delete [] fNCl;
110 for (Int_t i = 0; i < fGeom->GetNlayers(); i++) {
111 if (fPhiList) delete fPhiList[i];
112 if (fLambdaList) delete fLambdaList[i];
113 if (fXList) delete fXList[i];
114 if (fYList) delete fYList[i];
115 if (fZList) delete fZList[i];
116 if (fSxList) delete fSxList[i];
117 if (fSyList) delete fSyList[i];
118 if (fSzList) delete fSzList[i];
120 if (fPhiList) delete[] fPhiList;
121 if (fLambdaList) delete[] fLambdaList;
122 if (fXList) delete[] fXList;
123 if (fYList) delete[] fYList;
124 if (fZList) delete[] fZList;
125 if (fSxList) delete[] fSxList;
126 if (fSyList) delete[] fSyList;
127 if (fSzList) delete[] fSzList;
130 //__________________________________________________________
132 void AliITSclusterTable::FillArray(TTree* clusterTree){
135 Int_t nm = fGeom->GetIndexMax();
136 fDet = new TArrayI*[nm];
138 TArrayI** vect = new TArrayI*[fGeom->GetNlayers()];
139 Int_t * firstmod = new Int_t[fGeom->GetNlayers()+1];
140 firstmod[fGeom->GetNlayers()]=fGeom->GetIndexMax(); // upper limit
141 for(Int_t nlayer=0;nlayer<fGeom->GetNlayers();nlayer++){
142 firstmod[nlayer] = fGeom->GetModuleIndex(nlayer+1,1,1);
143 Int_t ncl = fTracker->GetNumberOfClustersLayer(nlayer);
144 vect[nlayer]=new TArrayI(ncl);
145 for(Int_t j=0;j<ncl;j++){
146 AliITSclusterV2* cl = fTracker->GetClusterLayer(nlayer,j);
147 vect[nlayer]->AddAt(cl->GetDetectorIndex()+firstmod[nlayer],j);
151 TBranch *brancht=(TBranch*)clusterTree->GetBranch("Clusters");
152 if(!brancht) Warning("FillArray","No cluster branch");
153 TClonesArray* clus = new TClonesArray("AliITSclusterV2",10000);
154 brancht->SetAddress(&clus);
156 for(Int_t mod=0;mod<nm;mod++){
158 clusterTree->GetEvent(mod);
159 Int_t ncl = clus->GetEntries();
160 fDet[mod] = new TArrayI(ncl);
162 Int_t nlr = FindIndex(fGeom->GetNlayers(),firstmod,mod);
164 Fatal("FillArray","Wrong module number %d . Limits: %d , %d",mod,firstmod[0],firstmod[fGeom->GetNlayers()+1]);
168 for(Int_t n=0;n<vect[nlr]->GetSize();n++){
169 Int_t mm=vect[nlr]->At(n);
170 if(nc>=fDet[mod]->GetSize()) fDet[mod]->Set(nc*2+10);
171 if(mm==mod) {(*fDet[mod])[nc]=n; nc+=1; }
178 for(Int_t n=0;n<fGeom->GetNlayers();n++)delete vect[n];
183 //_________________________________________________________________
184 void AliITSclusterTable::FillArrayLabel(Int_t numberofparticles){
187 fLbl = new TArrayI*[numberofparticles];
188 const Int_t knm =fGeom->GetNlayers();
189 for(Int_t nlab=0;nlab<numberofparticles;nlab++){
190 fLbl[nlab] = new TArrayI(knm);
191 Int_t * nn = new Int_t[knm];
192 for(Int_t i=0;i<knm;i++)nn[i]=0;
193 for(Int_t nlayer=0;nlayer<knm;nlayer++){
194 Int_t ncl = fTracker->GetNumberOfClustersLayer(nlayer);
196 AliITSclusterV2* cl = fTracker->GetClusterLayer(nlayer,ncl);
197 if(cl->IsUsed()==1) continue;
198 if(cl->GetLabel(0)==nlab || cl->GetLabel(1)==nlab || cl->GetLabel(2)==nlab){
204 fLbl[nlab]->AddAt(nn[nlayer],nlayer);
211 //_______________________________________________________________
212 Int_t AliITSclusterTable::ThisParticleIsTrackable(Int_t label,Int_t numberofpoints){
214 //Returns 1 if particle with label "label" is trackable.
217 for(Int_t i=0;i<fGeom->GetNlayers();i++){
218 Int_t ncl = fLbl[label]->At(i);
221 if(nb>=numberofpoints) return 1;
226 //_______________________________________________________________
227 Int_t AliITSclusterTable::FindIndex(Int_t ndim, Int_t *ptr, Int_t value){
228 // ptr[ndim+1] is an array of integers
229 // ndim is its dimension minus 1
230 // value is a number such as: ptr[0]<=value < ptr[ndim]
231 // if ptr[i]<=value<ptr[i+1] the index i is returned; -1 if out of bounds
233 for(Int_t k=0;k<ndim;k++){
234 if(value>=ptr[k] && value <ptr[k+1]){
242 void AliITSclusterTable::FillArrayCoorAngles(){
243 //Fill arrays with phi,lambda and indices of clusters for each layer
245 fPhiList = new TArrayD*[fGeom->GetNlayers()];
246 fLambdaList = new TArrayD*[fGeom->GetNlayers()];
247 fXList = new TArrayF*[fGeom->GetNlayers()];
248 fYList = new TArrayF*[fGeom->GetNlayers()];
249 fZList = new TArrayF*[fGeom->GetNlayers()];
250 fSxList = new TArrayF*[fGeom->GetNlayers()];
251 fSyList = new TArrayF*[fGeom->GetNlayers()];
252 fSzList = new TArrayF*[fGeom->GetNlayers()];
254 Int_t * firstmod = new Int_t[fGeom->GetNlayers()+1];
255 firstmod[fGeom->GetNlayers()]=fGeom->GetIndexMax(); // upper limit
257 for(Int_t nlay=0;nlay<fGeom->GetNlayers();nlay++){
258 firstmod[nlay] = fGeom->GetModuleIndex(nlay+1,1,1);
259 Int_t ncl = fTracker->GetNumberOfClustersLayer(nlay);
260 fPhiList[nlay] = new TArrayD(ncl);
261 fLambdaList[nlay]=new TArrayD(ncl);
262 fXList[nlay]=new TArrayF(ncl);
263 fYList[nlay]=new TArrayF(ncl);
264 fZList[nlay]=new TArrayF(ncl);
265 fSxList[nlay]=new TArrayF(ncl);
266 fSyList[nlay]=new TArrayF(ncl);
267 fSzList[nlay]=new TArrayF(ncl);
269 for(Int_t j=0;j<ncl;j++){
270 AliITSclusterV2* cl = fTracker->GetClusterLayer(nlay,j);
271 Double_t phi=0;Double_t lambda=0;
272 Float_t x=0;Float_t y=0;Float_t z=0;
273 Float_t sx=0;Float_t sy=0;Float_t sz=0;
274 Int_t module = cl->GetDetectorIndex()+firstmod[nlay];
275 GetCoorAngles(cl,module,phi,lambda,x,y,z);
276 GetCoorErrors(cl,module,sx,sy,sz);
277 fPhiList[nlay]->AddAt(phi,j);
278 fLambdaList[nlay]->AddAt(lambda,j);
279 fXList[nlay]->AddAt(x,j);
280 fYList[nlay]->AddAt(y,j);
281 fZList[nlay]->AddAt(z,j);
282 fSxList[nlay]->AddAt(sx,j);
283 fSyList[nlay]->AddAt(sy,j);
284 fSzList[nlay]->AddAt(sz,j);
292 void AliITSclusterTable::GetCoorAngles(AliITSclusterV2* cl,Int_t module,Double_t &phi,Double_t &lambda, Float_t &x, Float_t &y,Float_t &z){
293 //Returns values of phi (azimuthal) and lambda angles for a given cluster
295 Double_t rot[9]; fGeom->GetRotMatrix(module,rot);
296 Int_t lay,lad,det; fGeom->GetModuleId(module,lay,lad,det);
297 Float_t tx,ty,tz; fGeom->GetTrans(lay,lad,det,tx,ty,tz);
299 Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
300 Double_t phi1=TMath::Pi()/2+alpha;
301 if (lay==1) phi1+=TMath::Pi();
303 Float_t cp=TMath::Cos(phi1), sp=TMath::Sin(phi1);
304 Float_t r=tx*cp+ty*sp;
306 x= r*cp - cl->GetY()*sp;
307 y= r*sp + cl->GetY()*cp;
310 phi=TMath::ATan2(y,x);
311 lambda=TMath::ATan2(z-fPrimaryVertex[2],TMath::Sqrt((x-fPrimaryVertex[0])*(x-fPrimaryVertex[0])+(y-fPrimaryVertex[1])*(y-fPrimaryVertex[1])));
314 void AliITSclusterTable::GetCoorErrors(AliITSclusterV2* cl, Int_t module,Float_t &sx,Float_t &sy, Float_t &sz){
316 //returns x,y,z of cluster in global coordinates
318 Double_t rot[9]; fGeom->GetRotMatrix(module,rot);
319 Int_t lay,lad,det; fGeom->GetModuleId(module,lay,lad,det);
321 Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
322 Double_t phi=TMath::Pi()/2+alpha;
323 if (lay==1) phi+=TMath::Pi();
325 Float_t cp=TMath::Cos(phi), sp=TMath::Sin(phi);
327 sx = TMath::Sqrt(sp*sp*cl->GetSigmaY2());
328 sy = TMath::Sqrt(cp*cp*cl->GetSigmaY2());
329 sz = TMath::Sqrt(cl->GetSigmaZ2());