]>
Commit | Line | Data |
---|---|---|
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. // | |
bef31448 | 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 // | |
13918578 | 30 | /////////////////////////////////////////////////////////////////////////// |
31 | ||
32 | ||
30a92536 | 33 | #include <stdlib.h> |
13918578 | 34 | #include "AliITSclusterTable.h" |
35 | #include "AliITSclusterV2.h" | |
36 | #include "AliITSgeom.h" | |
37 | #include "AliITStrackerSA.h" | |
38 | #include<TBranch.h> | |
39 | #include<TClonesArray.h> | |
40 | #include<TTree.h> | |
41 | ClassImp(AliITSclusterTable) | |
42 | ||
43 | //__________________________________________________________ | |
44 | AliITSclusterTable::AliITSclusterTable(){ | |
45 | // Default constructor | |
46 | fDet=0; | |
47 | fNCl = 0; | |
48 | fLbl=0; | |
49 | fGeom = 0; | |
50 | fTracker = 0; | |
bef31448 | 51 | fPhiList = 0; |
52 | fLambdaList = 0; | |
53 | fXList = 0; | |
54 | fYList =0; | |
2257f27e | 55 | fZList =0; |
56 | fSxList = 0; | |
57 | fSyList =0; | |
58 | fSzList =0; | |
bef31448 | 59 | for(Int_t i=0;i<3;i++){fPrimaryVertex[i]=0;} |
13918578 | 60 | } |
61 | ||
62 | //__________________________________________________________ | |
bef31448 | 63 | AliITSclusterTable::AliITSclusterTable(AliITSgeom* geom, AliITStrackerSA* tracker,Double_t* primaryVertex) { |
13918578 | 64 | // Standard constructor |
65 | fDet=0; | |
66 | Int_t nm = geom->GetIndexMax(); | |
67 | fNCl = new Int_t[nm]; | |
68 | for(Int_t i=0;i<nm;i++){fNCl[i]=0;} | |
69 | fLbl=0; | |
70 | fGeom = geom; | |
71 | fTracker = tracker; | |
bef31448 | 72 | for(Int_t i=0;i<3;i++){fPrimaryVertex[i]=primaryVertex[i];} |
73 | fPhiList = 0; | |
74 | fLambdaList = 0; | |
75 | fXList = 0; | |
76 | fYList = 0; | |
2257f27e | 77 | fZList =0; |
78 | fSxList = 0; | |
79 | fSyList =0; | |
80 | fSzList =0; | |
13918578 | 81 | } |
82 | ||
83 | //______________________________________________________________________ | |
84 | AliITSclusterTable::AliITSclusterTable(const AliITSclusterTable &tab) : | |
85 | TObject(tab) { | |
86 | // Copy constructor | |
87 | // Copies are not allowed. The method is protected to avoid misuse. | |
88 | Error("AliITSclusterTable","Copy constructor not allowed\n"); | |
89 | } | |
90 | ||
91 | //______________________________________________________________________ | |
92 | AliITSclusterTable& AliITSclusterTable::operator=(const | |
93 | AliITSclusterTable& /* tab */){ | |
94 | // Assignment operator | |
95 | // Assignment is not allowed. The method is protected to avoid misuse. | |
96 | Error("= operator","Assignment operator not allowed\n"); | |
97 | return *this; | |
98 | } | |
99 | ||
100 | //__________________________________________________________ | |
101 | AliITSclusterTable::~AliITSclusterTable(){ | |
102 | // Destructor | |
103 | Int_t nm = fGeom->GetIndexMax(); | |
104 | if(fDet){ | |
105 | for (Int_t i=0; i<nm; i++){ | |
106 | delete fDet[i]; | |
107 | } | |
2257f27e | 108 | delete[] fDet; |
13918578 | 109 | } |
2257f27e | 110 | if (fLbl)delete [] fLbl; // memory leak! |
13918578 | 111 | if (fNCl)delete [] fNCl; |
2257f27e | 112 | for (Int_t i = 0; i < fGeom->GetNlayers(); i++) { |
113 | if (fPhiList) delete fPhiList[i]; | |
114 | if (fLambdaList) delete fLambdaList[i]; | |
115 | if (fXList) delete fXList[i]; | |
116 | if (fYList) delete fYList[i]; | |
117 | if (fZList) delete fZList[i]; | |
118 | if (fSxList) delete fSxList[i]; | |
119 | if (fSyList) delete fSyList[i]; | |
120 | if (fSzList) delete fSzList[i]; | |
121 | } | |
122 | if (fPhiList) delete[] fPhiList; | |
123 | if (fLambdaList) delete[] fLambdaList; | |
124 | if (fXList) delete[] fXList; | |
125 | if (fYList) delete[] fYList; | |
126 | if (fZList) delete[] fZList; | |
127 | if (fSxList) delete[] fSxList; | |
128 | if (fSyList) delete[] fSyList; | |
129 | if (fSzList) delete[] fSzList; | |
13918578 | 130 | } |
131 | ||
132 | //__________________________________________________________ | |
133 | ||
2257f27e | 134 | void AliITSclusterTable::FillArray(TTree* clusterTree){ |
13918578 | 135 | |
136 | // | |
137 | Int_t nm = fGeom->GetIndexMax(); | |
138 | fDet = new TArrayI*[nm]; | |
13918578 | 139 | |
140 | TArrayI** vect = new TArrayI*[fGeom->GetNlayers()]; | |
141 | ||
037efb75 | 142 | Int_t * firstmod = new Int_t[fGeom->GetNlayers()+1]; |
13918578 | 143 | firstmod[fGeom->GetNlayers()]=fGeom->GetIndexMax(); // upper limit |
144 | for(Int_t nlayer=0;nlayer<fGeom->GetNlayers();nlayer++){ | |
145 | firstmod[nlayer] = fGeom->GetModuleIndex(nlayer+1,1,1); | |
146 | Int_t ncl = fTracker->GetNumberOfClustersLayer(nlayer); | |
147 | vect[nlayer]=new TArrayI(ncl); | |
148 | for(Int_t j=0;j<ncl;j++){ | |
149 | AliITSclusterV2* cl = fTracker->GetClusterLayer(nlayer,j); | |
150 | vect[nlayer]->AddAt(cl->GetDetectorIndex()+firstmod[nlayer],j); | |
151 | } | |
152 | } | |
153 | ||
154 | TBranch *brancht=(TBranch*)clusterTree->GetBranch("Clusters"); | |
155 | if(!brancht) Warning("FillArray","No cluster branch"); | |
156 | TClonesArray* clus = new TClonesArray("AliITSclusterV2",10000); | |
157 | brancht->SetAddress(&clus); | |
158 | ||
159 | ||
160 | for(Int_t mod=0;mod<nm;mod++){ | |
161 | Int_t nc=0; | |
162 | clusterTree->GetEvent(mod); | |
163 | Int_t ncl = clus->GetEntries(); | |
164 | fDet[mod] = new TArrayI(ncl); | |
165 | fNCl[mod]= ncl; | |
166 | Int_t nlr = FindIndex(fGeom->GetNlayers(),firstmod,mod); | |
167 | if(nlr<0){ | |
168 | Fatal("FillArray","Wrong module number %d . Limits: %d , %d",mod,firstmod[0],firstmod[fGeom->GetNlayers()+1]); | |
2257f27e | 169 | exit(1); |
13918578 | 170 | } |
171 | else { | |
172 | for(Int_t n=0;n<vect[nlr]->GetSize();n++){ | |
173 | Int_t mm=vect[nlr]->At(n); | |
174 | if(mm==mod) {fDet[mod]->AddAt(n,nc); nc+=1; } | |
175 | } | |
176 | } | |
177 | } | |
178 | ||
179 | ||
2257f27e | 180 | clus->Delete(); |
181 | delete clus; | |
13918578 | 182 | for(Int_t n=0;n<fGeom->GetNlayers();n++)delete vect[n]; |
2257f27e | 183 | delete [] vect; |
037efb75 | 184 | delete [] firstmod; |
13918578 | 185 | } |
186 | ||
187 | //_________________________________________________________________ | |
2257f27e | 188 | void AliITSclusterTable::FillArrayLabel(Int_t numberofparticles){ |
13918578 | 189 | // |
190 | ||
191 | ||
192 | fLbl = new TArrayI*[numberofparticles]; | |
13918578 | 193 | const Int_t knm =fGeom->GetNlayers(); |
194 | for(Int_t nlab=0;nlab<numberofparticles;nlab++){ | |
195 | fLbl[nlab] = new TArrayI(knm); | |
037efb75 | 196 | Int_t * nn = new Int_t[knm]; |
197 | for(Int_t i=0;i<knm;i++)nn[i]=0; | |
13918578 | 198 | for(Int_t nlayer=0;nlayer<knm;nlayer++){ |
199 | Int_t ncl = fTracker->GetNumberOfClustersLayer(nlayer); | |
200 | while(ncl--){ | |
201 | AliITSclusterV2* cl = fTracker->GetClusterLayer(nlayer,ncl); | |
202 | if(cl->IsUsed()==1) continue; | |
203 | if(cl->GetLabel(0)==nlab || cl->GetLabel(1)==nlab || cl->GetLabel(2)==nlab){ | |
204 | nn[nlayer]+=1; | |
205 | cl->Use(); | |
206 | break; | |
207 | } | |
208 | } | |
209 | fLbl[nlab]->AddAt(nn[nlayer],nlayer); | |
210 | } | |
037efb75 | 211 | delete [] nn; |
13918578 | 212 | } |
213 | ||
13918578 | 214 | } |
215 | ||
216 | //_______________________________________________________________ | |
217 | Int_t AliITSclusterTable::ThisParticleIsTrackable(Int_t label,Int_t numberofpoints){ | |
218 | ||
219 | //Returns 1 if particle with label "label" is trackable. | |
220 | ||
221 | Int_t nb=0; | |
222 | for(Int_t i=0;i<fGeom->GetNlayers();i++){ | |
223 | Int_t ncl = fLbl[label]->At(i); | |
224 | if(ncl>0) nb++; | |
225 | } | |
226 | if(nb>=numberofpoints) return 1; | |
227 | else return 0; | |
228 | ||
229 | } | |
230 | ||
231 | //_______________________________________________________________ | |
232 | Int_t AliITSclusterTable::FindIndex(Int_t ndim, Int_t *ptr, Int_t value){ | |
233 | // ptr[ndim+1] is an array of integers | |
234 | // ndim is its dimension minus 1 | |
235 | // value is a number such as: ptr[0]<=value < ptr[ndim] | |
236 | // if ptr[i]<=value<ptr[i+1] the index i is returned; -1 if out of bounds | |
237 | Int_t retval = -1; | |
238 | for(Int_t k=0;k<ndim;k++){ | |
239 | if(value>=ptr[k] && value <ptr[k+1]){ | |
240 | retval = k; | |
241 | break; | |
242 | } | |
243 | } | |
244 | return retval; | |
245 | } | |
bef31448 | 246 | |
2257f27e | 247 | void AliITSclusterTable::FillArrayCoorAngles(){ |
bef31448 | 248 | //Fill arrays with phi,lambda and indices of clusters for each layer |
249 | Info("FillArrayCoorAngles","Filling Array..."); | |
250 | ||
251 | fPhiList = new TArrayD*[fGeom->GetNlayers()]; | |
252 | fLambdaList = new TArrayD*[fGeom->GetNlayers()]; | |
253 | fXList = new TArrayD*[fGeom->GetNlayers()]; | |
254 | fYList = new TArrayD*[fGeom->GetNlayers()]; | |
255 | fZList = new TArrayD*[fGeom->GetNlayers()]; | |
256 | fSxList = new TArrayD*[fGeom->GetNlayers()]; | |
257 | fSyList = new TArrayD*[fGeom->GetNlayers()]; | |
258 | fSzList = new TArrayD*[fGeom->GetNlayers()]; | |
259 | ||
bef31448 | 260 | Int_t * firstmod = new Int_t[fGeom->GetNlayers()+1]; |
261 | firstmod[fGeom->GetNlayers()]=fGeom->GetIndexMax(); // upper limit | |
262 | ||
263 | for(Int_t nlay=0;nlay<fGeom->GetNlayers();nlay++){ | |
264 | firstmod[nlay] = fGeom->GetModuleIndex(nlay+1,1,1); | |
265 | Int_t ncl = fTracker->GetNumberOfClustersLayer(nlay); | |
266 | fPhiList[nlay] = new TArrayD(ncl); | |
267 | fLambdaList[nlay]=new TArrayD(ncl); | |
268 | fXList[nlay]=new TArrayD(ncl); | |
269 | fYList[nlay]=new TArrayD(ncl); | |
270 | fZList[nlay]=new TArrayD(ncl); | |
271 | fSxList[nlay]=new TArrayD(ncl); | |
272 | fSyList[nlay]=new TArrayD(ncl); | |
273 | fSzList[nlay]=new TArrayD(ncl); | |
274 | ||
275 | for(Int_t j=0;j<ncl;j++){ | |
276 | AliITSclusterV2* cl = fTracker->GetClusterLayer(nlay,j); | |
277 | Double_t phi=0;Double_t lambda=0; | |
278 | Double_t x=0;Double_t y=0;Double_t z=0; | |
279 | Double_t sx=0;Double_t sy=0;Double_t sz=0; | |
280 | Int_t module = cl->GetDetectorIndex()+firstmod[nlay]; | |
281 | GetCoorAngles(cl,module,phi,lambda,x,y,z); | |
282 | GetCoorErrors(cl,module,sx,sy,sz); | |
283 | fPhiList[nlay]->AddAt(phi,j); | |
284 | fLambdaList[nlay]->AddAt(lambda,j); | |
285 | fXList[nlay]->AddAt(x,j); | |
286 | fYList[nlay]->AddAt(y,j); | |
287 | fZList[nlay]->AddAt(z,j); | |
288 | fSxList[nlay]->AddAt(sx,j); | |
289 | fSyList[nlay]->AddAt(sy,j); | |
290 | fSzList[nlay]->AddAt(sz,j); | |
291 | ||
292 | } | |
293 | ||
294 | } | |
295 | ||
bef31448 | 296 | delete [] firstmod; |
297 | } | |
298 | ||
299 | void AliITSclusterTable::GetCoorAngles(AliITSclusterV2* cl,Int_t module,Double_t &phi,Double_t &lambda, Double_t &x, Double_t &y,Double_t &z){ | |
300 | //Returns values of phi (azimuthal) and lambda angles for a given cluster | |
301 | ||
302 | Double_t rot[9]; fGeom->GetRotMatrix(module,rot); | |
303 | Int_t lay,lad,det; fGeom->GetModuleId(module,lay,lad,det); | |
304 | Float_t tx,ty,tz; fGeom->GetTrans(lay,lad,det,tx,ty,tz); | |
305 | ||
306 | Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi(); | |
307 | Double_t phi1=TMath::Pi()/2+alpha; | |
308 | if (lay==1) phi1+=TMath::Pi(); | |
309 | ||
310 | Double_t cp=TMath::Cos(phi1), sp=TMath::Sin(phi1); | |
311 | Double_t r=tx*cp+ty*sp; | |
312 | ||
313 | x= r*cp - cl->GetY()*sp; | |
314 | y= r*sp + cl->GetY()*cp; | |
315 | z=cl->GetZ(); | |
316 | ||
317 | phi=TMath::ATan2(y,x); | |
318 | lambda=TMath::ATan2(z-fPrimaryVertex[2],TMath::Sqrt((x-fPrimaryVertex[0])*(x-fPrimaryVertex[0])+(y-fPrimaryVertex[1])*(y-fPrimaryVertex[1]))); | |
319 | } | |
320 | ||
321 | void AliITSclusterTable::GetCoorErrors(AliITSclusterV2* cl, Int_t module,Double_t &sx,Double_t &sy, Double_t &sz){ | |
322 | ||
323 | //returns x,y,z of cluster in global coordinates | |
324 | ||
325 | Double_t rot[9]; fGeom->GetRotMatrix(module,rot); | |
326 | Int_t lay,lad,det; fGeom->GetModuleId(module,lay,lad,det); | |
327 | ||
328 | Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi(); | |
329 | Double_t phi=TMath::Pi()/2+alpha; | |
330 | if (lay==1) phi+=TMath::Pi(); | |
331 | ||
332 | Double_t cp=TMath::Cos(phi), sp=TMath::Sin(phi); | |
333 | ||
334 | ||
335 | sx = TMath::Sqrt(sp*sp*cl->GetSigmaY2()); | |
336 | sy = TMath::Sqrt(cp*cp*cl->GetSigmaY2()); | |
337 | sz = TMath::Sqrt(cl->GetSigmaZ2()); | |
338 | ||
339 | } |