]>
Commit | Line | Data |
---|---|---|
7f4044f0 | 1 | //------------------------------------------------------------------------- |
2 | // Implementation of the ITS clusterer V2 class | |
3 | // | |
4 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch | |
5 | //------------------------------------------------------------------------- | |
6 | //uncomment the line below for running with V1 cluster finder classes | |
7 | //#define V1 | |
8 | ||
9 | #include "AliRun.h" | |
10 | ||
11 | #include "AliITSclustererV2.h" | |
12 | #include "AliITSclusterV2.h" | |
7941072e | 13 | #include "AliRawReader.h" |
c391f9d9 | 14 | #include "AliITSRawStreamSPD.h" |
15 | #include "AliITSRawStreamSDD.h" | |
16 | #include "AliITSRawStreamSSD.h" | |
7f4044f0 | 17 | |
7f4044f0 | 18 | #include <TFile.h> |
19 | #include <TTree.h> | |
20 | #include <TClonesArray.h> | |
21 | #include "AliITSgeom.h" | |
e869281d | 22 | #include "AliITSdigitSPD.h" |
23 | #include "AliITSdigitSDD.h" | |
24 | #include "AliITSdigitSSD.h" | |
5d12ce38 | 25 | #include "AliMC.h" |
7f4044f0 | 26 | |
27 | ClassImp(AliITSclustererV2) | |
28 | ||
29 | extern AliRun *gAlice; | |
30 | ||
31 | AliITSclustererV2::AliITSclustererV2(const AliITSgeom *geom) { | |
32 | //------------------------------------------------------------ | |
33 | // Standard constructor | |
34 | //------------------------------------------------------------ | |
35 | AliITSgeom *g=(AliITSgeom*)geom; | |
36 | ||
37 | fEvent=0; | |
38 | fI=0; | |
39 | ||
40 | Int_t mmax=geom->GetIndexMax(); | |
c630aafd | 41 | if (mmax>2200) { |
caa92d6a | 42 | Fatal("AliITSclustererV2","Too many ITS subdetectors !"); |
c630aafd | 43 | } |
7f4044f0 | 44 | Int_t m; |
45 | for (m=0; m<mmax; m++) { | |
46 | Int_t lay,lad,det; g->GetModuleId(m,lay,lad,det); | |
47 | Float_t x,y,z; g->GetTrans(lay,lad,det,x,y,z); | |
48 | Double_t rot[9]; g->GetRotMatrix(lay,lad,det,rot); | |
f363d377 | 49 | Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi(); |
50 | Double_t ca=TMath::Cos(alpha), sa=TMath::Sin(alpha); | |
51 | fYshift[m] = x*ca + y*sa; | |
7f4044f0 | 52 | fZshift[m] = (Double_t)z; |
53 | fNdet[m] = (lad-1)*g->GetNdetectors(lay) + (det-1); | |
e43c066c | 54 | fNlayer[m] = lay-1; |
7f4044f0 | 55 | } |
c391f9d9 | 56 | fNModules = g->GetIndexMax(); |
7f4044f0 | 57 | |
58 | //SPD geometry | |
59 | fLastSPD1=g->GetModuleIndex(2,1,1)-1; | |
60 | fNySPD=256; fNzSPD=160; | |
61 | fYpitchSPD=0.0050; | |
62 | fZ1pitchSPD=0.0425; fZ2pitchSPD=0.0625; | |
63 | fHwSPD=0.64; fHlSPD=3.48; | |
64 | fYSPD[0]=0.5*fYpitchSPD; | |
65 | for (m=1; m<fNySPD; m++) fYSPD[m]=fYSPD[m-1]+fYpitchSPD; | |
66 | fZSPD[0]=fZ1pitchSPD; | |
67 | for (m=1; m<fNzSPD; m++) { | |
68 | Double_t dz=fZ1pitchSPD; | |
69 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || | |
70 | m==127 || m==128) dz=fZ2pitchSPD; | |
71 | fZSPD[m]=fZSPD[m-1]+dz; | |
72 | } | |
73 | for (m=0; m<fNzSPD; m++) { | |
74 | Double_t dz=0.5*fZ1pitchSPD; | |
75 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || | |
76 | m==127 || m==128) dz=0.5*fZ2pitchSPD; | |
77 | fZSPD[m]-=dz; | |
78 | } | |
79 | ||
80 | //SDD geometry | |
81 | fNySDD=256; fNzSDD=256; | |
82 | fYpitchSDD=0.01825; | |
83 | fZpitchSDD=0.02940; | |
84 | fHwSDD=3.5085; fHlSDD=3.7632; | |
85 | fYoffSDD=0.0425; | |
86 | ||
87 | //SSD geometry | |
88 | fLastSSD1=g->GetModuleIndex(6,1,1)-1; | |
89 | fYpitchSSD=0.0095; | |
90 | fHwSSD=3.65; | |
91 | fHlSSD=2.00; | |
92 | fTanP=0.0275; | |
93 | fTanN=0.0075; | |
94 | } | |
95 | ||
e3d91d99 | 96 | |
c630aafd | 97 | Int_t AliITSclustererV2::Digits2Clusters(TTree *dTree, TTree *cTree) { |
7f4044f0 | 98 | //------------------------------------------------------------ |
99 | // This function creates ITS clusters | |
100 | //------------------------------------------------------------ | |
101 | Int_t ncl=0; | |
7f4044f0 | 102 | |
7f4044f0 | 103 | if (!dTree) { |
c630aafd | 104 | Error("Digits2Clusters","Can't get the tree with digits !"); |
105 | return 1; | |
7f4044f0 | 106 | } |
107 | ||
108 | TClonesArray *digitsSPD=new TClonesArray("AliITSdigitSPD",3000); | |
109 | dTree->SetBranchAddress("ITSDigitsSPD",&digitsSPD); | |
110 | TClonesArray *digitsSDD=new TClonesArray("AliITSdigitSDD",3000); | |
111 | dTree->SetBranchAddress("ITSDigitsSDD",&digitsSDD); | |
112 | TClonesArray *digitsSSD=new TClonesArray("AliITSdigitSSD",3000); | |
113 | dTree->SetBranchAddress("ITSDigitsSSD",&digitsSSD); | |
114 | ||
7f4044f0 | 115 | TClonesArray *clusters=new TClonesArray("AliITSclusterV2",1000); |
c630aafd | 116 | TBranch *branch=cTree->GetBranch("Clusters"); |
117 | if (!branch) cTree->Branch("Clusters",&clusters); | |
118 | else branch->SetAddress(&clusters); | |
119 | ||
120 | Int_t mmax=(Int_t)dTree->GetEntries(); | |
7f4044f0 | 121 | |
122 | for (fI=0; fI<mmax; fI++) { | |
123 | dTree->GetEvent(fI); | |
124 | ||
125 | if (digitsSPD->GetEntriesFast()!=0) | |
babd135a | 126 | FindClustersSPD(digitsSPD,clusters); |
127 | else | |
128 | if(digitsSDD->GetEntriesFast()!=0) | |
129 | FindClustersSDD(digitsSDD,clusters); | |
130 | else if(digitsSSD->GetEntriesFast()!=0) | |
131 | FindClustersSSD(digitsSSD,clusters); | |
132 | ||
7f4044f0 | 133 | ncl+=clusters->GetEntriesFast(); |
134 | ||
c630aafd | 135 | cTree->Fill(); |
7f4044f0 | 136 | |
137 | digitsSPD->Clear(); | |
138 | digitsSDD->Clear(); | |
139 | digitsSSD->Clear(); | |
140 | clusters->Clear(); | |
141 | } | |
c630aafd | 142 | |
143 | //cTree->Write(); | |
7f4044f0 | 144 | |
145 | delete clusters; | |
146 | ||
147 | delete digitsSPD; | |
148 | delete digitsSDD; | |
149 | delete digitsSSD; | |
150 | ||
7941072e | 151 | //delete dTree; |
152 | ||
c630aafd | 153 | Info("Digits2Clusters","Number of found clusters : %d",ncl); |
7f4044f0 | 154 | |
c630aafd | 155 | return 0; |
7f4044f0 | 156 | } |
157 | ||
7941072e | 158 | void AliITSclustererV2::Digits2Clusters(AliRawReader* rawReader) { |
c391f9d9 | 159 | //------------------------------------------------------------ |
160 | // This function creates ITS clusters from raw data | |
161 | //------------------------------------------------------------ | |
7941072e | 162 | AliRunLoader* runLoader = AliRunLoader::GetRunLoader(); |
163 | if (!runLoader) { | |
164 | Error("Digits2Clusters", "no run loader found"); | |
165 | return; | |
166 | } | |
babd135a | 167 | runLoader->LoadKinematics(); |
7941072e | 168 | AliLoader* itsLoader = runLoader->GetLoader("ITSLoader"); |
169 | if (!itsLoader) { | |
170 | Error("Digits2Clusters", "no loader for ITS found"); | |
c391f9d9 | 171 | return; |
172 | } | |
7941072e | 173 | if (!itsLoader->TreeR()) itsLoader->MakeTree("R"); |
174 | TTree* cTree = itsLoader->TreeR(); | |
c391f9d9 | 175 | |
c391f9d9 | 176 | TClonesArray *array=new TClonesArray("AliITSclusterV2",1000); |
7941072e | 177 | cTree->Branch("Clusters",&array); |
c391f9d9 | 178 | delete array; |
179 | ||
f1e0c1c5 | 180 | TClonesArray** clusters = new TClonesArray*[fNModules]; |
04fa961a | 181 | for (Int_t iModule = 0; iModule < fNModules; iModule++) { |
182 | clusters[iModule] = NULL; | |
183 | } | |
c391f9d9 | 184 | // one TClonesArray per module |
185 | ||
7941072e | 186 | rawReader->Reset(); |
187 | AliITSRawStreamSPD inputSPD(rawReader); | |
c391f9d9 | 188 | FindClustersSPD(&inputSPD, clusters); |
7941072e | 189 | |
190 | rawReader->Reset(); | |
191 | AliITSRawStreamSDD inputSDD(rawReader); | |
c391f9d9 | 192 | FindClustersSDD(&inputSDD, clusters); |
7941072e | 193 | |
194 | rawReader->Reset(); | |
195 | AliITSRawStreamSSD inputSSD(rawReader); | |
c391f9d9 | 196 | FindClustersSSD(&inputSSD, clusters); |
197 | ||
198 | // write all clusters to the tree | |
199 | Int_t nClusters = 0; | |
200 | for (Int_t iModule = 0; iModule < fNModules; iModule++) { | |
04fa961a | 201 | array = clusters[iModule]; |
c391f9d9 | 202 | if (!array) { |
203 | Error("Digits2Clusters", "data for module %d missing!", iModule); | |
204 | array = new TClonesArray("AliITSclusterV2"); | |
205 | } | |
7941072e | 206 | cTree->SetBranchAddress("Clusters", &array); |
207 | cTree->Fill(); | |
c391f9d9 | 208 | nClusters += array->GetEntriesFast(); |
209 | delete array; | |
210 | } | |
7941072e | 211 | itsLoader->WriteRecPoints("OVERWRITE"); |
c391f9d9 | 212 | |
04fa961a | 213 | delete[] clusters; |
214 | ||
c391f9d9 | 215 | Info("Digits2Clusters", "total number of found clusters in ITS: %d\n", |
216 | nClusters); | |
217 | } | |
218 | ||
7f4044f0 | 219 | //**** Fast clusters ******************************* |
220 | #include "TParticle.h" | |
221 | ||
222 | #include "AliITS.h" | |
223 | #include "AliITSmodule.h" | |
224 | #include "AliITSRecPoint.h" | |
225 | #include "AliITSsimulationFastPoints.h" | |
226 | #include "AliITSRecPoint.h" | |
227 | ||
babd135a | 228 | /* |
7f4044f0 | 229 | static void CheckLabels(Int_t lab[3]) { |
230 | //------------------------------------------------------------ | |
231 | // Tries to find mother's labels | |
232 | //------------------------------------------------------------ | |
233 | Int_t label=lab[0]; | |
234 | if (label>=0) { | |
5d12ce38 | 235 | TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label); |
7f4044f0 | 236 | label=-3; |
237 | while (part->P() < 0.005) { | |
238 | Int_t m=part->GetFirstMother(); | |
c630aafd | 239 | if (m<0) { |
240 | Info("CheckLabels","Primary momentum: %f",part->P()); | |
241 | break; | |
242 | } | |
1cca57bf | 243 | if (part->GetStatusCode()>0) { |
c630aafd | 244 | Info("CheckLabels","Primary momentum: %f",part->P()); |
245 | break; | |
1cca57bf | 246 | } |
7f4044f0 | 247 | label=m; |
5d12ce38 | 248 | part=(TParticle*)gAlice->GetMCApp()->Particle(label); |
7f4044f0 | 249 | } |
250 | if (lab[1]<0) lab[1]=label; | |
251 | else if (lab[2]<0) lab[2]=label; | |
252 | else ;//cerr<<"CheckLabels : No empty labels !\n"; | |
253 | } | |
254 | } | |
babd135a | 255 | */ |
256 | static void CheckLabels(Int_t lab[3]) { | |
257 | //------------------------------------------------------------ | |
258 | // Tries to find mother's labels | |
259 | //------------------------------------------------------------ | |
260 | ||
261 | Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); | |
262 | for (Int_t i=0;i<3;i++){ | |
263 | Int_t label = lab[i]; | |
264 | if (label>=0 && label<ntracks) { | |
265 | TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label); | |
266 | if (part->P() < 0.005) { | |
267 | Int_t m=part->GetFirstMother(); | |
268 | if (m<0) { | |
269 | continue; | |
270 | } | |
271 | if (part->GetStatusCode()>0) { | |
272 | continue; | |
273 | } | |
274 | lab[i]=m; | |
275 | } | |
276 | } | |
277 | } | |
278 | ||
279 | } | |
280 | ||
281 | static void CheckLabels2(Int_t lab[10]) { | |
282 | //------------------------------------------------------------ | |
283 | // Tries to find mother's labels | |
284 | //------------------------------------------------------------ | |
285 | ||
286 | Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); | |
e43c066c | 287 | Int_t nlabels =0; |
288 | for (Int_t i=0;i<10;i++) if (lab[i]>=0) nlabels++; | |
289 | ||
babd135a | 290 | for (Int_t i=0;i<10;i++){ |
291 | Int_t label = lab[i]; | |
292 | if (label>=0 && label<ntracks) { | |
293 | TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label); | |
e43c066c | 294 | if (part->P() < 0.02) { |
295 | Int_t m=part->GetFirstMother(); | |
296 | if (m<0) { | |
297 | continue; | |
298 | } | |
299 | if (part->GetStatusCode()>0) { | |
300 | continue; | |
301 | } | |
302 | lab[i]=m; | |
303 | } | |
304 | else | |
305 | if (part->P() < 0.12 && nlabels>3) { | |
306 | lab[i]=-2; | |
307 | nlabels--; | |
308 | } | |
309 | } | |
310 | else{ | |
311 | if ( (label>ntracks||label <0) && nlabels>3) { | |
312 | lab[i]=-2; | |
313 | nlabels--; | |
314 | } | |
315 | } | |
316 | } | |
317 | if (nlabels>3){ | |
318 | for (Int_t i=0;i<10;i++){ | |
319 | if (nlabels>3){ | |
320 | Int_t label = lab[i]; | |
321 | if (label>=0 && label<ntracks) { | |
322 | TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label); | |
323 | if (part->P() < 0.1) { | |
324 | lab[i]=-2; | |
325 | nlabels--; | |
326 | } | |
babd135a | 327 | } |
babd135a | 328 | } |
e43c066c | 329 | } |
babd135a | 330 | } |
e43c066c | 331 | |
babd135a | 332 | //compress labels -- if multi-times the same |
333 | Int_t lab2[10]; | |
334 | for (Int_t i=0;i<10;i++) lab2[i]=-2; | |
335 | for (Int_t i=0;i<10 ;i++){ | |
336 | if (lab[i]<0) continue; | |
337 | for (Int_t j=0;j<10 &&lab2[j]!=lab[i];j++){ | |
338 | if (lab2[j]<0) { | |
339 | lab2[j]= lab[i]; | |
340 | break; | |
341 | } | |
342 | } | |
343 | } | |
344 | for (Int_t j=0;j<10;j++) lab[j]=lab2[j]; | |
345 | ||
346 | } | |
347 | ||
348 | static void AddLabel(Int_t lab[10], Int_t label) { | |
e43c066c | 349 | Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); |
350 | if (label>ntracks) return; | |
babd135a | 351 | for (Int_t i=0;i<10;i++){ |
352 | if (label<0) break; | |
353 | if (lab[i]==label) break; | |
354 | if (lab[i]<0) { | |
355 | lab[i]= label; | |
356 | break; | |
357 | } | |
358 | } | |
359 | } | |
7f4044f0 | 360 | |
1cca57bf | 361 | void AliITSclustererV2::RecPoints2Clusters |
362 | (const TClonesArray *points, Int_t idx, TClonesArray *clusters) { | |
7f4044f0 | 363 | //------------------------------------------------------------ |
1cca57bf | 364 | // Conversion AliITSRecPoint -> AliITSclusterV2 for the ITS |
365 | // subdetector indexed by idx | |
7f4044f0 | 366 | //------------------------------------------------------------ |
367 | TClonesArray &cl=*clusters; | |
368 | Int_t ncl=points->GetEntriesFast(); | |
369 | for (Int_t i=0; i<ncl; i++) { | |
370 | AliITSRecPoint *p = (AliITSRecPoint *)points->UncheckedAt(i); | |
371 | Float_t lp[5]; | |
f363d377 | 372 | lp[0]=-(-p->GetX()+fYshift[idx]); if (idx<=fLastSPD1) lp[0]*=-1; //SPD1 |
373 | lp[1]= -p->GetZ()+fZshift[idx]; | |
1cca57bf | 374 | lp[2]=p->GetSigmaX2(); |
375 | lp[3]=p->GetSigmaZ2(); | |
b6087704 | 376 | lp[4]=p->GetQ()*36./23333.; //electrons -> ADC |
7f4044f0 | 377 | Int_t lab[4]; |
378 | lab[0]=p->GetLabel(0); lab[1]=p->GetLabel(1); lab[2]=p->GetLabel(2); | |
1cca57bf | 379 | lab[3]=fNdet[idx]; |
7f4044f0 | 380 | CheckLabels(lab); |
babd135a | 381 | Int_t dummy[3]={0,0,0}; |
382 | new (cl[i]) AliITSclusterV2(lab,lp, dummy); | |
7f4044f0 | 383 | } |
384 | } | |
385 | ||
c630aafd | 386 | Int_t AliITSclustererV2::Hits2Clusters(TTree *hTree, TTree *cTree) { |
7f4044f0 | 387 | //------------------------------------------------------------ |
388 | // This function creates ITS clusters | |
389 | //------------------------------------------------------------ | |
7f4044f0 | 390 | if (!gAlice) { |
c630aafd | 391 | Error("Hits2Clusters","gAlice==0 !"); |
392 | return 1; | |
7f4044f0 | 393 | } |
394 | ||
395 | AliITS *its = (AliITS*)gAlice->GetModule("ITS"); | |
396 | if (!its) { | |
c630aafd | 397 | Error("Hits2Clusters","Can't find the ITS !"); |
398 | return 2; | |
7f4044f0 | 399 | } |
400 | AliITSgeom *geom=its->GetITSgeom(); | |
401 | Int_t mmax=geom->GetIndexMax(); | |
402 | ||
403 | its->InitModules(-1,mmax); | |
c630aafd | 404 | its->FillModules(hTree,0); |
7f4044f0 | 405 | |
7f4044f0 | 406 | TClonesArray *clusters=new TClonesArray("AliITSclusterV2",1000); |
c630aafd | 407 | TBranch *branch=cTree->GetBranch("Clusters"); |
408 | if (!branch) cTree->Branch("Clusters",&clusters); | |
409 | else branch->SetAddress(&clusters); | |
7f4044f0 | 410 | |
411 | static TClonesArray *points=its->RecPoints(); | |
412 | AliITSsimulationFastPoints sim; | |
413 | Int_t ncl=0; | |
414 | for (Int_t m=0; m<mmax; m++) { | |
415 | AliITSmodule *mod=its->GetModule(m); | |
416 | sim.CreateFastRecPoints(mod,m,gRandom); | |
417 | ||
1cca57bf | 418 | RecPoints2Clusters(points, m, clusters); |
7f4044f0 | 419 | its->ResetRecPoints(); |
420 | ||
421 | ncl+=clusters->GetEntriesFast(); | |
c630aafd | 422 | cTree->Fill(); |
7f4044f0 | 423 | clusters->Clear(); |
424 | } | |
7f4044f0 | 425 | |
c630aafd | 426 | Info("Hits2Clusters","Number of found fast clusters : %d",ncl); |
427 | ||
428 | //cTree->Write(); | |
7f4044f0 | 429 | |
430 | delete clusters; | |
431 | ||
c630aafd | 432 | return 0; |
7f4044f0 | 433 | } |
434 | ||
435 | //*********************************** | |
436 | ||
437 | #ifndef V1 | |
438 | ||
439 | void AliITSclustererV2:: | |
440 | FindCluster(Int_t k,Int_t maxz,AliBin *bins,Int_t &n,Int_t *idx) { | |
441 | //------------------------------------------------------------ | |
442 | // returns an array of indices of digits belonging to the cluster | |
443 | // (needed when the segmentation is not regular) | |
444 | //------------------------------------------------------------ | |
445 | if (n<200) idx[n++]=bins[k].GetIndex(); | |
446 | bins[k].Use(); | |
447 | ||
448 | if (bins[k-maxz].IsNotUsed()) FindCluster(k-maxz,maxz,bins,n,idx); | |
449 | if (bins[k-1 ].IsNotUsed()) FindCluster(k-1 ,maxz,bins,n,idx); | |
450 | if (bins[k+maxz].IsNotUsed()) FindCluster(k+maxz,maxz,bins,n,idx); | |
451 | if (bins[k+1 ].IsNotUsed()) FindCluster(k+1 ,maxz,bins,n,idx); | |
452 | /* | |
453 | if (bins[k-maxz-1].IsNotUsed()) FindCluster(k-maxz-1,maxz,bins,n,idx); | |
454 | if (bins[k-maxz+1].IsNotUsed()) FindCluster(k-maxz+1,maxz,bins,n,idx); | |
455 | if (bins[k+maxz-1].IsNotUsed()) FindCluster(k+maxz-1,maxz,bins,n,idx); | |
456 | if (bins[k+maxz+1].IsNotUsed()) FindCluster(k+maxz+1,maxz,bins,n,idx); | |
457 | */ | |
458 | } | |
459 | ||
460 | void AliITSclustererV2:: | |
461 | FindClustersSPD(const TClonesArray *digits, TClonesArray *clusters) { | |
462 | //------------------------------------------------------------ | |
463 | // Actual SPD cluster finder | |
464 | //------------------------------------------------------------ | |
c391f9d9 | 465 | Int_t kNzBins = fNzSPD + 2; |
466 | const Int_t kMAXBIN=kNzBins*(fNySPD+2); | |
7f4044f0 | 467 | |
468 | Int_t ndigits=digits->GetEntriesFast(); | |
469 | AliBin *bins=new AliBin[kMAXBIN]; | |
470 | ||
471 | Int_t k; | |
472 | AliITSdigitSPD *d=0; | |
473 | for (k=0; k<ndigits; k++) { | |
474 | d=(AliITSdigitSPD*)digits->UncheckedAt(k); | |
475 | Int_t i=d->GetCoord2()+1; //y | |
476 | Int_t j=d->GetCoord1()+1; | |
c391f9d9 | 477 | bins[i*kNzBins+j].SetIndex(k); |
478 | bins[i*kNzBins+j].SetMask(1); | |
7f4044f0 | 479 | } |
480 | ||
481 | Int_t n=0; TClonesArray &cl=*clusters; | |
482 | for (k=0; k<kMAXBIN; k++) { | |
483 | if (!bins[k].IsNotUsed()) continue; | |
484 | Int_t ni=0, idx[200]; | |
c391f9d9 | 485 | FindCluster(k,kNzBins,bins,ni,idx); |
c630aafd | 486 | if (ni==200) { |
487 | Info("FindClustersSPD","Too big cluster !"); | |
488 | continue; | |
489 | } | |
babd135a | 490 | Int_t milab[10]; |
491 | for (Int_t ilab=0;ilab<10;ilab++){ | |
492 | milab[ilab]=-2; | |
493 | } | |
494 | ||
7f4044f0 | 495 | d=(AliITSdigitSPD*)digits->UncheckedAt(idx[0]); |
496 | Int_t ymin=d->GetCoord2(),ymax=ymin; | |
497 | Int_t zmin=d->GetCoord1(),zmax=zmin; | |
e43c066c | 498 | |
7f4044f0 | 499 | for (Int_t l=0; l<ni; l++) { |
500 | d=(AliITSdigitSPD*)digits->UncheckedAt(idx[l]); | |
501 | ||
502 | if (ymin > d->GetCoord2()) ymin=d->GetCoord2(); | |
503 | if (ymax < d->GetCoord2()) ymax=d->GetCoord2(); | |
504 | if (zmin > d->GetCoord1()) zmin=d->GetCoord1(); | |
505 | if (zmax < d->GetCoord1()) zmax=d->GetCoord1(); | |
e43c066c | 506 | // MI addition - find all labels in cluster |
507 | for (Int_t dlab=0;dlab<10;dlab++){ | |
babd135a | 508 | Int_t digitlab = (d->GetTracks())[dlab]; |
509 | if (digitlab<0) continue; | |
e43c066c | 510 | AddLabel(milab,digitlab); |
babd135a | 511 | } |
e43c066c | 512 | if (milab[9]>0) CheckLabels2(milab); |
513 | } | |
babd135a | 514 | CheckLabels2(milab); |
e43c066c | 515 | // |
516 | //Int_t idy = (fNlayer[fI]==0)? 2:3; | |
517 | //for (Int_t iz=zmin; iz<=zmax;iz+=2) | |
518 | //Int_t idy = (ymax-ymin)/4.; // max 2 clusters | |
519 | Int_t idy = 0; // max 2 clusters | |
520 | if (fNlayer[fI]==0 &&idy<3) idy=3; | |
521 | if (fNlayer[fI]==1 &&idy<4) idy=4; | |
522 | Int_t idz =3; | |
523 | for (Int_t iz=zmin; iz<=zmax;iz+=idz) | |
524 | for (Int_t iy=ymin; iy<=ymax;iy+=idy){ | |
525 | // | |
526 | Int_t ndigits =0; | |
527 | Double_t y=0.,z=0.,q=0.; | |
528 | for (Int_t l=0; l<ni; l++) { | |
529 | d=(AliITSdigitSPD*)digits->UncheckedAt(idx[l]); | |
530 | if (zmax-zmin>=idz || ymax-ymin>=idy){ | |
531 | if (TMath::Abs( d->GetCoord2()-iy)>0.75*idy) continue; | |
532 | if (TMath::Abs( d->GetCoord1()-iz)>0.75*idz) continue; | |
533 | } | |
534 | ndigits++; | |
535 | Double_t qq=d->GetSignal(); | |
536 | y+=qq*fYSPD[d->GetCoord2()]; z+=qq*fZSPD[d->GetCoord1()]; q+=qq; | |
537 | ||
538 | } | |
539 | if (ndigits==0) continue; | |
540 | y/=q; z/=q; | |
541 | y-=fHwSPD; z-=fHlSPD; | |
542 | ||
543 | Float_t lp[5]; | |
544 | lp[0]=-(-y+fYshift[fI]); if (fI<=fLastSPD1) lp[0]=-lp[0]; | |
545 | lp[1]= -z+fZshift[fI]; | |
546 | // Float_t factor=TMath::Max(double(ni-3.),1.5); | |
547 | Float_t factory=TMath::Max(ymax-ymin,1); | |
548 | Float_t factorz=TMath::Max(zmax-zmin,1); | |
549 | factory*= factory; | |
550 | factorz*= factorz; | |
551 | //lp[2]= (fYpitchSPD*fYpitchSPD/12.)*factory; | |
552 | //lp[3]= (fZ1pitchSPD*fZ1pitchSPD/12.)*factorz; | |
553 | lp[2]= (fYpitchSPD*fYpitchSPD/12.); | |
554 | lp[3]= (fZ1pitchSPD*fZ1pitchSPD/12.); | |
555 | //lp[4]= q; | |
556 | lp[4]= (zmax-zmin+1)*100 + (ymax-ymin+1); | |
557 | ||
558 | milab[3]=fNdet[fI]; | |
559 | d=(AliITSdigitSPD*)digits->UncheckedAt(idx[0]); | |
560 | Int_t info[3] = {ymax-ymin+1,zmax-zmin+1,fNlayer[fI]}; | |
561 | new (cl[n]) AliITSclusterV2(milab,lp,info); n++; | |
562 | } | |
7f4044f0 | 563 | } |
e43c066c | 564 | |
38bcdcc1 | 565 | delete [] bins; |
7f4044f0 | 566 | } |
567 | ||
c391f9d9 | 568 | void AliITSclustererV2::FindClustersSPD(AliITSRawStream* input, |
569 | TClonesArray** clusters) | |
570 | { | |
571 | //------------------------------------------------------------ | |
572 | // Actual SPD cluster finder for raw data | |
573 | //------------------------------------------------------------ | |
574 | ||
575 | Int_t nClustersSPD = 0; | |
576 | Int_t kNzBins = fNzSPD + 2; | |
577 | Int_t kNyBins = fNySPD + 2; | |
578 | Int_t kMaxBin = kNzBins * kNyBins; | |
579 | AliBin* bins = NULL; | |
580 | ||
581 | // read raw data input stream | |
582 | while (kTRUE) { | |
583 | Bool_t next = input->Next(); | |
584 | if (!next || input->IsNewModule()) { | |
585 | Int_t iModule = input->GetPrevModuleID(); | |
586 | ||
587 | // when all data from a module was read, search for clusters | |
588 | if (bins) { | |
589 | clusters[iModule] = new TClonesArray("AliITSclusterV2"); | |
590 | Int_t nClusters = 0; | |
591 | ||
592 | for (Int_t iBin = 0; iBin < kMaxBin; iBin++) { | |
593 | if (bins[iBin].IsUsed()) continue; | |
594 | Int_t nBins = 0; | |
595 | Int_t idxBins[200]; | |
596 | FindCluster(iBin, kNzBins, bins, nBins, idxBins); | |
597 | if (nBins == 200) { | |
598 | Error("FindClustersSPD", "SPD: Too big cluster !\n"); | |
599 | continue; | |
600 | } | |
601 | ||
602 | Int_t label[4]; | |
603 | label[0] = -2; | |
604 | label[1] = -2; | |
605 | label[2] = -2; | |
606 | // label[3] = iModule; | |
607 | label[3] = fNdet[iModule]; | |
608 | ||
609 | Int_t ymin = (idxBins[0] / kNzBins) - 1; | |
610 | Int_t ymax = ymin; | |
611 | Int_t zmin = (idxBins[0] % kNzBins) - 1; | |
612 | Int_t zmax = zmin; | |
613 | Float_t y = 0.; | |
614 | Float_t z = 0.; | |
615 | Float_t q = 0.; | |
616 | for (Int_t idx = 0; idx < nBins; idx++) { | |
617 | Int_t iy = (idxBins[idx] / kNzBins) - 1; | |
618 | Int_t iz = (idxBins[idx] % kNzBins) - 1; | |
619 | if (ymin > iy) ymin = iy; | |
620 | if (ymax < iy) ymax = iy; | |
621 | if (zmin > iz) zmin = iz; | |
622 | if (zmax < iz) zmax = iz; | |
623 | ||
624 | Float_t qBin = bins[idxBins[idx]].GetQ(); | |
625 | y += qBin * fYSPD[iy]; | |
626 | z += qBin * fZSPD[iz]; | |
627 | q += qBin; | |
628 | } | |
629 | y /= q; | |
630 | z /= q; | |
631 | y -= fHwSPD; | |
632 | z -= fHlSPD; | |
633 | ||
634 | Float_t hit[5]; // y, z, sigma(y)^2, sigma(z)^2, charge | |
635 | hit[0] = -y-fYshift[iModule]; | |
636 | if (iModule <= fLastSPD1) hit[0] = -hit[0]; | |
637 | hit[1] = z+fZshift[iModule]; | |
638 | hit[2] = fYpitchSPD*fYpitchSPD/12.; | |
639 | hit[3] = fZ1pitchSPD*fZ1pitchSPD/12.; | |
640 | // hit[4] = q; | |
641 | hit[4] = (zmax-zmin+1)*100 + (ymax-ymin+1); | |
642 | ||
babd135a | 643 | CheckLabels(label); |
644 | Int_t info[3]={0,0,0}; | |
c391f9d9 | 645 | new (clusters[iModule]->AddrAt(nClusters)) |
babd135a | 646 | AliITSclusterV2(label, hit,info); |
c391f9d9 | 647 | nClusters++; |
648 | } | |
649 | ||
650 | nClustersSPD += nClusters; | |
651 | delete bins; | |
652 | } | |
653 | ||
654 | if (!next) break; | |
655 | bins = new AliBin[kMaxBin]; | |
656 | } | |
657 | ||
658 | // fill the current digit into the bins array | |
659 | Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1); | |
660 | bins[index].SetIndex(index); | |
661 | bins[index].SetMask(1); | |
662 | bins[index].SetQ(1); | |
663 | } | |
664 | ||
665 | Info("FindClustersSPD", "found clusters in ITS SPD: %d", nClustersSPD); | |
666 | } | |
667 | ||
668 | ||
7f4044f0 | 669 | Bool_t AliITSclustererV2::IsMaximum(Int_t k,Int_t max,const AliBin *bins) { |
670 | //------------------------------------------------------------ | |
671 | //is this a local maximum ? | |
672 | //------------------------------------------------------------ | |
673 | UShort_t q=bins[k].GetQ(); | |
674 | if (q==1023) return kFALSE; | |
675 | if (bins[k-max].GetQ() > q) return kFALSE; | |
676 | if (bins[k-1 ].GetQ() > q) return kFALSE; | |
677 | if (bins[k+max].GetQ() > q) return kFALSE; | |
678 | if (bins[k+1 ].GetQ() > q) return kFALSE; | |
679 | if (bins[k-max-1].GetQ() > q) return kFALSE; | |
680 | if (bins[k+max-1].GetQ() > q) return kFALSE; | |
681 | if (bins[k+max+1].GetQ() > q) return kFALSE; | |
682 | if (bins[k-max+1].GetQ() > q) return kFALSE; | |
683 | return kTRUE; | |
684 | } | |
685 | ||
686 | void AliITSclustererV2:: | |
687 | FindPeaks(Int_t k,Int_t max,AliBin *b,Int_t *idx,UInt_t *msk,Int_t& n) { | |
688 | //------------------------------------------------------------ | |
689 | //find local maxima | |
690 | //------------------------------------------------------------ | |
691 | if (n<31) | |
692 | if (IsMaximum(k,max,b)) { | |
693 | idx[n]=k; msk[n]=(2<<n); | |
694 | n++; | |
695 | } | |
696 | b[k].SetMask(0); | |
697 | if (b[k-max].GetMask()&1) FindPeaks(k-max,max,b,idx,msk,n); | |
698 | if (b[k-1 ].GetMask()&1) FindPeaks(k-1 ,max,b,idx,msk,n); | |
699 | if (b[k+max].GetMask()&1) FindPeaks(k+max,max,b,idx,msk,n); | |
700 | if (b[k+1 ].GetMask()&1) FindPeaks(k+1 ,max,b,idx,msk,n); | |
701 | } | |
702 | ||
703 | void AliITSclustererV2:: | |
704 | MarkPeak(Int_t k, Int_t max, AliBin *bins, UInt_t m) { | |
705 | //------------------------------------------------------------ | |
706 | //mark this peak | |
707 | //------------------------------------------------------------ | |
708 | UShort_t q=bins[k].GetQ(); | |
709 | ||
710 | bins[k].SetMask(bins[k].GetMask()|m); | |
711 | ||
712 | if (bins[k-max].GetQ() <= q) | |
713 | if ((bins[k-max].GetMask()&m) == 0) MarkPeak(k-max,max,bins,m); | |
714 | if (bins[k-1 ].GetQ() <= q) | |
715 | if ((bins[k-1 ].GetMask()&m) == 0) MarkPeak(k-1 ,max,bins,m); | |
716 | if (bins[k+max].GetQ() <= q) | |
717 | if ((bins[k+max].GetMask()&m) == 0) MarkPeak(k+max,max,bins,m); | |
718 | if (bins[k+1 ].GetQ() <= q) | |
719 | if ((bins[k+1 ].GetMask()&m) == 0) MarkPeak(k+1 ,max,bins,m); | |
720 | } | |
721 | ||
722 | void AliITSclustererV2:: | |
723 | MakeCluster(Int_t k,Int_t max,AliBin *bins,UInt_t m,AliITSclusterV2 &c) { | |
724 | //------------------------------------------------------------ | |
725 | //make cluster using digits of this peak | |
726 | //------------------------------------------------------------ | |
727 | Float_t q=(Float_t)bins[k].GetQ(); | |
728 | Int_t i=k/max, j=k-i*max; | |
729 | ||
730 | c.SetQ(c.GetQ()+q); | |
731 | c.SetY(c.GetY()+i*q); | |
732 | c.SetZ(c.GetZ()+j*q); | |
733 | c.SetSigmaY2(c.GetSigmaY2()+i*i*q); | |
734 | c.SetSigmaZ2(c.GetSigmaZ2()+j*j*q); | |
735 | ||
736 | bins[k].SetMask(0xFFFFFFFE); | |
737 | ||
738 | if (bins[k-max].GetMask() == m) MakeCluster(k-max,max,bins,m,c); | |
739 | if (bins[k-1 ].GetMask() == m) MakeCluster(k-1 ,max,bins,m,c); | |
740 | if (bins[k+max].GetMask() == m) MakeCluster(k+max,max,bins,m,c); | |
741 | if (bins[k+1 ].GetMask() == m) MakeCluster(k+1 ,max,bins,m,c); | |
742 | } | |
743 | ||
744 | void AliITSclustererV2:: | |
c391f9d9 | 745 | FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins, |
746 | const TClonesArray *digits, TClonesArray *clusters) { | |
7f4044f0 | 747 | //------------------------------------------------------------ |
748 | // Actual SDD cluster finder | |
749 | //------------------------------------------------------------ | |
7f4044f0 | 750 | Int_t ncl=0; TClonesArray &cl=*clusters; |
751 | for (Int_t s=0; s<2; s++) | |
c391f9d9 | 752 | for (Int_t i=0; i<nMaxBin; i++) { |
7f4044f0 | 753 | if (bins[s][i].IsUsed()) continue; |
754 | Int_t idx[32]; UInt_t msk[32]; Int_t npeaks=0; | |
c391f9d9 | 755 | FindPeaks(i, nzBins, bins[s], idx, msk, npeaks); |
7f4044f0 | 756 | |
757 | if (npeaks>30) continue; | |
e43c066c | 758 | if (npeaks==0) continue; |
7f4044f0 | 759 | |
760 | Int_t k,l; | |
761 | for (k=0; k<npeaks-1; k++){//mark adjacent peaks | |
762 | if (idx[k] < 0) continue; //this peak is already removed | |
763 | for (l=k+1; l<npeaks; l++) { | |
764 | if (idx[l] < 0) continue; //this peak is already removed | |
c391f9d9 | 765 | Int_t ki=idx[k]/nzBins, kj=idx[k] - ki*nzBins; |
766 | Int_t li=idx[l]/nzBins, lj=idx[l] - li*nzBins; | |
7f4044f0 | 767 | Int_t di=TMath::Abs(ki - li); |
768 | Int_t dj=TMath::Abs(kj - lj); | |
769 | if (di>1 || dj>1) continue; | |
770 | if (bins[s][idx[k]].GetQ() > bins[s][idx[l]].GetQ()) { | |
771 | msk[l]=msk[k]; | |
772 | idx[l]*=-1; | |
773 | } else { | |
774 | msk[k]=msk[l]; | |
775 | idx[k]*=-1; | |
776 | break; | |
777 | } | |
778 | } | |
779 | } | |
780 | ||
781 | for (k=0; k<npeaks; k++) { | |
c391f9d9 | 782 | MarkPeak(TMath::Abs(idx[k]), nzBins, bins[s], msk[k]); |
7f4044f0 | 783 | } |
784 | ||
785 | for (k=0; k<npeaks; k++) { | |
786 | if (idx[k] < 0) continue; //removed peak | |
787 | AliITSclusterV2 c; | |
c391f9d9 | 788 | MakeCluster(idx[k], nzBins, bins[s], msk[k], c); |
babd135a | 789 | //mi change |
790 | Int_t milab[10]; | |
791 | for (Int_t ilab=0;ilab<10;ilab++){ | |
792 | milab[ilab]=-2; | |
793 | } | |
e43c066c | 794 | Int_t maxi=0,mini=0,maxj=0,minj=0; |
795 | //AliBin *bmax=&bins[s][idx[k]]; | |
796 | //Float_t max = TMath::Max(TMath::Abs(bmax->GetQ())/5.,3.); | |
797 | Float_t max=3; | |
798 | for (Int_t di=-2; di<=2;di++) | |
799 | for (Int_t dj=-3;dj<=3;dj++){ | |
800 | Int_t index = idx[k]+di+dj*nzBins; | |
801 | if (index<0) continue; | |
802 | if (index>=nMaxBin) continue; | |
803 | AliBin *b=&bins[s][index]; | |
804 | if (TMath::Abs(b->GetQ())>max){ | |
805 | if (di>maxi) maxi=di; | |
806 | if (di<mini) mini=di; | |
807 | if (dj>maxj) maxj=dj; | |
808 | if (dj<minj) minj=dj; | |
809 | // | |
810 | if (TMath::Abs(di)<2&&TMath::Abs(dj)<2){ | |
811 | AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex()); | |
812 | for (Int_t itrack=0;itrack<10;itrack++){ | |
813 | Int_t track = (d->GetTracks())[itrack]; | |
814 | if (track>=0) { | |
815 | AddLabel(milab, track); | |
816 | } | |
817 | } | |
818 | } | |
819 | } | |
820 | } | |
821 | ||
822 | /* | |
823 | Float_t s2 = c.GetSigmaY2()/c.GetQ() - c.GetY()*c.GetY(); | |
824 | Float_t w=par->GetPadPitchWidth(sec); | |
825 | c.SetSigmaY2(s2); | |
826 | if (s2 != 0.) { | |
827 | c.SetSigmaY2(c.GetSigmaY2()*0.108); | |
828 | if (sec<par->GetNInnerSector()) c.SetSigmaY2(c.GetSigmaY2()*2.07); | |
829 | } | |
830 | s2 = c.GetSigmaZ2()/c.GetQ() - c.GetZ()*c.GetZ(); | |
831 | w=par->GetZWidth(); | |
832 | c.SetSigmaZ2(s2); | |
833 | ||
834 | if (s2 != 0.) { | |
835 | c.SetSigmaZ2(c.GetSigmaZ2()*0.169); | |
836 | if (sec<par->GetNInnerSector()) c.SetSigmaZ2(c.GetSigmaZ2()*1.77); | |
837 | } | |
7f4044f0 | 838 | */ |
839 | ||
840 | c.SetSigmaY2(0.0030*0.0030); | |
841 | c.SetSigmaZ2(0.0020*0.0020); | |
842 | c.SetDetectorIndex(fNdet[fI]); | |
843 | ||
844 | Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ(); | |
845 | y/=q; z/=q; | |
e43c066c | 846 | // |
847 | //Float_t s2 = c.GetSigmaY2()/c.GetQ() - y*y; | |
848 | // c.SetSigmaY2(s2); | |
849 | //s2 = c.GetSigmaZ2()/c.GetQ() - z*z; | |
850 | //c.SetSigmaZ2(s2); | |
851 | // | |
7f4044f0 | 852 | y=(y-0.5)*fYpitchSDD; |
853 | y-=fHwSDD; | |
854 | y-=fYoffSDD; //delay ? | |
855 | if (s) y=-y; | |
856 | ||
857 | z=(z-0.5)*fZpitchSDD; | |
858 | z-=fHlSDD; | |
859 | ||
f363d377 | 860 | y=-(-y+fYshift[fI]); |
861 | z= -z+fZshift[fI]; | |
7f4044f0 | 862 | c.SetY(y); |
863 | c.SetZ(z); | |
e43c066c | 864 | c.SetNy(maxj-minj+1); |
865 | c.SetNz(maxi-mini+1); | |
866 | c.SetType(npeaks); | |
e3d91d99 | 867 | c.SetQ(q/12.7); //to be consistent with the SSD charges |
868 | ||
869 | if (c.GetQ() < 20.) continue; //noise cluster | |
e43c066c | 870 | |
871 | if (digits) { | |
872 | // AliBin *b=&bins[s][idx[k]]; | |
873 | // AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex()); | |
c391f9d9 | 874 | { |
e43c066c | 875 | //Int_t lab[3]; |
876 | //lab[0]=(d->GetTracks())[0]; | |
877 | //lab[1]=(d->GetTracks())[1]; | |
878 | //lab[2]=(d->GetTracks())[2]; | |
879 | //CheckLabels(lab); | |
babd135a | 880 | CheckLabels2(milab); |
881 | c.SetLabel(milab[0],0); | |
882 | c.SetLabel(milab[1],1); | |
883 | c.SetLabel(milab[2],2); | |
e43c066c | 884 | c.SetLayer(fNlayer[fI]); |
c391f9d9 | 885 | } |
886 | } | |
7f4044f0 | 887 | new (cl[ncl]) AliITSclusterV2(c); ncl++; |
888 | } | |
889 | } | |
c391f9d9 | 890 | } |
891 | ||
892 | void AliITSclustererV2:: | |
893 | FindClustersSDD(const TClonesArray *digits, TClonesArray *clusters) { | |
894 | //------------------------------------------------------------ | |
895 | // Actual SDD cluster finder | |
896 | //------------------------------------------------------------ | |
897 | Int_t kNzBins = fNzSDD + 2; | |
898 | const Int_t kMAXBIN=kNzBins*(fNySDD+2); | |
899 | ||
900 | AliBin *bins[2]; | |
901 | bins[0]=new AliBin[kMAXBIN]; | |
902 | bins[1]=new AliBin[kMAXBIN]; | |
903 | ||
904 | AliITSdigitSDD *d=0; | |
905 | Int_t i, ndigits=digits->GetEntriesFast(); | |
906 | for (i=0; i<ndigits; i++) { | |
907 | d=(AliITSdigitSDD*)digits->UncheckedAt(i); | |
908 | Int_t y=d->GetCoord2()+1; //y | |
909 | Int_t z=d->GetCoord1()+1; //z | |
910 | Int_t q=d->GetSignal(); | |
e43c066c | 911 | if (q<3) continue; |
e3d91d99 | 912 | |
c391f9d9 | 913 | if (z <= fNzSDD) { |
914 | bins[0][y*kNzBins+z].SetQ(q); | |
915 | bins[0][y*kNzBins+z].SetMask(1); | |
916 | bins[0][y*kNzBins+z].SetIndex(i); | |
917 | } else { | |
918 | z-=fNzSDD; | |
919 | bins[1][y*kNzBins+z].SetQ(q); | |
920 | bins[1][y*kNzBins+z].SetMask(1); | |
921 | bins[1][y*kNzBins+z].SetIndex(i); | |
922 | } | |
923 | } | |
924 | ||
925 | FindClustersSDD(bins, kMAXBIN, kNzBins, digits, clusters); | |
7f4044f0 | 926 | |
927 | delete[] bins[0]; | |
928 | delete[] bins[1]; | |
929 | } | |
930 | ||
c391f9d9 | 931 | void AliITSclustererV2::FindClustersSDD(AliITSRawStream* input, |
932 | TClonesArray** clusters) | |
933 | { | |
934 | //------------------------------------------------------------ | |
935 | // Actual SDD cluster finder for raw data | |
936 | //------------------------------------------------------------ | |
937 | Int_t nClustersSDD = 0; | |
938 | Int_t kNzBins = fNzSDD + 2; | |
939 | Int_t kMaxBin = kNzBins * (fNySDD+2); | |
940 | AliBin* bins[2] = {NULL, NULL}; | |
941 | ||
942 | // read raw data input stream | |
943 | while (kTRUE) { | |
944 | Bool_t next = input->Next(); | |
945 | if (!next || input->IsNewModule()) { | |
946 | Int_t iModule = input->GetPrevModuleID(); | |
947 | ||
948 | // when all data from a module was read, search for clusters | |
949 | if (bins[0]) { | |
950 | clusters[iModule] = new TClonesArray("AliITSclusterV2"); | |
951 | fI = iModule; | |
952 | FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]); | |
953 | Int_t nClusters = clusters[iModule]->GetEntriesFast(); | |
954 | nClustersSDD += nClusters; | |
955 | delete[] bins[0]; | |
956 | delete[] bins[1]; | |
957 | } | |
958 | ||
959 | if (!next) break; | |
960 | bins[0] = new AliBin[kMaxBin]; | |
961 | bins[1] = new AliBin[kMaxBin]; | |
962 | } | |
963 | ||
964 | // fill the current digit into the bins array | |
965 | Int_t iz = input->GetCoord1()+1; | |
966 | Int_t side = ((iz <= fNzSDD) ? 0 : 1); | |
967 | iz -= side*fNzSDD; | |
968 | Int_t index = (input->GetCoord2()+1) * kNzBins + iz; | |
969 | bins[side][index].SetQ(input->GetSignal()); | |
970 | bins[side][index].SetMask(1); | |
971 | bins[side][index].SetIndex(index); | |
972 | } | |
973 | ||
974 | Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD); | |
975 | } | |
976 | ||
e43c066c | 977 | |
978 | ||
c391f9d9 | 979 | void AliITSclustererV2:: |
980 | FindClustersSSD(Ali1Dcluster* neg, Int_t nn, | |
981 | Ali1Dcluster* pos, Int_t np, | |
982 | TClonesArray *clusters) { | |
983 | //------------------------------------------------------------ | |
984 | // Actual SSD cluster finder | |
985 | //------------------------------------------------------------ | |
986 | TClonesArray &cl=*clusters; | |
e43c066c | 987 | // |
c391f9d9 | 988 | Float_t tanp=fTanP, tann=fTanN; |
989 | if (fI>fLastSSD1) {tann=fTanP; tanp=fTanN;} | |
c391f9d9 | 990 | Int_t idet=fNdet[fI]; |
991 | Int_t ncl=0; | |
e43c066c | 992 | // |
993 | Int_t negativepair[30000]; | |
994 | Int_t cnegative[3000]; | |
995 | Int_t cused1[3000]; | |
996 | Int_t positivepair[30000]; | |
997 | Int_t cpositive[3000]; | |
998 | Int_t cused2[3000]; | |
999 | for (Int_t i=0;i<3000;i++) {cnegative[i]=0; cused1[i]=0;} | |
1000 | for (Int_t i=0;i<3000;i++) {cpositive[i]=0; cused2[i]=0;} | |
a06cb96e | 1001 | // Short_t pairs[1000][1000]; |
1002 | Short_t ** pairs = new Short_t*[1000]; | |
1003 | for (Int_t i=0; i<1000; i++) { | |
1004 | pairs[i] = new Short_t[1000]; | |
1005 | memset(pairs[i],0,sizeof(Short_t)*1000); | |
1006 | } | |
e43c066c | 1007 | // |
1008 | // find available pairs | |
1009 | // | |
1010 | for (Int_t i=0; i<np; i++) { | |
1011 | Float_t yp=pos[i].GetY()*fYpitchSSD; | |
1012 | if (pos[i].GetQ()<3) continue; | |
1013 | for (Int_t j=0; j<nn; j++) { | |
1014 | if (neg[j].GetQ()<3) continue; | |
1015 | Float_t yn=neg[j].GetY()*fYpitchSSD; | |
1016 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
1017 | Float_t yt=yn + tann*zt; | |
1018 | zt-=fHlSSD; yt-=fHwSSD; | |
1019 | if (TMath::Abs(yt)<fHwSSD+0.01) | |
1020 | if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) { | |
1021 | negativepair[i*10+cnegative[i]] =j; //index | |
1022 | positivepair[j*10+cpositive[j]] =i; | |
1023 | cnegative[i]++; //counters | |
1024 | cpositive[j]++; | |
1025 | pairs[i][j]=100; | |
1026 | } | |
1027 | } | |
1028 | } | |
1029 | // | |
1030 | for (Int_t i=0; i<np; i++) { | |
1031 | Float_t yp=pos[i].GetY()*fYpitchSSD; | |
1032 | if (pos[i].GetQ()<3) continue; | |
1033 | for (Int_t j=0; j<nn; j++) { | |
1034 | if (neg[j].GetQ()<3) continue; | |
1035 | if (cpositive[j]&&cnegative[i]) continue; | |
1036 | Float_t yn=neg[j].GetY()*fYpitchSSD; | |
1037 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
1038 | Float_t yt=yn + tann*zt; | |
1039 | zt-=fHlSSD; yt-=fHwSSD; | |
1040 | if (TMath::Abs(yt)<fHwSSD+0.1) | |
1041 | if (TMath::Abs(zt)<fHlSSD+0.15) { | |
1042 | if (cnegative[i]==0) pos[i].SetNd(100); // not available pair | |
1043 | if (cpositive[j]==0) neg[j].SetNd(100); // not available pair | |
1044 | negativepair[i*10+cnegative[i]] =j; //index | |
1045 | positivepair[j*10+cpositive[j]] =i; | |
1046 | cnegative[i]++; //counters | |
1047 | cpositive[j]++; | |
1048 | pairs[i][j]=100; | |
1049 | } | |
1050 | } | |
1051 | } | |
1052 | // | |
1053 | Float_t lp[5]; | |
1054 | Int_t milab[10]; | |
1055 | Double_t ratio; | |
1056 | ||
1057 | // | |
1058 | // sign gold tracks | |
1059 | // | |
1060 | for (Int_t ip=0;ip<np;ip++){ | |
1061 | Float_t ybest=1000,zbest=1000,qbest=0; | |
1062 | // | |
1063 | // select gold clusters | |
1064 | if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){ | |
1065 | Float_t yp=pos[ip].GetY()*fYpitchSSD; | |
1066 | Int_t j = negativepair[10*ip]; | |
1067 | ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ()); | |
1068 | // | |
1069 | Float_t yn=neg[j].GetY()*fYpitchSSD; | |
1070 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
1071 | Float_t yt=yn + tann*zt; | |
1072 | zt-=fHlSSD; yt-=fHwSSD; | |
1073 | ybest=yt; zbest=zt; | |
1074 | qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ()); | |
1075 | lp[0]=-(-ybest+fYshift[fI]); | |
1076 | lp[1]= -zbest+fZshift[fI]; | |
1077 | lp[2]=0.0025*0.0025; //SigmaY2 | |
1078 | lp[3]=0.110*0.110; //SigmaZ2 | |
1079 | ||
1080 | lp[4]=qbest; //Q | |
1081 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1082 | for (Int_t ilab=0;ilab<3;ilab++){ | |
1083 | milab[ilab] = pos[ip].GetLabel(ilab); | |
1084 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
1085 | } | |
1086 | // | |
1087 | CheckLabels2(milab); | |
1088 | milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det | |
1089 | Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fI]}; | |
1090 | AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
1091 | ncl++; | |
1092 | cl2->SetChargeRatio(ratio); | |
1093 | cl2->SetType(1); | |
1094 | pairs[ip][j]=1; | |
1095 | if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster | |
1096 | cl2->SetType(2); | |
1097 | pairs[ip][j]=2; | |
1098 | } | |
1099 | cused1[ip]++; | |
1100 | cused2[j]++; | |
1101 | } | |
1102 | } | |
1103 | ||
1104 | for (Int_t ip=0;ip<np;ip++){ | |
1105 | Float_t ybest=1000,zbest=1000,qbest=0; | |
1106 | // | |
1107 | // | |
1108 | // select "silber" cluster | |
1109 | if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){ | |
1110 | Int_t in = negativepair[10*ip]; | |
1111 | Int_t ip2 = positivepair[10*in]; | |
1112 | if (ip2==ip) ip2 = positivepair[10*in+1]; | |
1113 | Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ(); | |
1114 | if (TMath::Abs(pcharge-neg[in].GetQ())<10){ | |
1115 | // | |
1116 | // add first pair | |
1117 | if (pairs[ip][in]==100){ // | |
1118 | Float_t yp=pos[ip].GetY()*fYpitchSSD; | |
1119 | Float_t yn=neg[in].GetY()*fYpitchSSD; | |
1120 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
1121 | Float_t yt=yn + tann*zt; | |
1122 | zt-=fHlSSD; yt-=fHwSSD; | |
1123 | ybest =yt; zbest=zt; | |
1124 | qbest =pos[ip].GetQ(); | |
1125 | lp[0]=-(-ybest+fYshift[fI]); | |
1126 | lp[1]= -zbest+fZshift[fI]; | |
1127 | lp[2]=0.0025*0.0025; //SigmaY2 | |
1128 | lp[3]=0.110*0.110; //SigmaZ2 | |
1129 | ||
1130 | lp[4]=qbest; //Q | |
1131 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1132 | for (Int_t ilab=0;ilab<3;ilab++){ | |
1133 | milab[ilab] = pos[ip].GetLabel(ilab); | |
1134 | milab[ilab+3] = neg[in].GetLabel(ilab); | |
1135 | } | |
1136 | // | |
1137 | CheckLabels2(milab); | |
1138 | ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ()); | |
1139 | milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det | |
1140 | Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fI]}; | |
1141 | AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
1142 | ncl++; | |
1143 | cl2->SetChargeRatio(ratio); | |
1144 | cl2->SetType(5); | |
1145 | pairs[ip][in] = 5; | |
1146 | if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster | |
1147 | cl2->SetType(6); | |
1148 | pairs[ip][in] = 6; | |
1149 | } | |
1150 | } | |
1151 | // | |
1152 | // add second pair | |
1153 | ||
1154 | // if (!(cused1[ip2] || cused2[in])){ // | |
1155 | if (pairs[ip2][in]==100){ | |
1156 | Float_t yp=pos[ip2].GetY()*fYpitchSSD; | |
1157 | Float_t yn=neg[in].GetY()*fYpitchSSD; | |
1158 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
1159 | Float_t yt=yn + tann*zt; | |
1160 | zt-=fHlSSD; yt-=fHwSSD; | |
1161 | ybest =yt; zbest=zt; | |
1162 | qbest =pos[ip2].GetQ(); | |
1163 | lp[0]=-(-ybest+fYshift[fI]); | |
1164 | lp[1]= -zbest+fZshift[fI]; | |
1165 | lp[2]=0.0025*0.0025; //SigmaY2 | |
1166 | lp[3]=0.110*0.110; //SigmaZ2 | |
1167 | ||
1168 | lp[4]=qbest; //Q | |
1169 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1170 | for (Int_t ilab=0;ilab<3;ilab++){ | |
1171 | milab[ilab] = pos[ip2].GetLabel(ilab); | |
1172 | milab[ilab+3] = neg[in].GetLabel(ilab); | |
1173 | } | |
1174 | // | |
1175 | CheckLabels2(milab); | |
1176 | ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ()); | |
1177 | milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det | |
1178 | Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fI]}; | |
1179 | AliITSclusterV2 *cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
1180 | ncl++; | |
1181 | cl2->SetChargeRatio(ratio); | |
1182 | cl2->SetType(5); | |
1183 | pairs[ip2][in] =5; | |
1184 | if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster | |
1185 | cl2->SetType(6); | |
1186 | pairs[ip2][in] =6; | |
1187 | } | |
1188 | } | |
1189 | cused1[ip]++; | |
1190 | cused1[ip2]++; | |
1191 | cused2[in]++; | |
1192 | } | |
1193 | } | |
1194 | } | |
1195 | ||
1196 | // | |
1197 | for (Int_t jn=0;jn<nn;jn++){ | |
1198 | if (cused2[jn]) continue; | |
1199 | Float_t ybest=1000,zbest=1000,qbest=0; | |
1200 | // select "silber" cluster | |
1201 | if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){ | |
1202 | Int_t ip = positivepair[10*jn]; | |
1203 | Int_t jn2 = negativepair[10*ip]; | |
1204 | if (jn2==jn) jn2 = negativepair[10*ip+1]; | |
1205 | Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ(); | |
1206 | // | |
1207 | if (TMath::Abs(pcharge-pos[ip].GetQ())<10){ | |
1208 | // | |
1209 | // add first pair | |
1210 | // if (!(cused1[ip]||cused2[jn])){ | |
1211 | if (pairs[ip][jn]==100){ | |
1212 | Float_t yn=neg[jn].GetY()*fYpitchSSD; | |
1213 | Float_t yp=pos[ip].GetY()*fYpitchSSD; | |
1214 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
1215 | Float_t yt=yn + tann*zt; | |
1216 | zt-=fHlSSD; yt-=fHwSSD; | |
1217 | ybest =yt; zbest=zt; | |
1218 | qbest =neg[jn].GetQ(); | |
1219 | lp[0]=-(-ybest+fYshift[fI]); | |
1220 | lp[1]= -zbest+fZshift[fI]; | |
1221 | lp[2]=0.0025*0.0025; //SigmaY2 | |
1222 | lp[3]=0.110*0.110; //SigmaZ2 | |
1223 | ||
1224 | lp[4]=qbest; //Q | |
1225 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1226 | for (Int_t ilab=0;ilab<3;ilab++){ | |
1227 | milab[ilab] = pos[ip].GetLabel(ilab); | |
1228 | milab[ilab+3] = neg[jn].GetLabel(ilab); | |
1229 | } | |
1230 | // | |
1231 | CheckLabels2(milab); | |
1232 | ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ()); | |
1233 | milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det | |
1234 | Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fI]}; | |
1235 | AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
1236 | ncl++; | |
1237 | cl2->SetChargeRatio(ratio); | |
1238 | cl2->SetType(7); | |
1239 | pairs[ip][jn] =7; | |
1240 | if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster | |
1241 | cl2->SetType(8); | |
1242 | pairs[ip][jn]=8; | |
1243 | } | |
1244 | } | |
1245 | // | |
1246 | // add second pair | |
1247 | // if (!(cused1[ip]||cused2[jn2])){ | |
1248 | if (pairs[ip][jn2]==100){ | |
1249 | Float_t yn=neg[jn2].GetY()*fYpitchSSD; | |
1250 | Double_t yp=pos[ip].GetY()*fYpitchSSD; | |
1251 | Double_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
1252 | Double_t yt=yn + tann*zt; | |
1253 | zt-=fHlSSD; yt-=fHwSSD; | |
1254 | ybest =yt; zbest=zt; | |
1255 | qbest =neg[jn2].GetQ(); | |
1256 | lp[0]=-(-ybest+fYshift[fI]); | |
1257 | lp[1]= -zbest+fZshift[fI]; | |
1258 | lp[2]=0.0025*0.0025; //SigmaY2 | |
1259 | lp[3]=0.110*0.110; //SigmaZ2 | |
1260 | ||
1261 | lp[4]=qbest; //Q | |
1262 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1263 | for (Int_t ilab=0;ilab<3;ilab++){ | |
1264 | milab[ilab] = pos[ip].GetLabel(ilab); | |
1265 | milab[ilab+3] = neg[jn2].GetLabel(ilab); | |
1266 | } | |
1267 | // | |
1268 | CheckLabels2(milab); | |
1269 | ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ()); | |
1270 | milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det | |
1271 | Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fI]}; | |
1272 | AliITSclusterV2* cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
1273 | ncl++; | |
1274 | cl2->SetChargeRatio(ratio); | |
1275 | pairs[ip][jn2]=7; | |
1276 | cl2->SetType(7); | |
1277 | if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster | |
1278 | cl2->SetType(8); | |
1279 | pairs[ip][jn2]=8; | |
1280 | } | |
1281 | } | |
1282 | cused1[ip]++; | |
1283 | cused2[jn]++; | |
1284 | cused2[jn2]++; | |
1285 | } | |
1286 | } | |
1287 | } | |
1288 | ||
1289 | for (Int_t ip=0;ip<np;ip++){ | |
1290 | Float_t ybest=1000,zbest=1000,qbest=0; | |
1291 | // | |
1292 | // 2x2 clusters | |
1293 | // | |
1294 | if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){ | |
1295 | Float_t minchargediff =4.; | |
1296 | Int_t j=-1; | |
1297 | for (Int_t di=0;di<cnegative[ip];di++){ | |
1298 | Int_t jc = negativepair[ip*10+di]; | |
1299 | Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ(); | |
1300 | if (TMath::Abs(chargedif)<minchargediff){ | |
1301 | j =jc; | |
1302 | minchargediff = TMath::Abs(chargedif); | |
1303 | } | |
1304 | } | |
1305 | if (j<0) continue; // not proper cluster | |
1306 | Int_t count =0; | |
1307 | for (Int_t di=0;di<cnegative[ip];di++){ | |
1308 | Int_t jc = negativepair[ip*10+di]; | |
1309 | Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ(); | |
1310 | if (TMath::Abs(chargedif)<minchargediff+3.) count++; | |
1311 | } | |
1312 | if (count>1) continue; // more than one "proper" cluster for positive | |
1313 | // | |
1314 | count =0; | |
1315 | for (Int_t dj=0;dj<cpositive[j];dj++){ | |
1316 | Int_t ic = positivepair[j*10+dj]; | |
1317 | Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ(); | |
1318 | if (TMath::Abs(chargedif)<minchargediff+3.) count++; | |
1319 | } | |
1320 | if (count>1) continue; // more than one "proper" cluster for negative | |
1321 | ||
1322 | Int_t jp = 0; | |
1323 | ||
1324 | count =0; | |
1325 | for (Int_t dj=0;dj<cnegative[jp];dj++){ | |
1326 | Int_t ic = positivepair[jp*10+dj]; | |
1327 | Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ(); | |
1328 | if (TMath::Abs(chargedif)<minchargediff+4.) count++; | |
1329 | } | |
1330 | if (count>1) continue; | |
1331 | if (pairs[ip][j]<100) continue; | |
1332 | // | |
1333 | //almost gold clusters | |
1334 | Float_t yp=pos[ip].GetY()*fYpitchSSD; | |
1335 | Float_t yn=neg[j].GetY()*fYpitchSSD; | |
1336 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
1337 | Float_t yt=yn + tann*zt; | |
1338 | zt-=fHlSSD; yt-=fHwSSD; | |
1339 | ybest=yt; zbest=zt; | |
1340 | qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ()); | |
1341 | lp[0]=-(-ybest+fYshift[fI]); | |
1342 | lp[1]= -zbest+fZshift[fI]; | |
1343 | lp[2]=0.0025*0.0025; //SigmaY2 | |
1344 | lp[3]=0.110*0.110; //SigmaZ2 | |
1345 | lp[4]=qbest; //Q | |
1346 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1347 | for (Int_t ilab=0;ilab<3;ilab++){ | |
1348 | milab[ilab] = pos[ip].GetLabel(ilab); | |
1349 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
1350 | } | |
1351 | // | |
1352 | CheckLabels2(milab); | |
1353 | ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ()); | |
1354 | milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det | |
1355 | Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fI]}; | |
1356 | AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
1357 | ncl++; | |
1358 | cl2->SetChargeRatio(ratio); | |
1359 | cl2->SetType(10); | |
1360 | pairs[ip][j]=10; | |
1361 | if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster | |
1362 | cl2->SetType(11); | |
1363 | pairs[ip][j]=11; | |
1364 | } | |
1365 | cused1[ip]++; | |
1366 | cused2[j]++; | |
1367 | } | |
1368 | ||
1369 | } | |
1370 | ||
1371 | // | |
c391f9d9 | 1372 | for (Int_t i=0; i<np; i++) { |
c391f9d9 | 1373 | Float_t ybest=1000,zbest=1000,qbest=0; |
1374 | Float_t yp=pos[i].GetY()*fYpitchSSD; | |
e43c066c | 1375 | if (pos[i].GetQ()<3) continue; |
c391f9d9 | 1376 | for (Int_t j=0; j<nn; j++) { |
e43c066c | 1377 | // for (Int_t di = 0;di<cpositive[i];di++){ |
1378 | // Int_t j = negativepair[10*i+di]; | |
1379 | if (neg[j].GetQ()<3) continue; | |
1380 | if (cused2[j]||cused1[i]) continue; | |
1381 | if (pairs[i][j]>0 &&pairs[i][j]<100) continue; | |
1382 | ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ()); | |
c391f9d9 | 1383 | Float_t yn=neg[j].GetY()*fYpitchSSD; |
1384 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
1385 | Float_t yt=yn + tann*zt; | |
1386 | zt-=fHlSSD; yt-=fHwSSD; | |
1387 | if (TMath::Abs(yt)<fHwSSD+0.01) | |
e43c066c | 1388 | if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) { |
c391f9d9 | 1389 | ybest=yt; zbest=zt; |
1390 | qbest=0.5*(pos[i].GetQ()+neg[j].GetQ()); | |
f363d377 | 1391 | lp[0]=-(-ybest+fYshift[fI]); |
1392 | lp[1]= -zbest+fZshift[fI]; | |
e43c066c | 1393 | lp[2]=0.0025*0.0025; //SigmaY2 |
1394 | lp[3]=0.110*0.110; //SigmaZ2 | |
1395 | ||
c391f9d9 | 1396 | lp[4]=qbest; //Q |
babd135a | 1397 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; |
e43c066c | 1398 | for (Int_t ilab=0;ilab<3;ilab++){ |
1399 | milab[ilab] = pos[i].GetLabel(ilab); | |
1400 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
1401 | } | |
babd135a | 1402 | // |
babd135a | 1403 | CheckLabels2(milab); |
1404 | milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det | |
e43c066c | 1405 | Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fI]}; |
1406 | AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
1407 | ncl++; | |
1408 | cl2->SetChargeRatio(ratio); | |
1409 | cl2->SetType(100+cpositive[j]+cnegative[i]); | |
1410 | //cl2->SetType(0); | |
1411 | /* | |
1412 | if (pairs[i][j]<100){ | |
1413 | printf("problem:- %d\n", pairs[i][j]); | |
1414 | } | |
1415 | if (cnegative[i]<2&&cpositive[j]<2){ | |
1416 | printf("problem:- %d\n", pairs[i][j]); | |
1417 | } | |
1418 | */ | |
c391f9d9 | 1419 | } |
1420 | } | |
c391f9d9 | 1421 | } |
a06cb96e | 1422 | |
1423 | for (Int_t i=0; i<1000; i++) delete [] pairs[i]; | |
1424 | delete [] pairs; | |
1425 | ||
c391f9d9 | 1426 | } |
1427 | ||
e43c066c | 1428 | |
7f4044f0 | 1429 | void AliITSclustererV2:: |
e43c066c | 1430 | FindClustersSSD(const TClonesArray *alldigits, TClonesArray *clusters) { |
7f4044f0 | 1431 | //------------------------------------------------------------ |
1432 | // Actual SSD cluster finder | |
1433 | //------------------------------------------------------------ | |
e43c066c | 1434 | Int_t smaxall=alldigits->GetEntriesFast(); |
1435 | if (smaxall==0) return; | |
1436 | TObjArray *digits = new TObjArray; | |
1437 | for (Int_t i=0;i<smaxall; i++){ | |
1438 | AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i); | |
1439 | if (d->GetSignal()<3) continue; | |
1440 | digits->AddLast(d); | |
1441 | } | |
1442 | Int_t smax = digits->GetEntriesFast(); | |
7f4044f0 | 1443 | if (smax==0) return; |
e43c066c | 1444 | |
7f4044f0 | 1445 | const Int_t MAX=1000; |
1446 | Int_t np=0, nn=0; | |
1447 | Ali1Dcluster pos[MAX], neg[MAX]; | |
1448 | Float_t y=0., q=0., qmax=0.; | |
1449 | Int_t lab[4]={-2,-2,-2,-2}; | |
e43c066c | 1450 | |
7f4044f0 | 1451 | AliITSdigitSSD *d=(AliITSdigitSSD*)digits->UncheckedAt(0); |
1452 | q += d->GetSignal(); | |
1453 | y += d->GetCoord2()*d->GetSignal(); | |
1454 | qmax=d->GetSignal(); | |
1455 | lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2); | |
1456 | Int_t curr=d->GetCoord2(); | |
1457 | Int_t flag=d->GetCoord1(); | |
1458 | Int_t *n=&nn; | |
1459 | Ali1Dcluster *c=neg; | |
c391f9d9 | 1460 | Int_t nd=1; |
e43c066c | 1461 | Int_t milab[10]; |
1462 | for (Int_t ilab=0;ilab<10;ilab++){ | |
1463 | milab[ilab]=-2; | |
1464 | } | |
1465 | milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2); | |
1466 | ||
7f4044f0 | 1467 | for (Int_t s=1; s<smax; s++) { |
e43c066c | 1468 | d=(AliITSdigitSSD*)digits->UncheckedAt(s); |
7f4044f0 | 1469 | Int_t strip=d->GetCoord2(); |
1470 | if ((strip-curr) > 1 || flag!=d->GetCoord1()) { | |
1471 | c[*n].SetY(y/q); | |
1472 | c[*n].SetQ(q); | |
1473 | c[*n].SetNd(nd); | |
e43c066c | 1474 | CheckLabels2(milab); |
1475 | c[*n].SetLabels(milab); | |
7f4044f0 | 1476 | //Split suspiciously big cluster |
e43c066c | 1477 | /* |
1478 | if (nd>10&&nd<16){ | |
1479 | c[*n].SetY(y/q-0.3*nd); | |
1480 | c[*n].SetQ(0.5*q); | |
1481 | (*n)++; | |
1482 | if (*n==MAX) { | |
1483 | Error("FindClustersSSD","Too many 1D clusters !"); | |
7f4044f0 | 1484 | return; |
e43c066c | 1485 | } |
1486 | c[*n].SetY(y/q-0.0*nd); | |
1487 | c[*n].SetQ(0.5*q); | |
1488 | c[*n].SetNd(nd); | |
1489 | (*n)++; | |
1490 | if (*n==MAX) { | |
1491 | Error("FindClustersSSD","Too many 1D clusters !"); | |
1492 | return; | |
1493 | } | |
1494 | // | |
1495 | c[*n].SetY(y/q+0.3*nd); | |
1496 | c[*n].SetQ(0.5*q); | |
1497 | c[*n].SetNd(nd); | |
1498 | c[*n].SetLabels(milab); | |
1499 | } | |
1500 | else{ | |
1501 | */ | |
1502 | if (nd>4&&nd<25) { | |
1503 | c[*n].SetY(y/q-0.25*nd); | |
1504 | c[*n].SetQ(0.5*q); | |
1505 | (*n)++; | |
1506 | if (*n==MAX) { | |
1507 | Error("FindClustersSSD","Too many 1D clusters !"); | |
1508 | return; | |
1509 | } | |
1510 | c[*n].SetY(y/q+0.25*nd); | |
1511 | c[*n].SetQ(0.5*q); | |
1512 | c[*n].SetNd(nd); | |
1513 | c[*n].SetLabels(milab); | |
1514 | } | |
7f4044f0 | 1515 | (*n)++; |
1516 | if (*n==MAX) { | |
c630aafd | 1517 | Error("FindClustersSSD","Too many 1D clusters !"); |
7f4044f0 | 1518 | return; |
1519 | } | |
1520 | y=q=qmax=0.; | |
1521 | nd=0; | |
1522 | lab[0]=lab[1]=lab[2]=-2; | |
e43c066c | 1523 | // |
1524 | for (Int_t ilab=0;ilab<10;ilab++){ | |
1525 | milab[ilab]=-2; | |
1526 | } | |
1527 | // | |
7f4044f0 | 1528 | if (flag!=d->GetCoord1()) { n=&np; c=pos; } |
1529 | } | |
1530 | flag=d->GetCoord1(); | |
1531 | q += d->GetSignal(); | |
1532 | y += d->GetCoord2()*d->GetSignal(); | |
1533 | nd++; | |
1534 | if (d->GetSignal()>qmax) { | |
1535 | qmax=d->GetSignal(); | |
1536 | lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2); | |
1537 | } | |
e43c066c | 1538 | for (Int_t ilab=0;ilab<10;ilab++) { |
1539 | if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab))); | |
1540 | } | |
7f4044f0 | 1541 | curr=strip; |
1542 | } | |
1543 | c[*n].SetY(y/q); | |
1544 | c[*n].SetQ(q); | |
1545 | c[*n].SetNd(nd); | |
1546 | c[*n].SetLabels(lab); | |
1547 | //Split suspiciously big cluster | |
1548 | if (nd>3) { | |
1549 | c[*n].SetY(y/q-0.5*nd); | |
1550 | c[*n].SetQ(0.5*q); | |
1551 | (*n)++; | |
1552 | if (*n==MAX) { | |
c630aafd | 1553 | Error("FindClustersSSD","Too many 1D clusters !"); |
7f4044f0 | 1554 | return; |
1555 | } | |
1556 | c[*n].SetY(y/q+0.5*nd); | |
1557 | c[*n].SetQ(0.5*q); | |
1558 | c[*n].SetNd(nd); | |
1559 | c[*n].SetLabels(lab); | |
1560 | } | |
1561 | (*n)++; | |
1562 | if (*n==MAX) { | |
c630aafd | 1563 | Error("FindClustersSSD","Too many 1D clusters !"); |
7f4044f0 | 1564 | return; |
1565 | } | |
1566 | ||
c391f9d9 | 1567 | FindClustersSSD(neg, nn, pos, np, clusters); |
1568 | } | |
7f4044f0 | 1569 | |
c391f9d9 | 1570 | void AliITSclustererV2::FindClustersSSD(AliITSRawStream* input, |
1571 | TClonesArray** clusters) | |
1572 | { | |
1573 | //------------------------------------------------------------ | |
1574 | // Actual SSD cluster finder for raw data | |
1575 | //------------------------------------------------------------ | |
1576 | Int_t nClustersSSD = 0; | |
1577 | const Int_t MAX = 1000; | |
1578 | Ali1Dcluster clusters1D[2][MAX]; | |
1579 | Int_t nClusters[2] = {0, 0}; | |
1580 | Float_t q = 0.; | |
1581 | Float_t y = 0.; | |
1582 | Int_t nDigits = 0; | |
1583 | Int_t prevStrip = -1; | |
1584 | Int_t prevFlag = -1; | |
1585 | ||
1586 | // read raw data input stream | |
1587 | while (kTRUE) { | |
1588 | Bool_t next = input->Next(); | |
1589 | ||
1590 | // check if a new cluster starts | |
1591 | Int_t strip = input->GetCoord2(); | |
1592 | Int_t flag = input->GetCoord1(); | |
1593 | if ((!next || input->IsNewModule() || | |
1594 | (strip-prevStrip > 1) || (flag != prevFlag)) && | |
1595 | (nDigits > 0)) { | |
1596 | if (nClusters[prevFlag] == MAX) { | |
1597 | Error("FindClustersSSD", "Too many 1D clusters !"); | |
1598 | return; | |
1599 | } | |
1600 | Ali1Dcluster& cluster = clusters1D[prevFlag][nClusters[prevFlag]++]; | |
1601 | cluster.SetY(y/q); | |
1602 | cluster.SetQ(q); | |
1603 | cluster.SetNd(nDigits); | |
1604 | ||
1605 | //Split suspiciously big cluster | |
1606 | if (nDigits > 3) { | |
1607 | cluster.SetY(y/q - 0.5*nDigits); | |
1608 | cluster.SetQ(0.5*q); | |
1609 | if (nClusters[prevFlag] == MAX) { | |
1610 | Error("FindClustersSSD", "Too many 1D clusters !"); | |
1611 | return; | |
1612 | } | |
1613 | Ali1Dcluster& cluster2 = clusters1D[prevFlag][nClusters[prevFlag]++]; | |
1614 | cluster2.SetY(y/q + 0.5*nDigits); | |
1615 | cluster2.SetQ(0.5*q); | |
1616 | cluster2.SetNd(nDigits); | |
7f4044f0 | 1617 | } |
c391f9d9 | 1618 | y = q = 0.; |
1619 | nDigits = 0; | |
7f4044f0 | 1620 | } |
c391f9d9 | 1621 | |
1622 | if (!next || input->IsNewModule()) { | |
1623 | Int_t iModule = input->GetPrevModuleID(); | |
1624 | ||
1625 | // when all data from a module was read, search for clusters | |
1626 | if (prevFlag >= 0) { | |
1627 | clusters[iModule] = new TClonesArray("AliITSclusterV2"); | |
1628 | fI = iModule; | |
1629 | FindClustersSSD(&clusters1D[0][0], nClusters[0], | |
1630 | &clusters1D[1][0], nClusters[1], clusters[iModule]); | |
1631 | Int_t nClusters = clusters[iModule]->GetEntriesFast(); | |
1632 | nClustersSSD += nClusters; | |
1633 | } | |
1634 | ||
1635 | if (!next) break; | |
1636 | nClusters[0] = nClusters[1] = 0; | |
1637 | y = q = 0.; | |
1638 | nDigits = 0; | |
7f4044f0 | 1639 | } |
c391f9d9 | 1640 | |
1641 | // add digit to current cluster | |
1642 | q += input->GetSignal(); | |
1643 | y += strip * input->GetSignal(); | |
1644 | nDigits++; | |
1645 | prevStrip = strip; | |
1646 | prevFlag = flag; | |
7f4044f0 | 1647 | } |
c391f9d9 | 1648 | |
1649 | Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD); | |
7f4044f0 | 1650 | } |
1651 | ||
1652 | #else //V1 | |
1653 | ||
1654 | #include "AliITSDetType.h" | |
1655 | ||
1656 | #include "AliITSsegmentationSPD.h" | |
1657 | #include "AliITSClusterFinderSPD.h" | |
1658 | ||
1659 | #include "AliITSresponseSDD.h" | |
1660 | #include "AliITSsegmentationSDD.h" | |
1661 | #include "AliITSClusterFinderSDD.h" | |
1662 | ||
1663 | #include "AliITSsegmentationSSD.h" | |
1664 | #include "AliITSClusterFinderSSD.h" | |
1665 | ||
1666 | ||
1667 | void AliITSclustererV2:: | |
1668 | FindClustersSPD(const TClonesArray *digits, TClonesArray *clusters) { | |
1669 | //------------------------------------------------------------ | |
1670 | // Actual SPD cluster finding based on AliITSClusterFinderSPD | |
1671 | //------------------------------------------------------------ | |
1672 | static AliITS *its=(AliITS*)gAlice->GetModule("ITS"); | |
1673 | static TClonesArray *points=its->RecPoints(); | |
1674 | static AliITSsegmentationSPD *seg= | |
1675 | (AliITSsegmentationSPD *)its->DetType(0)->GetSegmentationModel(); | |
1676 | static AliITSClusterFinderSPD cf(seg, (TClonesArray*)digits, points); | |
1677 | ||
1678 | cf.FindRawClusters(fI); | |
1cca57bf | 1679 | RecPoints2Clusters(points, fI, clusters); |
7f4044f0 | 1680 | its->ResetRecPoints(); |
1681 | ||
1682 | } | |
1683 | ||
1684 | void AliITSclustererV2:: | |
1685 | FindClustersSDD(const TClonesArray *digits, TClonesArray *clusters) { | |
1686 | //------------------------------------------------------------ | |
1687 | // Actual SDD cluster finding based on AliITSClusterFinderSDD | |
1688 | //------------------------------------------------------------ | |
1689 | static AliITS *its=(AliITS*)gAlice->GetModule("ITS"); | |
1690 | static TClonesArray *points=its->RecPoints(); | |
1691 | static AliITSresponseSDD *resp= | |
1692 | (AliITSresponseSDD *)its->DetType(1)->GetResponseModel(); | |
1693 | static AliITSsegmentationSDD *seg= | |
1694 | (AliITSsegmentationSDD *)its->DetType(1)->GetSegmentationModel(); | |
1695 | static AliITSClusterFinderSDD | |
1696 | cf(seg,resp,(TClonesArray*)digits,its->ClustersAddress(1)); | |
1697 | ||
1698 | cf.FindRawClusters(fI); | |
1cca57bf | 1699 | Int_t nc=points->GetEntriesFast(); |
1700 | while (nc--) { //To be consistent with the SSD cluster charges | |
1701 | AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(nc); | |
e3d91d99 | 1702 | p->SetQ(p->GetQ()/12.); |
1cca57bf | 1703 | } |
1704 | RecPoints2Clusters(points, fI, clusters); | |
7f4044f0 | 1705 | its->ResetClusters(1); |
1706 | its->ResetRecPoints(); | |
1707 | ||
1708 | } | |
1709 | ||
1710 | void AliITSclustererV2:: | |
1711 | FindClustersSSD(const TClonesArray *digits, TClonesArray *clusters) { | |
1712 | //------------------------------------------------------------ | |
1713 | // Actual SSD cluster finding based on AliITSClusterFinderSSD | |
1714 | //------------------------------------------------------------ | |
1715 | static AliITS *its=(AliITS*)gAlice->GetModule("ITS"); | |
1716 | static TClonesArray *points=its->RecPoints(); | |
1717 | static AliITSsegmentationSSD *seg= | |
1718 | (AliITSsegmentationSSD *)its->DetType(2)->GetSegmentationModel(); | |
1719 | static AliITSClusterFinderSSD cf(seg,(TClonesArray*)digits); | |
1720 | ||
1721 | cf.FindRawClusters(fI); | |
1cca57bf | 1722 | RecPoints2Clusters(points, fI, clusters); |
7f4044f0 | 1723 | its->ResetRecPoints(); |
1724 | ||
1725 | } | |
1726 | ||
1727 | #endif |