]>
Commit | Line | Data |
---|---|---|
04366a57 | 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 | // Implementation of the ITS clusterer V2 class // | |
17 | // // | |
18 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch // | |
19 | // // | |
20 | /////////////////////////////////////////////////////////////////////////// | |
21 | ||
04366a57 | 22 | |
23 | #include "AliITSClusterFinderV2SSD.h" | |
24 | #include "AliITSclusterV2.h" | |
7d62fb64 | 25 | #include "AliITSDetTypeRec.h" |
04366a57 | 26 | #include "AliRawReader.h" |
27 | #include "AliITSRawStreamSSD.h" | |
28 | ||
29 | #include <TClonesArray.h> | |
04366a57 | 30 | #include "AliITSgeom.h" |
31 | #include "AliITSdigitSSD.h" | |
32 | ||
33 | ClassImp(AliITSClusterFinderV2SSD) | |
34 | ||
35 | ||
7d62fb64 | 36 | AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(AliITSgeom* geom):AliITSClusterFinderV2(geom){ |
04366a57 | 37 | |
38 | //Default constructor | |
39 | ||
7d62fb64 | 40 | fITSgeom = geom; |
41 | fLastSSD1=fITSgeom->GetModuleIndex(6,1,1)-1; | |
04366a57 | 42 | fYpitchSSD=0.0095; |
43 | fHwSSD=3.65; | |
44 | fHlSSD=2.00; | |
45 | fTanP=0.0275; | |
46 | fTanN=0.0075; | |
47 | ||
48 | ||
49 | ||
50 | } | |
51 | ||
52 | ||
53 | void AliITSClusterFinderV2SSD::FindRawClusters(Int_t mod){ | |
54 | ||
55 | //Find clusters V2 | |
56 | SetModule(mod); | |
57 | FindClustersSSD(fDigits); | |
58 | ||
59 | } | |
60 | ||
61 | void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) { | |
62 | //------------------------------------------------------------ | |
63 | // Actual SSD cluster finder | |
64 | //------------------------------------------------------------ | |
65 | Int_t smaxall=alldigits->GetEntriesFast(); | |
66 | if (smaxall==0) return; | |
67 | TObjArray *digits = new TObjArray; | |
68 | for (Int_t i=0;i<smaxall; i++){ | |
69 | AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i); | |
70 | if (d->GetSignal()<3) continue; | |
71 | digits->AddLast(d); | |
72 | } | |
73 | Int_t smax = digits->GetEntriesFast(); | |
74 | if (smax==0) return; | |
75 | ||
76 | const Int_t kMax=1000; | |
77 | Int_t np=0, nn=0; | |
78 | Ali1Dcluster pos[kMax], neg[kMax]; | |
79 | Float_t y=0., q=0., qmax=0.; | |
80 | Int_t lab[4]={-2,-2,-2,-2}; | |
81 | ||
82 | AliITSdigitSSD *d=(AliITSdigitSSD*)digits->UncheckedAt(0); | |
83 | q += d->GetSignal(); | |
84 | y += d->GetCoord2()*d->GetSignal(); | |
85 | qmax=d->GetSignal(); | |
86 | lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2); | |
87 | Int_t curr=d->GetCoord2(); | |
88 | Int_t flag=d->GetCoord1(); | |
89 | Int_t *n=&nn; | |
90 | Ali1Dcluster *c=neg; | |
91 | Int_t nd=1; | |
92 | Int_t milab[10]; | |
93 | for (Int_t ilab=0;ilab<10;ilab++){ | |
94 | milab[ilab]=-2; | |
95 | } | |
96 | milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2); | |
97 | ||
98 | for (Int_t s=1; s<smax; s++) { | |
99 | d=(AliITSdigitSSD*)digits->UncheckedAt(s); | |
100 | Int_t strip=d->GetCoord2(); | |
101 | if ((strip-curr) > 1 || flag!=d->GetCoord1()) { | |
102 | c[*n].SetY(y/q); | |
103 | c[*n].SetQ(q); | |
104 | c[*n].SetNd(nd); | |
105 | CheckLabels2(milab); | |
106 | c[*n].SetLabels(milab); | |
107 | //Split suspiciously big cluster | |
108 | /* | |
109 | if (nd>10&&nd<16){ | |
110 | c[*n].SetY(y/q-0.3*nd); | |
111 | c[*n].SetQ(0.5*q); | |
112 | (*n)++; | |
113 | if (*n==MAX) { | |
114 | Error("FindClustersSSD","Too many 1D clusters !"); | |
115 | return; | |
116 | } | |
117 | c[*n].SetY(y/q-0.0*nd); | |
118 | c[*n].SetQ(0.5*q); | |
119 | c[*n].SetNd(nd); | |
120 | (*n)++; | |
121 | if (*n==MAX) { | |
122 | Error("FindClustersSSD","Too many 1D clusters !"); | |
123 | return; | |
124 | } | |
125 | // | |
126 | c[*n].SetY(y/q+0.3*nd); | |
127 | c[*n].SetQ(0.5*q); | |
128 | c[*n].SetNd(nd); | |
129 | c[*n].SetLabels(milab); | |
130 | } | |
131 | else{ | |
132 | */ | |
133 | if (nd>4&&nd<25) { | |
134 | c[*n].SetY(y/q-0.25*nd); | |
135 | c[*n].SetQ(0.5*q); | |
136 | (*n)++; | |
137 | if (*n==kMax) { | |
138 | Error("FindClustersSSD","Too many 1D clusters !"); | |
139 | return; | |
140 | } | |
141 | c[*n].SetY(y/q+0.25*nd); | |
142 | c[*n].SetQ(0.5*q); | |
143 | c[*n].SetNd(nd); | |
144 | c[*n].SetLabels(milab); | |
145 | } | |
146 | (*n)++; | |
147 | if (*n==kMax) { | |
148 | Error("FindClustersSSD","Too many 1D clusters !"); | |
149 | return; | |
150 | } | |
151 | y=q=qmax=0.; | |
152 | nd=0; | |
153 | lab[0]=lab[1]=lab[2]=-2; | |
154 | // | |
155 | for (Int_t ilab=0;ilab<10;ilab++){ | |
156 | milab[ilab]=-2; | |
157 | } | |
158 | // | |
159 | if (flag!=d->GetCoord1()) { n=&np; c=pos; } | |
160 | } | |
161 | flag=d->GetCoord1(); | |
162 | q += d->GetSignal(); | |
163 | y += d->GetCoord2()*d->GetSignal(); | |
164 | nd++; | |
165 | if (d->GetSignal()>qmax) { | |
166 | qmax=d->GetSignal(); | |
167 | lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2); | |
168 | } | |
169 | for (Int_t ilab=0;ilab<10;ilab++) { | |
170 | if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab))); | |
171 | } | |
172 | curr=strip; | |
173 | } | |
174 | c[*n].SetY(y/q); | |
175 | c[*n].SetQ(q); | |
176 | c[*n].SetNd(nd); | |
177 | c[*n].SetLabels(lab); | |
178 | //Split suspiciously big cluster | |
179 | if (nd>4 && nd<25) { | |
180 | c[*n].SetY(y/q-0.25*nd); | |
181 | c[*n].SetQ(0.5*q); | |
182 | (*n)++; | |
183 | if (*n==kMax) { | |
184 | Error("FindClustersSSD","Too many 1D clusters !"); | |
185 | return; | |
186 | } | |
187 | c[*n].SetY(y/q+0.25*nd); | |
188 | c[*n].SetQ(0.5*q); | |
189 | c[*n].SetNd(nd); | |
190 | c[*n].SetLabels(lab); | |
191 | } | |
192 | (*n)++; | |
193 | if (*n==kMax) { | |
194 | Error("FindClustersSSD","Too many 1D clusters !"); | |
195 | return; | |
196 | } | |
197 | ||
198 | FindClustersSSD(neg, nn, pos, np); | |
199 | } | |
200 | ||
201 | ||
202 | void AliITSClusterFinderV2SSD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){ | |
203 | ||
204 | //------------------------------------------------------------ | |
205 | // This function creates ITS clusters from raw data | |
206 | //------------------------------------------------------------ | |
207 | rawReader->Reset(); | |
208 | AliITSRawStreamSSD inputSSD(rawReader); | |
209 | FindClustersSSD(&inputSSD,clusters); | |
210 | ||
211 | } | |
212 | ||
213 | void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStream* input, | |
214 | TClonesArray** clusters) | |
215 | { | |
216 | //------------------------------------------------------------ | |
217 | // Actual SSD cluster finder for raw data | |
218 | //------------------------------------------------------------ | |
219 | Int_t nClustersSSD = 0; | |
220 | const Int_t kMax = 1000; | |
221 | Ali1Dcluster clusters1D[2][kMax]; | |
222 | Int_t nClusters[2] = {0, 0}; | |
223 | Int_t lab[3]={-2,-2,-2}; | |
224 | Float_t q = 0.; | |
225 | Float_t y = 0.; | |
226 | Int_t nDigits = 0; | |
227 | Int_t prevStrip = -1; | |
228 | Int_t prevFlag = -1; | |
229 | Int_t prevModule = -1; | |
230 | ||
231 | // read raw data input stream | |
232 | while (kTRUE) { | |
233 | Bool_t next = input->Next(); | |
234 | ||
235 | if(input->GetSignal()<3 && next) continue; | |
236 | // check if a new cluster starts | |
237 | Int_t strip = input->GetCoord2(); | |
238 | Int_t flag = input->GetCoord1(); | |
239 | if ((!next || (input->GetModuleID() != prevModule)|| | |
240 | (strip-prevStrip > 1) || (flag != prevFlag)) && | |
241 | (nDigits > 0)) { | |
242 | if (nClusters[prevFlag] == kMax) { | |
243 | Error("FindClustersSSD", "Too many 1D clusters !"); | |
244 | return; | |
245 | } | |
246 | Ali1Dcluster& cluster = clusters1D[prevFlag][nClusters[prevFlag]++]; | |
247 | cluster.SetY(y/q); | |
248 | cluster.SetQ(q); | |
249 | cluster.SetNd(nDigits); | |
250 | cluster.SetLabels(lab); | |
251 | ||
252 | //Split suspiciously big cluster | |
253 | if (nDigits > 4&&nDigits < 25) { | |
254 | cluster.SetY(y/q - 0.25*nDigits); | |
255 | cluster.SetQ(0.5*q); | |
256 | if (nClusters[prevFlag] == kMax) { | |
257 | Error("FindClustersSSD", "Too many 1D clusters !"); | |
258 | return; | |
259 | } | |
260 | Ali1Dcluster& cluster2 = clusters1D[prevFlag][nClusters[prevFlag]++]; | |
261 | cluster2.SetY(y/q + 0.25*nDigits); | |
262 | cluster2.SetQ(0.5*q); | |
263 | cluster2.SetNd(nDigits); | |
264 | cluster2.SetLabels(lab); | |
265 | } | |
266 | y = q = 0.; | |
267 | nDigits = 0; | |
268 | } | |
269 | ||
270 | if (!next || (input->GetModuleID() != prevModule)) { | |
271 | Int_t iModule = prevModule; | |
272 | ||
273 | // when all data from a module was read, search for clusters | |
274 | if (prevFlag >= 0) { | |
275 | clusters[iModule] = new TClonesArray("AliITSclusterV2"); | |
276 | fModule = iModule; | |
277 | FindClustersSSD(&clusters1D[0][0], nClusters[0], | |
278 | &clusters1D[1][0], nClusters[1], clusters[iModule]); | |
279 | Int_t nClusters = clusters[iModule]->GetEntriesFast(); | |
280 | nClustersSSD += nClusters; | |
281 | } | |
282 | ||
283 | if (!next) break; | |
284 | nClusters[0] = nClusters[1] = 0; | |
285 | y = q = 0.; | |
286 | nDigits = 0; | |
287 | } | |
288 | ||
289 | // add digit to current cluster | |
290 | q += input->GetSignal(); | |
291 | y += strip * input->GetSignal(); | |
292 | nDigits++; | |
293 | prevStrip = strip; | |
294 | prevFlag = flag; | |
295 | prevModule = input->GetModuleID(); | |
296 | ||
297 | } | |
298 | ||
299 | Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD); | |
300 | } | |
301 | ||
302 | void AliITSClusterFinderV2SSD:: | |
303 | FindClustersSSD(Ali1Dcluster* neg, Int_t nn, | |
304 | Ali1Dcluster* pos, Int_t np, | |
305 | TClonesArray *clusters) { | |
306 | //------------------------------------------------------------ | |
307 | // Actual SSD cluster finder | |
308 | //------------------------------------------------------------ | |
309 | TClonesArray &cl=*clusters; | |
310 | // | |
311 | Float_t tanp=fTanP, tann=fTanN; | |
312 | if (fModule>fLastSSD1) {tann=fTanP; tanp=fTanN;} | |
313 | Int_t idet=fNdet[fModule]; | |
314 | Int_t ncl=0; | |
315 | // | |
316 | Int_t negativepair[30000]; | |
317 | Int_t cnegative[3000]; | |
318 | Int_t cused1[3000]; | |
319 | Int_t positivepair[30000]; | |
320 | Int_t cpositive[3000]; | |
321 | Int_t cused2[3000]; | |
322 | for (Int_t i=0;i<3000;i++) {cnegative[i]=0; cused1[i]=0;} | |
323 | for (Int_t i=0;i<3000;i++) {cpositive[i]=0; cused2[i]=0;} | |
324 | static Short_t pairs[1000][1000]; | |
325 | memset(pairs,0,sizeof(Short_t)*1000000); | |
326 | // Short_t ** pairs = new Short_t*[1000]; | |
327 | // for (Int_t i=0; i<1000; i++) { | |
328 | // pairs[i] = new Short_t[1000]; | |
329 | // memset(pairs[i],0,sizeof(Short_t)*1000); | |
330 | // } | |
331 | // | |
332 | // find available pairs | |
333 | // | |
334 | for (Int_t i=0; i<np; i++) { | |
335 | Float_t yp=pos[i].GetY()*fYpitchSSD; | |
336 | if (pos[i].GetQ()<3) continue; | |
337 | for (Int_t j=0; j<nn; j++) { | |
338 | if (neg[j].GetQ()<3) continue; | |
339 | Float_t yn=neg[j].GetY()*fYpitchSSD; | |
340 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
341 | Float_t yt=yn + tann*zt; | |
342 | zt-=fHlSSD; yt-=fHwSSD; | |
343 | if (TMath::Abs(yt)<fHwSSD+0.01) | |
344 | if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) { | |
345 | negativepair[i*10+cnegative[i]] =j; //index | |
346 | positivepair[j*10+cpositive[j]] =i; | |
347 | cnegative[i]++; //counters | |
348 | cpositive[j]++; | |
349 | pairs[i][j]=100; | |
350 | } | |
351 | } | |
352 | } | |
353 | // | |
354 | for (Int_t i=0; i<np; i++) { | |
355 | Float_t yp=pos[i].GetY()*fYpitchSSD; | |
356 | if (pos[i].GetQ()<3) continue; | |
357 | for (Int_t j=0; j<nn; j++) { | |
358 | if (neg[j].GetQ()<3) continue; | |
359 | if (cpositive[j]&&cnegative[i]) continue; | |
360 | Float_t yn=neg[j].GetY()*fYpitchSSD; | |
361 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
362 | Float_t yt=yn + tann*zt; | |
363 | zt-=fHlSSD; yt-=fHwSSD; | |
364 | if (TMath::Abs(yt)<fHwSSD+0.1) | |
365 | if (TMath::Abs(zt)<fHlSSD+0.15) { | |
366 | if (cnegative[i]==0) pos[i].SetNd(100); // not available pair | |
367 | if (cpositive[j]==0) neg[j].SetNd(100); // not available pair | |
368 | negativepair[i*10+cnegative[i]] =j; //index | |
369 | positivepair[j*10+cpositive[j]] =i; | |
370 | cnegative[i]++; //counters | |
371 | cpositive[j]++; | |
372 | pairs[i][j]=100; | |
373 | } | |
374 | } | |
375 | } | |
376 | // | |
377 | Float_t lp[5]; | |
378 | Int_t milab[10]; | |
379 | Double_t ratio; | |
380 | ||
381 | // | |
382 | // sign gold tracks | |
383 | // | |
384 | for (Int_t ip=0;ip<np;ip++){ | |
385 | Float_t ybest=1000,zbest=1000,qbest=0; | |
386 | // | |
387 | // select gold clusters | |
388 | if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){ | |
389 | Float_t yp=pos[ip].GetY()*fYpitchSSD; | |
390 | Int_t j = negativepair[10*ip]; | |
391 | ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ()); | |
392 | // | |
393 | Float_t yn=neg[j].GetY()*fYpitchSSD; | |
394 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
395 | Float_t yt=yn + tann*zt; | |
396 | zt-=fHlSSD; yt-=fHwSSD; | |
397 | ybest=yt; zbest=zt; | |
398 | qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ()); | |
399 | lp[0]=-(-ybest+fYshift[fModule]); | |
400 | lp[1]= -zbest+fZshift[fModule]; | |
401 | lp[2]=0.0025*0.0025; //SigmaY2 | |
402 | lp[3]=0.110*0.110; //SigmaZ2 | |
403 | ||
404 | lp[4]=qbest; //Q | |
405 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
406 | for (Int_t ilab=0;ilab<3;ilab++){ | |
407 | milab[ilab] = pos[ip].GetLabel(ilab); | |
408 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
409 | } | |
410 | // | |
411 | CheckLabels2(milab); | |
412 | milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det | |
413 | Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]}; | |
414 | AliITSclusterV2 * cl2; | |
415 | if(clusters) cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
416 | else{ | |
417 | cl2 = new AliITSclusterV2(milab,lp,info); | |
7d62fb64 | 418 | fDetTypeRec->AddClusterV2(*cl2); |
04366a57 | 419 | } |
420 | ncl++; | |
421 | cl2->SetChargeRatio(ratio); | |
422 | cl2->SetType(1); | |
423 | pairs[ip][j]=1; | |
424 | if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster | |
425 | cl2->SetType(2); | |
426 | pairs[ip][j]=2; | |
427 | } | |
428 | cused1[ip]++; | |
429 | cused2[j]++; | |
430 | } | |
431 | } | |
432 | ||
433 | for (Int_t ip=0;ip<np;ip++){ | |
434 | Float_t ybest=1000,zbest=1000,qbest=0; | |
435 | // | |
436 | // | |
437 | // select "silber" cluster | |
438 | if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){ | |
439 | Int_t in = negativepair[10*ip]; | |
440 | Int_t ip2 = positivepair[10*in]; | |
441 | if (ip2==ip) ip2 = positivepair[10*in+1]; | |
442 | Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ(); | |
443 | if (TMath::Abs(pcharge-neg[in].GetQ())<10){ | |
444 | // | |
445 | // add first pair | |
446 | if (pairs[ip][in]==100){ // | |
447 | Float_t yp=pos[ip].GetY()*fYpitchSSD; | |
448 | Float_t yn=neg[in].GetY()*fYpitchSSD; | |
449 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
450 | Float_t yt=yn + tann*zt; | |
451 | zt-=fHlSSD; yt-=fHwSSD; | |
452 | ybest =yt; zbest=zt; | |
453 | qbest =pos[ip].GetQ(); | |
454 | lp[0]=-(-ybest+fYshift[fModule]); | |
455 | lp[1]= -zbest+fZshift[fModule]; | |
456 | lp[2]=0.0025*0.0025; //SigmaY2 | |
457 | lp[3]=0.110*0.110; //SigmaZ2 | |
458 | ||
459 | lp[4]=qbest; //Q | |
460 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
461 | for (Int_t ilab=0;ilab<3;ilab++){ | |
462 | milab[ilab] = pos[ip].GetLabel(ilab); | |
463 | milab[ilab+3] = neg[in].GetLabel(ilab); | |
464 | } | |
465 | // | |
466 | CheckLabels2(milab); | |
467 | ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ()); | |
468 | milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det | |
469 | Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]}; | |
470 | ||
471 | AliITSclusterV2 * cl2; | |
472 | if(clusters) cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
473 | else{ | |
474 | cl2 = new AliITSclusterV2(milab,lp,info); | |
7d62fb64 | 475 | fDetTypeRec->AddClusterV2(*cl2); |
04366a57 | 476 | } |
477 | ncl++; | |
478 | cl2->SetChargeRatio(ratio); | |
479 | cl2->SetType(5); | |
480 | pairs[ip][in] = 5; | |
481 | if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster | |
482 | cl2->SetType(6); | |
483 | pairs[ip][in] = 6; | |
484 | } | |
485 | } | |
486 | // | |
487 | // add second pair | |
488 | ||
489 | // if (!(cused1[ip2] || cused2[in])){ // | |
490 | if (pairs[ip2][in]==100){ | |
491 | Float_t yp=pos[ip2].GetY()*fYpitchSSD; | |
492 | Float_t yn=neg[in].GetY()*fYpitchSSD; | |
493 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
494 | Float_t yt=yn + tann*zt; | |
495 | zt-=fHlSSD; yt-=fHwSSD; | |
496 | ybest =yt; zbest=zt; | |
497 | qbest =pos[ip2].GetQ(); | |
498 | lp[0]=-(-ybest+fYshift[fModule]); | |
499 | lp[1]= -zbest+fZshift[fModule]; | |
500 | lp[2]=0.0025*0.0025; //SigmaY2 | |
501 | lp[3]=0.110*0.110; //SigmaZ2 | |
502 | ||
503 | lp[4]=qbest; //Q | |
504 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
505 | for (Int_t ilab=0;ilab<3;ilab++){ | |
506 | milab[ilab] = pos[ip2].GetLabel(ilab); | |
507 | milab[ilab+3] = neg[in].GetLabel(ilab); | |
508 | } | |
509 | // | |
510 | CheckLabels2(milab); | |
511 | ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ()); | |
512 | milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det | |
513 | Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]}; | |
514 | ||
515 | AliITSclusterV2 * cl2; | |
516 | if(clusters) cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
517 | else{ | |
518 | cl2 = new AliITSclusterV2(milab,lp,info); | |
7d62fb64 | 519 | fDetTypeRec->AddClusterV2(*cl2); |
04366a57 | 520 | } |
521 | ncl++; | |
522 | cl2->SetChargeRatio(ratio); | |
523 | cl2->SetType(5); | |
524 | pairs[ip2][in] =5; | |
525 | if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster | |
526 | cl2->SetType(6); | |
527 | pairs[ip2][in] =6; | |
528 | } | |
529 | } | |
530 | cused1[ip]++; | |
531 | cused1[ip2]++; | |
532 | cused2[in]++; | |
533 | } | |
534 | } | |
535 | } | |
536 | ||
537 | // | |
538 | for (Int_t jn=0;jn<nn;jn++){ | |
539 | if (cused2[jn]) continue; | |
540 | Float_t ybest=1000,zbest=1000,qbest=0; | |
541 | // select "silber" cluster | |
542 | if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){ | |
543 | Int_t ip = positivepair[10*jn]; | |
544 | Int_t jn2 = negativepair[10*ip]; | |
545 | if (jn2==jn) jn2 = negativepair[10*ip+1]; | |
546 | Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ(); | |
547 | // | |
548 | if (TMath::Abs(pcharge-pos[ip].GetQ())<10){ | |
549 | // | |
550 | // add first pair | |
551 | // if (!(cused1[ip]||cused2[jn])){ | |
552 | if (pairs[ip][jn]==100){ | |
553 | Float_t yn=neg[jn].GetY()*fYpitchSSD; | |
554 | Float_t yp=pos[ip].GetY()*fYpitchSSD; | |
555 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
556 | Float_t yt=yn + tann*zt; | |
557 | zt-=fHlSSD; yt-=fHwSSD; | |
558 | ybest =yt; zbest=zt; | |
559 | qbest =neg[jn].GetQ(); | |
560 | lp[0]=-(-ybest+fYshift[fModule]); | |
561 | lp[1]= -zbest+fZshift[fModule]; | |
562 | lp[2]=0.0025*0.0025; //SigmaY2 | |
563 | lp[3]=0.110*0.110; //SigmaZ2 | |
564 | ||
565 | lp[4]=qbest; //Q | |
566 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
567 | for (Int_t ilab=0;ilab<3;ilab++){ | |
568 | milab[ilab] = pos[ip].GetLabel(ilab); | |
569 | milab[ilab+3] = neg[jn].GetLabel(ilab); | |
570 | } | |
571 | // | |
572 | CheckLabels2(milab); | |
573 | ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ()); | |
574 | milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det | |
575 | Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]}; | |
576 | ||
577 | AliITSclusterV2 * cl2; | |
578 | if(clusters) cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
579 | else{ | |
580 | cl2 = new AliITSclusterV2(milab,lp,info); | |
7d62fb64 | 581 | fDetTypeRec->AddClusterV2(*cl2); |
04366a57 | 582 | } |
583 | ncl++; | |
584 | cl2->SetChargeRatio(ratio); | |
585 | cl2->SetType(7); | |
586 | pairs[ip][jn] =7; | |
587 | if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster | |
588 | cl2->SetType(8); | |
589 | pairs[ip][jn]=8; | |
590 | } | |
591 | } | |
592 | // | |
593 | // add second pair | |
594 | // if (!(cused1[ip]||cused2[jn2])){ | |
595 | if (pairs[ip][jn2]==100){ | |
596 | Float_t yn=neg[jn2].GetY()*fYpitchSSD; | |
597 | Double_t yp=pos[ip].GetY()*fYpitchSSD; | |
598 | Double_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
599 | Double_t yt=yn + tann*zt; | |
600 | zt-=fHlSSD; yt-=fHwSSD; | |
601 | ybest =yt; zbest=zt; | |
602 | qbest =neg[jn2].GetQ(); | |
603 | lp[0]=-(-ybest+fYshift[fModule]); | |
604 | lp[1]= -zbest+fZshift[fModule]; | |
605 | lp[2]=0.0025*0.0025; //SigmaY2 | |
606 | lp[3]=0.110*0.110; //SigmaZ2 | |
607 | ||
608 | lp[4]=qbest; //Q | |
609 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
610 | for (Int_t ilab=0;ilab<3;ilab++){ | |
611 | milab[ilab] = pos[ip].GetLabel(ilab); | |
612 | milab[ilab+3] = neg[jn2].GetLabel(ilab); | |
613 | } | |
614 | // | |
615 | CheckLabels2(milab); | |
616 | ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ()); | |
617 | milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det | |
618 | Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]}; | |
619 | AliITSclusterV2 * cl2; | |
620 | if(clusters) cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
621 | else{ | |
622 | cl2 = new AliITSclusterV2(milab,lp,info); | |
7d62fb64 | 623 | fDetTypeRec->AddClusterV2(*cl2); |
04366a57 | 624 | } |
625 | ||
626 | ncl++; | |
627 | cl2->SetChargeRatio(ratio); | |
628 | pairs[ip][jn2]=7; | |
629 | cl2->SetType(7); | |
630 | if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster | |
631 | cl2->SetType(8); | |
632 | pairs[ip][jn2]=8; | |
633 | } | |
634 | } | |
635 | cused1[ip]++; | |
636 | cused2[jn]++; | |
637 | cused2[jn2]++; | |
638 | } | |
639 | } | |
640 | } | |
641 | ||
642 | for (Int_t ip=0;ip<np;ip++){ | |
643 | Float_t ybest=1000,zbest=1000,qbest=0; | |
644 | // | |
645 | // 2x2 clusters | |
646 | // | |
647 | if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){ | |
648 | Float_t minchargediff =4.; | |
649 | Int_t j=-1; | |
650 | for (Int_t di=0;di<cnegative[ip];di++){ | |
651 | Int_t jc = negativepair[ip*10+di]; | |
652 | Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ(); | |
653 | if (TMath::Abs(chargedif)<minchargediff){ | |
654 | j =jc; | |
655 | minchargediff = TMath::Abs(chargedif); | |
656 | } | |
657 | } | |
658 | if (j<0) continue; // not proper cluster | |
659 | Int_t count =0; | |
660 | for (Int_t di=0;di<cnegative[ip];di++){ | |
661 | Int_t jc = negativepair[ip*10+di]; | |
662 | Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ(); | |
663 | if (TMath::Abs(chargedif)<minchargediff+3.) count++; | |
664 | } | |
665 | if (count>1) continue; // more than one "proper" cluster for positive | |
666 | // | |
667 | count =0; | |
668 | for (Int_t dj=0;dj<cpositive[j];dj++){ | |
669 | Int_t ic = positivepair[j*10+dj]; | |
670 | Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ(); | |
671 | if (TMath::Abs(chargedif)<minchargediff+3.) count++; | |
672 | } | |
673 | if (count>1) continue; // more than one "proper" cluster for negative | |
674 | ||
675 | Int_t jp = 0; | |
676 | ||
677 | count =0; | |
678 | for (Int_t dj=0;dj<cnegative[jp];dj++){ | |
679 | Int_t ic = positivepair[jp*10+dj]; | |
680 | Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ(); | |
681 | if (TMath::Abs(chargedif)<minchargediff+4.) count++; | |
682 | } | |
683 | if (count>1) continue; | |
684 | if (pairs[ip][j]<100) continue; | |
685 | // | |
686 | //almost gold clusters | |
687 | Float_t yp=pos[ip].GetY()*fYpitchSSD; | |
688 | Float_t yn=neg[j].GetY()*fYpitchSSD; | |
689 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
690 | Float_t yt=yn + tann*zt; | |
691 | zt-=fHlSSD; yt-=fHwSSD; | |
692 | ybest=yt; zbest=zt; | |
693 | qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ()); | |
694 | lp[0]=-(-ybest+fYshift[fModule]); | |
695 | lp[1]= -zbest+fZshift[fModule]; | |
696 | lp[2]=0.0025*0.0025; //SigmaY2 | |
697 | lp[3]=0.110*0.110; //SigmaZ2 | |
698 | lp[4]=qbest; //Q | |
699 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
700 | for (Int_t ilab=0;ilab<3;ilab++){ | |
701 | milab[ilab] = pos[ip].GetLabel(ilab); | |
702 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
703 | } | |
704 | // | |
705 | CheckLabels2(milab); | |
706 | ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ()); | |
707 | milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det | |
708 | Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]}; | |
709 | AliITSclusterV2 * cl2; | |
710 | if(clusters) cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
711 | else{ | |
712 | cl2 = new AliITSclusterV2(milab,lp,info); | |
7d62fb64 | 713 | fDetTypeRec->AddClusterV2(*cl2); |
04366a57 | 714 | } |
715 | ||
716 | ||
717 | ncl++; | |
718 | cl2->SetChargeRatio(ratio); | |
719 | cl2->SetType(10); | |
720 | pairs[ip][j]=10; | |
721 | if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster | |
722 | cl2->SetType(11); | |
723 | pairs[ip][j]=11; | |
724 | } | |
725 | cused1[ip]++; | |
726 | cused2[j]++; | |
727 | } | |
728 | ||
729 | } | |
730 | ||
731 | // | |
732 | for (Int_t i=0; i<np; i++) { | |
733 | Float_t ybest=1000,zbest=1000,qbest=0; | |
734 | Float_t yp=pos[i].GetY()*fYpitchSSD; | |
735 | if (pos[i].GetQ()<3) continue; | |
736 | for (Int_t j=0; j<nn; j++) { | |
737 | // for (Int_t di = 0;di<cpositive[i];di++){ | |
738 | // Int_t j = negativepair[10*i+di]; | |
739 | if (neg[j].GetQ()<3) continue; | |
740 | if (cused2[j]||cused1[i]) continue; | |
741 | if (pairs[i][j]>0 &&pairs[i][j]<100) continue; | |
742 | ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ()); | |
743 | Float_t yn=neg[j].GetY()*fYpitchSSD; | |
744 | Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp); | |
745 | Float_t yt=yn + tann*zt; | |
746 | zt-=fHlSSD; yt-=fHwSSD; | |
747 | if (TMath::Abs(yt)<fHwSSD+0.01) | |
748 | if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) { | |
749 | ybest=yt; zbest=zt; | |
750 | qbest=0.5*(pos[i].GetQ()+neg[j].GetQ()); | |
751 | lp[0]=-(-ybest+fYshift[fModule]); | |
752 | lp[1]= -zbest+fZshift[fModule]; | |
753 | lp[2]=0.0025*0.0025; //SigmaY2 | |
754 | lp[3]=0.110*0.110; //SigmaZ2 | |
755 | ||
756 | lp[4]=qbest; //Q | |
757 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
758 | for (Int_t ilab=0;ilab<3;ilab++){ | |
759 | milab[ilab] = pos[i].GetLabel(ilab); | |
760 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
761 | } | |
762 | // | |
763 | CheckLabels2(milab); | |
764 | milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det | |
765 | Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]}; | |
766 | AliITSclusterV2 * cl2; | |
767 | if(clusters) cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info); | |
768 | else{ | |
769 | cl2 = new AliITSclusterV2(milab,lp,info); | |
7d62fb64 | 770 | fDetTypeRec->AddClusterV2(*cl2); |
04366a57 | 771 | } |
772 | ncl++; | |
773 | cl2->SetChargeRatio(ratio); | |
774 | cl2->SetType(100+cpositive[j]+cnegative[i]); | |
775 | //cl2->SetType(0); | |
776 | /* | |
777 | if (pairs[i][j]<100){ | |
778 | printf("problem:- %d\n", pairs[i][j]); | |
779 | } | |
780 | if (cnegative[i]<2&&cpositive[j]<2){ | |
781 | printf("problem:- %d\n", pairs[i][j]); | |
782 | } | |
783 | */ | |
784 | } | |
785 | } | |
786 | } | |
787 | ||
788 | // for (Int_t i=0; i<1000; i++) delete [] pairs[i]; | |
789 | // delete [] pairs; | |
790 | ||
791 | } | |
792 | ||
793 | ||
794 |