1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
19 // Implementation of the ITS clusterer V2 class //
21 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch //
22 // Revised: Enrico Fragiacomo, enrico.fragiacomo@ts.infn.it //
24 ///////////////////////////////////////////////////////////////////////////
26 #include <Riostream.h>
29 #include "AliITSClusterFinderV2SSD.h"
30 #include "AliITSRecPoint.h"
31 #include "AliITSgeomTGeo.h"
32 #include "AliITSDetTypeRec.h"
33 #include "AliRawReader.h"
34 #include "AliITSRawStreamSSD.h"
35 #include <TClonesArray.h>
36 #include "AliITSdigitSSD.h"
37 #include "AliITSCalibrationSSD.h"
39 Short_t *AliITSClusterFinderV2SSD::fgPairs = 0x0;
40 Int_t AliITSClusterFinderV2SSD::fgPairsSize = 0;
42 ClassImp(AliITSClusterFinderV2SSD)
45 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp),
46 fLastSSD1(AliITSgeomTGeo::GetModuleIndex(6,1,1)-1),
57 //______________________________________________________________________
58 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(const AliITSClusterFinderV2SSD &cf) : AliITSClusterFinderV2(cf), fLastSSD1(cf.fLastSSD1),
59 fYpitchSSD(cf.fYpitchSSD),
69 //______________________________________________________________________
70 AliITSClusterFinderV2SSD& AliITSClusterFinderV2SSD::operator=(const AliITSClusterFinderV2SSD& cf ){
71 // Assignment operator
73 this->~AliITSClusterFinderV2SSD();
74 new(this) AliITSClusterFinderV2SSD(cf);
79 void AliITSClusterFinderV2SSD::FindRawClusters(Int_t mod){
83 FindClustersSSD(fDigits);
87 void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
88 //------------------------------------------------------------
89 // Actual SSD cluster finder
90 //------------------------------------------------------------
91 AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
94 Int_t smaxall=alldigits->GetEntriesFast();
95 if (smaxall==0) return;
96 // TObjArray *digits = new TObjArray;
98 for (Int_t i=0;i<smaxall; i++){
99 AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i);
101 if(d->IsSideP()) gain = cal->GetGainP(d->GetStripNumber());
102 else gain = cal->GetGainN(d->GetStripNumber());
104 Float_t q=gain*d->GetSignal(); // calibration brings mip peaks around 120 (in ADC units)
105 q=cal->ADCToKeV(q); // converts the charge in KeV from ADC units
106 //Float_t q=d->GetSignal()/4.29;// temp. fix (for PID purposed - normalis. to be checked)
107 d->SetSignal(Int_t(q));
109 if (d->GetSignal()<3) continue;
112 Int_t smax = digits.GetEntriesFast();
115 const Int_t kMax=1000;
117 Ali1Dcluster pos[kMax], neg[kMax];
118 Float_t y=0., q=0., qmax=0.;
119 Int_t lab[4]={-2,-2,-2,-2};
121 AliITSdigitSSD *d=(AliITSdigitSSD*)digits.UncheckedAt(0);
123 y += d->GetCoord2()*d->GetSignal();
125 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
126 Int_t curr=d->GetCoord2();
127 Int_t flag=d->GetCoord1();
132 for (Int_t ilab=0;ilab<10;ilab++){
135 milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2);
137 for (Int_t s=1; s<smax; s++) {
138 d=(AliITSdigitSSD*)digits.UncheckedAt(s);
139 Int_t strip=d->GetCoord2();
140 if ((strip-curr) > 1 || flag!=d->GetCoord1()) {
145 c[*n].SetLabels(milab);
146 //Split suspiciously big cluster
148 c[*n].SetY(y/q-0.25*nd);
152 Error("FindClustersSSD","Too many 1D clusters !");
155 c[*n].SetY(y/q+0.25*nd);
158 c[*n].SetLabels(milab);
162 Error("FindClustersSSD","Too many 1D clusters !");
167 lab[0]=lab[1]=lab[2]=-2;
169 for (Int_t ilab=0;ilab<10;ilab++){
173 if (flag!=d->GetCoord1()) { n=&np; c=pos; }
177 y += d->GetCoord2()*d->GetSignal();
179 if (d->GetSignal()>qmax) {
181 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
183 for (Int_t ilab=0;ilab<10;ilab++) {
184 if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab)));
191 c[*n].SetLabels(lab);
192 //Split suspiciously big cluster
194 c[*n].SetY(y/q-0.25*nd);
198 Error("FindClustersSSD","Too many 1D clusters !");
201 c[*n].SetY(y/q+0.25*nd);
204 c[*n].SetLabels(lab);
208 Error("FindClustersSSD","Too many 1D clusters !");
212 FindClustersSSD(neg, nn, pos, np);
216 void AliITSClusterFinderV2SSD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){
218 //------------------------------------------------------------
219 // This function creates ITS clusters from raw data
220 //------------------------------------------------------------
222 AliITSRawStreamSSD inputSSD(rawReader);
223 // rawReader->SelectEquipment(-1,0,15);
224 FindClustersSSD(&inputSSD,clusters);
228 void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
229 TClonesArray** clusters)
231 //------------------------------------------------------------
232 // Actual SSD cluster finder for raw data
233 //------------------------------------------------------------
234 Int_t nClustersSSD = 0;
235 const Int_t kMax = 1000;
236 Ali1Dcluster clusters1D[2][kMax];
237 Int_t nClusters[2] = {0, 0};
238 Int_t lab[3]={-2,-2,-2};
245 AliITSCalibrationSSD* cal=NULL;
249 Int_t matrix[12][1536];
257 Int_t osignal = 65535;
262 // read raw data input stream
265 // reset signal matrix
266 for(Int_t i=0; i<12; i++) { for(Int_t j=0; j<1536; j++) { matrix[i][j] = 65535;} }
270 matrix[oadc][ostrip] = osignal; // recover data from previous occurence of input->Next()
273 // buffer data for ddl=iddl and ad=iad
276 next = input->Next();
279 if((!next)&&(input->flag)) continue;
280 adc = input->GetADC(); adc = (adc<6)? adc : adc - 2;
281 strip = input->GetStrip();
282 if(input->GetSideFlag()) strip=1535-strip;
283 signal = input->GetSignal();
284 //cout<<ddl<<" "<<ad<<" "<<adc<<" "<<strip<<" "<<signal<<endl;
286 if((ddl==iddl)&&(ad==iad)) {n++; matrix[adc][strip] = signal;}
287 else {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
292 if(n==0) continue; // first occurence
296 for(Int_t iadc=0; iadc<12; iadc++) { // loop over ADC index for ddl=oddl and ad=oad
298 Int_t iimod = (oad - 1) * 12 + iadc;
299 iModule = AliITSRawStreamSSD::GetModuleNumber(oddl,iimod);
300 if(iModule==-1) continue;
301 //cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<endl;
302 cal = (AliITSCalibrationSSD*)GetResp(iModule);
306 for(Int_t istrip=0; istrip<768; istrip++) { // P-side
308 signal = matrix[iadc][istrip];
310 noise = cal->GetNoiseP(istrip);
311 if(signal<3*noise) signal = 65535; // in case ZS was not done in hw do it now
314 gain = cal->GetGainP(istrip);
315 signal = (Int_t) ( signal * gain ); // signal is corrected for gain
316 //cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<" strip= "<<istrip<<
317 // " sig="<<signal<<endl;
318 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
320 q += signal; // add digit to current cluster
321 y += istrip * signal;
328 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
330 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
333 cluster.SetNd(nDigits);
334 cluster.SetLabels(lab);
336 //Split suspiciously big cluster
337 if (nDigits > 4&&nDigits < 25) {
338 cluster.SetY(y/q - 0.25*nDigits);
340 if (nClusters[0] == kMax) {
341 Error("FindClustersSSD", "Too many 1D clusters !");
344 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
345 cluster2.SetY(y/q + 0.25*nDigits);
346 cluster2.SetQ(0.5*q);
347 cluster2.SetNd(nDigits);
348 cluster2.SetLabels(lab);
358 } // loop over strip on P-side
360 // if last strip does have signal
363 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
365 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
368 cluster.SetNd(nDigits);
369 cluster.SetLabels(lab);
371 //Split suspiciously big cluster
372 if (nDigits > 4&&nDigits < 25) {
373 cluster.SetY(y/q - 0.25*nDigits);
375 if (nClusters[0] == kMax) {
376 Error("FindClustersSSD", "Too many 1D clusters !");
379 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
380 cluster2.SetY(y/q + 0.25*nDigits);
381 cluster2.SetQ(0.5*q);
382 cluster2.SetNd(nDigits);
383 cluster2.SetLabels(lab);
394 for(Int_t istrip=768; istrip<1536; istrip++) { // N-side
396 signal = matrix[iadc][istrip];
399 noise = cal->GetNoiseN(strip);
400 if(signal<3*noise) signal = 65535; // in case ZS was not done in hw do it now
403 gain = cal->GetGainN(strip);
404 signal = (Int_t) ( signal * gain); // signal is corrected for gain
405 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
407 // add digit to current cluster
416 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
418 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
421 cluster.SetNd(nDigits);
422 cluster.SetLabels(lab);
424 //Split suspiciously big cluster
425 if (nDigits > 4&&nDigits < 25) {
426 cluster.SetY(y/q - 0.25*nDigits);
428 if (nClusters[1] == kMax) {
429 Error("FindClustersSSD", "Too many 1D clusters !");
432 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
433 cluster2.SetY(y/q + 0.25*nDigits);
434 cluster2.SetQ(0.5*q);
435 cluster2.SetNd(nDigits);
436 cluster2.SetLabels(lab);
445 } // loop over strips on N-side
449 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
451 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
454 cluster.SetNd(nDigits);
455 cluster.SetLabels(lab);
457 //Split suspiciously big cluster
458 if (nDigits > 4&&nDigits < 25) {
459 cluster.SetY(y/q - 0.25*nDigits);
461 if (nClusters[1] == kMax) {
462 Error("FindClustersSSD", "Too many 1D clusters !");
465 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
466 cluster2.SetY(y/q + 0.25*nDigits);
467 cluster2.SetQ(0.5*q);
468 cluster2.SetNd(nDigits);
469 cluster2.SetLabels(lab);
479 if((nClusters[0])&&(nClusters[1])) {
481 //cout<<"creating recpoint for module="<<iModule<<" "<<nClusters[0]<<" "<<nClusters[1]<<endl;
482 clusters[iModule] = new TClonesArray("AliITSRecPoint");
485 FindClustersSSD(&clusters1D[0][0], nClusters[0],
486 &clusters1D[1][0], nClusters[1], clusters[iModule]);
487 Int_t nClusters = clusters[iModule]->GetEntriesFast();
488 nClustersSSD += nClusters;
491 nClusters[0] = nClusters[1] = 0;
497 if((!next)||(iddl==528)) break;
500 Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD);
503 void AliITSClusterFinderV2SSD::
504 FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
505 Ali1Dcluster* pos, Int_t np,
506 TClonesArray *clusters) {
507 //------------------------------------------------------------
508 // Actual SSD cluster finder
509 //------------------------------------------------------------
513 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
515 TClonesArray &cl=*clusters;
517 Float_t tanp=fTanP, tann=fTanN;
518 if (fModule>fLastSSD1) {tann=fTanP; tanp=fTanN;}
519 Int_t idet=fNdet[fModule];
522 Int_t negativepair[30000];
523 Int_t cnegative[3000];
525 Int_t positivepair[30000];
526 Int_t cpositive[3000];
528 for (Int_t i=0;i<3000;i++) {cnegative[i]=0; cused1[i]=0;}
529 for (Int_t i=0;i<3000;i++) {cpositive[i]=0; cused2[i]=0;}
530 for (Int_t i=0;i<30000;i++) {negativepair[i]=0; positivepair[i]=0;}
532 if ((np*nn) > fgPairsSize) {
533 if (fgPairs) delete [] fgPairs;
534 fgPairsSize = 4*np*nn;
535 fgPairs = new Short_t[fgPairsSize];
537 memset(fgPairs,0,sizeof(Short_t)*np*nn);
540 // find available pairs
542 for (Int_t i=0; i<np; i++) {
543 Float_t yp=pos[i].GetY()*fYpitchSSD;
544 if (pos[i].GetQ()<3) continue;
545 for (Int_t j=0; j<nn; j++) {
546 if (neg[j].GetQ()<3) continue;
547 Float_t yn=neg[j].GetY()*fYpitchSSD;
548 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
549 Float_t yt=yn + tann*zt;
550 zt-=fHlSSD; yt-=fHwSSD;
551 if (TMath::Abs(yt)<fHwSSD+0.01)
552 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
553 negativepair[i*10+cnegative[i]] =j; //index
554 positivepair[j*10+cpositive[j]] =i;
555 cnegative[i]++; //counters
563 // try to recover points out of but close to the module boundaries
565 for (Int_t i=0; i<np; i++) {
566 Float_t yp=pos[i].GetY()*fYpitchSSD;
567 if (pos[i].GetQ()<3) continue;
568 for (Int_t j=0; j<nn; j++) {
569 if (neg[j].GetQ()<3) continue;
570 // if both 1Dclusters have an other cross continue
571 if (cpositive[j]&&cnegative[i]) continue;
572 Float_t yn=neg[j].GetY()*fYpitchSSD;
573 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
574 Float_t yt=yn + tann*zt;
575 zt-=fHlSSD; yt-=fHwSSD;
576 if (TMath::Abs(yt)<fHwSSD+0.1)
577 if (TMath::Abs(zt)<fHlSSD+0.15) {
578 // tag 1Dcluster (eventually will produce low quality recpoint)
579 if (cnegative[i]==0) pos[i].SetNd(100); // not available pair
580 if (cpositive[j]==0) neg[j].SetNd(100); // not available pair
581 negativepair[i*10+cnegative[i]] =j; //index
582 positivepair[j*10+cpositive[j]] =i;
583 cnegative[i]++; //counters
598 for (Int_t ip=0;ip<np;ip++){
599 Float_t ybest=1000,zbest=1000,qbest=0;
601 // select gold clusters
602 if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){
603 Float_t yp=pos[ip].GetY()*fYpitchSSD;
604 Int_t j = negativepair[10*ip];
605 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
607 Float_t yn=neg[j].GetY()*fYpitchSSD;
608 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
609 Float_t yt=yn + tann*zt;
610 zt-=fHlSSD; yt-=fHwSSD;
612 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
614 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
615 mT2L->MasterToLocal(loc,trk);
619 lp[2]=0.0025*0.0025; //SigmaY2
620 lp[3]=0.110*0.110; //SigmaZ2
623 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
624 for (Int_t ilab=0;ilab<3;ilab++){
625 milab[ilab] = pos[ip].GetLabel(ilab);
626 milab[ilab+3] = neg[j].GetLabel(ilab);
630 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
631 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
632 AliITSRecPoint * cl2;
634 if(clusters){ // Note clusters != 0 when method is called for rawdata
637 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
639 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
641 cl2->SetChargeRatio(ratio);
644 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
652 else{ // Note clusters == 0 when method is called for digits
654 cl2 = new AliITSRecPoint(milab,lp,info);
656 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
658 cl2->SetChargeRatio(ratio);
661 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
667 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" gold"<<endl;
668 fDetTypeRec->AddRecPoint(*cl2);
674 for (Int_t ip=0;ip<np;ip++){
675 Float_t ybest=1000,zbest=1000,qbest=0;
678 // select "silber" cluster
679 if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){
680 Int_t in = negativepair[10*ip];
681 Int_t ip2 = positivepair[10*in];
682 if (ip2==ip) ip2 = positivepair[10*in+1];
683 Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
684 if (TMath::Abs(pcharge-neg[in].GetQ())<10){
687 if (fgPairs[ip*nn+in]==100){ //
688 Float_t yp=pos[ip].GetY()*fYpitchSSD;
689 Float_t yn=neg[in].GetY()*fYpitchSSD;
690 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
691 Float_t yt=yn + tann*zt;
692 zt-=fHlSSD; yt-=fHwSSD;
694 qbest =pos[ip].GetQ();
696 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
697 mT2L->MasterToLocal(loc,trk);
701 lp[2]=0.0025*0.0025; //SigmaY2
702 lp[3]=0.110*0.110; //SigmaZ2
705 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
706 for (Int_t ilab=0;ilab<3;ilab++){
707 milab[ilab] = pos[ip].GetLabel(ilab);
708 milab[ilab+3] = neg[in].GetLabel(ilab);
712 ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ());
713 milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
714 Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
716 AliITSRecPoint * cl2;
719 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
721 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
723 cl2->SetChargeRatio(ratio);
725 fgPairs[ip*nn+in] = 5;
726 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
728 fgPairs[ip*nn+in] = 6;
732 cl2 = new AliITSRecPoint(milab,lp,info);
733 cl2->SetChargeRatio(ratio);
735 fgPairs[ip*nn+in] = 5;
736 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
738 fgPairs[ip*nn+in] = 6;
740 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver1"<<endl;
742 fDetTypeRec->AddRecPoint(*cl2);
750 // if (!(cused1[ip2] || cused2[in])){ //
751 if (fgPairs[ip2*nn+in]==100){
752 Float_t yp=pos[ip2].GetY()*fYpitchSSD;
753 Float_t yn=neg[in].GetY()*fYpitchSSD;
754 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
755 Float_t yt=yn + tann*zt;
756 zt-=fHlSSD; yt-=fHwSSD;
758 qbest =pos[ip2].GetQ();
760 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
761 mT2L->MasterToLocal(loc,trk);
765 lp[2]=0.0025*0.0025; //SigmaY2
766 lp[3]=0.110*0.110; //SigmaZ2
769 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
770 for (Int_t ilab=0;ilab<3;ilab++){
771 milab[ilab] = pos[ip2].GetLabel(ilab);
772 milab[ilab+3] = neg[in].GetLabel(ilab);
776 ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ());
777 milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
778 Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
780 AliITSRecPoint * cl2;
782 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
784 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
786 cl2->SetChargeRatio(ratio);
788 fgPairs[ip2*nn+in] =5;
789 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
791 fgPairs[ip2*nn+in] =6;
795 cl2 = new AliITSRecPoint(milab,lp,info);
796 cl2->SetChargeRatio(ratio);
798 fgPairs[ip2*nn+in] =5;
799 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
801 fgPairs[ip2*nn+in] =6;
804 // cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver2"<<endl;
805 fDetTypeRec->AddRecPoint(*cl2);
817 for (Int_t jn=0;jn<nn;jn++){
818 if (cused2[jn]) continue;
819 Float_t ybest=1000,zbest=1000,qbest=0;
820 // select "silber" cluster
821 if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){
822 Int_t ip = positivepair[10*jn];
823 Int_t jn2 = negativepair[10*ip];
824 if (jn2==jn) jn2 = negativepair[10*ip+1];
825 Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
827 if (TMath::Abs(pcharge-pos[ip].GetQ())<10){
830 // if (!(cused1[ip]||cused2[jn])){
831 if (fgPairs[ip*nn+jn]==100){
832 Float_t yn=neg[jn].GetY()*fYpitchSSD;
833 Float_t yp=pos[ip].GetY()*fYpitchSSD;
834 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
835 Float_t yt=yn + tann*zt;
836 zt-=fHlSSD; yt-=fHwSSD;
838 qbest =neg[jn].GetQ();
840 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
841 mT2L->MasterToLocal(loc,trk);
845 lp[2]=0.0025*0.0025; //SigmaY2
846 lp[3]=0.110*0.110; //SigmaZ2
849 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
850 for (Int_t ilab=0;ilab<3;ilab++){
851 milab[ilab] = pos[ip].GetLabel(ilab);
852 milab[ilab+3] = neg[jn].GetLabel(ilab);
856 ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ());
857 milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
858 Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]};
860 AliITSRecPoint * cl2;
862 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
864 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
866 cl2->SetChargeRatio(ratio);
868 fgPairs[ip*nn+jn] =7;
869 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
876 cl2 = new AliITSRecPoint(milab,lp,info);
877 cl2->SetChargeRatio(ratio);
879 fgPairs[ip*nn+jn] =7;
880 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
884 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN1"<<endl;
886 fDetTypeRec->AddRecPoint(*cl2);
892 // if (!(cused1[ip]||cused2[jn2])){
893 if (fgPairs[ip*nn+jn2]==100){
894 Float_t yn=neg[jn2].GetY()*fYpitchSSD;
895 Double_t yp=pos[ip].GetY()*fYpitchSSD;
896 Double_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
897 Double_t yt=yn + tann*zt;
898 zt-=fHlSSD; yt-=fHwSSD;
900 qbest =neg[jn2].GetQ();
902 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
903 mT2L->MasterToLocal(loc,trk);
907 lp[2]=0.0025*0.0025; //SigmaY2
908 lp[3]=0.110*0.110; //SigmaZ2
911 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
912 for (Int_t ilab=0;ilab<3;ilab++){
913 milab[ilab] = pos[ip].GetLabel(ilab);
914 milab[ilab+3] = neg[jn2].GetLabel(ilab);
918 ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
919 milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
920 Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]};
921 AliITSRecPoint * cl2;
923 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
925 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
927 cl2->SetChargeRatio(ratio);
928 fgPairs[ip*nn+jn2]=7;
930 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
932 fgPairs[ip*nn+jn2]=8;
937 cl2 = new AliITSRecPoint(milab,lp,info);
938 cl2->SetChargeRatio(ratio);
939 fgPairs[ip*nn+jn2]=7;
941 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
943 fgPairs[ip*nn+jn2]=8;
945 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN2"<<endl;
947 fDetTypeRec->AddRecPoint(*cl2);
959 for (Int_t ip=0;ip<np;ip++){
960 Float_t ybest=1000,zbest=1000,qbest=0;
964 if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){
965 Float_t minchargediff =4.;
967 for (Int_t di=0;di<cnegative[ip];di++){
968 Int_t jc = negativepair[ip*10+di];
969 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
970 if (TMath::Abs(chargedif)<minchargediff){
972 minchargediff = TMath::Abs(chargedif);
975 if (j<0) continue; // not proper cluster
978 for (Int_t di=0;di<cnegative[ip];di++){
979 Int_t jc = negativepair[ip*10+di];
980 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
981 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
983 if (count>1) continue; // more than one "proper" cluster for positive
986 for (Int_t dj=0;dj<cpositive[j];dj++){
987 Int_t ic = positivepair[j*10+dj];
988 Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
989 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
991 if (count>1) continue; // more than one "proper" cluster for negative
996 for (Int_t dj=0;dj<cnegative[jp];dj++){
997 Int_t ic = positivepair[jp*10+dj];
998 Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
999 if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1001 if (count>1) continue;
1002 if (fgPairs[ip*nn+j]<100) continue;
1004 //almost gold clusters
1005 Float_t yp=pos[ip].GetY()*fYpitchSSD;
1006 Float_t yn=neg[j].GetY()*fYpitchSSD;
1007 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1008 Float_t yt=yn + tann*zt;
1009 zt-=fHlSSD; yt-=fHwSSD;
1011 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1013 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1014 mT2L->MasterToLocal(loc,trk);
1018 lp[2]=0.0025*0.0025; //SigmaY2
1019 lp[3]=0.110*0.110; //SigmaZ2
1021 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1022 for (Int_t ilab=0;ilab<3;ilab++){
1023 milab[ilab] = pos[ip].GetLabel(ilab);
1024 milab[ilab+3] = neg[j].GetLabel(ilab);
1027 CheckLabels2(milab);
1028 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1029 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1030 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1031 AliITSRecPoint * cl2;
1033 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1035 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1037 cl2->SetChargeRatio(ratio);
1039 fgPairs[ip*nn+j]=10;
1040 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1042 fgPairs[ip*nn+j]=11;
1048 cl2 = new AliITSRecPoint(milab,lp,info);
1049 cl2->SetChargeRatio(ratio);
1051 fgPairs[ip*nn+j]=10;
1052 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1054 fgPairs[ip*nn+j]=11;
1059 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" 2x2"<<endl;
1061 fDetTypeRec->AddRecPoint(*cl2);
1069 for (Int_t i=0; i<np; i++) {
1070 Float_t ybest=1000,zbest=1000,qbest=0;
1071 Float_t yp=pos[i].GetY()*fYpitchSSD;
1072 if (pos[i].GetQ()<3) continue;
1073 for (Int_t j=0; j<nn; j++) {
1074 // for (Int_t di = 0;di<cpositive[i];di++){
1075 // Int_t j = negativepair[10*i+di];
1076 if (neg[j].GetQ()<3) continue;
1077 if (cused2[j]||cused1[i]) continue;
1078 if (fgPairs[i*nn+j]>0 &&fgPairs[i*nn+j]<100) continue;
1079 ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ());
1080 Float_t yn=neg[j].GetY()*fYpitchSSD;
1081 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1082 Float_t yt=yn + tann*zt;
1083 zt-=fHlSSD; yt-=fHwSSD;
1084 if (TMath::Abs(yt)<fHwSSD+0.01)
1085 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
1087 qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
1089 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1090 mT2L->MasterToLocal(loc,trk);
1094 lp[2]=0.0025*0.0025; //SigmaY2
1095 lp[3]=0.110*0.110; //SigmaZ2
1098 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1099 for (Int_t ilab=0;ilab<3;ilab++){
1100 milab[ilab] = pos[i].GetLabel(ilab);
1101 milab[ilab+3] = neg[j].GetLabel(ilab);
1104 CheckLabels2(milab);
1105 milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
1106 Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1107 AliITSRecPoint * cl2;
1109 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1111 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1113 cl2->SetChargeRatio(ratio);
1114 cl2->SetType(100+cpositive[j]+cnegative[i]);
1117 cl2 = new AliITSRecPoint(milab,lp,info);
1118 cl2->SetChargeRatio(ratio);
1119 cl2->SetType(100+cpositive[j]+cnegative[i]);
1121 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" other"<<endl;
1123 fDetTypeRec->AddRecPoint(*cl2);
1128 if (fgPairs[i*nn+j]<100){
1129 printf("problem:- %d\n", fgPairs[i*nn+j]);
1131 if (cnegative[i]<2&&cpositive[j]<2){
1132 printf("problem:- %d\n", fgPairs[i*nn+j]);