1 /**************************************************************************
2 * Copyright(c) 2007-2009, 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 "AliITSReconstructor.h"
38 #include "AliITSCalibrationSSD.h"
40 Short_t *AliITSClusterFinderV2SSD::fgPairs = 0x0;
41 Int_t AliITSClusterFinderV2SSD::fgPairsSize = 0;
43 ClassImp(AliITSClusterFinderV2SSD)
46 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp),
47 fLastSSD1(AliITSgeomTGeo::GetModuleIndex(6,1,1)-1),
58 //______________________________________________________________________
59 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(const AliITSClusterFinderV2SSD &cf) : AliITSClusterFinderV2(cf), fLastSSD1(cf.fLastSSD1),
60 fYpitchSSD(cf.fYpitchSSD),
70 //______________________________________________________________________
71 AliITSClusterFinderV2SSD& AliITSClusterFinderV2SSD::operator=(const AliITSClusterFinderV2SSD& cf ){
72 // Assignment operator
74 this->~AliITSClusterFinderV2SSD();
75 new(this) AliITSClusterFinderV2SSD(cf);
80 void AliITSClusterFinderV2SSD::FindRawClusters(Int_t mod){
84 FindClustersSSD(fDigits);
88 void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
89 //------------------------------------------------------------
90 // Actual SSD cluster finder
91 //------------------------------------------------------------
93 static AliITSRecoParam *repa = NULL;
95 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
97 repa = AliITSRecoParam::GetHighFluxParam();
98 AliWarning("Using default AliITSRecoParam class");
102 AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
105 Int_t smaxall=alldigits->GetEntriesFast();
106 if (smaxall==0) return;
107 // TObjArray *digits = new TObjArray;
109 for (Int_t i=0;i<smaxall; i++){
110 AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i);
112 if(d->IsSideP()) gain = cal->GetGainP(d->GetStripNumber());
113 else gain = cal->GetGainN(d->GetStripNumber());
115 Float_t q=gain*d->GetSignal(); // calibration brings mip peaks around 120 (in ADC units)
116 q=cal->ADCToKeV(q); // converts the charge in KeV from ADC units
117 //Float_t q=d->GetSignal()/4.29;// temp. fix (for PID purposed - normalis. to be checked)
118 d->SetSignal(Int_t(q));
120 if (d->GetSignal()<3) continue;
123 Int_t smax = digits.GetEntriesFast();
126 const Int_t kMax=1000;
128 Ali1Dcluster pos[kMax], neg[kMax];
129 Float_t y=0., q=0., qmax=0.;
130 Int_t lab[4]={-2,-2,-2,-2};
132 AliITSdigitSSD *d=(AliITSdigitSSD*)digits.UncheckedAt(0);
134 y += d->GetCoord2()*d->GetSignal();
136 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
137 Int_t curr=d->GetCoord2();
138 Int_t flag=d->GetCoord1();
143 for (Int_t ilab=0;ilab<10;ilab++){
146 milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2);
148 for (Int_t s=1; s<smax; s++) {
149 d=(AliITSdigitSSD*)digits.UncheckedAt(s);
150 Int_t strip=d->GetCoord2();
151 if ((strip-curr) > 1 || flag!=d->GetCoord1()) {
156 c[*n].SetLabels(milab);
158 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
160 //Split suspiciously big cluster
162 c[*n].SetY(y/q-0.25*nd);
166 Error("FindClustersSSD","Too many 1D clusters !");
169 c[*n].SetY(y/q+0.25*nd);
172 c[*n].SetLabels(milab);
179 Error("FindClustersSSD","Too many 1D clusters !");
184 lab[0]=lab[1]=lab[2]=-2;
186 for (Int_t ilab=0;ilab<10;ilab++){
190 if (flag!=d->GetCoord1()) { n=&np; c=pos; }
194 y += d->GetCoord2()*d->GetSignal();
196 if (d->GetSignal()>qmax) {
198 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
200 for (Int_t ilab=0;ilab<10;ilab++) {
201 if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab)));
208 c[*n].SetLabels(lab);
210 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
212 //Split suspiciously big cluster
214 c[*n].SetY(y/q-0.25*nd);
218 Error("FindClustersSSD","Too many 1D clusters !");
221 c[*n].SetY(y/q+0.25*nd);
224 c[*n].SetLabels(lab);
230 Error("FindClustersSSD","Too many 1D clusters !");
234 FindClustersSSD(neg, nn, pos, np);
238 void AliITSClusterFinderV2SSD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){
240 //------------------------------------------------------------
241 // This function creates ITS clusters from raw data
242 //------------------------------------------------------------
245 const UInt_t *evid; evid = rawReader->GetEventId();
246 cout<<"Event="<<evid[0]<<endl;
248 AliITSRawStreamSSD inputSSD(rawReader);
249 // rawReader->SelectEquipment(-1,0,15);
250 FindClustersSSD(&inputSSD,clusters);
254 void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
255 TClonesArray** clusters)
257 //------------------------------------------------------------
258 // Actual SSD cluster finder for raw data
259 //------------------------------------------------------------
261 static AliITSRecoParam *repa = NULL;
263 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
265 repa = AliITSRecoParam::GetHighFluxParam();
266 AliWarning("Using default AliITSRecoParam class");
270 Int_t nClustersSSD = 0;
271 const Int_t kMax = 1000;
272 Ali1Dcluster clusters1D[2][kMax];
273 Int_t nClusters[2] = {0, 0};
274 Int_t lab[3]={-2,-2,-2};
280 // Float_t pedestal=0.;
282 AliITSCalibrationSSD* cal=NULL;
284 Int_t matrix[12][1536];
291 Int_t osignal = 65535;
295 // read raw data input stream
298 // reset signal matrix
299 for(Int_t i=0; i<12; i++) { for(Int_t j=0; j<1536; j++) { matrix[i][j] = 65535;} }
303 matrix[oadc][ostrip] = osignal; // recover data from previous occurence of input->Next()
306 // buffer data for ddl=iddl and ad=iad
309 next = input->Next();
310 if((!next)&&(input->flag)) continue;
311 Int_t ddl=input->GetDDL();
312 Int_t ad=input->GetAD();
313 Int_t adc = input->GetADC(); adc = (adc<6)? adc : adc - 2;
314 Int_t strip = input->GetStrip();
315 if(input->GetSideFlag()) strip=1535-strip;
316 Int_t signal = input->GetSignal();
317 //cout<<ddl<<" "<<ad<<" "<<adc<<" "<<strip<<" "<<signal<<endl;
319 if((ddl==iddl)&&(ad==iad)) {n++; matrix[adc][strip] = signal;}
320 else {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
322 if(!next) {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
327 if(!next && oddl<0) break;
329 if(n==0) continue; // first occurence
333 for(Int_t iadc=0; iadc<12; iadc++) { // loop over ADC index for ddl=oddl and ad=oad
335 Int_t iimod = (oad - 1) * 12 + iadc;
336 Int_t iModule = AliITSRawStreamSSD::GetModuleNumber(oddl,iimod);
337 if(iModule==-1) continue;
338 // cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<endl;
339 cal = (AliITSCalibrationSSD*)GetResp(iModule);
344 for(Int_t istrip=0; istrip<768; istrip++) { // P-side
345 Int_t signal = matrix[iadc][istrip];
346 pedestal = cal->GetPedestalP(istrip);
347 matrix[iadc][istrip]=signal-(Int_t)pedestal;
353 for(Int_t l=0; l<6; l++) {
355 for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
357 for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
362 for(Int_t istrip=0; istrip<768; istrip++) { // P-side
364 Int_t signal = TMath::Abs(matrix[iadc][istrip]);
367 noise = cal->GetNoiseP(istrip); if(noise<1.) signal = 65535;
368 if(signal<5*noise) signal = 65535; // in case ZS was not done in hw do it now
369 if( (signal<30.) || (istrip<10) || (istrip>758) ) signal=65535;
372 gain = cal->GetGainP(istrip);
373 signal = (Int_t) ( signal * gain ); // signal is corrected for gain
374 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
376 q += signal; // add digit to current cluster
377 y += istrip * signal;
384 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
386 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
389 cluster.SetNd(nDigits);
390 cluster.SetLabels(lab);
392 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
394 //Split suspiciously big cluster
395 if (nDigits > 4&&nDigits < 25) {
396 cluster.SetY(y/q - 0.25*nDigits);
398 if (nClusters[0] == kMax) {
399 Error("FindClustersSSD", "Too many 1D clusters !");
402 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
403 cluster2.SetY(y/q + 0.25*nDigits);
404 cluster2.SetQ(0.5*q);
405 cluster2.SetNd(nDigits);
406 cluster2.SetLabels(lab);
416 } // loop over strip on P-side
418 // if last strip does have signal
421 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
423 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
426 cluster.SetNd(nDigits);
427 cluster.SetLabels(lab);
429 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
431 //Split suspiciously big cluster
432 if (nDigits > 4&&nDigits < 25) {
433 cluster.SetY(y/q - 0.25*nDigits);
435 if (nClusters[0] == kMax) {
436 Error("FindClustersSSD", "Too many 1D clusters !");
439 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
440 cluster2.SetY(y/q + 0.25*nDigits);
441 cluster2.SetQ(0.5*q);
442 cluster2.SetNd(nDigits);
443 cluster2.SetLabels(lab);
454 for(Int_t istrip=768; istrip<1536; istrip++) { // P-side
455 Int_t signal = matrix[iadc][istrip];
456 pedestal = cal->GetPedestalN(1535-istrip);
457 matrix[iadc][istrip]=signal-(Int_t)pedestal;
462 for(Int_t l=6; l<12; l++) {
464 for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
466 for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
472 for(Int_t istrip=768; istrip<1536; istrip++) { // N-side
474 Int_t signal = TMath::Abs(matrix[iadc][istrip]);
475 //cout<<"####"<<" "<<oddl<<" "<<oad<<" "<<iadc<<" "<<istrip<<" "<<signal<<endl;
477 Int_t strip = 1535-istrip;
480 noise = cal->GetNoiseN(strip); if(noise<1.) signal=65535;
481 if(signal<5*noise) signal = 65535; // in case ZS was not done in hw do it now
482 if( (signal<30.) || (istrip<778) || (istrip>1526) ) signal=65535;
485 // cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<" strip= "<<istrip<<
486 // " sig="<<signal<<" "<<cal->GetPedestalN(strip)<<endl;
487 gain = cal->GetGainN(strip);
488 signal = (Int_t) ( signal * gain); // signal is corrected for gain
489 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
491 // add digit to current cluster
500 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
502 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
505 cluster.SetNd(nDigits);
506 cluster.SetLabels(lab);
508 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
510 //Split suspiciously big cluster
511 if (nDigits > 4&&nDigits < 25) {
512 cluster.SetY(y/q - 0.25*nDigits);
514 if (nClusters[1] == kMax) {
515 Error("FindClustersSSD", "Too many 1D clusters !");
518 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
519 cluster2.SetY(y/q + 0.25*nDigits);
520 cluster2.SetQ(0.5*q);
521 cluster2.SetNd(nDigits);
522 cluster2.SetLabels(lab);
532 } // loop over strips on N-side
536 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
538 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
541 cluster.SetNd(nDigits);
542 cluster.SetLabels(lab);
544 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
546 //Split suspiciously big cluster
547 if (nDigits > 4&&nDigits < 25) {
548 cluster.SetY(y/q - 0.25*nDigits);
550 if (nClusters[1] == kMax) {
551 Error("FindClustersSSD", "Too many 1D clusters !");
554 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
555 cluster2.SetY(y/q + 0.25*nDigits);
556 cluster2.SetQ(0.5*q);
557 cluster2.SetNd(nDigits);
558 cluster2.SetLabels(lab);
569 if((nClusters[0])&&(nClusters[1])) {
571 //cout<<"creating recpoint for module="<<iModule<<" "<<nClusters[0]<<" "<<nClusters[1]<<endl;
572 clusters[iModule] = new TClonesArray("AliITSRecPoint");
575 FindClustersSSD(&clusters1D[0][0], nClusters[0],
576 &clusters1D[1][0], nClusters[1], clusters[iModule]);
577 Int_t nClusters = clusters[iModule]->GetEntriesFast();
578 nClustersSSD += nClusters;
581 nClusters[0] = nClusters[1] = 0;
590 Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD);
593 void AliITSClusterFinderV2SSD::
594 FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
595 Ali1Dcluster* pos, Int_t np,
596 TClonesArray *clusters) {
597 //------------------------------------------------------------
598 // Actual SSD cluster finder
599 //------------------------------------------------------------
603 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
605 TClonesArray &cl=*clusters;
607 Float_t tanp=fTanP, tann=fTanN;
608 if (fModule>fLastSSD1) {tann=fTanP; tanp=fTanN;}
609 Int_t idet=fNdet[fModule];
612 Int_t negativepair[30000];
613 Int_t cnegative[3000];
615 Int_t positivepair[30000];
616 Int_t cpositive[3000];
618 for (Int_t i=0;i<3000;i++) {cnegative[i]=0; cused1[i]=0;}
619 for (Int_t i=0;i<3000;i++) {cpositive[i]=0; cused2[i]=0;}
620 for (Int_t i=0;i<30000;i++) {negativepair[i]=0; positivepair[i]=0;}
622 if ((np*nn) > fgPairsSize) {
623 if (fgPairs) delete [] fgPairs;
624 fgPairsSize = 4*np*nn;
625 fgPairs = new Short_t[fgPairsSize];
627 memset(fgPairs,0,sizeof(Short_t)*np*nn);
630 // find available pairs
632 for (Int_t i=0; i<np; i++) {
633 Float_t yp=pos[i].GetY()*fYpitchSSD;
634 if (pos[i].GetQ()<3) continue;
635 for (Int_t j=0; j<nn; j++) {
636 if (neg[j].GetQ()<3) continue;
637 Float_t yn=neg[j].GetY()*fYpitchSSD;
638 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
639 Float_t yt=yn + tann*zt;
640 zt-=fHlSSD; yt-=fHwSSD;
641 if (TMath::Abs(yt)<fHwSSD+0.01)
642 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
643 negativepair[i*10+cnegative[i]] =j; //index
644 positivepair[j*10+cpositive[j]] =i;
645 cnegative[i]++; //counters
653 // try to recover points out of but close to the module boundaries
655 for (Int_t i=0; i<np; i++) {
656 Float_t yp=pos[i].GetY()*fYpitchSSD;
657 if (pos[i].GetQ()<3) continue;
658 for (Int_t j=0; j<nn; j++) {
659 if (neg[j].GetQ()<3) continue;
660 // if both 1Dclusters have an other cross continue
661 if (cpositive[j]&&cnegative[i]) continue;
662 Float_t yn=neg[j].GetY()*fYpitchSSD;
663 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
664 Float_t yt=yn + tann*zt;
665 zt-=fHlSSD; yt-=fHwSSD;
666 if (TMath::Abs(yt)<fHwSSD+0.1)
667 if (TMath::Abs(zt)<fHlSSD+0.15) {
668 // tag 1Dcluster (eventually will produce low quality recpoint)
669 if (cnegative[i]==0) pos[i].SetNd(100); // not available pair
670 if (cpositive[j]==0) neg[j].SetNd(100); // not available pair
671 negativepair[i*10+cnegative[i]] =j; //index
672 positivepair[j*10+cpositive[j]] =i;
673 cnegative[i]++; //counters
686 static AliITSRecoParam *repa = NULL;
688 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
690 repa = AliITSRecoParam::GetHighFluxParam();
691 AliWarning("Using default AliITSRecoParam class");
695 if(repa->GetUseChargeMatchingInClusterFinderSSD()==kTRUE) {
703 for (Int_t ip=0;ip<np;ip++){
704 Float_t ybest=1000,zbest=1000,qbest=0;
706 // select gold clusters
707 if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){
708 Float_t yp=pos[ip].GetY()*fYpitchSSD;
709 Int_t j = negativepair[10*ip];
710 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
712 Float_t yn=neg[j].GetY()*fYpitchSSD;
713 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
714 Float_t yt=yn + tann*zt;
715 zt-=fHlSSD; yt-=fHwSSD;
717 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
719 //cout<<yt<<" "<<zt<<" "<<qbest<<endl;
722 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
723 mT2L->MasterToLocal(loc,trk);
727 lp[2]=0.0025*0.0025; //SigmaY2
728 lp[3]=0.110*0.110; //SigmaZ2
731 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
732 for (Int_t ilab=0;ilab<3;ilab++){
733 milab[ilab] = pos[ip].GetLabel(ilab);
734 milab[ilab+3] = neg[j].GetLabel(ilab);
738 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
739 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
740 AliITSRecPoint * cl2;
742 if(clusters){ // Note clusters != 0 when method is called for rawdata
745 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
747 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
749 cl2->SetChargeRatio(ratio);
752 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
760 else{ // Note clusters == 0 when method is called for digits
762 cl2 = new AliITSRecPoint(milab,lp,info);
764 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
766 cl2->SetChargeRatio(ratio);
769 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
775 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" gold"<<endl;
776 fDetTypeRec->AddRecPoint(*cl2);
782 for (Int_t ip=0;ip<np;ip++){
783 Float_t ybest=1000,zbest=1000,qbest=0;
786 // select "silber" cluster
787 if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){
788 Int_t in = negativepair[10*ip];
789 Int_t ip2 = positivepair[10*in];
790 if (ip2==ip) ip2 = positivepair[10*in+1];
791 Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
792 if (TMath::Abs(pcharge-neg[in].GetQ())<10){
795 if (fgPairs[ip*nn+in]==100){ //
796 Float_t yp=pos[ip].GetY()*fYpitchSSD;
797 Float_t yn=neg[in].GetY()*fYpitchSSD;
798 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
799 Float_t yt=yn + tann*zt;
800 zt-=fHlSSD; yt-=fHwSSD;
802 qbest =pos[ip].GetQ();
804 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
805 mT2L->MasterToLocal(loc,trk);
809 lp[2]=0.0025*0.0025; //SigmaY2
810 lp[3]=0.110*0.110; //SigmaZ2
813 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
814 for (Int_t ilab=0;ilab<3;ilab++){
815 milab[ilab] = pos[ip].GetLabel(ilab);
816 milab[ilab+3] = neg[in].GetLabel(ilab);
820 ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ());
821 milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
822 Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
824 AliITSRecPoint * cl2;
827 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
829 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
831 cl2->SetChargeRatio(ratio);
833 fgPairs[ip*nn+in] = 5;
834 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
836 fgPairs[ip*nn+in] = 6;
840 cl2 = new AliITSRecPoint(milab,lp,info);
841 cl2->SetChargeRatio(ratio);
843 fgPairs[ip*nn+in] = 5;
844 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
846 fgPairs[ip*nn+in] = 6;
848 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver1"<<endl;
850 fDetTypeRec->AddRecPoint(*cl2);
858 // if (!(cused1[ip2] || cused2[in])){ //
859 if (fgPairs[ip2*nn+in]==100){
860 Float_t yp=pos[ip2].GetY()*fYpitchSSD;
861 Float_t yn=neg[in].GetY()*fYpitchSSD;
862 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
863 Float_t yt=yn + tann*zt;
864 zt-=fHlSSD; yt-=fHwSSD;
866 qbest =pos[ip2].GetQ();
868 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
869 mT2L->MasterToLocal(loc,trk);
873 lp[2]=0.0025*0.0025; //SigmaY2
874 lp[3]=0.110*0.110; //SigmaZ2
877 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
878 for (Int_t ilab=0;ilab<3;ilab++){
879 milab[ilab] = pos[ip2].GetLabel(ilab);
880 milab[ilab+3] = neg[in].GetLabel(ilab);
884 ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ());
885 milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
886 Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
888 AliITSRecPoint * cl2;
890 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
892 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
894 cl2->SetChargeRatio(ratio);
896 fgPairs[ip2*nn+in] =5;
897 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
899 fgPairs[ip2*nn+in] =6;
903 cl2 = new AliITSRecPoint(milab,lp,info);
904 cl2->SetChargeRatio(ratio);
906 fgPairs[ip2*nn+in] =5;
907 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
909 fgPairs[ip2*nn+in] =6;
912 // cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver2"<<endl;
913 fDetTypeRec->AddRecPoint(*cl2);
924 } // use charge matching
928 for (Int_t jn=0;jn<nn;jn++){
929 if (cused2[jn]) continue;
930 Float_t ybest=1000,zbest=1000,qbest=0;
931 // select "silber" cluster
932 if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){
933 Int_t ip = positivepair[10*jn];
934 Int_t jn2 = negativepair[10*ip];
935 if (jn2==jn) jn2 = negativepair[10*ip+1];
936 Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
938 if (TMath::Abs(pcharge-pos[ip].GetQ())<10){
941 // if (!(cused1[ip]||cused2[jn])){
942 if (fgPairs[ip*nn+jn]==100){
943 Float_t yn=neg[jn].GetY()*fYpitchSSD;
944 Float_t yp=pos[ip].GetY()*fYpitchSSD;
945 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
946 Float_t yt=yn + tann*zt;
947 zt-=fHlSSD; yt-=fHwSSD;
949 qbest =neg[jn].GetQ();
951 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
952 mT2L->MasterToLocal(loc,trk);
956 lp[2]=0.0025*0.0025; //SigmaY2
957 lp[3]=0.110*0.110; //SigmaZ2
960 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
961 for (Int_t ilab=0;ilab<3;ilab++){
962 milab[ilab] = pos[ip].GetLabel(ilab);
963 milab[ilab+3] = neg[jn].GetLabel(ilab);
967 ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ());
968 milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
969 Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]};
971 AliITSRecPoint * cl2;
973 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
975 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
977 cl2->SetChargeRatio(ratio);
979 fgPairs[ip*nn+jn] =7;
980 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
987 cl2 = new AliITSRecPoint(milab,lp,info);
988 cl2->SetChargeRatio(ratio);
990 fgPairs[ip*nn+jn] =7;
991 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
995 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN1"<<endl;
997 fDetTypeRec->AddRecPoint(*cl2);
1003 // if (!(cused1[ip]||cused2[jn2])){
1004 if (fgPairs[ip*nn+jn2]==100){
1005 Float_t yn=neg[jn2].GetY()*fYpitchSSD;
1006 Double_t yp=pos[ip].GetY()*fYpitchSSD;
1007 Double_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1008 Double_t yt=yn + tann*zt;
1009 zt-=fHlSSD; yt-=fHwSSD;
1010 ybest =yt; zbest=zt;
1011 qbest =neg[jn2].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
1022 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1023 for (Int_t ilab=0;ilab<3;ilab++){
1024 milab[ilab] = pos[ip].GetLabel(ilab);
1025 milab[ilab+3] = neg[jn2].GetLabel(ilab);
1028 CheckLabels2(milab);
1029 ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
1030 milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
1031 Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]};
1032 AliITSRecPoint * cl2;
1034 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1036 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1038 cl2->SetChargeRatio(ratio);
1039 fgPairs[ip*nn+jn2]=7;
1041 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
1043 fgPairs[ip*nn+jn2]=8;
1048 cl2 = new AliITSRecPoint(milab,lp,info);
1049 cl2->SetChargeRatio(ratio);
1050 fgPairs[ip*nn+jn2]=7;
1052 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
1054 fgPairs[ip*nn+jn2]=8;
1056 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN2"<<endl;
1058 fDetTypeRec->AddRecPoint(*cl2);
1070 for (Int_t ip=0;ip<np;ip++){
1071 Float_t ybest=1000,zbest=1000,qbest=0;
1075 if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){
1076 Float_t minchargediff =4.;
1078 for (Int_t di=0;di<cnegative[ip];di++){
1079 Int_t jc = negativepair[ip*10+di];
1080 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1081 if (TMath::Abs(chargedif)<minchargediff){
1083 minchargediff = TMath::Abs(chargedif);
1086 if (j<0) continue; // not proper cluster
1089 for (Int_t di=0;di<cnegative[ip];di++){
1090 Int_t jc = negativepair[ip*10+di];
1091 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1092 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1094 if (count>1) continue; // more than one "proper" cluster for positive
1097 for (Int_t dj=0;dj<cpositive[j];dj++){
1098 Int_t ic = positivepair[j*10+dj];
1099 Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
1100 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1102 if (count>1) continue; // more than one "proper" cluster for negative
1107 for (Int_t dj=0;dj<cnegative[jp];dj++){
1108 Int_t ic = positivepair[jp*10+dj];
1109 Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
1110 if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1112 if (count>1) continue;
1113 if (fgPairs[ip*nn+j]<100) continue;
1115 //almost gold clusters
1116 Float_t yp=pos[ip].GetY()*fYpitchSSD;
1117 Float_t yn=neg[j].GetY()*fYpitchSSD;
1118 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1119 Float_t yt=yn + tann*zt;
1120 zt-=fHlSSD; yt-=fHwSSD;
1122 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1124 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1125 mT2L->MasterToLocal(loc,trk);
1129 lp[2]=0.0025*0.0025; //SigmaY2
1130 lp[3]=0.110*0.110; //SigmaZ2
1132 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1133 for (Int_t ilab=0;ilab<3;ilab++){
1134 milab[ilab] = pos[ip].GetLabel(ilab);
1135 milab[ilab+3] = neg[j].GetLabel(ilab);
1138 CheckLabels2(milab);
1139 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1140 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1141 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1142 AliITSRecPoint * cl2;
1144 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1146 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1148 cl2->SetChargeRatio(ratio);
1150 fgPairs[ip*nn+j]=10;
1151 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1153 fgPairs[ip*nn+j]=11;
1159 cl2 = new AliITSRecPoint(milab,lp,info);
1160 cl2->SetChargeRatio(ratio);
1162 fgPairs[ip*nn+j]=10;
1163 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1165 fgPairs[ip*nn+j]=11;
1170 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" 2x2"<<endl;
1172 fDetTypeRec->AddRecPoint(*cl2);
1180 for (Int_t i=0; i<np; i++) {
1181 Float_t ybest=1000,zbest=1000,qbest=0;
1182 Float_t yp=pos[i].GetY()*fYpitchSSD;
1183 if (pos[i].GetQ()<3) continue;
1184 for (Int_t j=0; j<nn; j++) {
1185 // for (Int_t di = 0;di<cpositive[i];di++){
1186 // Int_t j = negativepair[10*i+di];
1187 if (neg[j].GetQ()<3) continue;
1188 if (cused2[j]||cused1[i]) continue;
1189 if (fgPairs[i*nn+j]>0 &&fgPairs[i*nn+j]<100) continue;
1190 ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ());
1191 Float_t yn=neg[j].GetY()*fYpitchSSD;
1192 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1193 Float_t yt=yn + tann*zt;
1194 zt-=fHlSSD; yt-=fHwSSD;
1195 if (TMath::Abs(yt)<fHwSSD+0.01)
1196 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
1198 qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
1200 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1201 mT2L->MasterToLocal(loc,trk);
1205 lp[2]=0.0025*0.0025; //SigmaY2
1206 lp[3]=0.110*0.110; //SigmaZ2
1209 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1210 for (Int_t ilab=0;ilab<3;ilab++){
1211 milab[ilab] = pos[i].GetLabel(ilab);
1212 milab[ilab+3] = neg[j].GetLabel(ilab);
1215 CheckLabels2(milab);
1216 milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
1217 Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1218 AliITSRecPoint * cl2;
1220 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1222 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1224 cl2->SetChargeRatio(ratio);
1225 cl2->SetType(100+cpositive[j]+cnegative[i]);
1228 cl2 = new AliITSRecPoint(milab,lp,info);
1229 cl2->SetChargeRatio(ratio);
1230 cl2->SetType(100+cpositive[j]+cnegative[i]);
1232 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" other"<<endl;
1234 fDetTypeRec->AddRecPoint(*cl2);
1239 if (fgPairs[i*nn+j]<100){
1240 printf("problem:- %d\n", fgPairs[i*nn+j]);
1242 if (cnegative[i]<2&&cpositive[j]<2){
1243 printf("problem:- %d\n", fgPairs[i*nn+j]);