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 // Last revision: 13-05-09 Enrico Fragiacomo //
23 // enrico.fragiacomo@ts.infn.it //
25 ///////////////////////////////////////////////////////////////////////////
27 #include <Riostream.h>
30 #include "AliITSClusterFinderV2SSD.h"
31 #include "AliITSRecPoint.h"
32 #include "AliITSRecPointContainer.h"
33 #include "AliITSgeomTGeo.h"
34 #include "AliITSDetTypeRec.h"
35 #include "AliRawReader.h"
36 #include "AliITSRawStreamSSD.h"
37 #include <TClonesArray.h>
38 #include "AliITSdigitSSD.h"
39 #include "AliITSReconstructor.h"
40 #include "AliITSCalibrationSSD.h"
41 #include "AliITSsegmentationSSD.h"
43 Short_t *AliITSClusterFinderV2SSD::fgPairs = 0x0;
44 Int_t AliITSClusterFinderV2SSD::fgPairsSize = 0;
45 const Float_t AliITSClusterFinderV2SSD::fgkThreshold = 5.;
47 const Float_t AliITSClusterFinderV2SSD::fgkCosmic2008StripShifts[16][9] =
48 {{-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35}, // DDL 512
49 {-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35}, // DDL 513
50 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 514
51 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 515
52 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 516
53 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 517
54 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 518
55 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 519
56 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.25,-0.15}, // DDL 520
57 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 521
58 {-0.10,-0.10,-0.10,-0.40,-0.40,-0.40,-0.10,-0.10,-0.45}, // DDL 522
59 {-0.10,-0.10,-0.10,-0.35,-0.35,-0.35,-0.10,-0.35,-0.50}, // DDL 523
60 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 524
61 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 525
62 { 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35}, // DDL 526
63 { 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45}}; // DDL 527
65 ClassImp(AliITSClusterFinderV2SSD)
68 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(AliITSDetTypeRec* dettyp):AliITSClusterFinder(dettyp),
69 fLastSSD1(AliITSgeomTGeo::GetModuleIndex(6,1,1)-1)
75 //______________________________________________________________________
76 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(const AliITSClusterFinderV2SSD &cf) : AliITSClusterFinder(cf), fLastSSD1(cf.fLastSSD1)
81 //______________________________________________________________________
82 AliITSClusterFinderV2SSD& AliITSClusterFinderV2SSD::operator=(const AliITSClusterFinderV2SSD& cf ){
83 // Assignment operator
85 this->~AliITSClusterFinderV2SSD();
86 new(this) AliITSClusterFinderV2SSD(cf);
91 void AliITSClusterFinderV2SSD::FindRawClusters(Int_t mod){
95 FindClustersSSD(fDigits);
99 void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
100 //------------------------------------------------------------
101 // Actual SSD cluster finder
102 //------------------------------------------------------------
103 Int_t smaxall=alldigits->GetEntriesFast();
104 if (smaxall==0) return;
107 //---------------------------------------
108 // load recoparam and calibration
110 static AliITSRecoParam *repa = NULL;
112 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
114 repa = AliITSRecoParam::GetHighFluxParam();
115 AliWarning("Using default AliITSRecoParam class");
119 AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
122 //---------------------------------------
125 //------------------------------------
126 // fill the digits array with zero-suppression condition
127 // Signal is converted in KeV
130 for (Int_t i=0;i<smaxall; i++){
131 AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i);
133 if(d->IsSideP()) noise = cal->GetNoiseP(d->GetStripNumber());
134 else noise = cal->GetNoiseN(d->GetStripNumber());
135 if (d->GetSignal()<3.*noise) continue;
137 if(d->IsSideP()) gain = cal->GetGainP(d->GetStripNumber());
138 else gain = cal->GetGainN(d->GetStripNumber());
140 Float_t q=gain*d->GetSignal(); //
141 q=cal->ADCToKeV(q); // converts the charge in KeV from ADC units
142 d->SetSignal(Int_t(q));
146 Int_t smax = digits.GetEntriesFast();
148 //------------------------------------
151 const Int_t kMax=1000;
153 Ali1Dcluster pos[kMax], neg[kMax];
154 Float_t y=0., q=0., qmax=0.;
155 Int_t lab[4]={-2,-2,-2,-2};
159 cout<<"-----------------------------"<<endl;
160 cout<<"this is module "<<fModule;
165 //--------------------------------------------------------
166 // start 1D-clustering from the first digit in the digits array
168 AliITSdigitSSD *d=(AliITSdigitSSD*)digits.UncheckedAt(0);
170 y += d->GetCoord2()*d->GetSignal();
172 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
175 noise = cal->GetNoiseP(d->GetStripNumber());
176 gain = cal->GetGainP(d->GetStripNumber());
179 noise = cal->GetNoiseN(d->GetStripNumber());
180 gain = cal->GetGainN(d->GetStripNumber());
183 noise=cal->ADCToKeV(noise); // converts noise in KeV from ADC units
185 if(qmax>fgkThreshold*noise) flag5=1; // seed for the cluster
188 cout<<d->GetSignal()<<" "<<noise<<" "<<flag5<<" "<<
189 d->GetCoord1()<<" "<<d->GetCoord2()<<endl;
192 Int_t curr=d->GetCoord2();
193 Int_t flag=d->GetCoord1();
195 // Note: the first side which will be processed is supposed to be the
196 // P-side which is neg
199 if(flag) {n=&np; c=pos;} // in case we have only Nstrips (P was bad!)
203 for (Int_t ilab=0;ilab<10;ilab++){
206 milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2);
209 //----------------------------------------------------------
210 // search for neighboring digits
212 for (Int_t s=1; s<smax; s++) {
213 d=(AliITSdigitSSD*)digits.UncheckedAt(s);
214 Int_t strip=d->GetCoord2();
216 // if digits is not a neighbour or side did not change
217 // and at least one of the previous digits met the seed condition
218 // then creates a new 1D cluster
219 if ( ( ((strip-curr) > 1) || (flag!=d->GetCoord1()) ) ) {
222 //cout<<"here1"<<endl;
227 c[*n].SetLabels(milab);
229 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
230 // Note: fUseUnfoldingInClusterFinderSSD=kFALSE by default in RecoParam
232 //Split suspiciously big cluster
234 c[*n].SetY(y/q-0.25*nd);
238 Error("FindClustersSSD","Too many 1D clusters !");
241 c[*n].SetY(y/q+0.25*nd);
244 c[*n].SetLabels(milab);
251 Error("FindClustersSSD","Too many 1D clusters !");
261 lab[0]=lab[1]=lab[2]=-2;
262 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
264 // if side changed from P to N, switch to pos 1D clusters
265 // (if for some reason the side changed from N to P then do the opposite)
266 if (flag!=d->GetCoord1())
267 { if(!flag) {n=&np; c=pos;} else {n=&nn; c=neg;} }
269 } // end create new 1D cluster from previous neighboring digits
271 // continues adding digits to the previous cluster
272 // or start a new one
275 y += d->GetCoord2()*d->GetSignal();
279 noise = cal->GetNoiseP(d->GetStripNumber());
280 gain = cal->GetGainP(d->GetStripNumber());
283 noise = cal->GetNoiseN(d->GetStripNumber());
284 gain = cal->GetGainN(d->GetStripNumber());
287 noise=cal->ADCToKeV(noise); // converts the charge in KeV from ADC units
289 if(d->GetSignal()>fgkThreshold*noise) flag5=1;
292 cout<<d->GetSignal()<<" "<<noise<<" "<<flag5<<" "<<
293 d->GetCoord1()<<" "<<d->GetCoord2()<<endl;
296 if (d->GetSignal()>qmax) {
298 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
300 for (Int_t ilab=0;ilab<10;ilab++) {
301 if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab)));
306 } // loop over digits, no more digits in the digits array
309 // add the last 1D cluster
312 // cout<<"here2"<<endl;
317 c[*n].SetLabels(lab);
319 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
321 //Split suspiciously big cluster
323 c[*n].SetY(y/q-0.25*nd);
327 Error("FindClustersSSD","Too many 1D clusters !");
330 c[*n].SetY(y/q+0.25*nd);
333 c[*n].SetLabels(lab);
339 Error("FindClustersSSD","Too many 1D clusters !");
343 } // if flag5 last 1D cluster added
346 //------------------------------------------------------
347 // call FindClustersSSD to pair neg and pos 1D clusters
348 // and create recpoints from the crosses
349 // Note1: neg are Pside and pos are Nside!!
350 // Note2: if there are no Pside digits nn=0 (bad strips!!) (same for Nside)
352 // cout<<nn<<" Pside and "<<np<<" Nside clusters"<<endl;
353 FindClustersSSD(neg, nn, pos, np);
355 //-----------------------------------------------------
360 void AliITSClusterFinderV2SSD::RawdataToClusters(AliRawReader* rawReader){
362 //------------------------------------------------------------
363 // This function creates ITS clusters from raw data
364 //------------------------------------------------------------
366 AliITSRawStreamSSD inputSSD(rawReader);
367 FindClustersSSD(&inputSSD);
371 void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input)
373 //------------------------------------------------------------
374 // Actual SSD cluster finder for raw data
375 //------------------------------------------------------------
377 AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
378 static AliITSRecoParam *repa = NULL;
380 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
382 repa = AliITSRecoParam::GetHighFluxParam();
383 AliWarning("Using default AliITSRecoParam class");
387 Int_t nClustersSSD = 0;
388 const Int_t kMax = 1000;
389 Ali1Dcluster clusters1D[2][kMax];
390 Int_t nClusters[2] = {0, 0};
391 Int_t lab[3]={-2,-2,-2};
397 // Float_t pedestal=0.;
399 AliITSCalibrationSSD* cal=NULL;
401 Int_t matrix[12][1536];
408 Int_t osignal = 65535;
412 // read raw data input stream
415 // reset signal matrix
416 for(Int_t i=0; i<12; i++) { for(Int_t j=0; j<1536; j++) { matrix[i][j] = 65535;} }
418 if((osignal!=65535)&&(ostrip>0)&&(ostrip<1536)) {
420 matrix[oadc][ostrip] = osignal; // recover data from previous occurence of input->Next()
423 // buffer data for ddl=iddl and ad=iad
426 next = input->Next();
427 if((!next)&&(input->flag)) continue;
428 Int_t ddl=input->GetDDL();
429 Int_t ad=input->GetAD();
430 Int_t adc = input->GetADC(); adc = (adc<6)? adc : adc - 2;
431 Int_t strip = input->GetStrip();
432 if(input->GetSideFlag()) strip=1535-strip;
433 Int_t signal = input->GetSignal();
435 if((ddl==iddl)&&(ad==iad)&&(strip>0)&&(strip<1536)) {n++; matrix[adc][strip] = signal;}
436 else {if ((strip<1536) && (strip>0)) {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}}
438 if(!next) {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
443 if(!next && oddl<0) break;
445 if(n==0) continue; // first occurence
449 if (repa->GetUseCosmicRunShiftsSSD()) { // Special condition for 2007/2008 cosmic data
450 dStrip = fgkCosmic2008StripShifts[oddl][oad-1];
452 if (TMath::Abs(dStrip) > 1.5)
453 AliError(Form("Indexing error ? oddl = %d, dStrip %f\n",oddl,dStrip));
455 for(Int_t iadc=0; iadc<12; iadc++) { // loop over ADC index for ddl=oddl and ad=oad
457 Int_t iimod = (oad - 1) * 12 + iadc;
458 Int_t iModule = AliITSRawStreamSSD::GetModuleNumber(oddl,iimod);
459 if(iModule==-1) continue;
460 cal = (AliITSCalibrationSSD*)GetResp(iModule);
466 for(Int_t istrip=0; istrip<768; istrip++) { // P-side
467 Int_t signal = matrix[iadc][istrip];
468 pedestal = cal->GetPedestalP(istrip);
469 matrix[iadc][istrip]=signal-(Int_t)pedestal;
475 for(Int_t l=0; l<6; l++) {
477 for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
479 for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
485 for(istrip=0; istrip<768; istrip++) { // P-side
487 Int_t signal = TMath::Abs(matrix[iadc][istrip]);
490 noise = cal->GetNoiseP(istrip); if(noise<1.) signal = 65535;
491 if(signal<3*noise) signal = 65535; // in case ZS was not done in hw do it now
493 // if(cal->IsPChannelBad(istrip)) signal=0;
496 gain = cal->GetGainP(istrip);
497 signal = (Int_t) ( signal * gain ); // signal is corrected for gain
498 if(signal>fgkThreshold*noise) flag5=1;
499 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
501 q += signal; // add digit to current cluster
502 y += istrip * signal;
509 if ( (nDigits>0) && flag5 ) {
511 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
513 if(q!=0) cluster.SetY(y/q + dStrip);
514 else cluster.SetY(istrip + dStrip -1);
517 cluster.SetNd(nDigits);
518 cluster.SetLabels(lab);
520 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
522 //Split suspiciously big cluster
523 if (nDigits > 4&&nDigits < 25) {
524 if(q!=0) cluster.SetY(y/q + dStrip - 0.25*nDigits);
525 else cluster.SetY(istrip-1 + dStrip - 0.25*nDigits);
527 if (nClusters[0] == kMax) {
528 Error("FindClustersSSD", "Too many 1D clusters !");
531 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
532 if(q!=0) cluster2.SetY(y/q + dStrip + 0.25*nDigits);
533 else cluster2.SetY(istrip-1 + dStrip + 0.25*nDigits);
534 cluster2.SetQ(0.5*q);
535 cluster2.SetNd(nDigits);
536 cluster2.SetLabels(lab);
547 } // loop over strip on P-side
549 // if last strip does have signal
552 if ( (nDigits>0) && flag5 ) {
554 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
556 if(q!=0) cluster.SetY(y/q + dStrip);
557 else cluster.SetY(istrip - 1 + dStrip);
560 cluster.SetNd(nDigits);
561 cluster.SetLabels(lab);
563 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
565 //Split suspiciously big cluster
566 if (nDigits > 4&&nDigits < 25) {
567 if(q!=0) cluster.SetY(y/q + dStrip - 0.25*nDigits);
568 else cluster.SetY(istrip-1 + dStrip - 0.25*nDigits);
570 if (nClusters[0] == kMax) {
571 Error("FindClustersSSD", "Too many 1D clusters !");
574 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
575 if(q!=0) cluster2.SetY(y/q + dStrip + 0.25*nDigits);
576 else cluster2.SetY(istrip-1 + dStrip + 0.25*nDigits);
577 cluster2.SetQ(0.5*q);
578 cluster2.SetNd(nDigits);
579 cluster2.SetLabels(lab);
591 for(Int_t istrip=768; istrip<1536; istrip++) { // P-side
592 Int_t signal = matrix[iadc][istrip];
593 pedestal = cal->GetPedestalN(1535-istrip);
594 matrix[iadc][istrip]=signal-(Int_t)pedestal;
599 for(Int_t l=6; l<12; l++) {
601 for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
603 for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
610 for(Int_t iistrip=768; iistrip<1536; iistrip++) { // N-side
612 Int_t signal = TMath::Abs(matrix[iadc][iistrip]);
613 strip = 1535-iistrip;
616 noise = cal->GetNoiseN(strip); if(noise<1.) signal=65535;
618 // if(cal->IsNChannelBad(strip)) signal=0;
620 if(signal<3*noise) signal = 65535; // in case ZS was not done in hw do it now
623 gain = cal->GetGainN(strip);
624 signal = (Int_t) ( signal * gain); // signal is corrected for gain
625 if(signal>fgkThreshold*noise) flag5=1;
626 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
628 // add digit to current cluster
637 if ( (nDigits>0) && flag5 ) {
639 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
641 if(q!=0) cluster.SetY(y/q - dStrip);
642 else cluster.SetY(strip+1 - dStrip);
645 cluster.SetNd(nDigits);
646 cluster.SetLabels(lab);
648 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
650 //Split suspiciously big cluster
651 if (nDigits > 4&&nDigits < 25) {
652 cluster.SetY(y/q - dStrip - 0.25*nDigits);
654 if (nClusters[1] == kMax) {
655 Error("FindClustersSSD", "Too many 1D clusters !");
658 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
659 cluster2.SetY(y/q - dStrip + 0.25*nDigits);
660 cluster2.SetQ(0.5*q);
661 cluster2.SetNd(nDigits);
662 cluster2.SetLabels(lab);
673 } // loop over strips on N-side
677 if ( (nDigits>0) && flag5 ) {
679 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
681 if(q!=0) cluster.SetY(y/q - dStrip);
682 else cluster.SetY(strip - dStrip + 1);
685 cluster.SetNd(nDigits);
686 cluster.SetLabels(lab);
688 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
690 //Split suspiciously big cluster
691 if (nDigits > 4&&nDigits < 25) {
692 if(q!=0) cluster.SetY(y/q - dStrip - 0.25*nDigits);
693 else cluster.SetY(strip+1 - dStrip - 0.25*nDigits);
695 if (nClusters[1] == kMax) {
696 Error("FindClustersSSD", "Too many 1D clusters !");
699 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
700 if(q!=0) cluster2.SetY(y/q - dStrip + 0.25*nDigits);
701 else cluster2.SetY(strip+1 - dStrip + 0.25*nDigits);
702 cluster2.SetQ(0.5*q);
703 cluster2.SetNd(nDigits);
704 cluster2.SetLabels(lab);
716 if((nClusters[0])&&(nClusters[1])) {
718 TClonesArray* clusters = rpc->UncheckedGetClusters(fModule);
719 FindClustersSSD(&clusters1D[0][0], nClusters[0],
720 &clusters1D[1][0], nClusters[1], clusters);
721 Int_t nClustersn = clusters->GetEntriesFast();
722 nClustersSSD += nClustersn;
725 nClusters[0] = nClusters[1] = 0;
734 AliDebug(1,Form("found clusters in ITS SSD: %d", nClustersSSD));
737 void AliITSClusterFinderV2SSD::
738 FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
739 Ali1Dcluster* pos, Int_t np,
740 TClonesArray *clusters) {
741 //------------------------------------------------------------
742 // Actual SSD cluster finder
743 //------------------------------------------------------------
745 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
747 //---------------------------------------
750 static AliITSRecoParam *repa = NULL;
752 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
754 repa = AliITSRecoParam::GetHighFluxParam();
755 AliWarning("Using default AliITSRecoParam class");
759 TClonesArray &cl=*clusters;
761 AliITSsegmentationSSD *seg = dynamic_cast<AliITSsegmentationSSD*>(fDetTypeRec->GetSegmentationModel(2));
762 if (fModule>fLastSSD1)
767 Float_t hwSSD = seg->Dx()*1e-4/2;
768 Float_t hlSSD = seg->Dz()*1e-4/2;
770 Int_t idet=fNdet[fModule];
774 Int_t *cnegative = new Int_t[np];
775 Int_t *cused1 = new Int_t[np];
776 Int_t *negativepair = new Int_t[10*np];
777 Int_t *cpositive = new Int_t[nn];
778 Int_t *cused2 = new Int_t[nn];
779 Int_t *positivepair = new Int_t[10*nn];
780 for (Int_t i=0;i<np;i++) {cnegative[i]=0; cused1[i]=0;}
781 for (Int_t i=0;i<nn;i++) {cpositive[i]=0; cused2[i]=0;}
782 for (Int_t i=0;i<10*np;i++) {negativepair[i]=0;}
783 for (Int_t i=0;i<10*nn;i++) {positivepair[i]=0;}
785 if ((np*nn) > fgPairsSize) {
787 if (fgPairs) delete [] fgPairs;
788 fgPairsSize = 4*np*nn;
789 fgPairs = new Short_t[fgPairsSize];
791 memset(fgPairs,0,sizeof(Short_t)*np*nn);
794 // find available pairs
796 for (Int_t i=0; i<np; i++) {
797 Float_t yp=pos[i].GetY();
798 if ( (pos[i].GetQ()>0) && (pos[i].GetQ()<3) ) continue;
799 for (Int_t j=0; j<nn; j++) {
800 if ( (neg[j].GetQ()>0) && (neg[j].GetQ()<3) ) continue;
801 Float_t yn=neg[j].GetY();
804 seg->GetPadCxz(yn, yp, xt, zt);
805 //cout<<yn<<" "<<yp<<" "<<xt<<" "<<zt<<endl;
807 if (TMath::Abs(xt)<hwSSD)
808 if (TMath::Abs(zt)<hlSSD) {
809 Int_t in = i*10+cnegative[i];
810 Int_t ip = j*10+cpositive[j];
811 if ((in < 10*np) && (ip < 10*nn)) {
812 negativepair[in] =j; //index
814 cnegative[i]++; //counters
819 AliError(Form("Index out of range: ip=%d, in=%d",ip,in));
825 // try to recover points out of but close to the module boundaries
827 for (Int_t i=0; i<np; i++) {
828 Float_t yp=pos[i].GetY();
829 if ( (pos[i].GetQ()>0) && (pos[i].GetQ()<3) ) continue;
830 for (Int_t j=0; j<nn; j++) {
831 if ( (neg[j].GetQ()>0) && (neg[j].GetQ()<3) ) continue;
832 // if both 1Dclusters have an other cross continue
833 if (cpositive[j]&&cnegative[i]) continue;
834 Float_t yn=neg[j].GetY();
837 seg->GetPadCxz(yn, yp, xt, zt);
839 if (TMath::Abs(xt)<hwSSD+0.1)
840 if (TMath::Abs(zt)<hlSSD+0.15) {
841 // tag 1Dcluster (eventually will produce low quality recpoint)
842 if (cnegative[i]==0) pos[i].SetNd(100); // not available pair
843 if (cpositive[j]==0) neg[j].SetNd(100); // not available pair
844 Int_t in = i*10+cnegative[i];
845 Int_t ip = j*10+cpositive[j];
846 if ((in < 10*np) && (ip < 10*nn)) {
847 negativepair[in] =j; //index
849 cnegative[i]++; //counters
854 AliError(Form("Index out of range: ip=%d, in=%d",ip,in));
866 if(repa->GetUseChargeMatchingInClusterFinderSSD()==kTRUE) {
872 for (Int_t ip=0;ip<np;ip++){
873 Float_t xbest=1000,zbest=1000,qbest=0;
875 // select gold clusters
876 if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){
877 Float_t yp=pos[ip].GetY();
878 Int_t j = negativepair[10*ip];
880 if( (pos[ip].GetQ()==0) && (neg[j].GetQ() ==0) ) {
881 // both bad, hence continue;
882 // mark both as used (to avoid recover at the end)
888 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
889 //cout<<"ratio="<<ratio<<endl;
891 // charge matching (note that if posQ or negQ is 0 -> ratio=1 and the following condition is met
892 if (TMath::Abs(ratio)>0.2) continue; // note: 0.2=3xsigma_ratio calculated in cosmics tests
895 Float_t yn=neg[j].GetY();
898 seg->GetPadCxz(yn, yp, xt, zt);
903 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
904 if( (pos[ip].GetQ()==0)||(neg[j].GetQ()==0)) qbest*=2; // in case of bad strips on one side keep all charge from the other one
907 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
908 mT2L->MasterToLocal(loc,trk);
913 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
914 for (Int_t ilab=0;ilab<3;ilab++){
915 milab[ilab] = pos[ip].GetLabel(ilab);
916 milab[ilab+3] = neg[j].GetLabel(ilab);
920 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
921 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
923 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
924 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
925 // out-of-diagonal element of covariance matrix
926 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
927 else if ( (info[0]>1) && (info[1]>1) ) {
928 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
929 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
933 lp[2]=4.80e-06; // 0.00219*0.00219
934 lp[3]=0.0093; // 0.0964*0.0964;
939 lp[2]=2.79e-06; // 0.0017*0.0017;
940 lp[3]=0.00935; // 0.967*0.967;
945 AliITSRecPoint * cl2;
947 if(clusters){ // Note clusters != 0 when method is called for rawdata
950 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
952 cl2->SetChargeRatio(ratio);
956 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
961 if(pos[ip].GetQ()==0) cl2->SetType(3);
962 if(neg[j].GetQ()==0) cl2->SetType(4);
968 else{ // Note clusters == 0 when method is called for digits
970 cl2 = new AliITSRecPoint(milab,lp,info);
972 cl2->SetChargeRatio(ratio);
976 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
981 if(pos[ip].GetQ()==0) cl2->SetType(3);
982 if(neg[j].GetQ()==0) cl2->SetType(4);
987 fDetTypeRec->AddRecPoint(*cl2);
993 for (Int_t ip=0;ip<np;ip++){
994 Float_t xbest=1000,zbest=1000,qbest=0;
997 // select "silber" cluster
998 if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){
999 Int_t in = negativepair[10*ip];
1000 Int_t ip2 = positivepair[10*in];
1001 if (ip2==ip) ip2 = positivepair[10*in+1];
1002 Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
1006 ratio = (pcharge-neg[in].GetQ())/(pcharge+neg[in].GetQ());
1007 if ( (TMath::Abs(ratio)<0.2) && (pcharge!=0) ) {
1008 //if ( (TMath::Abs(pcharge-neg[in].GetQ())<30) && (pcharge!=0) ) { //
1012 if ( (fgPairs[ip*nn+in]==100)&&(pos[ip].GetQ() ) ) { //
1014 Float_t yp=pos[ip].GetY();
1015 Float_t yn=neg[in].GetY();
1018 seg->GetPadCxz(yn, yp, xt, zt);
1022 qbest =pos[ip].GetQ();
1023 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1024 mT2L->MasterToLocal(loc,trk);
1029 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1030 for (Int_t ilab=0;ilab<3;ilab++){
1031 milab[ilab] = pos[ip].GetLabel(ilab);
1032 milab[ilab+3] = neg[in].GetLabel(ilab);
1035 CheckLabels2(milab);
1036 ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ());
1037 milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
1038 Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
1040 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1041 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1042 // out-of-diagonal element of covariance matrix
1043 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1044 else if ( (info[0]>1) && (info[1]>1) ) {
1045 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1046 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1050 lp[2]=4.80e-06; // 0.00219*0.00219
1051 lp[3]=0.0093; // 0.0964*0.0964;
1056 lp[2]=2.79e-06; // 0.0017*0.0017;
1057 lp[3]=0.00935; // 0.967*0.967;
1062 AliITSRecPoint * cl2;
1065 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1066 cl2->SetChargeRatio(ratio);
1068 fgPairs[ip*nn+in] = 5;
1069 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
1071 fgPairs[ip*nn+in] = 6;
1075 cl2 = new AliITSRecPoint(milab,lp,info);
1076 cl2->SetChargeRatio(ratio);
1078 fgPairs[ip*nn+in] = 5;
1079 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
1081 fgPairs[ip*nn+in] = 6;
1084 fDetTypeRec->AddRecPoint(*cl2);
1093 // if (!(cused1[ip2] || cused2[in])){ //
1094 if ( (fgPairs[ip2*nn+in]==100) && (pos[ip2].GetQ()) ) {
1096 Float_t yp=pos[ip2].GetY();
1097 Float_t yn=neg[in].GetY();
1100 seg->GetPadCxz(yn, yp, xt, zt);
1104 qbest =pos[ip2].GetQ();
1106 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1107 mT2L->MasterToLocal(loc,trk);
1112 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1113 for (Int_t ilab=0;ilab<3;ilab++){
1114 milab[ilab] = pos[ip2].GetLabel(ilab);
1115 milab[ilab+3] = neg[in].GetLabel(ilab);
1118 CheckLabels2(milab);
1119 ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ());
1120 milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
1121 Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
1123 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1124 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1125 // out-of-diagonal element of covariance matrix
1126 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1127 else if ( (info[0]>1) && (info[1]>1) ) {
1128 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1129 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1133 lp[2]=4.80e-06; // 0.00219*0.00219
1134 lp[3]=0.0093; // 0.0964*0.0964;
1139 lp[2]=2.79e-06; // 0.0017*0.0017;
1140 lp[3]=0.00935; // 0.967*0.967;
1145 AliITSRecPoint * cl2;
1147 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1149 cl2->SetChargeRatio(ratio);
1151 fgPairs[ip2*nn+in] =5;
1152 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
1154 fgPairs[ip2*nn+in] =6;
1158 cl2 = new AliITSRecPoint(milab,lp,info);
1159 cl2->SetChargeRatio(ratio);
1161 fgPairs[ip2*nn+in] =5;
1162 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
1164 fgPairs[ip2*nn+in] =6;
1167 fDetTypeRec->AddRecPoint(*cl2);
1176 } // charge matching condition
1178 } // 2 Pside cross 1 Nside
1179 } // loop over Pside clusters
1184 for (Int_t jn=0;jn<nn;jn++){
1185 if (cused2[jn]) continue;
1186 Float_t xbest=1000,zbest=1000,qbest=0;
1187 // select "silber" cluster
1188 if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){
1189 Int_t ip = positivepair[10*jn];
1190 Int_t jn2 = negativepair[10*ip];
1191 if (jn2==jn) jn2 = negativepair[10*ip+1];
1192 Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
1196 ratio = (pcharge-pos[ip].GetQ())/(pcharge+pos[ip].GetQ());
1197 if ( (TMath::Abs(ratio)<0.2) && (pcharge!=0) ) {
1200 if ( (TMath::Abs(pcharge-pos[ip].GetQ())<30) && // charge matching
1201 (pcharge!=0) ) { // reject combinations of bad strips
1207 // if (!(cused1[ip]||cused2[jn])){
1208 if ( (fgPairs[ip*nn+jn]==100) && (neg[jn].GetQ()) ) { //
1210 Float_t yn=neg[jn].GetY();
1211 Float_t yp=pos[ip].GetY();
1214 seg->GetPadCxz(yn, yp, xt, zt);
1218 qbest =neg[jn].GetQ();
1221 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1222 mT2L->MasterToLocal(loc,trk);
1228 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1229 for (Int_t ilab=0;ilab<3;ilab++){
1230 milab[ilab] = pos[ip].GetLabel(ilab);
1231 milab[ilab+3] = neg[jn].GetLabel(ilab);
1234 CheckLabels2(milab);
1235 ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ());
1236 milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
1237 Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]};
1239 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1240 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1241 // out-of-diagonal element of covariance matrix
1242 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1243 else if ( (info[0]>1) && (info[1]>1) ) {
1244 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1245 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1249 lp[2]=4.80e-06; // 0.00219*0.00219
1250 lp[3]=0.0093; // 0.0964*0.0964;
1255 lp[2]=2.79e-06; // 0.0017*0.0017;
1256 lp[3]=0.00935; // 0.967*0.967;
1261 AliITSRecPoint * cl2;
1263 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1265 cl2->SetChargeRatio(ratio);
1267 fgPairs[ip*nn+jn] =7;
1268 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
1270 fgPairs[ip*nn+jn]=8;
1275 cl2 = new AliITSRecPoint(milab,lp,info);
1276 cl2->SetChargeRatio(ratio);
1278 fgPairs[ip*nn+jn] =7;
1279 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
1281 fgPairs[ip*nn+jn]=8;
1284 fDetTypeRec->AddRecPoint(*cl2);
1290 // if (!(cused1[ip]||cused2[jn2])){
1291 if ( (fgPairs[ip*nn+jn2]==100)&&(neg[jn2].GetQ() ) ) { //
1293 Float_t yn=neg[jn2].GetY();
1294 Double_t yp=pos[ip].GetY();
1297 seg->GetPadCxz(yn, yp, xt, zt);
1301 qbest =neg[jn2].GetQ();
1304 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1305 mT2L->MasterToLocal(loc,trk);
1311 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1312 for (Int_t ilab=0;ilab<3;ilab++){
1313 milab[ilab] = pos[ip].GetLabel(ilab);
1314 milab[ilab+3] = neg[jn2].GetLabel(ilab);
1317 CheckLabels2(milab);
1318 ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
1319 milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
1320 Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]};
1322 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1323 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1324 // out-of-diagonal element of covariance matrix
1325 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1326 else if ( (info[0]>1) && (info[1]>1) ) {
1327 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1328 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1332 lp[2]=4.80e-06; // 0.00219*0.00219
1333 lp[3]=0.0093; // 0.0964*0.0964;
1338 lp[2]=2.79e-06; // 0.0017*0.0017;
1339 lp[3]=0.00935; // 0.967*0.967;
1344 AliITSRecPoint * cl2;
1346 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1349 cl2->SetChargeRatio(ratio);
1350 fgPairs[ip*nn+jn2]=7;
1352 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
1354 fgPairs[ip*nn+jn2]=8;
1359 cl2 = new AliITSRecPoint(milab,lp,info);
1360 cl2->SetChargeRatio(ratio);
1361 fgPairs[ip*nn+jn2]=7;
1363 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
1365 fgPairs[ip*nn+jn2]=8;
1368 fDetTypeRec->AddRecPoint(*cl2);
1377 } // charge matching condition
1379 } // 2 Nside cross 1 Pside
1380 } // loop over Pside clusters
1384 for (Int_t ip=0;ip<np;ip++){
1386 if(cused1[ip]) continue;
1389 Float_t xbest=1000,zbest=1000,qbest=0;
1393 if ( (cnegative[ip]==2) && cpositive[negativepair[10*ip]]==2){
1394 Float_t minchargediff =4.;
1395 Float_t minchargeratio =0.2;
1398 for (Int_t di=0;di<cnegative[ip];di++){
1399 Int_t jc = negativepair[ip*10+di];
1400 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1401 ratio = (pos[ip].GetQ()-neg[jc].GetQ())/(pos[ip].GetQ()+neg[jc].GetQ());
1402 //if (TMath::Abs(chargedif)<minchargediff){
1403 if (TMath::Abs(ratio)<0.2){
1405 minchargediff = TMath::Abs(chargedif);
1406 minchargeratio = TMath::Abs(ratio);
1409 if (j<0) continue; // not proper cluster
1413 for (Int_t di=0;di<cnegative[ip];di++){
1414 Int_t jc = negativepair[ip*10+di];
1415 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1416 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1418 if (count>1) continue; // more than one "proper" cluster for positive
1422 for (Int_t dj=0;dj<cpositive[j];dj++){
1423 Int_t ic = positivepair[j*10+dj];
1424 Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
1425 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1427 if (count>1) continue; // more than one "proper" cluster for negative
1432 for (Int_t dj=0;dj<cnegative[jp];dj++){
1433 Int_t ic = positivepair[jp*10+dj];
1434 Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
1435 if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1437 if (count>1) continue;
1438 if (fgPairs[ip*nn+j]<100) continue;
1443 //almost gold clusters
1444 Float_t yp=pos[ip].GetY();
1445 Float_t yn=neg[j].GetY();
1447 seg->GetPadCxz(yn, yp, xt, zt);
1449 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1451 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1452 mT2L->MasterToLocal(loc,trk);
1457 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1458 for (Int_t ilab=0;ilab<3;ilab++){
1459 milab[ilab] = pos[ip].GetLabel(ilab);
1460 milab[ilab+3] = neg[j].GetLabel(ilab);
1463 CheckLabels2(milab);
1464 if ((neg[j].GetQ()==0)&&(pos[ip].GetQ()==0)) continue; // reject crosses of bad strips!!
1465 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1466 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1467 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1469 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1470 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1471 // out-of-diagonal element of covariance matrix
1472 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1473 else if ( (info[0]>1) && (info[1]>1) ) {
1474 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1475 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1479 lp[2]=4.80e-06; // 0.00219*0.00219
1480 lp[3]=0.0093; // 0.0964*0.0964;
1485 lp[2]=2.79e-06; // 0.0017*0.0017;
1486 lp[3]=0.00935; // 0.967*0.967;
1491 AliITSRecPoint * cl2;
1493 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1495 cl2->SetChargeRatio(ratio);
1497 fgPairs[ip*nn+j]=10;
1498 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1500 fgPairs[ip*nn+j]=11;
1506 cl2 = new AliITSRecPoint(milab,lp,info);
1507 cl2->SetChargeRatio(ratio);
1509 fgPairs[ip*nn+j]=10;
1510 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1512 fgPairs[ip*nn+j]=11;
1517 fDetTypeRec->AddRecPoint(*cl2);
1522 } // loop over Pside 1Dclusters
1526 for (Int_t ip=0;ip<np;ip++){
1528 if(cused1[ip]) continue;
1531 Float_t xbest=1000,zbest=1000,qbest=0;
1533 // manyxmany clusters
1535 if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){
1536 Float_t minchargediff =4.;
1538 for (Int_t di=0;di<cnegative[ip];di++){
1539 Int_t jc = negativepair[ip*10+di];
1540 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1541 if (TMath::Abs(chargedif)<minchargediff){
1543 minchargediff = TMath::Abs(chargedif);
1546 if (j<0) continue; // not proper cluster
1549 for (Int_t di=0;di<cnegative[ip];di++){
1550 Int_t jc = negativepair[ip*10+di];
1551 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1552 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1554 if (count>1) continue; // more than one "proper" cluster for positive
1558 for (Int_t dj=0;dj<cpositive[j];dj++){
1559 Int_t ic = positivepair[j*10+dj];
1560 Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
1561 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1563 if (count>1) continue; // more than one "proper" cluster for negative
1568 for (Int_t dj=0;dj<cnegative[jp];dj++){
1569 Int_t ic = positivepair[jp*10+dj];
1570 Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
1571 if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1573 if (count>1) continue;
1574 if (fgPairs[ip*nn+j]<100) continue;
1577 //almost gold clusters
1578 Float_t yp=pos[ip].GetY();
1579 Float_t yn=neg[j].GetY();
1583 seg->GetPadCxz(yn, yp, xt, zt);
1587 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1590 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1591 mT2L->MasterToLocal(loc,trk);
1596 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1597 for (Int_t ilab=0;ilab<3;ilab++){
1598 milab[ilab] = pos[ip].GetLabel(ilab);
1599 milab[ilab+3] = neg[j].GetLabel(ilab);
1602 CheckLabels2(milab);
1603 if ((neg[j].GetQ()==0)&&(pos[ip].GetQ()==0)) continue; // reject crosses of bad strips!!
1604 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1605 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1606 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1608 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1609 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1610 // out-of-diagonal element of covariance matrix
1611 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1612 else if ( (info[0]>1) && (info[1]>1) ) {
1613 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1614 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1618 lp[2]=4.80e-06; // 0.00219*0.00219
1619 lp[3]=0.0093; // 0.0964*0.0964;
1624 lp[2]=2.79e-06; // 0.0017*0.0017;
1625 lp[3]=0.00935; // 0.967*0.967;
1630 AliITSRecPoint * cl2;
1632 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1634 cl2->SetChargeRatio(ratio);
1636 fgPairs[ip*nn+j]=12;
1637 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1639 fgPairs[ip*nn+j]=13;
1645 cl2 = new AliITSRecPoint(milab,lp,info);
1646 cl2->SetChargeRatio(ratio);
1648 fgPairs[ip*nn+j]=12;
1649 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1651 fgPairs[ip*nn+j]=13;
1656 fDetTypeRec->AddRecPoint(*cl2);
1661 } // loop over Pside 1Dclusters
1663 } // use charge matching
1666 // recover all the other crosses
1668 for (Int_t i=0; i<np; i++) {
1669 Float_t xbest=1000,zbest=1000,qbest=0;
1670 Float_t yp=pos[i].GetY();
1671 if ((pos[i].GetQ()>0)&&(pos[i].GetQ()<3)) continue;
1672 for (Int_t j=0; j<nn; j++) {
1673 // for (Int_t di = 0;di<cpositive[i];di++){
1674 // Int_t j = negativepair[10*i+di];
1675 if ((neg[j].GetQ()>0)&&(neg[j].GetQ()<3)) continue;
1677 if ((neg[j].GetQ()==0)&&(pos[i].GetQ()==0)) continue; // reject crosses of bad strips!!
1679 if (cused2[j]||cused1[i]) continue;
1680 if (fgPairs[i*nn+j]>0 &&fgPairs[i*nn+j]<100) continue;
1681 ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ());
1682 Float_t yn=neg[j].GetY();
1685 seg->GetPadCxz(yn, yp, xt, zt);
1687 if (TMath::Abs(xt)<hwSSD)
1688 if (TMath::Abs(zt)<hlSSD) {
1691 qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
1694 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1695 mT2L->MasterToLocal(loc,trk);
1700 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1701 for (Int_t ilab=0;ilab<3;ilab++){
1702 milab[ilab] = pos[i].GetLabel(ilab);
1703 milab[ilab+3] = neg[j].GetLabel(ilab);
1706 CheckLabels2(milab);
1707 milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
1708 Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1710 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1711 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1712 // out-of-diagonal element of covariance matrix
1713 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1714 else if ( (info[0]>1) && (info[1]>1) ) {
1715 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1716 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1720 lp[2]=4.80e-06; // 0.00219*0.00219
1721 lp[3]=0.0093; // 0.0964*0.0964;
1726 lp[2]=2.79e-06; // 0.0017*0.0017;
1727 lp[3]=0.00935; // 0.967*0.967;
1732 AliITSRecPoint * cl2;
1734 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1736 cl2->SetChargeRatio(ratio);
1737 cl2->SetType(100+cpositive[j]+cnegative[i]);
1739 if(pos[i].GetQ()==0) cl2->SetType(200+cpositive[j]+cnegative[i]);
1740 if(neg[j].GetQ()==0) cl2->SetType(300+cpositive[j]+cnegative[i]);
1744 cl2 = new AliITSRecPoint(milab,lp,info);
1745 cl2->SetChargeRatio(ratio);
1746 cl2->SetType(100+cpositive[j]+cnegative[i]);
1748 if(pos[i].GetQ()==0) cl2->SetType(200+cpositive[j]+cnegative[i]);
1749 if(neg[j].GetQ()==0) cl2->SetType(300+cpositive[j]+cnegative[i]);
1751 fDetTypeRec->AddRecPoint(*cl2);
1760 if(repa->GetUseBadChannelsInClusterFinderSSD()==kTRUE) {
1762 //---------------------------------------------------------
1763 // recover crosses of good 1D clusters with bad strips on the other side
1764 // Note1: at first iteration skip modules with a bad side (or almost), (would produce too many fake!)
1765 // Note2: for modules with a bad side see below
1767 AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
1768 Int_t countPbad=0, countNbad=0;
1769 for(Int_t ib=0; ib<768; ib++) {
1770 if(cal->IsPChannelBad(ib)) countPbad++;
1771 if(cal->IsNChannelBad(ib)) countNbad++;
1773 // AliInfo(Form("module %d has %d P- and %d N-bad strips",fModule,countPbad,countNbad));
1775 if( (countPbad<100) && (countNbad<100) ) { // no bad side!!
1777 for (Int_t i=0; i<np; i++) { // loop over Nside 1Dclusters with no crosses
1778 if(cnegative[i]) continue; // if intersecting Pside clusters continue;
1780 // for(Int_t ib=0; ib<768; ib++) { // loop over all Pstrips
1781 for(Int_t ib=15; ib<753; ib++) { // loop over all Pstrips
1783 if(cal->IsPChannelBad(ib)) { // check if strips is bad
1784 Float_t yN=pos[i].GetY();
1786 seg->GetPadCxz(1.*ib, yN, xt, zt);
1789 // bad Pstrip is crossing the Nside 1Dcluster -> create recpoint
1791 if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
1792 Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
1793 mT2L->MasterToLocal(loc,trk);
1796 lp[4]=pos[i].GetQ(); //Q
1797 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1798 for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = pos[i].GetLabel(ilab);
1799 CheckLabels2(milab);
1800 milab[3]=( (i<<10) << 10 ) + idet; // pos|neg|det
1801 Int_t info[3] = {pos[i].GetNd(),0,fNlayer[fModule]};
1803 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1804 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1805 lp[5]=-0.00012; // out-of-diagonal element of covariance matrix
1812 AliITSRecPoint * cl2;
1814 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1815 cl2->SetChargeRatio(1.);
1819 cl2 = new AliITSRecPoint(milab,lp,info);
1820 cl2->SetChargeRatio(1.);
1822 fDetTypeRec->AddRecPoint(*cl2);
1825 } // cross is within the detector
1831 } // end loop over Pstrips
1833 } // end loop over Nside 1D clusters
1835 for (Int_t j=0; j<nn; j++) { // loop over Pside 1D clusters with no crosses
1836 if(cpositive[j]) continue;
1838 // for(Int_t ib=0; ib<768; ib++) { // loop over all Nside strips
1839 for(Int_t ib=15; ib<753; ib++) { // loop over all Nside strips
1841 if(cal->IsNChannelBad(ib)) { // check if strip is bad
1842 Float_t yP=neg[j].GetY();
1844 seg->GetPadCxz(yP, 1.*ib, xt, zt);
1847 // bad Nstrip is crossing the Pside 1Dcluster -> create recpoint
1849 if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
1850 Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
1851 mT2L->MasterToLocal(loc,trk);
1854 lp[4]=neg[j].GetQ(); //Q
1855 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1856 for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = neg[j].GetLabel(ilab);
1857 CheckLabels2(milab);
1858 milab[3]=( j << 10 ) + idet; // pos|neg|det
1859 Int_t info[3]={0,(Int_t)neg[j].GetNd(),fNlayer[fModule]};
1861 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1862 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1863 lp[5]=-0.00012; // out-of-diagonal element of covariance matrix
1870 AliITSRecPoint * cl2;
1872 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1873 cl2->SetChargeRatio(1.);
1877 cl2 = new AliITSRecPoint(milab,lp,info);
1878 cl2->SetChargeRatio(1.);
1880 fDetTypeRec->AddRecPoint(*cl2);
1883 } // cross is within the detector
1888 } // end loop over Nstrips
1889 } // end loop over Pside 1D clusters
1893 //---------------------------------------------------------
1895 else if( (countPbad>700) && (countNbad<100) ) { // bad Pside!!
1897 for (Int_t i=0; i<np; i++) { // loop over Nside 1Dclusters with no crosses
1898 if(cnegative[i]) continue; // if intersecting Pside clusters continue;
1901 Float_t yN=pos[i].GetY();
1903 if (seg->GetLayer()==5) yP = yN + (7.6/1.9);
1904 else yP = yN - (7.6/1.9);
1905 seg->GetPadCxz(yP, yN, xt, zt);
1907 if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
1908 Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
1909 mT2L->MasterToLocal(loc,trk);
1912 lp[4]=pos[i].GetQ(); //Q
1913 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1914 for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = pos[i].GetLabel(ilab);
1915 CheckLabels2(milab);
1916 milab[3]=( (i<<10) << 10 ) + idet; // pos|neg|det
1917 Int_t info[3] = {(Int_t)pos[i].GetNd(),0,fNlayer[fModule]};
1919 lp[2]=0.00098; // 0.031*0.031; //SigmaY2
1920 lp[3]=1.329; // 1.15*1.15; //SigmaZ2
1922 if(info[0]>1) lp[2]=0.00097;
1924 AliITSRecPoint * cl2;
1926 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1927 cl2->SetChargeRatio(1.);
1931 cl2 = new AliITSRecPoint(milab,lp,info);
1932 cl2->SetChargeRatio(1.);
1934 fDetTypeRec->AddRecPoint(*cl2);
1937 } // cross is within the detector
1941 } // end loop over Nside 1D clusters
1943 } // bad Pside module
1945 else if( (countNbad>700) && (countPbad<100) ) { // bad Nside!!
1947 for (Int_t j=0; j<nn; j++) { // loop over Pside 1D clusters with no crosses
1948 if(cpositive[j]) continue;
1951 Float_t yP=neg[j].GetY();
1953 if (seg->GetLayer()==5) yN = yP - (7.6/1.9);
1954 else yN = yP + (7.6/1.9);
1955 seg->GetPadCxz(yP, yN, xt, zt);
1957 if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
1958 Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
1959 mT2L->MasterToLocal(loc,trk);
1962 lp[4]=neg[j].GetQ(); //Q
1963 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1964 for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = neg[j].GetLabel(ilab);
1965 CheckLabels2(milab);
1966 milab[3]=( j << 10 ) + idet; // pos|neg|det
1967 Int_t info[3] = {0,(Int_t)neg[j].GetNd(),fNlayer[fModule]};
1969 lp[2]=7.27e-05; // 0.0085*0.0085; //SigmaY2
1970 lp[3]=1.33; // 1.15*1.15; //SigmaZ2
1972 if(info[1]>1) lp[2]=6.91e-05;
1974 AliITSRecPoint * cl2;
1976 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1977 cl2->SetChargeRatio(1.);
1981 cl2 = new AliITSRecPoint(milab,lp,info);
1982 cl2->SetChargeRatio(1.);
1984 fDetTypeRec->AddRecPoint(*cl2);
1987 } // cross is within the detector
1991 } // end loop over Pside 1D clusters
1993 } // bad Nside module
1995 //---------------------------------------------------------
1997 } // use bad channels
1999 //cout<<ncl<<" clusters for this module"<<endl;
2001 delete [] cnegative;
2003 delete [] negativepair;
2004 delete [] cpositive;
2006 delete [] positivepair;