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 "AliITSClusterFinderV2SSD.h"
29 #include <Riostream.h>
30 #include <TGeoGlobalMagField.h>
34 #include "AliITSRecPoint.h"
35 #include "AliITSRecPointContainer.h"
36 #include "AliITSgeomTGeo.h"
37 #include "AliITSDetTypeRec.h"
38 #include "AliRawReader.h"
39 #include "AliITSRawStreamSSD.h"
40 #include <TClonesArray.h>
41 #include <TCollection.h>
42 #include "AliITSdigitSSD.h"
43 #include "AliITSReconstructor.h"
44 #include "AliITSCalibrationSSD.h"
45 #include "AliITSsegmentationSSD.h"
47 Short_t *AliITSClusterFinderV2SSD::fgPairs = 0x0;
48 Int_t AliITSClusterFinderV2SSD::fgPairsSize = 0;
49 const Float_t AliITSClusterFinderV2SSD::fgkThreshold = 5.;
51 const Float_t AliITSClusterFinderV2SSD::fgkCosmic2008StripShifts[16][9] =
52 {{-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35}, // DDL 512
53 {-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35}, // DDL 513
54 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 514
55 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 515
56 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 516
57 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 517
58 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 518
59 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 519
60 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.25,-0.15}, // DDL 520
61 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 521
62 {-0.10,-0.10,-0.10,-0.40,-0.40,-0.40,-0.10,-0.10,-0.45}, // DDL 522
63 {-0.10,-0.10,-0.10,-0.35,-0.35,-0.35,-0.10,-0.35,-0.50}, // DDL 523
64 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 524
65 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 525
66 { 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35}, // DDL 526
67 { 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45}}; // DDL 527
69 ClassImp(AliITSClusterFinderV2SSD)
72 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(AliITSDetTypeRec* dettyp):AliITSClusterFinder(dettyp),fLastSSD1(AliITSgeomTGeo::GetModuleIndex(6,1,1)-1), fLorentzShiftP(0), fLorentzShiftN(0)
75 static AliITSRecoParam *repa = NULL;
77 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
79 repa = AliITSRecoParam::GetHighFluxParam();
80 AliWarning("Using default AliITSRecoParam class");
84 if (repa->GetCorrectLorentzAngleSSD()) {
85 AliMagF* field = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField());
87 AliError("Cannot get magnetic field from TGeoGlobalMagField");
88 Float_t Bfield = field->SolenoidField();
89 // NB: spatial shift has opposite sign for lay 5 and 6, but strip numbering also changes direction, so no sign-change
90 // Shift due to ExB on drift N-side, units: strip width
91 fLorentzShiftP = -repa->GetTanLorentzAngleElectronsSSD() * 150.e-4/95.e-4 * Bfield / 5.0;
92 // Shift due to ExB on drift P-side, units: strip width
93 fLorentzShiftN = -repa->GetTanLorentzAngleHolesSSD() * 150.e-4/95.e-4 * Bfield / 5.0;
94 AliDebug(1,Form("Bfield %f Lorentz Shift P-side %f N-side %f",Bfield,fLorentzShiftN,fLorentzShiftP));
98 //______________________________________________________________________
99 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(const AliITSClusterFinderV2SSD &cf) : AliITSClusterFinder(cf), fLastSSD1(cf.fLastSSD1), fLorentzShiftP(cf.fLorentzShiftP), fLorentzShiftN(cf.fLorentzShiftN)
104 //______________________________________________________________________
105 AliITSClusterFinderV2SSD& AliITSClusterFinderV2SSD::operator=(const AliITSClusterFinderV2SSD& cf ){
106 // Assignment operator
108 this->~AliITSClusterFinderV2SSD();
109 new(this) AliITSClusterFinderV2SSD(cf);
114 void AliITSClusterFinderV2SSD::FindRawClusters(Int_t mod){
118 FindClustersSSD(fDigits);
122 void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
123 //------------------------------------------------------------
124 // Actual SSD cluster finder
125 //------------------------------------------------------------
126 Int_t smaxall=alldigits->GetEntriesFast();
127 if (smaxall==0) return;
130 //---------------------------------------
131 // load recoparam and calibration
133 static AliITSRecoParam *repa = NULL;
135 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
137 repa = AliITSRecoParam::GetHighFluxParam();
138 AliWarning("Using default AliITSRecoParam class");
142 AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
145 //---------------------------------------
148 //------------------------------------
149 // fill the digits array with zero-suppression condition
150 // Signal is converted in KeV
153 for (Int_t i=0;i<smaxall; i++){
154 AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i);
156 if(d->IsSideP()) noise = cal->GetNoiseP(d->GetStripNumber());
157 else noise = cal->GetNoiseN(d->GetStripNumber());
158 if (d->GetSignal()<3.*noise) continue;
160 if(d->IsSideP()) gain = cal->GetGainP(d->GetStripNumber());
161 else gain = cal->GetGainN(d->GetStripNumber());
163 Float_t q=gain*d->GetSignal(); //
164 q=cal->ADCToKeV(q); // converts the charge in KeV from ADC units
165 d->SetSignal(Int_t(q));
169 Int_t smax = digits.GetEntriesFast();
171 //------------------------------------
174 const Int_t kMax=1000;
176 Ali1Dcluster pos[kMax], neg[kMax];
177 Float_t y=0., q=0., qmax=0.;
178 Int_t lab[4]={-2,-2,-2,-2};
182 cout<<"-----------------------------"<<endl;
183 cout<<"this is module "<<fModule;
188 if (fModule>fLastSSD1)
191 //--------------------------------------------------------
192 // start 1D-clustering from the first digit in the digits array
194 AliITSdigitSSD *d=(AliITSdigitSSD*)digits.UncheckedAt(0);
196 y += d->GetCoord2()*d->GetSignal();
198 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
201 noise = cal->GetNoiseP(d->GetStripNumber());
202 gain = cal->GetGainP(d->GetStripNumber());
205 noise = cal->GetNoiseN(d->GetStripNumber());
206 gain = cal->GetGainN(d->GetStripNumber());
209 noise=cal->ADCToKeV(noise); // converts noise in KeV from ADC units
211 if(qmax>fgkThreshold*noise) flag5=1; // seed for the cluster
214 cout<<d->GetSignal()<<" "<<noise<<" "<<flag5<<" "<<
215 d->GetCoord1()<<" "<<d->GetCoord2()<<endl;
218 Int_t curr=d->GetCoord2();
219 Int_t flag=d->GetCoord1();
221 // Note: the first side which will be processed is supposed to be the
222 // P-side which is neg
225 if(flag) {n=&np; c=pos;} // in case we have only Nstrips (P was bad!)
229 for (Int_t ilab=0;ilab<10;ilab++){
232 milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2);
235 //----------------------------------------------------------
236 // search for neighboring digits
238 for (Int_t s=1; s<smax; s++) {
239 d=(AliITSdigitSSD*)digits.UncheckedAt(s);
240 Int_t strip=d->GetCoord2();
242 // if digits is not a neighbour or side did not change
243 // and at least one of the previous digits met the seed condition
244 // then creates a new 1D cluster
245 if ( ( ((strip-curr) > 1) || (flag!=d->GetCoord1()) ) ) {
248 //cout<<"here1"<<endl;
249 Float_t dLorentz = 0;
250 if (!flag) { // P-side is neg clust
251 dLorentz = fLorentzShiftN;
253 else { // N-side is p clust
254 dLorentz = fLorentzShiftP;
256 c[*n].SetY(y/q+dLorentz);
260 c[*n].SetLabels(milab);
262 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
263 // Note: fUseUnfoldingInClusterFinderSSD=kFALSE by default in RecoParam
265 //Split suspiciously big cluster
267 c[*n].SetY(y/q-0.25*nd+dLorentz);
271 Error("FindClustersSSD","Too many 1D clusters !");
274 c[*n].SetY(y/q+0.25*nd+dLorentz);
277 c[*n].SetLabels(milab);
284 Error("FindClustersSSD","Too many 1D clusters !");
294 lab[0]=lab[1]=lab[2]=-2;
295 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
297 // if side changed from P to N, switch to pos 1D clusters
298 // (if for some reason the side changed from N to P then do the opposite)
299 if (flag!=d->GetCoord1())
300 { if(!flag) {n=&np; c=pos;} else {n=&nn; c=neg;} }
302 } // end create new 1D cluster from previous neighboring digits
304 // continues adding digits to the previous cluster
305 // or start a new one
308 y += d->GetCoord2()*d->GetSignal();
312 noise = cal->GetNoiseP(d->GetStripNumber());
313 gain = cal->GetGainP(d->GetStripNumber());
316 noise = cal->GetNoiseN(d->GetStripNumber());
317 gain = cal->GetGainN(d->GetStripNumber());
320 noise=cal->ADCToKeV(noise); // converts the charge in KeV from ADC units
322 if(d->GetSignal()>fgkThreshold*noise) flag5=1;
325 cout<<d->GetSignal()<<" "<<noise<<" "<<flag5<<" "<<
326 d->GetCoord1()<<" "<<d->GetCoord2()<<endl;
329 if (d->GetSignal()>qmax) {
331 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
333 for (Int_t ilab=0;ilab<10;ilab++) {
334 if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab)));
339 } // loop over digits, no more digits in the digits array
342 // add the last 1D cluster
345 // cout<<"here2"<<endl;
346 Float_t dLorentz = 0;
347 if (!flag) { // P-side is neg clust
348 dLorentz = fLorentzShiftN;
350 else { // N-side is p clust
351 dLorentz = fLorentzShiftP;
354 c[*n].SetY(y/q + dLorentz);
357 c[*n].SetLabels(lab);
359 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
361 //Split suspiciously big cluster
363 c[*n].SetY(y/q-0.25*nd + dLorentz);
367 Error("FindClustersSSD","Too many 1D clusters !");
370 c[*n].SetY(y/q+0.25*nd + dLorentz);
373 c[*n].SetLabels(lab);
379 Error("FindClustersSSD","Too many 1D clusters !");
383 } // if flag5 last 1D cluster added
386 //------------------------------------------------------
387 // call FindClustersSSD to pair neg and pos 1D clusters
388 // and create recpoints from the crosses
389 // Note1: neg are Pside and pos are Nside!!
390 // Note2: if there are no Pside digits nn=0 (bad strips!!) (same for Nside)
392 // cout<<nn<<" Pside and "<<np<<" Nside clusters"<<endl;
394 AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
396 TClonesArray* clusters = rpc->UncheckedGetClusters(fModule);
398 FindClustersSSD(neg, nn, pos, np, clusters);
401 while ((irp = (AliITSRecPoint*)itr.Next())) fDetTypeRec->AddRecPoint(*irp);
403 //-----------------------------------------------------
407 void AliITSClusterFinderV2SSD::RawdataToClusters(AliRawReader* rawReader){
409 //------------------------------------------------------------
410 // This function creates ITS clusters from raw data
411 //------------------------------------------------------------
413 AliITSRawStreamSSD inputSSD(rawReader);
414 FindClustersSSD(&inputSSD);
419 void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input)
421 //------------------------------------------------------------
422 // Actual SSD cluster finder for raw data
423 //------------------------------------------------------------
425 AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
426 static AliITSRecoParam *repa = NULL;
428 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
430 repa = AliITSRecoParam::GetHighFluxParam();
431 AliWarning("Using default AliITSRecoParam class");
434 Int_t nClustersSSD = 0;
435 const Int_t kNADC = 12;
436 const Int_t kMaxADCClusters = 1000;
438 Int_t strips[kNADC][2][kMaxADCClusters][2]; // [ADC],[side],[istrip], [0]=istrip [1]=signal
439 Int_t nStrips[kNADC][2];
441 for( int i=0; i<kNADC; i++ ){
450 //* Loop over modules DDL+AD
455 bool next = input->Next();
458 //* Continue if corrupted input
461 if( (!next)&&(input->flag) ){
462 AliWarning(Form("ITSClustersFinderSSD: Corrupted data: warning from RawReader"));
466 Int_t newDDL = input->GetDDL();
467 Int_t newAD = input->GetAD();
470 if( newDDL<0 || newDDL>15 ){
471 AliWarning(Form("ITSClustersFinderSSD: Corrupted data: wrong DDL number (%d)",newDDL));
475 if( newAD<1 || newAD>9 ){
476 AliWarning(Form("ITSClustersFinderSSD: Corrupted data: wrong AD number (%d)",newAD));
481 bool newModule = ( !next || ddl!= newDDL || ad!=newAD );
483 if( newModule && ddl>=0 && ad>=0 ){
486 //* Reconstruct the previous block of 12 modules --- actual clusterfinder
489 for( int adc = 0; adc<kNADC; adc++ ){
493 Ali1Dcluster clusters1D[2][kMaxADCClusters]; // per ADC, per side
494 Int_t nClusters1D[2] = {0,0};
495 //int nstat[2] = {0,0};
496 fModule = AliITSRawStreamSSD::GetModuleNumber(ddl, (ad - 1) * 12 + adc );
499 // AliWarning(Form("ITSClustersFinderSSD: Corrupted data: module (ddl %d ad %d adc %d) not found in the map",ddl,ad,adc));
500 //CM channels are always present even everything is suppressed
505 if (fModule>fLastSSD1)
508 AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)fDetTypeRec->GetCalibrationModel(fModule);
510 AliWarning(Form("ITSClustersFinderSSD: No calibration found for module (ddl %d ad %d adc %d)",ddl,ad,adc));
516 if( repa->GetUseCosmicRunShiftsSSD()) { // Special condition for 2007/2008 cosmic data
517 dStrip = fgkCosmic2008StripShifts[ddl][ad-1];
518 if (TMath::Abs(dStrip) > 1.5){
519 AliWarning(Form("Indexing error in Cosmic calibration: ddl = %d, dStrip %f\n",ddl,dStrip));
524 for( int side=0; side<=1; side++ ){
526 Int_t lab[3]={-2,-2,-2};
533 Float_t dLorentz = 0;
534 if (side==0) { // P-side is neg clust
535 dLorentz = fLorentzShiftN;
537 else { // N-side is pos clust
538 dLorentz = fLorentzShiftP;
541 Int_t n = nStrips[adc][side];
542 for( int istr = 0; istr<n+1; istr++ ){
546 Float_t signal=0.0, noise=0.0, gain=0.0;
549 strip = strips[adc][side][istr][0];
550 signal = strips[adc][side][istr][1];
552 //cout<<"strip "<<adc<<" / "<<side<<": "<<strip<<endl;
555 noise = side ?cal->GetNoiseN(strip) :cal->GetNoiseP(strip);
556 gain = side ?cal->GetGainN(strip) :cal->GetGainP(strip);
557 stripOK = ( noise>=1. && signal>=3.0*noise
558 //&& !cal->IsPChannelBad(strip)
561 } else stripOK = 0; // end of data
563 bool newCluster = ( (abs(strip-ostrip)!=1) || !stripOK );
567 //* Store the previous cluster
569 if( nDigits>0 && q>0 && snFlag ){
571 if (nClusters1D[side] >= kMaxADCClusters-1 ) {
572 AliWarning("HLT ClustersFinderSSD: Too many 1D clusters !");
575 Ali1Dcluster &cluster = clusters1D[side][nClusters1D[side]++];
576 cluster.SetY( y / q + dStrip + dLorentz);
578 cluster.SetNd(nDigits);
579 cluster.SetLabels(lab);
580 //cout<<"cluster 1D side "<<side<<": y= "<<y<<" q= "<<q<<" d="<<dStrip<<" Y="<<cluster.GetY()<<endl;
581 //Split suspiciously big cluster
583 if( repa->GetUseUnfoldingInClusterFinderSSD()
584 && nDigits > 4 && nDigits < 25
586 cluster.SetY(y/q + dStrip - 0.25*nDigits + dLorentz);
588 Ali1Dcluster& cluster2 = clusters1D[side][nClusters1D[side]++];
589 cluster2.SetY(y/q + dStrip + 0.25*nDigits + dLorentz);
590 cluster2.SetQ(0.5*q);
591 cluster2.SetNd(nDigits);
592 cluster2.SetLabels(lab);
600 } //* End store the previous cluster
602 if( stripOK ){ // add new signal to the cluster
603 // signal = (Int_t) (signal * gain); // signal is corrected for gain
604 if( signal>fgkThreshold*noise) snFlag = 1;
605 signal = signal * gain; // signal is corrected for gain
606 // if( cal ) signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
607 if( cal ) signal = cal->ADCToKeV( signal ); // signal is converted in KeV
608 q += signal; // add digit to current cluster
615 } //* end loop over strips
617 } //* end loop over ADC sides
621 if( nClusters1D[0] && nClusters1D[1] && fModule>=0 ){
622 TClonesArray* clusters = rpc->UncheckedGetClusters(fModule);
623 FindClustersSSD( clusters1D[0], nClusters1D[0], clusters1D[1], nClusters1D[1], clusters);
624 Int_t nClustersn = clusters->GetEntriesFast();
625 nClustersSSD += nClustersn;
628 //cout<<"SG: "<<ddl<<" "<<ad<<" "<<adc<<": strips "<<nstat[0]<<"+"<<nstat[1]<<", clusters 1D= "<<nClusters1D[0]<<" + "<<nClusters1D[1]<<", 2D= "<<clusters.size()<<endl;
630 }//* end loop over adc
632 }//* end of reconstruction of previous block of 12 modules
637 //* Clean up arrays and set new module
640 for( int i=0; i<kNADC; i++ ){
650 //* Exit main loop when there is no more input
656 //* Fill the current strip information
659 Int_t adc = input->GetADC();
660 if( adc<0 || adc>=kNADC+2 || (adc>5&&adc<8) ){
661 AliWarning(Form("HLT ClustersFinderSSD: Corrupted data: wrong adc number (%d)", adc));
665 if( adc>7 ) adc-= 2; // shift ADC numbers 8-13 to 6-11
667 Bool_t side = input->GetSideFlag();
668 Int_t strip = input->GetStrip();
669 Int_t signal = input->GetSignal();
672 //cout<<"SSD: "<<ddl<<" "<<ad<<" "<<adc<<" "<<side<<" "<<strip<<" : "<<signal<<endl;
675 AliWarning(Form("HLT ClustersFinderSSD: Corrupted data: wrong strip number (ddl %d ad %d adc %d side %d, strip %d",
676 ddl, ad, adc, side,strip) );
679 if (strip < 0) continue;
681 int &n = nStrips[adc][side];
683 Int_t oldStrip = strips[adc][side][n-1][0];
685 if( strip==oldStrip ){
686 AliWarning(Form("HLT ClustersFinderSSD: Corrupted data: duplicated signal: ddl %d ad %d adc %d, side %d, strip %d",
687 ddl, ad, adc, side, strip ));
691 strips[adc][side][n][0] = strip;
692 strips[adc][side][n][1] = signal;
695 //cout<<"SSD: "<<input->GetDDL()<<" "<<input->GetAD()<<" "
696 //<<input->GetADC()<<" "<<input->GetSideFlag()<<" "<<((int)input->GetStrip())<<" "<<strip<<" : "<<input->GetSignal()<<endl;
698 } //* End main loop over the input
700 AliDebug(1,Form("found clusters in ITS SSD: %d", nClustersSSD));
704 void AliITSClusterFinderV2SSD::
705 FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
706 Ali1Dcluster* pos, Int_t np,
707 TClonesArray *clusters) {
708 //------------------------------------------------------------
709 // Actual SSD cluster finder
710 //------------------------------------------------------------
712 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
714 //---------------------------------------
717 static AliITSRecoParam *repa = NULL;
719 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
721 repa = AliITSRecoParam::GetHighFluxParam();
722 AliWarning("Using default AliITSRecoParam class");
726 // TClonesArray &cl=*clusters;
728 AliITSsegmentationSSD *seg = dynamic_cast<AliITSsegmentationSSD*>(fDetTypeRec->GetSegmentationModel(2));
729 if (fModule>fLastSSD1)
734 Float_t hwSSD = seg->Dx()*1e-4/2;
735 Float_t hlSSD = seg->Dz()*1e-4/2;
737 Int_t idet=fNdet[fModule];
741 Int_t *cnegative = new Int_t[np];
742 Int_t *cused1 = new Int_t[np];
743 Int_t *negativepair = new Int_t[10*np];
744 Int_t *cpositive = new Int_t[nn];
745 Int_t *cused2 = new Int_t[nn];
746 Int_t *positivepair = new Int_t[10*nn];
747 for (Int_t i=0;i<np;i++) {cnegative[i]=0; cused1[i]=0;}
748 for (Int_t i=0;i<nn;i++) {cpositive[i]=0; cused2[i]=0;}
749 for (Int_t i=0;i<10*np;i++) {negativepair[i]=0;}
750 for (Int_t i=0;i<10*nn;i++) {positivepair[i]=0;}
752 if ((np*nn) > fgPairsSize) {
754 if (fgPairs) delete [] fgPairs;
755 fgPairsSize = 4*np*nn;
756 fgPairs = new Short_t[fgPairsSize];
758 memset(fgPairs,0,sizeof(Short_t)*np*nn);
761 // find available pairs
764 for (Int_t i=0; i<np; i++) {
765 Float_t yp=pos[i].GetY();
766 if ( (pos[i].GetQ()>0) && (pos[i].GetQ()<3) ) continue;
767 for (Int_t j=0; j<nn; j++) {
768 if ( (neg[j].GetQ()>0) && (neg[j].GetQ()<3) ) continue;
769 Float_t yn=neg[j].GetY();
772 seg->GetPadCxz(yn, yp, xt, zt);
773 //cout<<yn<<" "<<yp<<" "<<xt<<" "<<zt<<endl;
775 if (TMath::Abs(xt)<hwSSD)
776 if (TMath::Abs(zt)<hlSSD) {
777 Int_t in = i*10+cnegative[i];
778 Int_t ip = j*10+cpositive[j];
779 if ((in < 10*np) && (ip < 10*nn)) {
780 negativepair[in] =j; //index
782 cnegative[i]++; //counters
788 AliError(Form("Index out of range: ip=%d, in=%d",ip,in));
796 delete [] negativepair;
799 delete [] positivepair;
802 //why not to allocate memorey here? if(!clusters) clusters = new TClonesArray("AliITSRecPoint", ncross);
805 // try to recover points out of but close to the module boundaries
807 for (Int_t i=0; i<np; i++) {
808 Float_t yp=pos[i].GetY();
809 if ( (pos[i].GetQ()>0) && (pos[i].GetQ()<3) ) continue;
810 for (Int_t j=0; j<nn; j++) {
811 if ( (neg[j].GetQ()>0) && (neg[j].GetQ()<3) ) continue;
812 // if both 1Dclusters have an other cross continue
813 if (cpositive[j]&&cnegative[i]) continue;
814 Float_t yn=neg[j].GetY();
817 seg->GetPadCxz(yn, yp, xt, zt);
819 if (TMath::Abs(xt)<hwSSD+0.1)
820 if (TMath::Abs(zt)<hlSSD+0.15) {
821 // tag 1Dcluster (eventually will produce low quality recpoint)
822 if (cnegative[i]==0) pos[i].SetNd(100); // not available pair
823 if (cpositive[j]==0) neg[j].SetNd(100); // not available pair
824 Int_t in = i*10+cnegative[i];
825 Int_t ip = j*10+cpositive[j];
826 if ((in < 10*np) && (ip < 10*nn)) {
827 negativepair[in] =j; //index
829 cnegative[i]++; //counters
834 AliError(Form("Index out of range: ip=%d, in=%d",ip,in));
846 if(repa->GetUseChargeMatchingInClusterFinderSSD()==kTRUE) {
852 for (Int_t ip=0;ip<np;ip++){
853 Float_t xbest=1000,zbest=1000,qbest=0;
855 // select gold clusters
856 if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){
857 Float_t yp=pos[ip].GetY();
858 Int_t j = negativepair[10*ip];
860 if( (pos[ip].GetQ()==0) && (neg[j].GetQ() ==0) ) {
861 // both bad, hence continue;
862 // mark both as used (to avoid recover at the end)
868 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
869 //cout<<"ratio="<<ratio<<endl;
871 // charge matching (note that if posQ or negQ is 0 -> ratio=1 and the following condition is met
872 if (TMath::Abs(ratio)>0.2) continue; // note: 0.2=3xsigma_ratio calculated in cosmics tests
875 Float_t yn=neg[j].GetY();
878 seg->GetPadCxz(yn, yp, xt, zt);
883 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
884 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
887 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
888 mT2L->MasterToLocal(loc,trk);
893 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
894 for (Int_t ilab=0;ilab<3;ilab++){
895 milab[ilab] = pos[ip].GetLabel(ilab);
896 milab[ilab+3] = neg[j].GetLabel(ilab);
900 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
901 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
903 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
904 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
905 // out-of-diagonal element of covariance matrix
906 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
907 else if ( (info[0]>1) && (info[1]>1) ) {
908 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
909 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
913 lp[2]=4.80e-06; // 0.00219*0.00219
914 lp[3]=0.0093; // 0.0964*0.0964;
919 lp[2]=2.79e-06; // 0.0017*0.0017;
920 lp[3]=0.00935; // 0.967*0.967;
925 AliITSRecPoint * cl2;
926 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
928 cl2->SetChargeRatio(ratio);
932 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
937 if(pos[ip].GetQ()==0) cl2->SetType(3);
938 if(neg[j].GetQ()==0) cl2->SetType(4);
947 for (Int_t ip=0;ip<np;ip++){
948 Float_t xbest=1000,zbest=1000,qbest=0;
951 // select "silber" cluster
952 if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){
953 Int_t in = negativepair[10*ip];
954 Int_t ip2 = positivepair[10*in];
955 if (ip2==ip) ip2 = positivepair[10*in+1];
956 Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
960 ratio = (pcharge-neg[in].GetQ())/(pcharge+neg[in].GetQ());
961 if ( (TMath::Abs(ratio)<0.2) && (pcharge!=0) ) {
962 //if ( (TMath::Abs(pcharge-neg[in].GetQ())<30) && (pcharge!=0) ) { //
966 if ( (fgPairs[ip*nn+in]==100)&&(pos[ip].GetQ() ) ) { //
968 Float_t yp=pos[ip].GetY();
969 Float_t yn=neg[in].GetY();
972 seg->GetPadCxz(yn, yp, xt, zt);
976 qbest =pos[ip].GetQ();
977 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
978 mT2L->MasterToLocal(loc,trk);
983 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
984 for (Int_t ilab=0;ilab<3;ilab++){
985 milab[ilab] = pos[ip].GetLabel(ilab);
986 milab[ilab+3] = neg[in].GetLabel(ilab);
990 ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ());
991 milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
992 Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
994 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
995 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
996 // out-of-diagonal element of covariance matrix
997 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
998 else if ( (info[0]>1) && (info[1]>1) ) {
999 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1000 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1004 lp[2]=4.80e-06; // 0.00219*0.00219
1005 lp[3]=0.0093; // 0.0964*0.0964;
1010 lp[2]=2.79e-06; // 0.0017*0.0017;
1011 lp[3]=0.00935; // 0.967*0.967;
1016 AliITSRecPoint * cl2;
1017 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1018 cl2->SetChargeRatio(ratio);
1020 fgPairs[ip*nn+in] = 5;
1021 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
1023 fgPairs[ip*nn+in] = 6;
1032 // if (!(cused1[ip2] || cused2[in])){ //
1033 if ( (fgPairs[ip2*nn+in]==100) && (pos[ip2].GetQ()) ) {
1035 Float_t yp=pos[ip2].GetY();
1036 Float_t yn=neg[in].GetY();
1039 seg->GetPadCxz(yn, yp, xt, zt);
1043 qbest =pos[ip2].GetQ();
1045 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1046 mT2L->MasterToLocal(loc,trk);
1051 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1052 for (Int_t ilab=0;ilab<3;ilab++){
1053 milab[ilab] = pos[ip2].GetLabel(ilab);
1054 milab[ilab+3] = neg[in].GetLabel(ilab);
1057 CheckLabels2(milab);
1058 ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ());
1059 milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
1060 Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
1062 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1063 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1064 // out-of-diagonal element of covariance matrix
1065 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1066 else if ( (info[0]>1) && (info[1]>1) ) {
1067 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1068 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1072 lp[2]=4.80e-06; // 0.00219*0.00219
1073 lp[3]=0.0093; // 0.0964*0.0964;
1078 lp[2]=2.79e-06; // 0.0017*0.0017;
1079 lp[3]=0.00935; // 0.967*0.967;
1084 AliITSRecPoint * cl2;
1085 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1087 cl2->SetChargeRatio(ratio);
1089 fgPairs[ip2*nn+in] =5;
1090 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
1092 fgPairs[ip2*nn+in] =6;
1101 } // charge matching condition
1103 } // 2 Pside cross 1 Nside
1104 } // loop over Pside clusters
1109 for (Int_t jn=0;jn<nn;jn++){
1110 if (cused2[jn]) continue;
1111 Float_t xbest=1000,zbest=1000,qbest=0;
1112 // select "silber" cluster
1113 if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){
1114 Int_t ip = positivepair[10*jn];
1115 Int_t jn2 = negativepair[10*ip];
1116 if (jn2==jn) jn2 = negativepair[10*ip+1];
1117 Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
1121 ratio = (pcharge-pos[ip].GetQ())/(pcharge+pos[ip].GetQ());
1122 if ( (TMath::Abs(ratio)<0.2) && (pcharge!=0) ) {
1125 if ( (TMath::Abs(pcharge-pos[ip].GetQ())<30) && // charge matching
1126 (pcharge!=0) ) { // reject combinations of bad strips
1132 // if (!(cused1[ip]||cused2[jn])){
1133 if ( (fgPairs[ip*nn+jn]==100) && (neg[jn].GetQ()) ) { //
1135 Float_t yn=neg[jn].GetY();
1136 Float_t yp=pos[ip].GetY();
1139 seg->GetPadCxz(yn, yp, xt, zt);
1143 qbest =neg[jn].GetQ();
1146 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1147 mT2L->MasterToLocal(loc,trk);
1153 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1154 for (Int_t ilab=0;ilab<3;ilab++){
1155 milab[ilab] = pos[ip].GetLabel(ilab);
1156 milab[ilab+3] = neg[jn].GetLabel(ilab);
1159 CheckLabels2(milab);
1160 ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ());
1161 milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
1162 Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]};
1164 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1165 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1166 // out-of-diagonal element of covariance matrix
1167 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1168 else if ( (info[0]>1) && (info[1]>1) ) {
1169 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1170 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1174 lp[2]=4.80e-06; // 0.00219*0.00219
1175 lp[3]=0.0093; // 0.0964*0.0964;
1180 lp[2]=2.79e-06; // 0.0017*0.0017;
1181 lp[3]=0.00935; // 0.967*0.967;
1186 AliITSRecPoint * cl2;
1187 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1189 cl2->SetChargeRatio(ratio);
1191 fgPairs[ip*nn+jn] =7;
1192 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
1194 fgPairs[ip*nn+jn]=8;
1200 // if (!(cused1[ip]||cused2[jn2])){
1201 if ( (fgPairs[ip*nn+jn2]==100)&&(neg[jn2].GetQ() ) ) { //
1203 Float_t yn=neg[jn2].GetY();
1204 Double_t yp=pos[ip].GetY();
1207 seg->GetPadCxz(yn, yp, xt, zt);
1211 qbest =neg[jn2].GetQ();
1214 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1215 mT2L->MasterToLocal(loc,trk);
1221 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1222 for (Int_t ilab=0;ilab<3;ilab++){
1223 milab[ilab] = pos[ip].GetLabel(ilab);
1224 milab[ilab+3] = neg[jn2].GetLabel(ilab);
1227 CheckLabels2(milab);
1228 ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
1229 milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
1230 Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]};
1232 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1233 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1234 // out-of-diagonal element of covariance matrix
1235 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1236 else if ( (info[0]>1) && (info[1]>1) ) {
1237 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1238 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1242 lp[2]=4.80e-06; // 0.00219*0.00219
1243 lp[3]=0.0093; // 0.0964*0.0964;
1248 lp[2]=2.79e-06; // 0.0017*0.0017;
1249 lp[3]=0.00935; // 0.967*0.967;
1254 AliITSRecPoint * cl2;
1255 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1258 cl2->SetChargeRatio(ratio);
1259 fgPairs[ip*nn+jn2]=7;
1261 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
1263 fgPairs[ip*nn+jn2]=8;
1271 } // charge matching condition
1273 } // 2 Nside cross 1 Pside
1274 } // loop over Pside clusters
1278 for (Int_t ip=0;ip<np;ip++){
1280 if(cused1[ip]) continue;
1283 Float_t xbest=1000,zbest=1000,qbest=0;
1287 if ( (cnegative[ip]==2) && cpositive[negativepair[10*ip]]==2){
1288 Float_t minchargediff =4.;
1289 Float_t minchargeratio =0.2;
1292 for (Int_t di=0;di<cnegative[ip];di++){
1293 Int_t jc = negativepair[ip*10+di];
1294 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1295 ratio = (pos[ip].GetQ()-neg[jc].GetQ())/(pos[ip].GetQ()+neg[jc].GetQ());
1296 //if (TMath::Abs(chargedif)<minchargediff){
1297 if (TMath::Abs(ratio)<0.2){
1299 minchargediff = TMath::Abs(chargedif);
1300 minchargeratio = TMath::Abs(ratio);
1303 if (j<0) continue; // not proper cluster
1307 for (Int_t di=0;di<cnegative[ip];di++){
1308 Int_t jc = negativepair[ip*10+di];
1309 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1310 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1312 if (count>1) continue; // more than one "proper" cluster for positive
1316 for (Int_t dj=0;dj<cpositive[j];dj++){
1317 Int_t ic = positivepair[j*10+dj];
1318 Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
1319 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1321 if (count>1) continue; // more than one "proper" cluster for negative
1326 for (Int_t dj=0;dj<cnegative[jp];dj++){
1327 Int_t ic = positivepair[jp*10+dj];
1328 Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
1329 if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1331 if (count>1) continue;
1332 if (fgPairs[ip*nn+j]<100) continue;
1337 //almost gold clusters
1338 Float_t yp=pos[ip].GetY();
1339 Float_t yn=neg[j].GetY();
1341 seg->GetPadCxz(yn, yp, xt, zt);
1343 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1345 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1346 mT2L->MasterToLocal(loc,trk);
1351 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1352 for (Int_t ilab=0;ilab<3;ilab++){
1353 milab[ilab] = pos[ip].GetLabel(ilab);
1354 milab[ilab+3] = neg[j].GetLabel(ilab);
1357 CheckLabels2(milab);
1358 if ((neg[j].GetQ()==0)&&(pos[ip].GetQ()==0)) continue; // reject crosses of bad strips!!
1359 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1360 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1361 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1363 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1364 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1365 // out-of-diagonal element of covariance matrix
1366 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1367 else if ( (info[0]>1) && (info[1]>1) ) {
1368 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1369 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1373 lp[2]=4.80e-06; // 0.00219*0.00219
1374 lp[3]=0.0093; // 0.0964*0.0964;
1379 lp[2]=2.79e-06; // 0.0017*0.0017;
1380 lp[3]=0.00935; // 0.967*0.967;
1385 AliITSRecPoint * cl2;
1386 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1388 cl2->SetChargeRatio(ratio);
1390 fgPairs[ip*nn+j]=10;
1391 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1393 fgPairs[ip*nn+j]=11;
1400 } // loop over Pside 1Dclusters
1404 for (Int_t ip=0;ip<np;ip++){
1406 if(cused1[ip]) continue;
1409 Float_t xbest=1000,zbest=1000,qbest=0;
1411 // manyxmany clusters
1413 if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){
1414 Float_t minchargediff =4.;
1416 for (Int_t di=0;di<cnegative[ip];di++){
1417 Int_t jc = negativepair[ip*10+di];
1418 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1419 if (TMath::Abs(chargedif)<minchargediff){
1421 minchargediff = TMath::Abs(chargedif);
1424 if (j<0) continue; // not proper cluster
1427 for (Int_t di=0;di<cnegative[ip];di++){
1428 Int_t jc = negativepair[ip*10+di];
1429 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1430 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1432 if (count>1) continue; // more than one "proper" cluster for positive
1436 for (Int_t dj=0;dj<cpositive[j];dj++){
1437 Int_t ic = positivepair[j*10+dj];
1438 Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
1439 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1441 if (count>1) continue; // more than one "proper" cluster for negative
1446 for (Int_t dj=0;dj<cnegative[jp];dj++){
1447 Int_t ic = positivepair[jp*10+dj];
1448 Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
1449 if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1451 if (count>1) continue;
1452 if (fgPairs[ip*nn+j]<100) continue;
1455 //almost gold clusters
1456 Float_t yp=pos[ip].GetY();
1457 Float_t yn=neg[j].GetY();
1461 seg->GetPadCxz(yn, yp, xt, zt);
1465 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1468 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1469 mT2L->MasterToLocal(loc,trk);
1474 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1475 for (Int_t ilab=0;ilab<3;ilab++){
1476 milab[ilab] = pos[ip].GetLabel(ilab);
1477 milab[ilab+3] = neg[j].GetLabel(ilab);
1480 CheckLabels2(milab);
1481 if ((neg[j].GetQ()==0)&&(pos[ip].GetQ()==0)) continue; // reject crosses of bad strips!!
1482 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1483 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1484 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1486 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1487 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1488 // out-of-diagonal element of covariance matrix
1489 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1490 else if ( (info[0]>1) && (info[1]>1) ) {
1491 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1492 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1496 lp[2]=4.80e-06; // 0.00219*0.00219
1497 lp[3]=0.0093; // 0.0964*0.0964;
1502 lp[2]=2.79e-06; // 0.0017*0.0017;
1503 lp[3]=0.00935; // 0.967*0.967;
1508 AliITSRecPoint * cl2;
1509 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1511 cl2->SetChargeRatio(ratio);
1513 fgPairs[ip*nn+j]=12;
1514 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1516 fgPairs[ip*nn+j]=13;
1523 } // loop over Pside 1Dclusters
1525 } // use charge matching
1528 // recover all the other crosses
1530 for (Int_t i=0; i<np; i++) {
1531 Float_t xbest=1000,zbest=1000,qbest=0;
1532 Float_t yp=pos[i].GetY();
1533 if ((pos[i].GetQ()>0)&&(pos[i].GetQ()<3)) continue;
1534 for (Int_t j=0; j<nn; j++) {
1535 // for (Int_t di = 0;di<cpositive[i];di++){
1536 // Int_t j = negativepair[10*i+di];
1537 if ((neg[j].GetQ()>0)&&(neg[j].GetQ()<3)) continue;
1539 if ((neg[j].GetQ()==0)&&(pos[i].GetQ()==0)) continue; // reject crosses of bad strips!!
1541 if (cused2[j]||cused1[i]) continue;
1542 if (fgPairs[i*nn+j]>0 &&fgPairs[i*nn+j]<100) continue;
1543 ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ());
1544 Float_t yn=neg[j].GetY();
1547 seg->GetPadCxz(yn, yp, xt, zt);
1549 if (TMath::Abs(xt)<hwSSD)
1550 if (TMath::Abs(zt)<hlSSD) {
1553 qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
1556 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1557 mT2L->MasterToLocal(loc,trk);
1562 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1563 for (Int_t ilab=0;ilab<3;ilab++){
1564 milab[ilab] = pos[i].GetLabel(ilab);
1565 milab[ilab+3] = neg[j].GetLabel(ilab);
1568 CheckLabels2(milab);
1569 milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
1570 Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1572 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1573 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1574 // out-of-diagonal element of covariance matrix
1575 if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
1576 else if ( (info[0]>1) && (info[1]>1) ) {
1577 lp[2]=2.63e-06; // 0.0016*0.0016; //SigmaY2
1578 lp[3]=0.0065; // 0.08*0.08; //SigmaZ2
1582 lp[2]=4.80e-06; // 0.00219*0.00219
1583 lp[3]=0.0093; // 0.0964*0.0964;
1588 lp[2]=2.79e-06; // 0.0017*0.0017;
1589 lp[3]=0.00935; // 0.967*0.967;
1594 AliITSRecPoint * cl2;
1595 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1597 cl2->SetChargeRatio(ratio);
1598 cl2->SetType(100+cpositive[j]+cnegative[i]);
1600 if(pos[i].GetQ()==0) cl2->SetType(200+cpositive[j]+cnegative[i]);
1601 if(neg[j].GetQ()==0) cl2->SetType(300+cpositive[j]+cnegative[i]);
1609 if(repa->GetUseBadChannelsInClusterFinderSSD()==kTRUE) {
1611 //---------------------------------------------------------
1612 // recover crosses of good 1D clusters with bad strips on the other side
1613 // Note1: at first iteration skip modules with a bad side (or almost), (would produce too many fake!)
1614 // Note2: for modules with a bad side see below
1616 AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
1617 Int_t countPbad=0, countNbad=0;
1618 for(Int_t ib=0; ib<768; ib++) {
1619 if(cal->IsPChannelBad(ib)) countPbad++;
1620 if(cal->IsNChannelBad(ib)) countNbad++;
1622 // AliInfo(Form("module %d has %d P- and %d N-bad strips",fModule,countPbad,countNbad));
1624 if( (countPbad<100) && (countNbad<100) ) { // no bad side!!
1626 for (Int_t i=0; i<np; i++) { // loop over Nside 1Dclusters with no crosses
1627 if(cnegative[i]) continue; // if intersecting Pside clusters continue;
1629 // for(Int_t ib=0; ib<768; ib++) { // loop over all Pstrips
1630 for(Int_t ib=15; ib<753; ib++) { // loop over all Pstrips
1632 if(cal->IsPChannelBad(ib)) { // check if strips is bad
1633 Float_t yN=pos[i].GetY();
1635 seg->GetPadCxz(1.*ib, yN, xt, zt);
1638 // bad Pstrip is crossing the Nside 1Dcluster -> create recpoint
1640 if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
1641 Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
1642 mT2L->MasterToLocal(loc,trk);
1645 lp[4]=pos[i].GetQ(); //Q
1646 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1647 for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = pos[i].GetLabel(ilab);
1648 CheckLabels2(milab);
1649 milab[3]=( (i<<10) << 10 ) + idet; // pos|neg|det
1650 Int_t info[3] = {pos[i].GetNd(),0,fNlayer[fModule]};
1652 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1653 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1654 lp[5]=-0.00012; // out-of-diagonal element of covariance matrix
1661 AliITSRecPoint * cl2;
1662 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1663 cl2->SetChargeRatio(1.);
1666 } // cross is within the detector
1672 } // end loop over Pstrips
1674 } // end loop over Nside 1D clusters
1676 for (Int_t j=0; j<nn; j++) { // loop over Pside 1D clusters with no crosses
1677 if(cpositive[j]) continue;
1679 // for(Int_t ib=0; ib<768; ib++) { // loop over all Nside strips
1680 for(Int_t ib=15; ib<753; ib++) { // loop over all Nside strips
1682 if(cal->IsNChannelBad(ib)) { // check if strip is bad
1683 Float_t yP=neg[j].GetY();
1685 seg->GetPadCxz(yP, 1.*ib, xt, zt);
1688 // bad Nstrip is crossing the Pside 1Dcluster -> create recpoint
1690 if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
1691 Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
1692 mT2L->MasterToLocal(loc,trk);
1695 lp[4]=neg[j].GetQ(); //Q
1696 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1697 for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = neg[j].GetLabel(ilab);
1698 CheckLabels2(milab);
1699 milab[3]=( j << 10 ) + idet; // pos|neg|det
1700 Int_t info[3]={0,(Int_t)neg[j].GetNd(),fNlayer[fModule]};
1702 lp[2]=4.968e-06; // 0.00223*0.00223; //SigmaY2
1703 lp[3]=0.012; // 0.110*0.110; //SigmaZ2
1704 lp[5]=-0.00012; // out-of-diagonal element of covariance matrix
1711 AliITSRecPoint * cl2;
1712 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1713 cl2->SetChargeRatio(1.);
1716 } // cross is within the detector
1721 } // end loop over Nstrips
1722 } // end loop over Pside 1D clusters
1726 //---------------------------------------------------------
1728 else if( (countPbad>700) && (countNbad<100) ) { // bad Pside!!
1730 for (Int_t i=0; i<np; i++) { // loop over Nside 1Dclusters with no crosses
1731 if(cnegative[i]) continue; // if intersecting Pside clusters continue;
1734 Float_t yN=pos[i].GetY();
1736 if (seg->GetLayer()==5) yP = yN + (7.6/1.9);
1737 else yP = yN - (7.6/1.9);
1738 seg->GetPadCxz(yP, yN, xt, zt);
1740 if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
1741 Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
1742 mT2L->MasterToLocal(loc,trk);
1745 lp[4]=pos[i].GetQ(); //Q
1746 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1747 for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = pos[i].GetLabel(ilab);
1748 CheckLabels2(milab);
1749 milab[3]=( (i<<10) << 10 ) + idet; // pos|neg|det
1750 Int_t info[3] = {(Int_t)pos[i].GetNd(),0,fNlayer[fModule]};
1752 lp[2]=0.00098; // 0.031*0.031; //SigmaY2
1753 lp[3]=1.329; // 1.15*1.15; //SigmaZ2
1755 if(info[0]>1) lp[2]=0.00097;
1757 AliITSRecPoint * cl2;
1758 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1759 cl2->SetChargeRatio(1.);
1762 } // cross is within the detector
1766 } // end loop over Nside 1D clusters
1768 } // bad Pside module
1770 else if( (countNbad>700) && (countPbad<100) ) { // bad Nside!!
1772 for (Int_t j=0; j<nn; j++) { // loop over Pside 1D clusters with no crosses
1773 if(cpositive[j]) continue;
1776 Float_t yP=neg[j].GetY();
1778 if (seg->GetLayer()==5) yN = yP - (7.6/1.9);
1779 else yN = yP + (7.6/1.9);
1780 seg->GetPadCxz(yP, yN, xt, zt);
1782 if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
1783 Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
1784 mT2L->MasterToLocal(loc,trk);
1787 lp[4]=neg[j].GetQ(); //Q
1788 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1789 for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = neg[j].GetLabel(ilab);
1790 CheckLabels2(milab);
1791 milab[3]=( j << 10 ) + idet; // pos|neg|det
1792 Int_t info[3] = {0,(Int_t)neg[j].GetNd(),fNlayer[fModule]};
1794 lp[2]=7.27e-05; // 0.0085*0.0085; //SigmaY2
1795 lp[3]=1.33; // 1.15*1.15; //SigmaZ2
1797 if(info[1]>1) lp[2]=6.91e-05;
1799 AliITSRecPoint * cl2;
1800 cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info);
1801 cl2->SetChargeRatio(1.);
1804 } // cross is within the detector
1808 } // end loop over Pside 1D clusters
1810 } // bad Nside module
1812 //---------------------------------------------------------
1814 } // use bad channels
1816 //cout<<ncl<<" clusters for this module"<<endl;
1818 delete [] cnegative;
1820 delete [] negativepair;
1821 delete [] cpositive;
1823 delete [] positivepair;