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 "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 //------------------------------------------------------------
223 const UInt_t *evid; evid = rawReader->GetEventId();
224 cout<<"Event="<<evid[0]<<endl;
226 AliITSRawStreamSSD inputSSD(rawReader);
227 // rawReader->SelectEquipment(-1,0,15);
228 FindClustersSSD(&inputSSD,clusters);
232 void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
233 TClonesArray** clusters)
235 //------------------------------------------------------------
236 // Actual SSD cluster finder for raw data
237 //------------------------------------------------------------
238 Int_t nClustersSSD = 0;
239 const Int_t kMax = 1000;
240 Ali1Dcluster clusters1D[2][kMax];
241 Int_t nClusters[2] = {0, 0};
242 Int_t lab[3]={-2,-2,-2};
248 // Float_t pedestal=0.;
250 AliITSCalibrationSSD* cal=NULL;
252 Int_t matrix[12][1536];
259 Int_t osignal = 65535;
263 // read raw data input stream
266 // reset signal matrix
267 for(Int_t i=0; i<12; i++) { for(Int_t j=0; j<1536; j++) { matrix[i][j] = 65535;} }
271 matrix[oadc][ostrip] = osignal; // recover data from previous occurence of input->Next()
274 // buffer data for ddl=iddl and ad=iad
277 next = input->Next();
278 if((!next)&&(input->flag)) continue;
279 Int_t ddl=input->GetDDL();
280 Int_t ad=input->GetAD();
281 Int_t adc = input->GetADC(); adc = (adc<6)? adc : adc - 2;
282 Int_t strip = input->GetStrip();
283 if(input->GetSideFlag()) strip=1535-strip;
284 Int_t signal = input->GetSignal();
285 //cout<<ddl<<" "<<ad<<" "<<adc<<" "<<strip<<" "<<signal<<endl;
287 if((ddl==iddl)&&(ad==iad)) {n++; matrix[adc][strip] = signal;}
288 else {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
290 if(!next) {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
295 if(!next && oddl<0) break;
297 if(n==0) continue; // first occurence
301 for(Int_t iadc=0; iadc<12; iadc++) { // loop over ADC index for ddl=oddl and ad=oad
303 Int_t iimod = (oad - 1) * 12 + iadc;
304 Int_t iModule = AliITSRawStreamSSD::GetModuleNumber(oddl,iimod);
305 if(iModule==-1) continue;
306 // cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<endl;
307 cal = (AliITSCalibrationSSD*)GetResp(iModule);
312 for(Int_t istrip=0; istrip<768; istrip++) { // P-side
313 Int_t signal = matrix[iadc][istrip];
314 pedestal = cal->GetPedestalP(istrip);
315 matrix[iadc][istrip]=signal-(Int_t)pedestal;
321 for(Int_t l=0; l<6; l++) {
323 for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
325 for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
330 for(Int_t istrip=0; istrip<768; istrip++) { // P-side
332 Int_t signal = TMath::Abs(matrix[iadc][istrip]);
335 noise = cal->GetNoiseP(istrip); if(noise<1.) signal = 65535;
336 if(signal<5*noise) signal = 65535; // in case ZS was not done in hw do it now
337 if( (signal<30.) || (istrip<10) || (istrip>758) ) signal=65535;
340 gain = cal->GetGainP(istrip);
341 signal = (Int_t) ( signal * gain ); // signal is corrected for gain
342 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
344 q += signal; // add digit to current cluster
345 y += istrip * signal;
352 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
354 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
357 cluster.SetNd(nDigits);
358 cluster.SetLabels(lab);
360 //Split suspiciously big cluster
361 if (nDigits > 4&&nDigits < 25) {
362 cluster.SetY(y/q - 0.25*nDigits);
364 if (nClusters[0] == kMax) {
365 Error("FindClustersSSD", "Too many 1D clusters !");
368 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
369 cluster2.SetY(y/q + 0.25*nDigits);
370 cluster2.SetQ(0.5*q);
371 cluster2.SetNd(nDigits);
372 cluster2.SetLabels(lab);
382 } // loop over strip on P-side
384 // if last strip does have signal
387 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
389 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
392 cluster.SetNd(nDigits);
393 cluster.SetLabels(lab);
395 //Split suspiciously big cluster
396 if (nDigits > 4&&nDigits < 25) {
397 cluster.SetY(y/q - 0.25*nDigits);
399 if (nClusters[0] == kMax) {
400 Error("FindClustersSSD", "Too many 1D clusters !");
403 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
404 cluster2.SetY(y/q + 0.25*nDigits);
405 cluster2.SetQ(0.5*q);
406 cluster2.SetNd(nDigits);
407 cluster2.SetLabels(lab);
417 for(Int_t istrip=768; istrip<1536; istrip++) { // P-side
418 Int_t signal = matrix[iadc][istrip];
419 pedestal = cal->GetPedestalN(1535-istrip);
420 matrix[iadc][istrip]=signal-(Int_t)pedestal;
425 for(Int_t l=6; l<12; l++) {
427 for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
429 for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
435 for(Int_t istrip=768; istrip<1536; istrip++) { // N-side
437 Int_t signal = TMath::Abs(matrix[iadc][istrip]);
438 //cout<<"####"<<" "<<oddl<<" "<<oad<<" "<<iadc<<" "<<istrip<<" "<<signal<<endl;
440 Int_t strip = 1535-istrip;
443 noise = cal->GetNoiseN(strip); if(noise<1.) signal=65535;
444 if(signal<5*noise) signal = 65535; // in case ZS was not done in hw do it now
445 if( (signal<30.) || (istrip<778) || (istrip>1526) ) signal=65535;
448 // cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<" strip= "<<istrip<<
449 // " sig="<<signal<<" "<<cal->GetPedestalN(strip)<<endl;
450 gain = cal->GetGainN(strip);
451 signal = (Int_t) ( signal * gain); // signal is corrected for gain
452 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
454 // add digit to current cluster
463 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
465 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
468 cluster.SetNd(nDigits);
469 cluster.SetLabels(lab);
471 //Split suspiciously big cluster
472 if (nDigits > 4&&nDigits < 25) {
473 cluster.SetY(y/q - 0.25*nDigits);
475 if (nClusters[1] == kMax) {
476 Error("FindClustersSSD", "Too many 1D clusters !");
479 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
480 cluster2.SetY(y/q + 0.25*nDigits);
481 cluster2.SetQ(0.5*q);
482 cluster2.SetNd(nDigits);
483 cluster2.SetLabels(lab);
492 } // loop over strips on N-side
496 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
498 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
501 cluster.SetNd(nDigits);
502 cluster.SetLabels(lab);
504 //Split suspiciously big cluster
505 if (nDigits > 4&&nDigits < 25) {
506 cluster.SetY(y/q - 0.25*nDigits);
508 if (nClusters[1] == kMax) {
509 Error("FindClustersSSD", "Too many 1D clusters !");
512 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
513 cluster2.SetY(y/q + 0.25*nDigits);
514 cluster2.SetQ(0.5*q);
515 cluster2.SetNd(nDigits);
516 cluster2.SetLabels(lab);
526 if((nClusters[0])&&(nClusters[1])) {
528 //cout<<"creating recpoint for module="<<iModule<<" "<<nClusters[0]<<" "<<nClusters[1]<<endl;
529 clusters[iModule] = new TClonesArray("AliITSRecPoint");
532 FindClustersSSD(&clusters1D[0][0], nClusters[0],
533 &clusters1D[1][0], nClusters[1], clusters[iModule]);
534 Int_t nClusters = clusters[iModule]->GetEntriesFast();
535 nClustersSSD += nClusters;
538 nClusters[0] = nClusters[1] = 0;
547 Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD);
550 void AliITSClusterFinderV2SSD::
551 FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
552 Ali1Dcluster* pos, Int_t np,
553 TClonesArray *clusters) {
554 //------------------------------------------------------------
555 // Actual SSD cluster finder
556 //------------------------------------------------------------
560 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
562 TClonesArray &cl=*clusters;
564 Float_t tanp=fTanP, tann=fTanN;
565 if (fModule>fLastSSD1) {tann=fTanP; tanp=fTanN;}
566 Int_t idet=fNdet[fModule];
569 Int_t negativepair[30000];
570 Int_t cnegative[3000];
572 Int_t positivepair[30000];
573 Int_t cpositive[3000];
575 for (Int_t i=0;i<3000;i++) {cnegative[i]=0; cused1[i]=0;}
576 for (Int_t i=0;i<3000;i++) {cpositive[i]=0; cused2[i]=0;}
577 for (Int_t i=0;i<30000;i++) {negativepair[i]=0; positivepair[i]=0;}
579 if ((np*nn) > fgPairsSize) {
580 if (fgPairs) delete [] fgPairs;
581 fgPairsSize = 4*np*nn;
582 fgPairs = new Short_t[fgPairsSize];
584 memset(fgPairs,0,sizeof(Short_t)*np*nn);
587 // find available pairs
589 for (Int_t i=0; i<np; i++) {
590 Float_t yp=pos[i].GetY()*fYpitchSSD;
591 if (pos[i].GetQ()<3) continue;
592 for (Int_t j=0; j<nn; j++) {
593 if (neg[j].GetQ()<3) continue;
594 Float_t yn=neg[j].GetY()*fYpitchSSD;
595 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
596 Float_t yt=yn + tann*zt;
597 zt-=fHlSSD; yt-=fHwSSD;
598 if (TMath::Abs(yt)<fHwSSD+0.01)
599 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
600 negativepair[i*10+cnegative[i]] =j; //index
601 positivepair[j*10+cpositive[j]] =i;
602 cnegative[i]++; //counters
610 // try to recover points out of but close to the module boundaries
612 for (Int_t i=0; i<np; i++) {
613 Float_t yp=pos[i].GetY()*fYpitchSSD;
614 if (pos[i].GetQ()<3) continue;
615 for (Int_t j=0; j<nn; j++) {
616 if (neg[j].GetQ()<3) continue;
617 // if both 1Dclusters have an other cross continue
618 if (cpositive[j]&&cnegative[i]) continue;
619 Float_t yn=neg[j].GetY()*fYpitchSSD;
620 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
621 Float_t yt=yn + tann*zt;
622 zt-=fHlSSD; yt-=fHwSSD;
623 if (TMath::Abs(yt)<fHwSSD+0.1)
624 if (TMath::Abs(zt)<fHlSSD+0.15) {
625 // tag 1Dcluster (eventually will produce low quality recpoint)
626 if (cnegative[i]==0) pos[i].SetNd(100); // not available pair
627 if (cpositive[j]==0) neg[j].SetNd(100); // not available pair
628 negativepair[i*10+cnegative[i]] =j; //index
629 positivepair[j*10+cpositive[j]] =i;
630 cnegative[i]++; //counters
645 for (Int_t ip=0;ip<np;ip++){
646 Float_t ybest=1000,zbest=1000,qbest=0;
648 // select gold clusters
649 if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){
650 Float_t yp=pos[ip].GetY()*fYpitchSSD;
651 Int_t j = negativepair[10*ip];
652 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
654 Float_t yn=neg[j].GetY()*fYpitchSSD;
655 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
656 Float_t yt=yn + tann*zt;
657 zt-=fHlSSD; yt-=fHwSSD;
659 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
661 //cout<<yt<<" "<<zt<<" "<<qbest<<endl;
664 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
665 mT2L->MasterToLocal(loc,trk);
669 lp[2]=0.0025*0.0025; //SigmaY2
670 lp[3]=0.110*0.110; //SigmaZ2
673 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
674 for (Int_t ilab=0;ilab<3;ilab++){
675 milab[ilab] = pos[ip].GetLabel(ilab);
676 milab[ilab+3] = neg[j].GetLabel(ilab);
680 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
681 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
682 AliITSRecPoint * cl2;
684 if(clusters){ // Note clusters != 0 when method is called for rawdata
687 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
689 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
691 cl2->SetChargeRatio(ratio);
694 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
702 else{ // Note clusters == 0 when method is called for digits
704 cl2 = new AliITSRecPoint(milab,lp,info);
706 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
708 cl2->SetChargeRatio(ratio);
711 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
717 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" gold"<<endl;
718 fDetTypeRec->AddRecPoint(*cl2);
724 for (Int_t ip=0;ip<np;ip++){
725 Float_t ybest=1000,zbest=1000,qbest=0;
728 // select "silber" cluster
729 if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){
730 Int_t in = negativepair[10*ip];
731 Int_t ip2 = positivepair[10*in];
732 if (ip2==ip) ip2 = positivepair[10*in+1];
733 Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
734 if (TMath::Abs(pcharge-neg[in].GetQ())<10){
737 if (fgPairs[ip*nn+in]==100){ //
738 Float_t yp=pos[ip].GetY()*fYpitchSSD;
739 Float_t yn=neg[in].GetY()*fYpitchSSD;
740 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
741 Float_t yt=yn + tann*zt;
742 zt-=fHlSSD; yt-=fHwSSD;
744 qbest =pos[ip].GetQ();
746 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
747 mT2L->MasterToLocal(loc,trk);
751 lp[2]=0.0025*0.0025; //SigmaY2
752 lp[3]=0.110*0.110; //SigmaZ2
755 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
756 for (Int_t ilab=0;ilab<3;ilab++){
757 milab[ilab] = pos[ip].GetLabel(ilab);
758 milab[ilab+3] = neg[in].GetLabel(ilab);
762 ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ());
763 milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
764 Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
766 AliITSRecPoint * cl2;
769 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
771 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
773 cl2->SetChargeRatio(ratio);
775 fgPairs[ip*nn+in] = 5;
776 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
778 fgPairs[ip*nn+in] = 6;
782 cl2 = new AliITSRecPoint(milab,lp,info);
783 cl2->SetChargeRatio(ratio);
785 fgPairs[ip*nn+in] = 5;
786 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
788 fgPairs[ip*nn+in] = 6;
790 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver1"<<endl;
792 fDetTypeRec->AddRecPoint(*cl2);
800 // if (!(cused1[ip2] || cused2[in])){ //
801 if (fgPairs[ip2*nn+in]==100){
802 Float_t yp=pos[ip2].GetY()*fYpitchSSD;
803 Float_t yn=neg[in].GetY()*fYpitchSSD;
804 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
805 Float_t yt=yn + tann*zt;
806 zt-=fHlSSD; yt-=fHwSSD;
808 qbest =pos[ip2].GetQ();
810 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
811 mT2L->MasterToLocal(loc,trk);
815 lp[2]=0.0025*0.0025; //SigmaY2
816 lp[3]=0.110*0.110; //SigmaZ2
819 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
820 for (Int_t ilab=0;ilab<3;ilab++){
821 milab[ilab] = pos[ip2].GetLabel(ilab);
822 milab[ilab+3] = neg[in].GetLabel(ilab);
826 ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ());
827 milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
828 Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
830 AliITSRecPoint * cl2;
832 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
834 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
836 cl2->SetChargeRatio(ratio);
838 fgPairs[ip2*nn+in] =5;
839 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
841 fgPairs[ip2*nn+in] =6;
845 cl2 = new AliITSRecPoint(milab,lp,info);
846 cl2->SetChargeRatio(ratio);
848 fgPairs[ip2*nn+in] =5;
849 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
851 fgPairs[ip2*nn+in] =6;
854 // cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver2"<<endl;
855 fDetTypeRec->AddRecPoint(*cl2);
867 for (Int_t jn=0;jn<nn;jn++){
868 if (cused2[jn]) continue;
869 Float_t ybest=1000,zbest=1000,qbest=0;
870 // select "silber" cluster
871 if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){
872 Int_t ip = positivepair[10*jn];
873 Int_t jn2 = negativepair[10*ip];
874 if (jn2==jn) jn2 = negativepair[10*ip+1];
875 Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
877 if (TMath::Abs(pcharge-pos[ip].GetQ())<10){
880 // if (!(cused1[ip]||cused2[jn])){
881 if (fgPairs[ip*nn+jn]==100){
882 Float_t yn=neg[jn].GetY()*fYpitchSSD;
883 Float_t yp=pos[ip].GetY()*fYpitchSSD;
884 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
885 Float_t yt=yn + tann*zt;
886 zt-=fHlSSD; yt-=fHwSSD;
888 qbest =neg[jn].GetQ();
890 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
891 mT2L->MasterToLocal(loc,trk);
895 lp[2]=0.0025*0.0025; //SigmaY2
896 lp[3]=0.110*0.110; //SigmaZ2
899 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
900 for (Int_t ilab=0;ilab<3;ilab++){
901 milab[ilab] = pos[ip].GetLabel(ilab);
902 milab[ilab+3] = neg[jn].GetLabel(ilab);
906 ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ());
907 milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
908 Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]};
910 AliITSRecPoint * cl2;
912 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
914 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
916 cl2->SetChargeRatio(ratio);
918 fgPairs[ip*nn+jn] =7;
919 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
926 cl2 = new AliITSRecPoint(milab,lp,info);
927 cl2->SetChargeRatio(ratio);
929 fgPairs[ip*nn+jn] =7;
930 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
934 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN1"<<endl;
936 fDetTypeRec->AddRecPoint(*cl2);
942 // if (!(cused1[ip]||cused2[jn2])){
943 if (fgPairs[ip*nn+jn2]==100){
944 Float_t yn=neg[jn2].GetY()*fYpitchSSD;
945 Double_t yp=pos[ip].GetY()*fYpitchSSD;
946 Double_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
947 Double_t yt=yn + tann*zt;
948 zt-=fHlSSD; yt-=fHwSSD;
950 qbest =neg[jn2].GetQ();
952 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
953 mT2L->MasterToLocal(loc,trk);
957 lp[2]=0.0025*0.0025; //SigmaY2
958 lp[3]=0.110*0.110; //SigmaZ2
961 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
962 for (Int_t ilab=0;ilab<3;ilab++){
963 milab[ilab] = pos[ip].GetLabel(ilab);
964 milab[ilab+3] = neg[jn2].GetLabel(ilab);
968 ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
969 milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
970 Int_t info[3] = {pos[ip].GetNd(),neg[jn2].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);
978 fgPairs[ip*nn+jn2]=7;
980 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
982 fgPairs[ip*nn+jn2]=8;
987 cl2 = new AliITSRecPoint(milab,lp,info);
988 cl2->SetChargeRatio(ratio);
989 fgPairs[ip*nn+jn2]=7;
991 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
993 fgPairs[ip*nn+jn2]=8;
995 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN2"<<endl;
997 fDetTypeRec->AddRecPoint(*cl2);
1009 for (Int_t ip=0;ip<np;ip++){
1010 Float_t ybest=1000,zbest=1000,qbest=0;
1014 if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){
1015 Float_t minchargediff =4.;
1017 for (Int_t di=0;di<cnegative[ip];di++){
1018 Int_t jc = negativepair[ip*10+di];
1019 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1020 if (TMath::Abs(chargedif)<minchargediff){
1022 minchargediff = TMath::Abs(chargedif);
1025 if (j<0) continue; // not proper cluster
1028 for (Int_t di=0;di<cnegative[ip];di++){
1029 Int_t jc = negativepair[ip*10+di];
1030 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1031 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1033 if (count>1) continue; // more than one "proper" cluster for positive
1036 for (Int_t dj=0;dj<cpositive[j];dj++){
1037 Int_t ic = positivepair[j*10+dj];
1038 Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
1039 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1041 if (count>1) continue; // more than one "proper" cluster for negative
1046 for (Int_t dj=0;dj<cnegative[jp];dj++){
1047 Int_t ic = positivepair[jp*10+dj];
1048 Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
1049 if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1051 if (count>1) continue;
1052 if (fgPairs[ip*nn+j]<100) continue;
1054 //almost gold clusters
1055 Float_t yp=pos[ip].GetY()*fYpitchSSD;
1056 Float_t yn=neg[j].GetY()*fYpitchSSD;
1057 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1058 Float_t yt=yn + tann*zt;
1059 zt-=fHlSSD; yt-=fHwSSD;
1061 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1063 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1064 mT2L->MasterToLocal(loc,trk);
1068 lp[2]=0.0025*0.0025; //SigmaY2
1069 lp[3]=0.110*0.110; //SigmaZ2
1071 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1072 for (Int_t ilab=0;ilab<3;ilab++){
1073 milab[ilab] = pos[ip].GetLabel(ilab);
1074 milab[ilab+3] = neg[j].GetLabel(ilab);
1077 CheckLabels2(milab);
1078 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1079 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1080 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1081 AliITSRecPoint * cl2;
1083 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1085 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1087 cl2->SetChargeRatio(ratio);
1089 fgPairs[ip*nn+j]=10;
1090 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1092 fgPairs[ip*nn+j]=11;
1098 cl2 = new AliITSRecPoint(milab,lp,info);
1099 cl2->SetChargeRatio(ratio);
1101 fgPairs[ip*nn+j]=10;
1102 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1104 fgPairs[ip*nn+j]=11;
1109 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" 2x2"<<endl;
1111 fDetTypeRec->AddRecPoint(*cl2);
1119 for (Int_t i=0; i<np; i++) {
1120 Float_t ybest=1000,zbest=1000,qbest=0;
1121 Float_t yp=pos[i].GetY()*fYpitchSSD;
1122 if (pos[i].GetQ()<3) continue;
1123 for (Int_t j=0; j<nn; j++) {
1124 // for (Int_t di = 0;di<cpositive[i];di++){
1125 // Int_t j = negativepair[10*i+di];
1126 if (neg[j].GetQ()<3) continue;
1127 if (cused2[j]||cused1[i]) continue;
1128 if (fgPairs[i*nn+j]>0 &&fgPairs[i*nn+j]<100) continue;
1129 ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ());
1130 Float_t yn=neg[j].GetY()*fYpitchSSD;
1131 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1132 Float_t yt=yn + tann*zt;
1133 zt-=fHlSSD; yt-=fHwSSD;
1134 if (TMath::Abs(yt)<fHwSSD+0.01)
1135 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
1137 qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
1139 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1140 mT2L->MasterToLocal(loc,trk);
1144 lp[2]=0.0025*0.0025; //SigmaY2
1145 lp[3]=0.110*0.110; //SigmaZ2
1148 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1149 for (Int_t ilab=0;ilab<3;ilab++){
1150 milab[ilab] = pos[i].GetLabel(ilab);
1151 milab[ilab+3] = neg[j].GetLabel(ilab);
1154 CheckLabels2(milab);
1155 milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
1156 Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1157 AliITSRecPoint * cl2;
1159 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1161 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1163 cl2->SetChargeRatio(ratio);
1164 cl2->SetType(100+cpositive[j]+cnegative[i]);
1167 cl2 = new AliITSRecPoint(milab,lp,info);
1168 cl2->SetChargeRatio(ratio);
1169 cl2->SetType(100+cpositive[j]+cnegative[i]);
1171 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" other"<<endl;
1173 fDetTypeRec->AddRecPoint(*cl2);
1178 if (fgPairs[i*nn+j]<100){
1179 printf("problem:- %d\n", fgPairs[i*nn+j]);
1181 if (cnegative[i]<2&&cpositive[j]<2){
1182 printf("problem:- %d\n", fgPairs[i*nn+j]);