1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
19 // Implementation of the ITS clusterer V2 class //
21 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch //
22 // Revised: Enrico Fragiacomo, enrico.fragiacomo@ts.infn.it //
23 // Revised 23/06/08: Marco Bregant
25 ///////////////////////////////////////////////////////////////////////////
27 #include <Riostream.h>
30 #include "AliITSClusterFinderV2SSD.h"
31 #include "AliITSRecPoint.h"
32 #include "AliITSgeomTGeo.h"
33 #include "AliITSDetTypeRec.h"
34 #include "AliRawReader.h"
35 #include "AliITSRawStreamSSD.h"
36 #include <TClonesArray.h>
37 #include "AliITSdigitSSD.h"
38 #include "AliITSReconstructor.h"
39 #include "AliITSCalibrationSSD.h"
40 #include "AliITSsegmentationSSD.h"
42 Short_t *AliITSClusterFinderV2SSD::fgPairs = 0x0;
43 Int_t AliITSClusterFinderV2SSD::fgPairsSize = 0;
44 const Float_t AliITSClusterFinderV2SSD::fgkCosmic2008StripShifts[16][9] =
45 {{-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35}, // DDL 512
46 {-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35}, // DDL 513
47 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 514
48 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 515
49 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 516
50 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 517
51 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 518
52 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 519
53 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.25,-0.15}, // DDL 520
54 {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 521
55 {-0.10,-0.10,-0.10,-0.40,-0.40,-0.40,-0.10,-0.10,-0.45}, // DDL 522
56 {-0.10,-0.10,-0.10,-0.35,-0.35,-0.35,-0.10,-0.35,-0.50}, // DDL 523
57 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 524
58 { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 525
59 { 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35}, // DDL 526
60 { 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45}}; // DDL 527
62 ClassImp(AliITSClusterFinderV2SSD)
65 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(AliITSDetTypeRec* dettyp):AliITSClusterFinder(dettyp),
66 fLastSSD1(AliITSgeomTGeo::GetModuleIndex(6,1,1)-1)
72 //______________________________________________________________________
73 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(const AliITSClusterFinderV2SSD &cf) : AliITSClusterFinder(cf), fLastSSD1(cf.fLastSSD1)
78 //______________________________________________________________________
79 AliITSClusterFinderV2SSD& AliITSClusterFinderV2SSD::operator=(const AliITSClusterFinderV2SSD& cf ){
80 // Assignment operator
82 this->~AliITSClusterFinderV2SSD();
83 new(this) AliITSClusterFinderV2SSD(cf);
88 void AliITSClusterFinderV2SSD::FindRawClusters(Int_t mod){
92 FindClustersSSD(fDigits);
96 void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
97 //------------------------------------------------------------
98 // Actual SSD cluster finder
99 //------------------------------------------------------------
101 static AliITSRecoParam *repa = NULL;
105 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
107 repa = AliITSRecoParam::GetHighFluxParam();
108 AliWarning("Using default AliITSRecoParam class");
112 AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
115 Int_t smaxall=alldigits->GetEntriesFast();
116 if (smaxall==0) return;
117 // TObjArray *digits = new TObjArray;
119 for (Int_t i=0;i<smaxall; i++){
120 AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i);
122 if(d->IsSideP()) gain = cal->GetGainP(d->GetStripNumber());
123 else gain = cal->GetGainN(d->GetStripNumber());
125 Float_t q=gain*d->GetSignal(); // calibration brings mip peaks around 120 (in ADC units)
126 q=cal->ADCToKeV(q); // converts the charge in KeV from ADC units
127 d->SetSignal(Int_t(q));
129 if (d->GetSignal()<3) continue;
132 Int_t smax = digits.GetEntriesFast();
135 const Int_t kMax=1000;
137 Ali1Dcluster pos[kMax], neg[kMax];
138 Float_t y=0., q=0., qmax=0.;
139 Int_t lab[4]={-2,-2,-2,-2};
141 AliITSdigitSSD *d=(AliITSdigitSSD*)digits.UncheckedAt(0);
143 y += d->GetCoord2()*d->GetSignal();
145 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
146 Int_t curr=d->GetCoord2();
147 Int_t flag=d->GetCoord1();
152 for (Int_t ilab=0;ilab<10;ilab++){
155 milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2);
157 for (Int_t s=1; s<smax; s++) {
158 d=(AliITSdigitSSD*)digits.UncheckedAt(s);
159 Int_t strip=d->GetCoord2();
160 if ((strip-curr) > 1 || flag!=d->GetCoord1()) {
165 c[*n].SetLabels(milab);
167 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
169 //Split suspiciously big cluster
171 c[*n].SetY(y/q-0.25*nd);
175 Error("FindClustersSSD","Too many 1D clusters !");
178 c[*n].SetY(y/q+0.25*nd);
181 c[*n].SetLabels(milab);
188 Error("FindClustersSSD","Too many 1D clusters !");
193 lab[0]=lab[1]=lab[2]=-2;
195 for (Int_t ilab=0;ilab<10;ilab++){
199 if (flag!=d->GetCoord1()) { n=&np; c=pos; }
203 y += d->GetCoord2()*d->GetSignal();
205 if (d->GetSignal()>qmax) {
207 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
209 for (Int_t ilab=0;ilab<10;ilab++) {
210 if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab)));
217 c[*n].SetLabels(lab);
219 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
221 //Split suspiciously big cluster
223 c[*n].SetY(y/q-0.25*nd);
227 Error("FindClustersSSD","Too many 1D clusters !");
230 c[*n].SetY(y/q+0.25*nd);
233 c[*n].SetLabels(lab);
239 Error("FindClustersSSD","Too many 1D clusters !");
243 FindClustersSSD(neg, nn, pos, np);
247 void AliITSClusterFinderV2SSD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){
249 //------------------------------------------------------------
250 // This function creates ITS clusters from raw data
251 //------------------------------------------------------------
253 AliITSRawStreamSSD inputSSD(rawReader);
254 FindClustersSSD(&inputSSD,clusters);
258 void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
259 TClonesArray** clusters)
261 //------------------------------------------------------------
262 // Actual SSD cluster finder for raw data
263 //------------------------------------------------------------
265 static AliITSRecoParam *repa = NULL;
267 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
269 repa = AliITSRecoParam::GetHighFluxParam();
270 AliWarning("Using default AliITSRecoParam class");
274 Int_t nClustersSSD = 0;
275 const Int_t kMax = 1000;
276 Ali1Dcluster clusters1D[2][kMax];
277 Int_t nClusters[2] = {0, 0};
278 Int_t lab[3]={-2,-2,-2};
284 // Float_t pedestal=0.;
286 AliITSCalibrationSSD* cal=NULL;
288 Int_t matrix[12][1536];
295 Int_t osignal = 65535;
299 // read raw data input stream
302 // reset signal matrix
303 for(Int_t i=0; i<12; i++) { for(Int_t j=0; j<1536; j++) { matrix[i][j] = 65535;} }
305 if((osignal!=65535)&&(ostrip>0)&&(ostrip<1536)) {
307 matrix[oadc][ostrip] = osignal; // recover data from previous occurence of input->Next()
310 // buffer data for ddl=iddl and ad=iad
313 next = input->Next();
314 if((!next)&&(input->flag)) continue;
315 Int_t ddl=input->GetDDL();
316 Int_t ad=input->GetAD();
317 Int_t adc = input->GetADC(); adc = (adc<6)? adc : adc - 2;
318 Int_t strip = input->GetStrip();
319 if(input->GetSideFlag()) strip=1535-strip;
320 Int_t signal = input->GetSignal();
322 if((ddl==iddl)&&(ad==iad)&&(strip>0)&&(strip<1536)) {n++; matrix[adc][strip] = signal;}
323 else {if ((strip<1536) && (strip>0)) {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}}
325 if(!next) {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
330 if(!next && oddl<0) break;
332 if(n==0) continue; // first occurence
336 if (repa->GetUseCosmicRunShiftsSSD()) { // Special condition for 2007/2008 cosmic data
337 dStrip = fgkCosmic2008StripShifts[oddl][oad-1];
339 if (TMath::Abs(dStrip) > 1.5)
340 AliError(Form("Indexing error ? oddl = %d, dStrip %f\n",oddl,dStrip));
342 for(Int_t iadc=0; iadc<12; iadc++) { // loop over ADC index for ddl=oddl and ad=oad
344 Int_t iimod = (oad - 1) * 12 + iadc;
345 Int_t iModule = AliITSRawStreamSSD::GetModuleNumber(oddl,iimod);
346 if(iModule==-1) continue;
347 cal = (AliITSCalibrationSSD*)GetResp(iModule);
352 for(Int_t istrip=0; istrip<768; istrip++) { // P-side
353 Int_t signal = matrix[iadc][istrip];
354 pedestal = cal->GetPedestalP(istrip);
355 matrix[iadc][istrip]=signal-(Int_t)pedestal;
361 for(Int_t l=0; l<6; l++) {
363 for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
365 for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
371 for(istrip=0; istrip<768; istrip++) { // P-side
373 Int_t signal = TMath::Abs(matrix[iadc][istrip]);
376 noise = cal->GetNoiseP(istrip); if(noise<1.) signal = 65535;
377 if(signal<3*noise) signal = 65535; // in case ZS was not done in hw do it now
379 // if(cal->IsPChannelBad(istrip)) signal=0;
382 gain = cal->GetGainP(istrip);
383 signal = (Int_t) ( signal * gain ); // signal is corrected for gain
384 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
386 q += signal; // add digit to current cluster
387 y += istrip * signal;
394 if ( ( (nDigits==1) && ( (q==0) || (q>5*oldnoise)) ) || (nDigits>1) ) {
396 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
398 if(q!=0) cluster.SetY(y/q + dStrip);
399 else cluster.SetY(istrip + dStrip -1);
402 cluster.SetNd(nDigits);
403 cluster.SetLabels(lab);
405 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
407 //Split suspiciously big cluster
408 if (nDigits > 4&&nDigits < 25) {
409 if(q!=0) cluster.SetY(y/q + dStrip - 0.25*nDigits);
410 else cluster.SetY(istrip-1 + dStrip - 0.25*nDigits);
412 if (nClusters[0] == kMax) {
413 Error("FindClustersSSD", "Too many 1D clusters !");
416 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
417 if(q!=0) cluster2.SetY(y/q + dStrip + 0.25*nDigits);
418 else cluster2.SetY(istrip-1 + dStrip + 0.25*nDigits);
419 cluster2.SetQ(0.5*q);
420 cluster2.SetNd(nDigits);
421 cluster2.SetLabels(lab);
431 } // loop over strip on P-side
433 // if last strip does have signal
436 if ( ( (nDigits==1) && ( (q==0) || (q>5*oldnoise)) ) || (nDigits>1) ) {
438 Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
440 if(q!=0) cluster.SetY(y/q + dStrip);
441 else cluster.SetY(istrip - 1 + dStrip);
444 cluster.SetNd(nDigits);
445 cluster.SetLabels(lab);
447 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
449 //Split suspiciously big cluster
450 if (nDigits > 4&&nDigits < 25) {
451 if(q!=0) cluster.SetY(y/q + dStrip - 0.25*nDigits);
452 else cluster.SetY(istrip-1 + dStrip - 0.25*nDigits);
454 if (nClusters[0] == kMax) {
455 Error("FindClustersSSD", "Too many 1D clusters !");
458 Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
459 if(q!=0) cluster2.SetY(y/q + dStrip + 0.25*nDigits);
460 else cluster2.SetY(istrip-1 + dStrip + 0.25*nDigits);
461 cluster2.SetQ(0.5*q);
462 cluster2.SetNd(nDigits);
463 cluster2.SetLabels(lab);
474 for(Int_t istrip=768; istrip<1536; istrip++) { // P-side
475 Int_t signal = matrix[iadc][istrip];
476 pedestal = cal->GetPedestalN(1535-istrip);
477 matrix[iadc][istrip]=signal-(Int_t)pedestal;
482 for(Int_t l=6; l<12; l++) {
484 for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
486 for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
493 for(Int_t iistrip=768; iistrip<1536; iistrip++) { // N-side
495 Int_t signal = TMath::Abs(matrix[iadc][iistrip]);
496 strip = 1535-iistrip;
499 noise = cal->GetNoiseN(strip); if(noise<1.) signal=65535;
501 // if(cal->IsNChannelBad(strip)) signal=0;
503 if(signal<3*noise) signal = 65535; // in case ZS was not done in hw do it now
506 gain = cal->GetGainN(strip);
507 signal = (Int_t) ( signal * gain); // signal is corrected for gain
508 signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV
510 // add digit to current cluster
519 if ( ( (nDigits==1) && ( (q==0) || (q>5*oldnoise)) ) || (nDigits>1) ) {
521 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
523 if(q!=0) cluster.SetY(y/q - dStrip);
524 else cluster.SetY(strip+1 - dStrip);
527 cluster.SetNd(nDigits);
528 cluster.SetLabels(lab);
530 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
532 //Split suspiciously big cluster
533 if (nDigits > 4&&nDigits < 25) {
534 cluster.SetY(y/q - dStrip - 0.25*nDigits);
536 if (nClusters[1] == kMax) {
537 Error("FindClustersSSD", "Too many 1D clusters !");
540 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
541 cluster2.SetY(y/q - dStrip + 0.25*nDigits);
542 cluster2.SetQ(0.5*q);
543 cluster2.SetNd(nDigits);
544 cluster2.SetLabels(lab);
554 } // loop over strips on N-side
558 if ( ( (nDigits==1) && ( (q==0) || (q>5*oldnoise)) ) || (nDigits>1) ) {
560 Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
562 if(q!=0) cluster.SetY(y/q - dStrip);
563 else cluster.SetY(strip - dStrip + 1);
566 cluster.SetNd(nDigits);
567 cluster.SetLabels(lab);
569 if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
571 //Split suspiciously big cluster
572 if (nDigits > 4&&nDigits < 25) {
573 if(q!=0) cluster.SetY(y/q - dStrip - 0.25*nDigits);
574 else cluster.SetY(strip+1 - dStrip - 0.25*nDigits);
576 if (nClusters[1] == kMax) {
577 Error("FindClustersSSD", "Too many 1D clusters !");
580 Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
581 if(q!=0) cluster2.SetY(y/q - dStrip + 0.25*nDigits);
582 else cluster2.SetY(strip+1 - dStrip + 0.25*nDigits);
583 cluster2.SetQ(0.5*q);
584 cluster2.SetNd(nDigits);
585 cluster2.SetLabels(lab);
596 if((nClusters[0])&&(nClusters[1])) {
598 clusters[iModule] = new TClonesArray("AliITSRecPoint");
600 FindClustersSSD(&clusters1D[0][0], nClusters[0],
601 &clusters1D[1][0], nClusters[1], clusters[iModule]);
602 Int_t nClustersn = clusters[iModule]->GetEntriesFast();
603 nClustersSSD += nClustersn;
606 nClusters[0] = nClusters[1] = 0;
615 Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD);
618 void AliITSClusterFinderV2SSD::
619 FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
620 Ali1Dcluster* pos, Int_t np,
621 TClonesArray *clusters) {
622 //------------------------------------------------------------
623 // Actual SSD cluster finder
624 //------------------------------------------------------------
626 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
628 TClonesArray &cl=*clusters;
630 AliITSsegmentationSSD *seg = dynamic_cast<AliITSsegmentationSSD*>(fDetTypeRec->GetSegmentationModel(2));
631 if (fModule>fLastSSD1)
636 Float_t hwSSD = seg->Dx()*1e-4/2;
637 Float_t hlSSD = seg->Dz()*1e-4/2;
639 Int_t idet=fNdet[fModule];
643 Int_t *cnegative = new Int_t[np];
644 Int_t *cused1 = new Int_t[np];
645 Int_t *negativepair = new Int_t[10*np];
646 Int_t *cpositive = new Int_t[nn];
647 Int_t *cused2 = new Int_t[nn];
648 Int_t *positivepair = new Int_t[10*nn];
649 for (Int_t i=0;i<np;i++) {cnegative[i]=0; cused1[i]=0;}
650 for (Int_t i=0;i<nn;i++) {cpositive[i]=0; cused2[i]=0;}
651 for (Int_t i=0;i<10*np;i++) {negativepair[i]=0;}
652 for (Int_t i=0;i<10*nn;i++) {positivepair[i]=0;}
654 if ((np*nn) > fgPairsSize) {
656 if (fgPairs) delete [] fgPairs;
657 fgPairsSize = 4*np*nn;
658 fgPairs = new Short_t[fgPairsSize];
660 memset(fgPairs,0,sizeof(Short_t)*np*nn);
663 // find available pairs
665 for (Int_t i=0; i<np; i++) {
666 Float_t yp=pos[i].GetY();
667 if ( (pos[i].GetQ()>0) && (pos[i].GetQ()<3) ) continue;
668 for (Int_t j=0; j<nn; j++) {
669 if ( (neg[j].GetQ()>0) && (neg[j].GetQ()<3) ) continue;
670 Float_t yn=neg[j].GetY();
673 seg->GetPadCxz(yn, yp, xt, zt);
675 if (TMath::Abs(xt)<hwSSD+0.01)
676 if (TMath::Abs(zt)<hlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
677 negativepair[i*10+cnegative[i]] =j; //index
678 positivepair[j*10+cpositive[j]] =i;
679 cnegative[i]++; //counters
687 // try to recover points out of but close to the module boundaries
689 for (Int_t i=0; i<np; i++) {
690 Float_t yp=pos[i].GetY();
691 if ( (pos[i].GetQ()>0) && (pos[i].GetQ()<3) ) continue;
692 for (Int_t j=0; j<nn; j++) {
693 if ( (neg[j].GetQ()>0) && (neg[j].GetQ()<3) ) continue;
694 // if both 1Dclusters have an other cross continue
695 if (cpositive[j]&&cnegative[i]) continue;
696 Float_t yn=neg[j].GetY();
699 seg->GetPadCxz(yn, yp, xt, zt);
701 if (TMath::Abs(xt)<hwSSD+0.1)
702 if (TMath::Abs(zt)<hlSSD+0.15) {
703 // tag 1Dcluster (eventually will produce low quality recpoint)
704 if (cnegative[i]==0) pos[i].SetNd(100); // not available pair
705 if (cpositive[j]==0) neg[j].SetNd(100); // not available pair
706 negativepair[i*10+cnegative[i]] =j; //index
707 positivepair[j*10+cpositive[j]] =i;
708 cnegative[i]++; //counters
721 static AliITSRecoParam *repa = NULL;
723 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
725 repa = AliITSRecoParam::GetHighFluxParam();
726 AliWarning("Using default AliITSRecoParam class");
730 if(repa->GetUseChargeMatchingInClusterFinderSSD()==kTRUE) {
736 for (Int_t ip=0;ip<np;ip++){
737 Float_t xbest=1000,zbest=1000,qbest=0;
739 // select gold clusters
740 if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){
741 Float_t yp=pos[ip].GetY();
742 Int_t j = negativepair[10*ip];
744 if( (pos[ip].GetQ()==0) && (neg[j].GetQ() ==0) ) {
745 // both bad, hence continue;
746 // mark both as used (to avoid recover at the end)
752 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
754 // charge matching (note that if posQ or negQ is 0 -> ratio=1 and the following condition is met
755 if (TMath::Abs(ratio)>0.2) continue; // note: 0.2=3xsigma_ratio calculated in cosmics tests
758 Float_t yn=neg[j].GetY();
761 seg->GetPadCxz(yn, yp, xt, zt);
766 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
767 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
770 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
771 mT2L->MasterToLocal(loc,trk);
775 lp[2]=0.0025*0.0025; //SigmaY2
776 lp[3]=0.110*0.110; //SigmaZ2
779 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
780 for (Int_t ilab=0;ilab<3;ilab++){
781 milab[ilab] = pos[ip].GetLabel(ilab);
782 milab[ilab+3] = neg[j].GetLabel(ilab);
786 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
787 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
788 AliITSRecPoint * cl2;
790 if(clusters){ // Note clusters != 0 when method is called for rawdata
793 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
795 cl2->SetChargeRatio(ratio);
799 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
804 if(pos[ip].GetQ()==0) cl2->SetType(3);
805 if(neg[j].GetQ()==0) cl2->SetType(4);
811 else{ // Note clusters == 0 when method is called for digits
813 cl2 = new AliITSRecPoint(milab,lp,info);
815 cl2->SetChargeRatio(ratio);
819 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
824 if(pos[ip].GetQ()==0) cl2->SetType(3);
825 if(neg[j].GetQ()==0) cl2->SetType(4);
830 fDetTypeRec->AddRecPoint(*cl2);
836 for (Int_t ip=0;ip<np;ip++){
837 Float_t xbest=1000,zbest=1000,qbest=0;
840 // select "silber" cluster
841 if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){
842 Int_t in = negativepair[10*ip];
843 Int_t ip2 = positivepair[10*in];
844 if (ip2==ip) ip2 = positivepair[10*in+1];
845 Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
847 if ( (TMath::Abs(pcharge-neg[in].GetQ())<30) && (pcharge!=0) ) { //
851 if ( (fgPairs[ip*nn+in]==100)&&(pos[ip].GetQ() ) ) { //
853 Float_t yp=pos[ip].GetY();
854 Float_t yn=neg[in].GetY();
857 seg->GetPadCxz(yn, yp, xt, zt);
861 qbest =pos[ip].GetQ();
862 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
863 mT2L->MasterToLocal(loc,trk);
867 lp[2]=0.0025*0.0025; //SigmaY2
868 lp[3]=0.110*0.110; //SigmaZ2
871 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
872 for (Int_t ilab=0;ilab<3;ilab++){
873 milab[ilab] = pos[ip].GetLabel(ilab);
874 milab[ilab+3] = neg[in].GetLabel(ilab);
878 ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ());
879 milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
880 Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
882 AliITSRecPoint * cl2;
885 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
886 cl2->SetChargeRatio(ratio);
888 fgPairs[ip*nn+in] = 5;
889 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
891 fgPairs[ip*nn+in] = 6;
895 cl2 = new AliITSRecPoint(milab,lp,info);
896 cl2->SetChargeRatio(ratio);
898 fgPairs[ip*nn+in] = 5;
899 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
901 fgPairs[ip*nn+in] = 6;
904 fDetTypeRec->AddRecPoint(*cl2);
913 // if (!(cused1[ip2] || cused2[in])){ //
914 if ( (fgPairs[ip2*nn+in]==100) && (pos[ip2].GetQ()) ) {
916 Float_t yp=pos[ip2].GetY();
917 Float_t yn=neg[in].GetY();
920 seg->GetPadCxz(yn, yp, xt, zt);
924 qbest =pos[ip2].GetQ();
926 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
927 mT2L->MasterToLocal(loc,trk);
931 lp[2]=0.0025*0.0025; //SigmaY2
932 lp[3]=0.110*0.110; //SigmaZ2
935 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
936 for (Int_t ilab=0;ilab<3;ilab++){
937 milab[ilab] = pos[ip2].GetLabel(ilab);
938 milab[ilab+3] = neg[in].GetLabel(ilab);
942 ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ());
943 milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
944 Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
946 AliITSRecPoint * cl2;
948 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
950 cl2->SetChargeRatio(ratio);
952 fgPairs[ip2*nn+in] =5;
953 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
955 fgPairs[ip2*nn+in] =6;
959 cl2 = new AliITSRecPoint(milab,lp,info);
960 cl2->SetChargeRatio(ratio);
962 fgPairs[ip2*nn+in] =5;
963 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
965 fgPairs[ip2*nn+in] =6;
968 fDetTypeRec->AddRecPoint(*cl2);
977 } // charge matching condition
979 } // 2 Pside cross 1 Nside
980 } // loop over Pside clusters
985 for (Int_t jn=0;jn<nn;jn++){
986 if (cused2[jn]) continue;
987 Float_t xbest=1000,zbest=1000,qbest=0;
988 // select "silber" cluster
989 if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){
990 Int_t ip = positivepair[10*jn];
991 Int_t jn2 = negativepair[10*ip];
992 if (jn2==jn) jn2 = negativepair[10*ip+1];
993 Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
996 if ( (TMath::Abs(pcharge-pos[ip].GetQ())<30) && // charge matching
997 (pcharge!=0) ) { // reject combinations of bad strips
1001 // if (!(cused1[ip]||cused2[jn])){
1002 if ( (fgPairs[ip*nn+jn]==100) && (neg[jn].GetQ()) ) { //
1004 Float_t yn=neg[jn].GetY();
1005 Float_t yp=pos[ip].GetY();
1008 seg->GetPadCxz(yn, yp, xt, zt);
1012 qbest =neg[jn].GetQ();
1015 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1016 mT2L->MasterToLocal(loc,trk);
1020 lp[2]=0.0025*0.0025; //SigmaY2
1021 lp[3]=0.110*0.110; //SigmaZ2
1024 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1025 for (Int_t ilab=0;ilab<3;ilab++){
1026 milab[ilab] = pos[ip].GetLabel(ilab);
1027 milab[ilab+3] = neg[jn].GetLabel(ilab);
1030 CheckLabels2(milab);
1031 ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ());
1032 milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
1033 Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]};
1035 AliITSRecPoint * cl2;
1037 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1039 cl2->SetChargeRatio(ratio);
1041 fgPairs[ip*nn+jn] =7;
1042 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
1044 fgPairs[ip*nn+jn]=8;
1049 cl2 = new AliITSRecPoint(milab,lp,info);
1050 cl2->SetChargeRatio(ratio);
1052 fgPairs[ip*nn+jn] =7;
1053 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
1055 fgPairs[ip*nn+jn]=8;
1058 fDetTypeRec->AddRecPoint(*cl2);
1064 // if (!(cused1[ip]||cused2[jn2])){
1065 if ( (fgPairs[ip*nn+jn2]==100)&&(neg[jn2].GetQ() ) ) { //
1067 Float_t yn=neg[jn2].GetY();
1068 Double_t yp=pos[ip].GetY();
1071 seg->GetPadCxz(yn, yp, xt, zt);
1075 qbest =neg[jn2].GetQ();
1078 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1079 mT2L->MasterToLocal(loc,trk);
1083 lp[2]=0.0025*0.0025; //SigmaY2
1084 lp[3]=0.110*0.110; //SigmaZ2
1087 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1088 for (Int_t ilab=0;ilab<3;ilab++){
1089 milab[ilab] = pos[ip].GetLabel(ilab);
1090 milab[ilab+3] = neg[jn2].GetLabel(ilab);
1093 CheckLabels2(milab);
1094 ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
1095 milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
1096 Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]};
1097 AliITSRecPoint * cl2;
1099 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1102 cl2->SetChargeRatio(ratio);
1103 fgPairs[ip*nn+jn2]=7;
1105 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
1107 fgPairs[ip*nn+jn2]=8;
1112 cl2 = new AliITSRecPoint(milab,lp,info);
1113 cl2->SetChargeRatio(ratio);
1114 fgPairs[ip*nn+jn2]=7;
1116 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
1118 fgPairs[ip*nn+jn2]=8;
1121 fDetTypeRec->AddRecPoint(*cl2);
1130 } // charge matching condition
1132 } // 2 Nside cross 1 Pside
1133 } // loop over Pside clusters
1137 for (Int_t ip=0;ip<np;ip++){
1138 Float_t xbest=1000,zbest=1000,qbest=0;
1142 if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){
1143 Float_t minchargediff =4.;
1145 for (Int_t di=0;di<cnegative[ip];di++){
1146 Int_t jc = negativepair[ip*10+di];
1147 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1148 if (TMath::Abs(chargedif)<minchargediff){
1150 minchargediff = TMath::Abs(chargedif);
1153 if (j<0) continue; // not proper cluster
1156 for (Int_t di=0;di<cnegative[ip];di++){
1157 Int_t jc = negativepair[ip*10+di];
1158 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1159 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1161 if (count>1) continue; // more than one "proper" cluster for positive
1165 for (Int_t dj=0;dj<cpositive[j];dj++){
1166 Int_t ic = positivepair[j*10+dj];
1167 Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
1168 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1170 if (count>1) continue; // more than one "proper" cluster for negative
1175 for (Int_t dj=0;dj<cnegative[jp];dj++){
1176 Int_t ic = positivepair[jp*10+dj];
1177 Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
1178 if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1180 if (count>1) continue;
1181 if (fgPairs[ip*nn+j]<100) continue;
1184 //almost gold clusters
1185 Float_t yp=pos[ip].GetY();
1186 Float_t yn=neg[j].GetY();
1190 seg->GetPadCxz(yn, yp, xt, zt);
1194 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1197 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1198 mT2L->MasterToLocal(loc,trk);
1202 lp[2]=0.0025*0.0025; //SigmaY2
1203 lp[3]=0.110*0.110; //SigmaZ2
1205 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1206 for (Int_t ilab=0;ilab<3;ilab++){
1207 milab[ilab] = pos[ip].GetLabel(ilab);
1208 milab[ilab+3] = neg[j].GetLabel(ilab);
1211 CheckLabels2(milab);
1212 if ((neg[j].GetQ()==0)&&(pos[ip].GetQ()==0)) continue; // reject crosses of bad strips!!
1213 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1214 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1215 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1216 AliITSRecPoint * cl2;
1218 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1220 cl2->SetChargeRatio(ratio);
1222 fgPairs[ip*nn+j]=10;
1223 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1225 fgPairs[ip*nn+j]=11;
1231 cl2 = new AliITSRecPoint(milab,lp,info);
1232 cl2->SetChargeRatio(ratio);
1234 fgPairs[ip*nn+j]=10;
1235 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1237 fgPairs[ip*nn+j]=11;
1242 fDetTypeRec->AddRecPoint(*cl2);
1247 } // loop over Pside 1Dclusters
1250 } // use charge matching
1253 // recover all the other crosses
1255 for (Int_t i=0; i<np; i++) {
1256 Float_t xbest=1000,zbest=1000,qbest=0;
1257 Float_t yp=pos[i].GetY();
1258 if ((pos[i].GetQ()>0)&&(pos[i].GetQ()<3)) continue;
1259 for (Int_t j=0; j<nn; j++) {
1260 // for (Int_t di = 0;di<cpositive[i];di++){
1261 // Int_t j = negativepair[10*i+di];
1262 if ((neg[j].GetQ()>0)&&(neg[j].GetQ()<3)) continue;
1264 if ((neg[j].GetQ()==0)&&(pos[i].GetQ()==0)) continue; // reject crosses of bad strips!!
1266 if (cused2[j]||cused1[i]) continue;
1267 if (fgPairs[i*nn+j]>0 &&fgPairs[i*nn+j]<100) continue;
1268 ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ());
1269 Float_t yn=neg[j].GetY();
1272 seg->GetPadCxz(yn, yp, xt, zt);
1274 if (TMath::Abs(xt)<hwSSD+0.01)
1275 if (TMath::Abs(zt)<hlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
1278 qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
1281 Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
1282 mT2L->MasterToLocal(loc,trk);
1286 lp[2]=0.0025*0.0025; //SigmaY2
1287 lp[3]=0.110*0.110; //SigmaZ2
1290 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1291 for (Int_t ilab=0;ilab<3;ilab++){
1292 milab[ilab] = pos[i].GetLabel(ilab);
1293 milab[ilab+3] = neg[j].GetLabel(ilab);
1296 CheckLabels2(milab);
1297 milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
1298 Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1299 AliITSRecPoint * cl2;
1301 cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1303 cl2->SetChargeRatio(ratio);
1304 cl2->SetType(100+cpositive[j]+cnegative[i]);
1306 if(pos[i].GetQ()==0) cl2->SetType(200+cpositive[j]+cnegative[i]);
1307 if(neg[j].GetQ()==0) cl2->SetType(300+cpositive[j]+cnegative[i]);
1311 cl2 = new AliITSRecPoint(milab,lp,info);
1312 cl2->SetChargeRatio(ratio);
1313 cl2->SetType(100+cpositive[j]+cnegative[i]);
1315 if(pos[i].GetQ()==0) cl2->SetType(200+cpositive[j]+cnegative[i]);
1316 if(neg[j].GetQ()==0) cl2->SetType(300+cpositive[j]+cnegative[i]);
1318 fDetTypeRec->AddRecPoint(*cl2);
1324 delete [] cnegative;
1326 delete [] negativepair;
1327 delete [] cpositive;
1329 delete [] positivepair;