]>
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 | ||
aa4b78e1 | 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) | |
13918578 | 42 | //__________________________________________________________ |
43 | AliITSclusterTable::AliITSclusterTable(){ | |
44 | // Default constructor | |
45 | fDet=0; | |
46 | fNCl = 0; | |
47 | fLbl=0; | |
48 | fGeom = 0; | |
49 | fTracker = 0; | |
bef31448 | 50 | fPhiList = 0; |
51 | fLambdaList = 0; | |
52 | fXList = 0; | |
53 | fYList =0; | |
2257f27e | 54 | fZList =0; |
55 | fSxList = 0; | |
56 | fSyList =0; | |
57 | fSzList =0; | |
bef31448 | 58 | for(Int_t i=0;i<3;i++){fPrimaryVertex[i]=0;} |
13918578 | 59 | } |
60 | ||
61 | //__________________________________________________________ | |
bef31448 | 62 | AliITSclusterTable::AliITSclusterTable(AliITSgeom* geom, AliITStrackerSA* tracker,Double_t* primaryVertex) { |
13918578 | 63 | // Standard constructor |
64 | fDet=0; | |
65 | Int_t nm = geom->GetIndexMax(); | |
66 | fNCl = new Int_t[nm]; | |
67 | for(Int_t i=0;i<nm;i++){fNCl[i]=0;} | |
68 | fLbl=0; | |
69 | fGeom = geom; | |
70 | fTracker = tracker; | |
bef31448 | 71 | for(Int_t i=0;i<3;i++){fPrimaryVertex[i]=primaryVertex[i];} |
72 | fPhiList = 0; | |
73 | fLambdaList = 0; | |
74 | fXList = 0; | |
75 | fYList = 0; | |
2257f27e | 76 | fZList =0; |
77 | fSxList = 0; | |
78 | fSyList =0; | |
79 | fSzList =0; | |
13918578 | 80 | } |
13918578 | 81 | //______________________________________________________________________ |
82 | AliITSclusterTable::AliITSclusterTable(const AliITSclusterTable &tab) : | |
83 | TObject(tab) { | |
84 | // Copy constructor | |
85 | // Copies are not allowed. The method is protected to avoid misuse. | |
86 | Error("AliITSclusterTable","Copy constructor not allowed\n"); | |
87 | } | |
88 | ||
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"); | |
95 | return *this; | |
96 | } | |
97 | ||
98 | //__________________________________________________________ | |
99 | AliITSclusterTable::~AliITSclusterTable(){ | |
100 | // Destructor | |
101 | Int_t nm = fGeom->GetIndexMax(); | |
102 | if(fDet){ | |
103 | for (Int_t i=0; i<nm; i++){ | |
104 | delete fDet[i]; | |
105 | } | |
2257f27e | 106 | delete[] fDet; |
13918578 | 107 | } |
2257f27e | 108 | if (fLbl)delete [] fLbl; // memory leak! |
13918578 | 109 | if (fNCl)delete [] fNCl; |
2257f27e | 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]; | |
119 | } | |
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; | |
13918578 | 128 | } |
129 | ||
130 | //__________________________________________________________ | |
131 | ||
2257f27e | 132 | void AliITSclusterTable::FillArray(TTree* clusterTree){ |
13918578 | 133 | |
134 | // | |
135 | Int_t nm = fGeom->GetIndexMax(); | |
136 | fDet = new TArrayI*[nm]; | |
13918578 | 137 | |
138 | TArrayI** vect = new TArrayI*[fGeom->GetNlayers()]; | |
037efb75 | 139 | Int_t * firstmod = new Int_t[fGeom->GetNlayers()+1]; |
13918578 | 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); | |
148 | } | |
149 | } | |
150 | ||
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); | |
155 | ||
13918578 | 156 | for(Int_t mod=0;mod<nm;mod++){ |
157 | Int_t nc=0; | |
158 | clusterTree->GetEvent(mod); | |
159 | Int_t ncl = clus->GetEntries(); | |
160 | fDet[mod] = new TArrayI(ncl); | |
161 | fNCl[mod]= ncl; | |
162 | Int_t nlr = FindIndex(fGeom->GetNlayers(),firstmod,mod); | |
163 | if(nlr<0){ | |
164 | Fatal("FillArray","Wrong module number %d . Limits: %d , %d",mod,firstmod[0],firstmod[fGeom->GetNlayers()+1]); | |
2257f27e | 165 | exit(1); |
13918578 | 166 | } |
167 | else { | |
168 | for(Int_t n=0;n<vect[nlr]->GetSize();n++){ | |
169 | Int_t mm=vect[nlr]->At(n); | |
4e05ab9a | 170 | if(nc>=fDet[mod]->GetSize()) fDet[mod]->Set(nc*2+10); |
babd135a | 171 | if(mm==mod) {(*fDet[mod])[nc]=n; nc+=1; } |
13918578 | 172 | } |
173 | } | |
174 | } | |
175 | ||
2257f27e | 176 | clus->Delete(); |
177 | delete clus; | |
13918578 | 178 | for(Int_t n=0;n<fGeom->GetNlayers();n++)delete vect[n]; |
2257f27e | 179 | delete [] vect; |
037efb75 | 180 | delete [] firstmod; |
13918578 | 181 | } |
182 | ||
183 | //_________________________________________________________________ | |
2257f27e | 184 | void AliITSclusterTable::FillArrayLabel(Int_t numberofparticles){ |
13918578 | 185 | // |
186 | ||
13918578 | 187 | fLbl = new TArrayI*[numberofparticles]; |
13918578 | 188 | const Int_t knm =fGeom->GetNlayers(); |
189 | for(Int_t nlab=0;nlab<numberofparticles;nlab++){ | |
190 | fLbl[nlab] = new TArrayI(knm); | |
037efb75 | 191 | Int_t * nn = new Int_t[knm]; |
192 | for(Int_t i=0;i<knm;i++)nn[i]=0; | |
13918578 | 193 | for(Int_t nlayer=0;nlayer<knm;nlayer++){ |
194 | Int_t ncl = fTracker->GetNumberOfClustersLayer(nlayer); | |
195 | while(ncl--){ | |
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){ | |
199 | nn[nlayer]+=1; | |
200 | cl->Use(); | |
201 | break; | |
202 | } | |
203 | } | |
204 | fLbl[nlab]->AddAt(nn[nlayer],nlayer); | |
205 | } | |
037efb75 | 206 | delete [] nn; |
13918578 | 207 | } |
208 | ||
13918578 | 209 | } |
210 | ||
211 | //_______________________________________________________________ | |
212 | Int_t AliITSclusterTable::ThisParticleIsTrackable(Int_t label,Int_t numberofpoints){ | |
213 | ||
214 | //Returns 1 if particle with label "label" is trackable. | |
215 | ||
216 | Int_t nb=0; | |
217 | for(Int_t i=0;i<fGeom->GetNlayers();i++){ | |
218 | Int_t ncl = fLbl[label]->At(i); | |
219 | if(ncl>0) nb++; | |
220 | } | |
221 | if(nb>=numberofpoints) return 1; | |
222 | else return 0; | |
223 | ||
224 | } | |
225 | ||
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 | |
232 | Int_t retval = -1; | |
233 | for(Int_t k=0;k<ndim;k++){ | |
234 | if(value>=ptr[k] && value <ptr[k+1]){ | |
235 | retval = k; | |
236 | break; | |
237 | } | |
238 | } | |
239 | return retval; | |
240 | } | |
bef31448 | 241 | |
2257f27e | 242 | void AliITSclusterTable::FillArrayCoorAngles(){ |
bef31448 | 243 | //Fill arrays with phi,lambda and indices of clusters for each layer |
4e05ab9a | 244 | |
bef31448 | 245 | fPhiList = new TArrayD*[fGeom->GetNlayers()]; |
246 | fLambdaList = new TArrayD*[fGeom->GetNlayers()]; | |
4e05ab9a | 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()]; | |
bef31448 | 253 | |
bef31448 | 254 | Int_t * firstmod = new Int_t[fGeom->GetNlayers()+1]; |
255 | firstmod[fGeom->GetNlayers()]=fGeom->GetIndexMax(); // upper limit | |
256 | ||
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); | |
4e05ab9a | 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); | |
bef31448 | 268 | |
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; | |
4e05ab9a | 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; | |
bef31448 | 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); | |
285 | ||
286 | } | |
287 | ||
288 | } | |
289 | ||
bef31448 | 290 | delete [] firstmod; |
291 | } | |
4e05ab9a | 292 | void AliITSclusterTable::GetCoorAngles(AliITSclusterV2* cl,Int_t module,Double_t &phi,Double_t &lambda, Float_t &x, Float_t &y,Float_t &z){ |
bef31448 | 293 | //Returns values of phi (azimuthal) and lambda angles for a given cluster |
294 | ||
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); | |
298 | ||
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(); | |
302 | ||
4e05ab9a | 303 | Float_t cp=TMath::Cos(phi1), sp=TMath::Sin(phi1); |
304 | Float_t r=tx*cp+ty*sp; | |
bef31448 | 305 | |
306 | x= r*cp - cl->GetY()*sp; | |
307 | y= r*sp + cl->GetY()*cp; | |
308 | z=cl->GetZ(); | |
309 | ||
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]))); | |
312 | } | |
313 | ||
4e05ab9a | 314 | void AliITSclusterTable::GetCoorErrors(AliITSclusterV2* cl, Int_t module,Float_t &sx,Float_t &sy, Float_t &sz){ |
bef31448 | 315 | |
316 | //returns x,y,z of cluster in global coordinates | |
317 | ||
318 | Double_t rot[9]; fGeom->GetRotMatrix(module,rot); | |
319 | Int_t lay,lad,det; fGeom->GetModuleId(module,lay,lad,det); | |
320 | ||
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(); | |
324 | ||
4e05ab9a | 325 | Float_t cp=TMath::Cos(phi), sp=TMath::Sin(phi); |
bef31448 | 326 | |
bef31448 | 327 | sx = TMath::Sqrt(sp*sp*cl->GetSigmaY2()); |
328 | sy = TMath::Sqrt(cp*cp*cl->GetSigmaY2()); | |
329 | sz = TMath::Sqrt(cl->GetSigmaZ2()); | |
330 | ||
331 | } |