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;
247 Int_t matrix[12][1536];
254 Int_t osignal = 65535;
258 // read raw data input stream
261 // reset signal matrix
262 for(Int_t i=0; i<12; i++) { for(Int_t j=0; j<1536; j++) { matrix[i][j] = 65535;} }
266 matrix[oadc][ostrip] = osignal; // recover data from previous occurence of input->Next()
269 // buffer data for ddl=iddl and ad=iad
272 next = input->Next();
273 if((!next)&&(input->flag)) continue;
274 Int_t ddl=input->GetDDL();
275 Int_t ad=input->GetAD();
276 Int_t adc = input->GetADC(); adc = (adc<6)? adc : adc - 2;
277 Int_t strip = input->GetStrip();
278 if(input->GetSideFlag()) strip=1535-strip;
279 Int_t signal = input->GetSignal();
280 //cout<<ddl<<" "<<ad<<" "<<adc<<" "<<strip<<" "<<signal<<endl;
282 if((ddl==iddl)&&(ad==iad)) {n++; matrix[adc][strip] = signal;}
283 else {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
289 if(!next && oddl<0) break;
291 if(n==0) continue; // first occurence
295 for(Int_t iadc=0; iadc<12; iadc++) { // loop over ADC index for ddl=oddl and ad=oad
297 Int_t iimod = (oad - 1) * 12 + iadc;
298 Int_t iModule = AliITSRawStreamSSD::GetModuleNumber(oddl,iimod);
299 if(iModule==-1) continue;
300 //cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<endl;
301 cal = (AliITSCalibrationSSD*)GetResp(iModule);
305 for(Int_t istrip=0; istrip<768; istrip++) { // P-side
307 Int_t signal = matrix[iadc][istrip];
309 noise = cal->GetNoiseP(istrip);
310 if(signal<3*noise) signal = 65535; // in case ZS was not done in hw do it now
313 gain = cal->GetGainP(istrip);
314 signal = (Int_t) ( signal * gain ); // signal is corrected for gain
315 //cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<" strip= "<<istrip<<
316 // " sig="<<signal<<endl;
317 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
319 q += signal; // add digit to current cluster
320 y += istrip * signal;
327 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
329 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
332 cluster.SetNd(nDigits);
333 cluster.SetLabels(lab);
335 //Split suspiciously big cluster
336 if (nDigits > 4&&nDigits < 25) {
337 cluster.SetY(y/q - 0.25*nDigits);
339 if (nClusters[0] == kMax) {
340 Error("FindClustersSSD", "Too many 1D clusters !");
343 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
344 cluster2.SetY(y/q + 0.25*nDigits);
345 cluster2.SetQ(0.5*q);
346 cluster2.SetNd(nDigits);
347 cluster2.SetLabels(lab);
357 } // loop over strip on P-side
359 // if last strip does have signal
362 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
364 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
367 cluster.SetNd(nDigits);
368 cluster.SetLabels(lab);
370 //Split suspiciously big cluster
371 if (nDigits > 4&&nDigits < 25) {
372 cluster.SetY(y/q - 0.25*nDigits);
374 if (nClusters[0] == kMax) {
375 Error("FindClustersSSD", "Too many 1D clusters !");
378 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
379 cluster2.SetY(y/q + 0.25*nDigits);
380 cluster2.SetQ(0.5*q);
381 cluster2.SetNd(nDigits);
382 cluster2.SetLabels(lab);
393 for(Int_t istrip=768; istrip<1536; istrip++) { // N-side
395 Int_t signal = matrix[iadc][istrip];
396 Int_t strip = 1535-istrip;
398 noise = cal->GetNoiseN(strip);
399 if(signal<3*noise) signal = 65535; // in case ZS was not done in hw do it now
402 gain = cal->GetGainN(strip);
403 signal = (Int_t) ( signal * gain); // signal is corrected for gain
404 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
406 // add digit to current cluster
415 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
417 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
420 cluster.SetNd(nDigits);
421 cluster.SetLabels(lab);
423 //Split suspiciously big cluster
424 if (nDigits > 4&&nDigits < 25) {
425 cluster.SetY(y/q - 0.25*nDigits);
427 if (nClusters[1] == kMax) {
428 Error("FindClustersSSD", "Too many 1D clusters !");
431 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
432 cluster2.SetY(y/q + 0.25*nDigits);
433 cluster2.SetQ(0.5*q);
434 cluster2.SetNd(nDigits);
435 cluster2.SetLabels(lab);
444 } // loop over strips on N-side
448 if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
450 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
453 cluster.SetNd(nDigits);
454 cluster.SetLabels(lab);
456 //Split suspiciously big cluster
457 if (nDigits > 4&&nDigits < 25) {
458 cluster.SetY(y/q - 0.25*nDigits);
460 if (nClusters[1] == kMax) {
461 Error("FindClustersSSD", "Too many 1D clusters !");
464 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
465 cluster2.SetY(y/q + 0.25*nDigits);
466 cluster2.SetQ(0.5*q);
467 cluster2.SetNd(nDigits);
468 cluster2.SetLabels(lab);
478 if((nClusters[0])&&(nClusters[1])) {
480 //cout<<"creating recpoint for module="<<iModule<<" "<<nClusters[0]<<" "<<nClusters[1]<<endl;
481 clusters[iModule] = new TClonesArray("AliITSRecPoint");
484 FindClustersSSD(&clusters1D[0][0], nClusters[0],
485 &clusters1D[1][0], nClusters[1], clusters[iModule]);
486 Int_t nClusters = clusters[iModule]->GetEntriesFast();
487 nClustersSSD += nClusters;
490 nClusters[0] = nClusters[1] = 0;
499 Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD);
502 void AliITSClusterFinderV2SSD::
503 FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
504 Ali1Dcluster* pos, Int_t np,
505 TClonesArray *clusters) {
506 //------------------------------------------------------------
507 // Actual SSD cluster finder
508 //------------------------------------------------------------
512 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
514 TClonesArray &cl=*clusters;
516 Float_t tanp=fTanP, tann=fTanN;
517 if (fModule>fLastSSD1) {tann=fTanP; tanp=fTanN;}
518 Int_t idet=fNdet[fModule];
521 Int_t negativepair[30000];
522 Int_t cnegative[3000];
524 Int_t positivepair[30000];
525 Int_t cpositive[3000];
527 for (Int_t i=0;i<3000;i++) {cnegative[i]=0; cused1[i]=0;}
528 for (Int_t i=0;i<3000;i++) {cpositive[i]=0; cused2[i]=0;}
529 for (Int_t i=0;i<30000;i++) {negativepair[i]=0; positivepair[i]=0;}
531 if ((np*nn) > fgPairsSize) {
532 if (fgPairs) delete [] fgPairs;
533 fgPairsSize = 4*np*nn;
534 fgPairs = new Short_t[fgPairsSize];
536 memset(fgPairs,0,sizeof(Short_t)*np*nn);
539 // find available pairs
541 for (Int_t i=0; i<np; i++) {
542 Float_t yp=pos[i].GetY()*fYpitchSSD;
543 if (pos[i].GetQ()<3) continue;
544 for (Int_t j=0; j<nn; j++) {
545 if (neg[j].GetQ()<3) continue;
546 Float_t yn=neg[j].GetY()*fYpitchSSD;
547 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
548 Float_t yt=yn + tann*zt;
549 zt-=fHlSSD; yt-=fHwSSD;
550 if (TMath::Abs(yt)<fHwSSD+0.01)
551 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
552 negativepair[i*10+cnegative[i]] =j; //index
553 positivepair[j*10+cpositive[j]] =i;
554 cnegative[i]++; //counters
562 // try to recover points out of but close to the module boundaries
564 for (Int_t i=0; i<np; i++) {
565 Float_t yp=pos[i].GetY()*fYpitchSSD;
566 if (pos[i].GetQ()<3) continue;
567 for (Int_t j=0; j<nn; j++) {
568 if (neg[j].GetQ()<3) continue;
569 // if both 1Dclusters have an other cross continue
570 if (cpositive[j]&&cnegative[i]) continue;
571 Float_t yn=neg[j].GetY()*fYpitchSSD;
572 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
573 Float_t yt=yn + tann*zt;
574 zt-=fHlSSD; yt-=fHwSSD;
575 if (TMath::Abs(yt)<fHwSSD+0.1)
576 if (TMath::Abs(zt)<fHlSSD+0.15) {
577 // tag 1Dcluster (eventually will produce low quality recpoint)
578 if (cnegative[i]==0) pos[i].SetNd(100); // not available pair
579 if (cpositive[j]==0) neg[j].SetNd(100); // not available pair
580 negativepair[i*10+cnegative[i]] =j; //index
581 positivepair[j*10+cpositive[j]] =i;
582 cnegative[i]++; //counters
597 for (Int_t ip=0;ip<np;ip++){
598 Float_t ybest=1000,zbest=1000,qbest=0;
600 // select gold clusters
601 if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){
602 Float_t yp=pos[ip].GetY()*fYpitchSSD;
603 Int_t j = negativepair[10*ip];
604 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
606 Float_t yn=neg[j].GetY()*fYpitchSSD;
607 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
608 Float_t yt=yn + tann*zt;
609 zt-=fHlSSD; yt-=fHwSSD;
611 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
613 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
614 mT2L->MasterToLocal(loc,trk);
618 lp[2]=0.0025*0.0025; //SigmaY2
619 lp[3]=0.110*0.110; //SigmaZ2
622 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
623 for (Int_t ilab=0;ilab<3;ilab++){
624 milab[ilab] = pos[ip].GetLabel(ilab);
625 milab[ilab+3] = neg[j].GetLabel(ilab);
629 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
630 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
631 AliITSRecPoint * cl2;
633 if(clusters){ // Note clusters != 0 when method is called for rawdata
636 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
638 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
640 cl2->SetChargeRatio(ratio);
643 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
651 else{ // Note clusters == 0 when method is called for digits
653 cl2 = new AliITSRecPoint(milab,lp,info);
655 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
657 cl2->SetChargeRatio(ratio);
660 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
666 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" gold"<<endl;
667 fDetTypeRec->AddRecPoint(*cl2);
673 for (Int_t ip=0;ip<np;ip++){
674 Float_t ybest=1000,zbest=1000,qbest=0;
677 // select "silber" cluster
678 if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){
679 Int_t in = negativepair[10*ip];
680 Int_t ip2 = positivepair[10*in];
681 if (ip2==ip) ip2 = positivepair[10*in+1];
682 Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
683 if (TMath::Abs(pcharge-neg[in].GetQ())<10){
686 if (fgPairs[ip*nn+in]==100){ //
687 Float_t yp=pos[ip].GetY()*fYpitchSSD;
688 Float_t yn=neg[in].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;
693 qbest =pos[ip].GetQ();
695 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
696 mT2L->MasterToLocal(loc,trk);
700 lp[2]=0.0025*0.0025; //SigmaY2
701 lp[3]=0.110*0.110; //SigmaZ2
704 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
705 for (Int_t ilab=0;ilab<3;ilab++){
706 milab[ilab] = pos[ip].GetLabel(ilab);
707 milab[ilab+3] = neg[in].GetLabel(ilab);
711 ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ());
712 milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
713 Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
715 AliITSRecPoint * cl2;
718 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
720 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
722 cl2->SetChargeRatio(ratio);
724 fgPairs[ip*nn+in] = 5;
725 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
727 fgPairs[ip*nn+in] = 6;
731 cl2 = new AliITSRecPoint(milab,lp,info);
732 cl2->SetChargeRatio(ratio);
734 fgPairs[ip*nn+in] = 5;
735 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
737 fgPairs[ip*nn+in] = 6;
739 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver1"<<endl;
741 fDetTypeRec->AddRecPoint(*cl2);
749 // if (!(cused1[ip2] || cused2[in])){ //
750 if (fgPairs[ip2*nn+in]==100){
751 Float_t yp=pos[ip2].GetY()*fYpitchSSD;
752 Float_t yn=neg[in].GetY()*fYpitchSSD;
753 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
754 Float_t yt=yn + tann*zt;
755 zt-=fHlSSD; yt-=fHwSSD;
757 qbest =pos[ip2].GetQ();
759 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
760 mT2L->MasterToLocal(loc,trk);
764 lp[2]=0.0025*0.0025; //SigmaY2
765 lp[3]=0.110*0.110; //SigmaZ2
768 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
769 for (Int_t ilab=0;ilab<3;ilab++){
770 milab[ilab] = pos[ip2].GetLabel(ilab);
771 milab[ilab+3] = neg[in].GetLabel(ilab);
775 ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ());
776 milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
777 Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
779 AliITSRecPoint * cl2;
781 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
783 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
785 cl2->SetChargeRatio(ratio);
787 fgPairs[ip2*nn+in] =5;
788 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
790 fgPairs[ip2*nn+in] =6;
794 cl2 = new AliITSRecPoint(milab,lp,info);
795 cl2->SetChargeRatio(ratio);
797 fgPairs[ip2*nn+in] =5;
798 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
800 fgPairs[ip2*nn+in] =6;
803 // cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver2"<<endl;
804 fDetTypeRec->AddRecPoint(*cl2);
816 for (Int_t jn=0;jn<nn;jn++){
817 if (cused2[jn]) continue;
818 Float_t ybest=1000,zbest=1000,qbest=0;
819 // select "silber" cluster
820 if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){
821 Int_t ip = positivepair[10*jn];
822 Int_t jn2 = negativepair[10*ip];
823 if (jn2==jn) jn2 = negativepair[10*ip+1];
824 Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
826 if (TMath::Abs(pcharge-pos[ip].GetQ())<10){
829 // if (!(cused1[ip]||cused2[jn])){
830 if (fgPairs[ip*nn+jn]==100){
831 Float_t yn=neg[jn].GetY()*fYpitchSSD;
832 Float_t yp=pos[ip].GetY()*fYpitchSSD;
833 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
834 Float_t yt=yn + tann*zt;
835 zt-=fHlSSD; yt-=fHwSSD;
837 qbest =neg[jn].GetQ();
839 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
840 mT2L->MasterToLocal(loc,trk);
844 lp[2]=0.0025*0.0025; //SigmaY2
845 lp[3]=0.110*0.110; //SigmaZ2
848 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
849 for (Int_t ilab=0;ilab<3;ilab++){
850 milab[ilab] = pos[ip].GetLabel(ilab);
851 milab[ilab+3] = neg[jn].GetLabel(ilab);
855 ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ());
856 milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
857 Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]};
859 AliITSRecPoint * cl2;
861 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
863 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
865 cl2->SetChargeRatio(ratio);
867 fgPairs[ip*nn+jn] =7;
868 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
875 cl2 = new AliITSRecPoint(milab,lp,info);
876 cl2->SetChargeRatio(ratio);
878 fgPairs[ip*nn+jn] =7;
879 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
883 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN1"<<endl;
885 fDetTypeRec->AddRecPoint(*cl2);
891 // if (!(cused1[ip]||cused2[jn2])){
892 if (fgPairs[ip*nn+jn2]==100){
893 Float_t yn=neg[jn2].GetY()*fYpitchSSD;
894 Double_t yp=pos[ip].GetY()*fYpitchSSD;
895 Double_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
896 Double_t yt=yn + tann*zt;
897 zt-=fHlSSD; yt-=fHwSSD;
899 qbest =neg[jn2].GetQ();
901 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
902 mT2L->MasterToLocal(loc,trk);
906 lp[2]=0.0025*0.0025; //SigmaY2
907 lp[3]=0.110*0.110; //SigmaZ2
910 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
911 for (Int_t ilab=0;ilab<3;ilab++){
912 milab[ilab] = pos[ip].GetLabel(ilab);
913 milab[ilab+3] = neg[jn2].GetLabel(ilab);
917 ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
918 milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
919 Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]};
920 AliITSRecPoint * cl2;
922 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
924 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
926 cl2->SetChargeRatio(ratio);
927 fgPairs[ip*nn+jn2]=7;
929 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
931 fgPairs[ip*nn+jn2]=8;
936 cl2 = new AliITSRecPoint(milab,lp,info);
937 cl2->SetChargeRatio(ratio);
938 fgPairs[ip*nn+jn2]=7;
940 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
942 fgPairs[ip*nn+jn2]=8;
944 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN2"<<endl;
946 fDetTypeRec->AddRecPoint(*cl2);
958 for (Int_t ip=0;ip<np;ip++){
959 Float_t ybest=1000,zbest=1000,qbest=0;
963 if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){
964 Float_t minchargediff =4.;
966 for (Int_t di=0;di<cnegative[ip];di++){
967 Int_t jc = negativepair[ip*10+di];
968 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
969 if (TMath::Abs(chargedif)<minchargediff){
971 minchargediff = TMath::Abs(chargedif);
974 if (j<0) continue; // not proper cluster
977 for (Int_t di=0;di<cnegative[ip];di++){
978 Int_t jc = negativepair[ip*10+di];
979 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
980 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
982 if (count>1) continue; // more than one "proper" cluster for positive
985 for (Int_t dj=0;dj<cpositive[j];dj++){
986 Int_t ic = positivepair[j*10+dj];
987 Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
988 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
990 if (count>1) continue; // more than one "proper" cluster for negative
995 for (Int_t dj=0;dj<cnegative[jp];dj++){
996 Int_t ic = positivepair[jp*10+dj];
997 Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
998 if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1000 if (count>1) continue;
1001 if (fgPairs[ip*nn+j]<100) continue;
1003 //almost gold clusters
1004 Float_t yp=pos[ip].GetY()*fYpitchSSD;
1005 Float_t yn=neg[j].GetY()*fYpitchSSD;
1006 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1007 Float_t yt=yn + tann*zt;
1008 zt-=fHlSSD; yt-=fHwSSD;
1010 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1012 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1013 mT2L->MasterToLocal(loc,trk);
1017 lp[2]=0.0025*0.0025; //SigmaY2
1018 lp[3]=0.110*0.110; //SigmaZ2
1020 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1021 for (Int_t ilab=0;ilab<3;ilab++){
1022 milab[ilab] = pos[ip].GetLabel(ilab);
1023 milab[ilab+3] = neg[j].GetLabel(ilab);
1026 CheckLabels2(milab);
1027 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1028 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1029 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1030 AliITSRecPoint * cl2;
1032 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1034 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1036 cl2->SetChargeRatio(ratio);
1038 fgPairs[ip*nn+j]=10;
1039 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1041 fgPairs[ip*nn+j]=11;
1047 cl2 = new AliITSRecPoint(milab,lp,info);
1048 cl2->SetChargeRatio(ratio);
1050 fgPairs[ip*nn+j]=10;
1051 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1053 fgPairs[ip*nn+j]=11;
1058 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" 2x2"<<endl;
1060 fDetTypeRec->AddRecPoint(*cl2);
1068 for (Int_t i=0; i<np; i++) {
1069 Float_t ybest=1000,zbest=1000,qbest=0;
1070 Float_t yp=pos[i].GetY()*fYpitchSSD;
1071 if (pos[i].GetQ()<3) continue;
1072 for (Int_t j=0; j<nn; j++) {
1073 // for (Int_t di = 0;di<cpositive[i];di++){
1074 // Int_t j = negativepair[10*i+di];
1075 if (neg[j].GetQ()<3) continue;
1076 if (cused2[j]||cused1[i]) continue;
1077 if (fgPairs[i*nn+j]>0 &&fgPairs[i*nn+j]<100) continue;
1078 ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ());
1079 Float_t yn=neg[j].GetY()*fYpitchSSD;
1080 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1081 Float_t yt=yn + tann*zt;
1082 zt-=fHlSSD; yt-=fHwSSD;
1083 if (TMath::Abs(yt)<fHwSSD+0.01)
1084 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
1086 qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
1088 Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1089 mT2L->MasterToLocal(loc,trk);
1093 lp[2]=0.0025*0.0025; //SigmaY2
1094 lp[3]=0.110*0.110; //SigmaZ2
1097 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1098 for (Int_t ilab=0;ilab<3;ilab++){
1099 milab[ilab] = pos[i].GetLabel(ilab);
1100 milab[ilab+3] = neg[j].GetLabel(ilab);
1103 CheckLabels2(milab);
1104 milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
1105 Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1106 AliITSRecPoint * cl2;
1108 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1110 // cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1112 cl2->SetChargeRatio(ratio);
1113 cl2->SetType(100+cpositive[j]+cnegative[i]);
1116 cl2 = new AliITSRecPoint(milab,lp,info);
1117 cl2->SetChargeRatio(ratio);
1118 cl2->SetType(100+cpositive[j]+cnegative[i]);
1120 //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" other"<<endl;
1122 fDetTypeRec->AddRecPoint(*cl2);
1127 if (fgPairs[i*nn+j]<100){
1128 printf("problem:- %d\n", fgPairs[i*nn+j]);
1130 if (cnegative[i]<2&&cpositive[j]<2){
1131 printf("problem:- %d\n", fgPairs[i*nn+j]);