1 //-------------------------------------------------------------------------
2 // Implementation of the ITS clusterer V2 class
4 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
5 //-------------------------------------------------------------------------
6 //uncomment the line below for running with V1 cluster finder classes
11 #include "AliITSclustererV2.h"
12 #include "AliITSclusterV2.h"
13 #include "AliITSDetTypeRec.h"
14 #include "AliRawReader.h"
15 #include "AliITSRawStreamSPD.h"
16 #include "AliITSRawStreamSDD.h"
17 #include "AliITSRawStreamSSD.h"
21 #include <TClonesArray.h>
22 #include "AliITSgeom.h"
23 #include "AliITSdigitSPD.h"
24 #include "AliITSdigitSDD.h"
25 #include "AliITSdigitSSD.h"
28 ClassImp(AliITSclustererV2)
30 extern AliRun *gAlice;
32 AliITSclustererV2::AliITSclustererV2(const AliITSgeom *geom) {
33 //------------------------------------------------------------
34 // Standard constructor
35 //------------------------------------------------------------
36 AliITSgeom *g=(AliITSgeom*)geom;
41 Int_t mmax=geom->GetIndexMax();
43 Fatal("AliITSclustererV2","Too many ITS subdetectors !");
46 for (m=0; m<mmax; m++) {
47 Int_t lay,lad,det; g->GetModuleId(m,lay,lad,det);
48 Float_t x,y,z; g->GetTrans(lay,lad,det,x,y,z);
49 Double_t rot[9]; g->GetRotMatrix(lay,lad,det,rot);
50 Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
51 Double_t ca=TMath::Cos(alpha), sa=TMath::Sin(alpha);
52 fYshift[m] = x*ca + y*sa;
53 fZshift[m] = (Double_t)z;
54 fNdet[m] = (lad-1)*g->GetNdetectors(lay) + (det-1);
57 fNModules = g->GetIndexMax();
60 fLastSPD1=g->GetModuleIndex(2,1,1)-1;
61 fNySPD=256; fNzSPD=160;
63 fZ1pitchSPD=0.0425; fZ2pitchSPD=0.0625;
64 fHwSPD=0.64; fHlSPD=3.48;
65 fYSPD[0]=0.5*fYpitchSPD;
66 for (m=1; m<fNySPD; m++) fYSPD[m]=fYSPD[m-1]+fYpitchSPD;
68 for (m=1; m<fNzSPD; m++) {
69 Double_t dz=fZ1pitchSPD;
70 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
71 m==127 || m==128) dz=fZ2pitchSPD;
72 fZSPD[m]=fZSPD[m-1]+dz;
74 for (m=0; m<fNzSPD; m++) {
75 Double_t dz=0.5*fZ1pitchSPD;
76 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
77 m==127 || m==128) dz=0.5*fZ2pitchSPD;
82 fNySDD=256; fNzSDD=256;
85 fHwSDD=3.5085; fHlSDD=3.7632;
89 fLastSSD1=g->GetModuleIndex(6,1,1)-1;
99 Int_t AliITSclustererV2::Digits2Clusters(TTree *dTree, TTree *cTree) {
100 //------------------------------------------------------------
101 // This function creates ITS clusters
102 //------------------------------------------------------------
106 Error("Digits2Clusters","Can't get the tree with digits !");
110 TClonesArray *digitsSPD=new TClonesArray("AliITSdigitSPD",3000);
111 dTree->SetBranchAddress("ITSDigitsSPD",&digitsSPD);
112 TClonesArray *digitsSDD=new TClonesArray("AliITSdigitSDD",3000);
113 dTree->SetBranchAddress("ITSDigitsSDD",&digitsSDD);
114 TClonesArray *digitsSSD=new TClonesArray("AliITSdigitSSD",3000);
115 dTree->SetBranchAddress("ITSDigitsSSD",&digitsSSD);
117 TClonesArray *clusters=new TClonesArray("AliITSclusterV2",1000);
118 TBranch *branch=cTree->GetBranch("Clusters");
119 if (!branch) cTree->Branch("Clusters",&clusters);
120 else branch->SetAddress(&clusters);
122 Int_t mmax=(Int_t)dTree->GetEntries();
123 if (mmax!=fNModules) {
124 Error("Digits2Clusters","Number of entries != number of modules !");
128 for (fI=0; fI<mmax; fI++) {
131 if (digitsSPD->GetEntriesFast()!=0)
132 FindClustersSPD(digitsSPD,clusters);
134 if(digitsSDD->GetEntriesFast()!=0)
135 FindClustersSDD(digitsSDD,clusters);
136 else if(digitsSSD->GetEntriesFast()!=0)
137 FindClustersSSD(digitsSSD,clusters);
139 ncl+=clusters->GetEntriesFast();
159 Info("Digits2Clusters","Number of found clusters : %d",ncl);
164 void AliITSclustererV2::Digits2Clusters(AliRawReader* rawReader) {
165 //------------------------------------------------------------
166 // This function creates ITS clusters from raw data
167 //------------------------------------------------------------
168 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
170 Error("Digits2Clusters", "no run loader found");
173 runLoader->LoadKinematics();
174 AliLoader* itsLoader = runLoader->GetLoader("ITSLoader");
176 Error("Digits2Clusters", "no loader for ITS found");
179 if (!itsLoader->TreeR()) itsLoader->MakeTree("R");
180 TTree* cTree = itsLoader->TreeR();
182 TClonesArray *array=new TClonesArray("AliITSclusterV2",1000);
183 cTree->Branch("Clusters",&array);
186 TClonesArray** clusters = new TClonesArray*[fNModules];
187 for (Int_t iModule = 0; iModule < fNModules; iModule++) {
188 clusters[iModule] = NULL;
190 // one TClonesArray per module
193 AliITSRawStreamSPD inputSPD(rawReader);
194 FindClustersSPD(&inputSPD, clusters);
197 AliITSRawStreamSDD inputSDD(rawReader);
198 FindClustersSDD(&inputSDD, clusters);
201 AliITSRawStreamSSD inputSSD(rawReader);
202 FindClustersSSD(&inputSSD, clusters);
204 // write all clusters to the tree
206 for (Int_t iModule = 0; iModule < fNModules; iModule++) {
207 array = clusters[iModule];
209 Error("Digits2Clusters", "data for module %d missing!", iModule);
210 array = new TClonesArray("AliITSclusterV2");
212 cTree->SetBranchAddress("Clusters", &array);
214 nClusters += array->GetEntriesFast();
217 itsLoader->WriteRecPoints("OVERWRITE");
221 Info("Digits2Clusters", "total number of found clusters in ITS: %d\n",
225 //**** Fast clusters *******************************
226 #include "TParticle.h"
228 //#include "AliITS.h"
229 #include "AliITSmodule.h"
230 #include "AliITSRecPoint.h"
231 #include "AliITSsimulationFastPoints.h"
232 #include "AliITSRecPoint.h"
235 static void CheckLabels(Int_t lab[3]) {
236 //------------------------------------------------------------
237 // Tries to find mother's labels
238 //------------------------------------------------------------
241 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
243 while (part->P() < 0.005) {
244 Int_t m=part->GetFirstMother();
246 Info("CheckLabels","Primary momentum: %f",part->P());
249 if (part->GetStatusCode()>0) {
250 Info("CheckLabels","Primary momentum: %f",part->P());
254 part=(TParticle*)gAlice->GetMCApp()->Particle(label);
256 if (lab[1]<0) lab[1]=label;
257 else if (lab[2]<0) lab[2]=label;
258 else ;//cerr<<"CheckLabels : No empty labels !\n";
263 static void CheckLabels(Int_t lab[3]) {
264 //------------------------------------------------------------
265 // Tries to find mother's labels
266 //------------------------------------------------------------
268 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
270 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
271 for (Int_t i=0;i<3;i++){
272 Int_t label = lab[i];
273 if (label>=0 && label<ntracks) {
274 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
275 if (part->P() < 0.005) {
276 Int_t m=part->GetFirstMother();
280 if (part->GetStatusCode()>0) {
290 static void CheckLabels2(Int_t lab[10]) {
291 //------------------------------------------------------------
292 // Tries to find mother's labels
293 //------------------------------------------------------------
295 for (Int_t i=0;i<10;i++) if (lab[i]>=0) nlabels++;
296 if(nlabels == 0) return; // In case of no labels just exit
298 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
300 for (Int_t i=0;i<10;i++){
301 Int_t label = lab[i];
302 if (label>=0 && label<ntracks) {
303 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
304 if (part->P() < 0.02) {
305 Int_t m=part->GetFirstMother();
309 if (part->GetStatusCode()>0) {
315 if (part->P() < 0.12 && nlabels>3) {
321 if ( (label>ntracks||label <0) && nlabels>3) {
328 for (Int_t i=0;i<10;i++){
330 Int_t label = lab[i];
331 if (label>=0 && label<ntracks) {
332 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
333 if (part->P() < 0.1) {
342 //compress labels -- if multi-times the same
344 for (Int_t i=0;i<10;i++) lab2[i]=-2;
345 for (Int_t i=0;i<10 ;i++){
346 if (lab[i]<0) continue;
347 for (Int_t j=0;j<10 &&lab2[j]!=lab[i];j++){
354 for (Int_t j=0;j<10;j++) lab[j]=lab2[j];
358 static void AddLabel(Int_t lab[10], Int_t label) {
360 if(label<0) return; // In case of no label just exit
362 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
363 if (label>ntracks) return;
364 for (Int_t i=0;i<10;i++){
365 // if (label<0) break;
366 if (lab[i]==label) break;
374 void AliITSclustererV2::RecPoints2Clusters
375 (const TClonesArray *points, Int_t idx, TClonesArray *clusters) {
376 //------------------------------------------------------------
377 // Conversion AliITSRecPoint -> AliITSclusterV2 for the ITS
378 // subdetector indexed by idx
379 //------------------------------------------------------------
380 TClonesArray &cl=*clusters;
381 Int_t ncl=points->GetEntriesFast();
382 for (Int_t i=0; i<ncl; i++) {
383 AliITSRecPoint *p = (AliITSRecPoint *)points->UncheckedAt(i);
385 lp[0]=-(-p->GetDetLocalX()+fYshift[idx]); if (idx<=fLastSPD1) lp[0]*=-1; //SPD1
386 lp[1]= -p->GetZ()+fZshift[idx];
387 lp[2]=p->GetSigmaDetLocX2();
388 lp[3]=p->GetSigmaZ2();
389 lp[4]=p->GetQ()*36./23333.; //electrons -> ADC
391 lab[0]=p->GetLabel(0); lab[1]=p->GetLabel(1); lab[2]=p->GetLabel(2);
394 Int_t dummy[3]={0,0,0};
395 new (cl[i]) AliITSclusterV2(lab,lp, dummy);
399 //***********************************
403 void AliITSclustererV2::
404 FindCluster(Int_t k,Int_t maxz,AliBin *bins,Int_t &n,Int_t *idx) {
405 //------------------------------------------------------------
406 // returns an array of indices of digits belonging to the cluster
407 // (needed when the segmentation is not regular)
408 //------------------------------------------------------------
409 if (n<200) idx[n++]=bins[k].GetIndex();
412 if (bins[k-maxz].IsNotUsed()) FindCluster(k-maxz,maxz,bins,n,idx);
413 if (bins[k-1 ].IsNotUsed()) FindCluster(k-1 ,maxz,bins,n,idx);
414 if (bins[k+maxz].IsNotUsed()) FindCluster(k+maxz,maxz,bins,n,idx);
415 if (bins[k+1 ].IsNotUsed()) FindCluster(k+1 ,maxz,bins,n,idx);
417 if (bins[k-maxz-1].IsNotUsed()) FindCluster(k-maxz-1,maxz,bins,n,idx);
418 if (bins[k-maxz+1].IsNotUsed()) FindCluster(k-maxz+1,maxz,bins,n,idx);
419 if (bins[k+maxz-1].IsNotUsed()) FindCluster(k+maxz-1,maxz,bins,n,idx);
420 if (bins[k+maxz+1].IsNotUsed()) FindCluster(k+maxz+1,maxz,bins,n,idx);
424 void AliITSclustererV2::
425 FindClustersSPD(const TClonesArray *digits, TClonesArray *clusters) {
426 //------------------------------------------------------------
427 // Actual SPD cluster finder
428 //------------------------------------------------------------
429 Int_t kNzBins = fNzSPD + 2;
430 const Int_t kMAXBIN=kNzBins*(fNySPD+2);
432 Int_t ndigits=digits->GetEntriesFast();
433 AliBin *bins=new AliBin[kMAXBIN];
437 for (k=0; k<ndigits; k++) {
438 d=(AliITSdigitSPD*)digits->UncheckedAt(k);
439 Int_t i=d->GetCoord2()+1; //y
440 Int_t j=d->GetCoord1()+1;
441 bins[i*kNzBins+j].SetIndex(k);
442 bins[i*kNzBins+j].SetMask(1);
445 Int_t n=0; TClonesArray &cl=*clusters;
446 for (k=0; k<kMAXBIN; k++) {
447 if (!bins[k].IsNotUsed()) continue;
448 Int_t ni=0, idx[200];
449 FindCluster(k,kNzBins,bins,ni,idx);
451 Info("FindClustersSPD","Too big cluster !");
455 for (Int_t ilab=0;ilab<10;ilab++){
459 d=(AliITSdigitSPD*)digits->UncheckedAt(idx[0]);
460 Int_t ymin=d->GetCoord2(),ymax=ymin;
461 Int_t zmin=d->GetCoord1(),zmax=zmin;
463 for (Int_t l=0; l<ni; l++) {
464 d=(AliITSdigitSPD*)digits->UncheckedAt(idx[l]);
466 if (ymin > d->GetCoord2()) ymin=d->GetCoord2();
467 if (ymax < d->GetCoord2()) ymax=d->GetCoord2();
468 if (zmin > d->GetCoord1()) zmin=d->GetCoord1();
469 if (zmax < d->GetCoord1()) zmax=d->GetCoord1();
470 // MI addition - find all labels in cluster
471 for (Int_t dlab=0;dlab<10;dlab++){
472 Int_t digitlab = (d->GetTracks())[dlab];
473 if (digitlab<0) continue;
474 AddLabel(milab,digitlab);
476 if (milab[9]>0) CheckLabels2(milab);
480 //Int_t idy = (fNlayer[fI]==0)? 2:3;
481 //for (Int_t iz=zmin; iz<=zmax;iz+=2)
482 //Int_t idy = (ymax-ymin)/4.; // max 2 clusters
483 Int_t idy = 0; // max 2 clusters
484 if (fNlayer[fI]==0 &&idy<3) idy=3;
485 if (fNlayer[fI]==1 &&idy<4) idy=4;
487 for (Int_t iz=zmin; iz<=zmax;iz+=idz)
488 for (Int_t iy=ymin; iy<=ymax;iy+=idy){
491 Float_t y=0.,z=0.,q=0.;
492 for (Int_t l=0; l<ni; l++) {
493 d=(AliITSdigitSPD*)digits->UncheckedAt(idx[l]);
494 if (zmax-zmin>=idz || ymax-ymin>=idy){
495 if (TMath::Abs( d->GetCoord2()-iy)>0.75*idy) continue;
496 if (TMath::Abs( d->GetCoord1()-iz)>0.75*idz) continue;
499 Float_t qq=d->GetSignal();
500 y+=qq*fYSPD[d->GetCoord2()]; z+=qq*fZSPD[d->GetCoord1()]; q+=qq;
503 if (ndigits==0) continue;
505 y-=fHwSPD; z-=fHlSPD;
508 lp[0]=-(-y+fYshift[fI]); if (fI<=fLastSPD1) lp[0]=-lp[0];
509 lp[1]= -z+fZshift[fI];
510 // Float_t factor=TMath::Max(double(ni-3.),1.5);
511 Float_t factory=TMath::Max(ymax-ymin,1);
512 Float_t factorz=TMath::Max(zmax-zmin,1);
515 //lp[2]= (fYpitchSPD*fYpitchSPD/12.)*factory;
516 //lp[3]= (fZ1pitchSPD*fZ1pitchSPD/12.)*factorz;
517 lp[2]= (fYpitchSPD*fYpitchSPD/12.);
518 lp[3]= (fZ1pitchSPD*fZ1pitchSPD/12.);
520 lp[4]= (zmax-zmin+1)*100 + (ymax-ymin+1);
523 d=(AliITSdigitSPD*)digits->UncheckedAt(idx[0]);
524 Int_t info[3] = {ymax-ymin+1,zmax-zmin+1,fNlayer[fI]};
525 new (cl[n]) AliITSclusterV2(milab,lp,info); n++;
532 void AliITSclustererV2::FindClustersSPD(AliITSRawStream* input,
533 TClonesArray** clusters)
535 //------------------------------------------------------------
536 // Actual SPD cluster finder for raw data
537 //------------------------------------------------------------
539 Int_t nClustersSPD = 0;
540 Int_t kNzBins = fNzSPD + 2;
541 Int_t kNyBins = fNySPD + 2;
542 Int_t kMaxBin = kNzBins * kNyBins;
543 AliBin *binsSPD = new AliBin[kMaxBin];
544 AliBin *binsSPDInit = new AliBin[kMaxBin];
547 // read raw data input stream
549 Bool_t next = input->Next();
550 if (!next || input->IsNewModule()) {
551 Int_t iModule = input->GetPrevModuleID();
553 // when all data from a module was read, search for clusters
555 clusters[iModule] = new TClonesArray("AliITSclusterV2");
558 for (Int_t iBin = 0; iBin < kMaxBin; iBin++) {
559 if (bins[iBin].IsUsed()) continue;
562 FindCluster(iBin, kNzBins, bins, nBins, idxBins);
564 Error("FindClustersSPD", "SPD: Too big cluster !\n");
572 // label[3] = iModule;
573 label[3] = fNdet[iModule];
575 Int_t ymin = (idxBins[0] / kNzBins) - 1;
577 Int_t zmin = (idxBins[0] % kNzBins) - 1;
579 for (Int_t idx = 0; idx < nBins; idx++) {
580 Int_t iy = (idxBins[idx] / kNzBins) - 1;
581 Int_t iz = (idxBins[idx] % kNzBins) - 1;
582 if (ymin > iy) ymin = iy;
583 if (ymax < iy) ymax = iy;
584 if (zmin > iz) zmin = iz;
585 if (zmax < iz) zmax = iz;
588 Int_t idy = 0; // max 2 clusters
589 if ((iModule <= fLastSPD1) &&idy<3) idy=3;
590 if ((iModule > fLastSPD1) &&idy<4) idy=4;
592 for (Int_t iiz=zmin; iiz<=zmax;iiz+=idz)
593 for (Int_t iiy=ymin; iiy<=ymax;iiy+=idy){
596 Float_t y=0.,z=0.,q=0.;
597 for (Int_t idx = 0; idx < nBins; idx++) {
598 Int_t iy = (idxBins[idx] / kNzBins) - 1;
599 Int_t iz = (idxBins[idx] % kNzBins) - 1;
600 if (zmax-zmin>=idz || ymax-ymin>=idy){
601 if (TMath::Abs(iy-iiy)>0.75*idy) continue;
602 if (TMath::Abs(iz-iiz)>0.75*idz) continue;
605 Float_t qBin = bins[idxBins[idx]].GetQ();
606 y += qBin * fYSPD[iy];
607 z += qBin * fZSPD[iz];
610 if (ndigits==0) continue;
616 Float_t hit[5]; // y, z, sigma(y)^2, sigma(z)^2, charge
617 hit[0] = -(-y+fYshift[iModule]);
618 if (iModule <= fLastSPD1) hit[0] = -hit[0];
619 hit[1] = -z+fZshift[iModule];
620 hit[2] = fYpitchSPD*fYpitchSPD/12.;
621 hit[3] = fZ1pitchSPD*fZ1pitchSPD/12.;
623 hit[4] = (zmax-zmin+1)*100 + (ymax-ymin+1);
624 // CheckLabels(label);
625 Int_t info[3]={ymax-ymin+1,zmax-zmin+1,fNlayer[iModule]};
626 new (clusters[iModule]->AddrAt(nClusters))
627 AliITSclusterV2(label, hit,info);
632 nClustersSPD += nClusters;
638 memcpy(binsSPD,binsSPDInit,sizeof(AliBin)*kMaxBin);
641 // fill the current digit into the bins array
642 Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1);
643 bins[index].SetIndex(index);
644 bins[index].SetMask(1);
648 delete [] binsSPDInit;
651 Info("FindClustersSPD", "found clusters in ITS SPD: %d", nClustersSPD);
655 Bool_t AliITSclustererV2::IsMaximum(Int_t k,Int_t max,const AliBin *bins) {
656 //------------------------------------------------------------
657 //is this a local maximum ?
658 //------------------------------------------------------------
659 UShort_t q=bins[k].GetQ();
660 if (q==1023) return kFALSE;
661 if (bins[k-max].GetQ() > q) return kFALSE;
662 if (bins[k-1 ].GetQ() > q) return kFALSE;
663 if (bins[k+max].GetQ() > q) return kFALSE;
664 if (bins[k+1 ].GetQ() > q) return kFALSE;
665 if (bins[k-max-1].GetQ() > q) return kFALSE;
666 if (bins[k+max-1].GetQ() > q) return kFALSE;
667 if (bins[k+max+1].GetQ() > q) return kFALSE;
668 if (bins[k-max+1].GetQ() > q) return kFALSE;
672 void AliITSclustererV2::
673 FindPeaks(Int_t k,Int_t max,AliBin *b,Int_t *idx,UInt_t *msk,Int_t& n) {
674 //------------------------------------------------------------
676 //------------------------------------------------------------
678 if (IsMaximum(k,max,b)) {
679 idx[n]=k; msk[n]=(2<<n);
683 if (b[k-max].GetMask()&1) FindPeaks(k-max,max,b,idx,msk,n);
684 if (b[k-1 ].GetMask()&1) FindPeaks(k-1 ,max,b,idx,msk,n);
685 if (b[k+max].GetMask()&1) FindPeaks(k+max,max,b,idx,msk,n);
686 if (b[k+1 ].GetMask()&1) FindPeaks(k+1 ,max,b,idx,msk,n);
689 void AliITSclustererV2::
690 MarkPeak(Int_t k, Int_t max, AliBin *bins, UInt_t m) {
691 //------------------------------------------------------------
693 //------------------------------------------------------------
694 UShort_t q=bins[k].GetQ();
696 bins[k].SetMask(bins[k].GetMask()|m);
698 if (bins[k-max].GetQ() <= q)
699 if ((bins[k-max].GetMask()&m) == 0) MarkPeak(k-max,max,bins,m);
700 if (bins[k-1 ].GetQ() <= q)
701 if ((bins[k-1 ].GetMask()&m) == 0) MarkPeak(k-1 ,max,bins,m);
702 if (bins[k+max].GetQ() <= q)
703 if ((bins[k+max].GetMask()&m) == 0) MarkPeak(k+max,max,bins,m);
704 if (bins[k+1 ].GetQ() <= q)
705 if ((bins[k+1 ].GetMask()&m) == 0) MarkPeak(k+1 ,max,bins,m);
708 void AliITSclustererV2::
709 MakeCluster(Int_t k,Int_t max,AliBin *bins,UInt_t m,AliITSclusterV2 &c) {
710 //------------------------------------------------------------
711 //make cluster using digits of this peak
712 //------------------------------------------------------------
713 Float_t q=(Float_t)bins[k].GetQ();
714 Int_t i=k/max, j=k-i*max;
717 c.SetY(c.GetY()+i*q);
718 c.SetZ(c.GetZ()+j*q);
719 c.SetSigmaY2(c.GetSigmaY2()+i*i*q);
720 c.SetSigmaZ2(c.GetSigmaZ2()+j*j*q);
722 bins[k].SetMask(0xFFFFFFFE);
724 if (bins[k-max].GetMask() == m) MakeCluster(k-max,max,bins,m,c);
725 if (bins[k-1 ].GetMask() == m) MakeCluster(k-1 ,max,bins,m,c);
726 if (bins[k+max].GetMask() == m) MakeCluster(k+max,max,bins,m,c);
727 if (bins[k+1 ].GetMask() == m) MakeCluster(k+1 ,max,bins,m,c);
730 void AliITSclustererV2::
731 FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins,
732 const TClonesArray *digits, TClonesArray *clusters) {
733 //------------------------------------------------------------
734 // Actual SDD cluster finder
735 //------------------------------------------------------------
736 Int_t ncl=0; TClonesArray &cl=*clusters;
737 for (Int_t s=0; s<2; s++)
738 for (Int_t i=0; i<nMaxBin; i++) {
739 if (bins[s][i].IsUsed()) continue;
740 Int_t idx[32]; UInt_t msk[32]; Int_t npeaks=0;
741 FindPeaks(i, nzBins, bins[s], idx, msk, npeaks);
743 if (npeaks>30) continue;
744 if (npeaks==0) continue;
747 for (k=0; k<npeaks-1; k++){//mark adjacent peaks
748 if (idx[k] < 0) continue; //this peak is already removed
749 for (l=k+1; l<npeaks; l++) {
750 if (idx[l] < 0) continue; //this peak is already removed
751 Int_t ki=idx[k]/nzBins, kj=idx[k] - ki*nzBins;
752 Int_t li=idx[l]/nzBins, lj=idx[l] - li*nzBins;
753 Int_t di=TMath::Abs(ki - li);
754 Int_t dj=TMath::Abs(kj - lj);
755 if (di>1 || dj>1) continue;
756 if (bins[s][idx[k]].GetQ() > bins[s][idx[l]].GetQ()) {
767 for (k=0; k<npeaks; k++) {
768 MarkPeak(TMath::Abs(idx[k]), nzBins, bins[s], msk[k]);
771 for (k=0; k<npeaks; k++) {
772 if (idx[k] < 0) continue; //removed peak
774 MakeCluster(idx[k], nzBins, bins[s], msk[k], c);
777 for (Int_t ilab=0;ilab<10;ilab++){
780 Int_t maxi=0,mini=0,maxj=0,minj=0;
781 //AliBin *bmax=&bins[s][idx[k]];
782 //Float_t max = TMath::Max(TMath::Abs(bmax->GetQ())/5.,3.);
784 for (Int_t di=-2; di<=2;di++)
785 for (Int_t dj=-3;dj<=3;dj++){
786 Int_t index = idx[k]+di+dj*nzBins;
787 if (index<0) continue;
788 if (index>=nMaxBin) continue;
789 AliBin *b=&bins[s][index];
790 if (TMath::Abs(b->GetQ())>max){
791 if (di>maxi) maxi=di;
792 if (di<mini) mini=di;
793 if (dj>maxj) maxj=dj;
794 if (dj<minj) minj=dj;
797 if (TMath::Abs(di)<2&&TMath::Abs(dj)<2){
798 AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
799 for (Int_t itrack=0;itrack<10;itrack++){
800 Int_t track = (d->GetTracks())[itrack];
802 AddLabel(milab, track);
811 Float_t s2 = c.GetSigmaY2()/c.GetQ() - c.GetY()*c.GetY();
812 Float_t w=par->GetPadPitchWidth(sec);
815 c.SetSigmaY2(c.GetSigmaY2()*0.108);
816 if (sec<par->GetNInnerSector()) c.SetSigmaY2(c.GetSigmaY2()*2.07);
818 s2 = c.GetSigmaZ2()/c.GetQ() - c.GetZ()*c.GetZ();
823 c.SetSigmaZ2(c.GetSigmaZ2()*0.169);
824 if (sec<par->GetNInnerSector()) c.SetSigmaZ2(c.GetSigmaZ2()*1.77);
828 c.SetSigmaY2(0.0030*0.0030);
829 c.SetSigmaZ2(0.0020*0.0020);
830 c.SetDetectorIndex(fNdet[fI]);
832 Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ();
835 //Float_t s2 = c.GetSigmaY2()/c.GetQ() - y*y;
837 //s2 = c.GetSigmaZ2()/c.GetQ() - z*z;
840 y=(y-0.5)*fYpitchSDD;
842 y-=fYoffSDD; //delay ?
845 z=(z-0.5)*fZpitchSDD;
852 c.SetNy(maxj-minj+1);
853 c.SetNz(maxi-mini+1);
855 c.SetQ(q/12.7); //to be consistent with the SSD charges
857 if (c.GetQ() < 20.) continue; //noise cluster
860 // AliBin *b=&bins[s][idx[k]];
861 // AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
864 //lab[0]=(d->GetTracks())[0];
865 //lab[1]=(d->GetTracks())[1];
866 //lab[2]=(d->GetTracks())[2];
869 c.SetLabel(milab[0],0);
870 c.SetLabel(milab[1],1);
871 c.SetLabel(milab[2],2);
872 c.SetLayer(fNlayer[fI]);
875 new (cl[ncl]) AliITSclusterV2(c); ncl++;
880 void AliITSclustererV2::
881 FindClustersSDD(const TClonesArray *digits, TClonesArray *clusters) {
882 //------------------------------------------------------------
883 // Actual SDD cluster finder
884 //------------------------------------------------------------
885 Int_t kNzBins = fNzSDD + 2;
886 const Int_t kMAXBIN=kNzBins*(fNySDD+2);
889 bins[0]=new AliBin[kMAXBIN];
890 bins[1]=new AliBin[kMAXBIN];
893 Int_t i, ndigits=digits->GetEntriesFast();
894 for (i=0; i<ndigits; i++) {
895 d=(AliITSdigitSDD*)digits->UncheckedAt(i);
896 Int_t y=d->GetCoord2()+1; //y
897 Int_t z=d->GetCoord1()+1; //z
898 Int_t q=d->GetSignal();
902 bins[0][y*kNzBins+z].SetQ(q);
903 bins[0][y*kNzBins+z].SetMask(1);
904 bins[0][y*kNzBins+z].SetIndex(i);
907 bins[1][y*kNzBins+z].SetQ(q);
908 bins[1][y*kNzBins+z].SetMask(1);
909 bins[1][y*kNzBins+z].SetIndex(i);
913 FindClustersSDD(bins, kMAXBIN, kNzBins, digits, clusters);
920 void AliITSclustererV2::FindClustersSDD(AliITSRawStream* input,
921 TClonesArray** clusters)
923 //------------------------------------------------------------
924 // Actual SDD cluster finder for raw data
925 //------------------------------------------------------------
926 Int_t nClustersSDD = 0;
927 Int_t kNzBins = fNzSDD + 2;
928 Int_t kMaxBin = kNzBins * (fNySDD+2);
929 AliBin *binsSDDInit = new AliBin[kMaxBin];
930 AliBin *binsSDD1 = new AliBin[kMaxBin];
931 AliBin *binsSDD2 = new AliBin[kMaxBin];
932 AliBin *bins[2] = {NULL, NULL};
934 // read raw data input stream
936 Bool_t next = input->Next();
937 if (!next || input->IsNewModule()) {
938 Int_t iModule = input->GetPrevModuleID();
940 // when all data from a module was read, search for clusters
942 clusters[iModule] = new TClonesArray("AliITSclusterV2");
944 FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]);
945 Int_t nClusters = clusters[iModule]->GetEntriesFast();
946 nClustersSDD += nClusters;
947 bins[0] = bins[1] = NULL;
953 memcpy(binsSDD1,binsSDDInit,sizeof(AliBin)*kMaxBin);
954 memcpy(binsSDD2,binsSDDInit,sizeof(AliBin)*kMaxBin);
957 // fill the current digit into the bins array
958 if(input->GetSignal()>=3) {
959 Int_t iz = input->GetCoord1()+1;
960 Int_t side = ((iz <= fNzSDD) ? 0 : 1);
962 Int_t index = (input->GetCoord2()+1) * kNzBins + iz;
963 bins[side][index].SetQ(input->GetSignal());
964 bins[side][index].SetMask(1);
965 bins[side][index].SetIndex(index);
971 delete[] binsSDDInit;
973 Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD);
978 void AliITSclustererV2::
979 FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
980 Ali1Dcluster* pos, Int_t np,
981 TClonesArray *clusters) {
982 //------------------------------------------------------------
983 // Actual SSD cluster finder
984 //------------------------------------------------------------
985 TClonesArray &cl=*clusters;
987 Float_t tanp=fTanP, tann=fTanN;
988 if (fI>fLastSSD1) {tann=fTanP; tanp=fTanN;}
989 Int_t idet=fNdet[fI];
992 Int_t negativepair[30000];
993 Int_t cnegative[3000];
995 Int_t positivepair[30000];
996 Int_t cpositive[3000];
998 for (Int_t i=0;i<3000;i++) {cnegative[i]=0; cused1[i]=0;}
999 for (Int_t i=0;i<3000;i++) {cpositive[i]=0; cused2[i]=0;}
1000 for (Int_t i=0;i<30000;i++){negativepair[i]=positivepair[i]=0;}
1001 static Short_t pairs[1000][1000];
1002 memset(pairs,0,sizeof(Short_t)*1000000);
1003 // Short_t ** pairs = new Short_t*[1000];
1004 // for (Int_t i=0; i<1000; i++) {
1005 // pairs[i] = new Short_t[1000];
1006 // memset(pairs[i],0,sizeof(Short_t)*1000);
1009 // find available pairs
1011 for (Int_t i=0; i<np; i++) {
1012 Float_t yp=pos[i].GetY()*fYpitchSSD;
1013 if (pos[i].GetQ()<3) continue;
1014 for (Int_t j=0; j<nn; j++) {
1015 if (neg[j].GetQ()<3) continue;
1016 Float_t yn=neg[j].GetY()*fYpitchSSD;
1017 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1018 Float_t yt=yn + tann*zt;
1019 zt-=fHlSSD; yt-=fHwSSD;
1020 if (TMath::Abs(yt)<fHwSSD+0.01)
1021 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
1022 negativepair[i*10+cnegative[i]] =j; //index
1023 positivepair[j*10+cpositive[j]] =i;
1024 cnegative[i]++; //counters
1031 for (Int_t i=0; i<np; i++) {
1032 Float_t yp=pos[i].GetY()*fYpitchSSD;
1033 if (pos[i].GetQ()<3) continue;
1034 for (Int_t j=0; j<nn; j++) {
1035 if (neg[j].GetQ()<3) continue;
1036 if (cpositive[j]&&cnegative[i]) continue;
1037 Float_t yn=neg[j].GetY()*fYpitchSSD;
1038 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1039 Float_t yt=yn + tann*zt;
1040 zt-=fHlSSD; yt-=fHwSSD;
1041 if (TMath::Abs(yt)<fHwSSD+0.1)
1042 if (TMath::Abs(zt)<fHlSSD+0.15) {
1043 if (cnegative[i]==0) pos[i].SetNd(100); // not available pair
1044 if (cpositive[j]==0) neg[j].SetNd(100); // not available pair
1045 negativepair[i*10+cnegative[i]] =j; //index
1046 positivepair[j*10+cpositive[j]] =i;
1047 cnegative[i]++; //counters
1061 for (Int_t ip=0;ip<np;ip++){
1062 Float_t ybest=1000,zbest=1000,qbest=0;
1064 // select gold clusters
1065 if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){
1066 Float_t yp=pos[ip].GetY()*fYpitchSSD;
1067 Int_t j = negativepair[10*ip];
1068 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1070 Float_t yn=neg[j].GetY()*fYpitchSSD;
1071 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1072 Float_t yt=yn + tann*zt;
1073 zt-=fHlSSD; yt-=fHwSSD;
1075 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1076 lp[0]=-(-ybest+fYshift[fI]);
1077 lp[1]= -zbest+fZshift[fI];
1078 lp[2]=0.0025*0.0025; //SigmaY2
1079 lp[3]=0.110*0.110; //SigmaZ2
1082 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1083 for (Int_t ilab=0;ilab<3;ilab++){
1084 milab[ilab] = pos[ip].GetLabel(ilab);
1085 milab[ilab+3] = neg[j].GetLabel(ilab);
1088 CheckLabels2(milab);
1089 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1090 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fI]};
1091 AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info);
1093 cl2->SetChargeRatio(ratio);
1096 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1105 for (Int_t ip=0;ip<np;ip++){
1106 Float_t ybest=1000,zbest=1000,qbest=0;
1109 // select "silber" cluster
1110 if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){
1111 Int_t in = negativepair[10*ip];
1112 Int_t ip2 = positivepair[10*in];
1113 if (ip2==ip) ip2 = positivepair[10*in+1];
1114 Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
1115 if (TMath::Abs(pcharge-neg[in].GetQ())<10){
1118 if (pairs[ip][in]==100){ //
1119 Float_t yp=pos[ip].GetY()*fYpitchSSD;
1120 Float_t yn=neg[in].GetY()*fYpitchSSD;
1121 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1122 Float_t yt=yn + tann*zt;
1123 zt-=fHlSSD; yt-=fHwSSD;
1124 ybest =yt; zbest=zt;
1125 qbest =pos[ip].GetQ();
1126 lp[0]=-(-ybest+fYshift[fI]);
1127 lp[1]= -zbest+fZshift[fI];
1128 lp[2]=0.0025*0.0025; //SigmaY2
1129 lp[3]=0.110*0.110; //SigmaZ2
1132 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1133 for (Int_t ilab=0;ilab<3;ilab++){
1134 milab[ilab] = pos[ip].GetLabel(ilab);
1135 milab[ilab+3] = neg[in].GetLabel(ilab);
1138 CheckLabels2(milab);
1139 ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ());
1140 milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
1141 Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fI]};
1142 AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info);
1144 cl2->SetChargeRatio(ratio);
1147 if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
1155 // if (!(cused1[ip2] || cused2[in])){ //
1156 if (pairs[ip2][in]==100){
1157 Float_t yp=pos[ip2].GetY()*fYpitchSSD;
1158 Float_t yn=neg[in].GetY()*fYpitchSSD;
1159 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1160 Float_t yt=yn + tann*zt;
1161 zt-=fHlSSD; yt-=fHwSSD;
1162 ybest =yt; zbest=zt;
1163 qbest =pos[ip2].GetQ();
1164 lp[0]=-(-ybest+fYshift[fI]);
1165 lp[1]= -zbest+fZshift[fI];
1166 lp[2]=0.0025*0.0025; //SigmaY2
1167 lp[3]=0.110*0.110; //SigmaZ2
1170 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1171 for (Int_t ilab=0;ilab<3;ilab++){
1172 milab[ilab] = pos[ip2].GetLabel(ilab);
1173 milab[ilab+3] = neg[in].GetLabel(ilab);
1176 CheckLabels2(milab);
1177 ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ());
1178 milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
1179 Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fI]};
1180 AliITSclusterV2 *cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info);
1182 cl2->SetChargeRatio(ratio);
1185 if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
1198 for (Int_t jn=0;jn<nn;jn++){
1199 if (cused2[jn]) continue;
1200 Float_t ybest=1000,zbest=1000,qbest=0;
1201 // select "silber" cluster
1202 if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){
1203 Int_t ip = positivepair[10*jn];
1204 Int_t jn2 = negativepair[10*ip];
1205 if (jn2==jn) jn2 = negativepair[10*ip+1];
1206 Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
1208 if (TMath::Abs(pcharge-pos[ip].GetQ())<10){
1211 // if (!(cused1[ip]||cused2[jn])){
1212 if (pairs[ip][jn]==100){
1213 Float_t yn=neg[jn].GetY()*fYpitchSSD;
1214 Float_t yp=pos[ip].GetY()*fYpitchSSD;
1215 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1216 Float_t yt=yn + tann*zt;
1217 zt-=fHlSSD; yt-=fHwSSD;
1218 ybest =yt; zbest=zt;
1219 qbest =neg[jn].GetQ();
1220 lp[0]=-(-ybest+fYshift[fI]);
1221 lp[1]= -zbest+fZshift[fI];
1222 lp[2]=0.0025*0.0025; //SigmaY2
1223 lp[3]=0.110*0.110; //SigmaZ2
1226 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1227 for (Int_t ilab=0;ilab<3;ilab++){
1228 milab[ilab] = pos[ip].GetLabel(ilab);
1229 milab[ilab+3] = neg[jn].GetLabel(ilab);
1232 CheckLabels2(milab);
1233 ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ());
1234 milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
1235 Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fI]};
1236 AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info);
1238 cl2->SetChargeRatio(ratio);
1241 if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
1248 // if (!(cused1[ip]||cused2[jn2])){
1249 if (pairs[ip][jn2]==100){
1250 Float_t yn=neg[jn2].GetY()*fYpitchSSD;
1251 Double_t yp=pos[ip].GetY()*fYpitchSSD;
1252 Double_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1253 Double_t yt=yn + tann*zt;
1254 zt-=fHlSSD; yt-=fHwSSD;
1255 ybest =yt; zbest=zt;
1256 qbest =neg[jn2].GetQ();
1257 lp[0]=-(-ybest+fYshift[fI]);
1258 lp[1]= -zbest+fZshift[fI];
1259 lp[2]=0.0025*0.0025; //SigmaY2
1260 lp[3]=0.110*0.110; //SigmaZ2
1263 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1264 for (Int_t ilab=0;ilab<3;ilab++){
1265 milab[ilab] = pos[ip].GetLabel(ilab);
1266 milab[ilab+3] = neg[jn2].GetLabel(ilab);
1269 CheckLabels2(milab);
1270 ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
1271 milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
1272 Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fI]};
1273 AliITSclusterV2* cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info);
1275 cl2->SetChargeRatio(ratio);
1278 if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
1290 for (Int_t ip=0;ip<np;ip++){
1291 Float_t ybest=1000,zbest=1000,qbest=0;
1295 if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){
1296 Float_t minchargediff =4.;
1298 for (Int_t di=0;di<cnegative[ip];di++){
1299 Int_t jc = negativepair[ip*10+di];
1300 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1301 if (TMath::Abs(chargedif)<minchargediff){
1303 minchargediff = TMath::Abs(chargedif);
1306 if (j<0) continue; // not proper cluster
1308 for (Int_t di=0;di<cnegative[ip];di++){
1309 Int_t jc = negativepair[ip*10+di];
1310 Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1311 if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1313 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 (pairs[ip][j]<100) continue;
1334 //almost gold clusters
1335 Float_t yp=pos[ip].GetY()*fYpitchSSD;
1336 Float_t yn=neg[j].GetY()*fYpitchSSD;
1337 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1338 Float_t yt=yn + tann*zt;
1339 zt-=fHlSSD; yt-=fHwSSD;
1341 qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1342 lp[0]=-(-ybest+fYshift[fI]);
1343 lp[1]= -zbest+fZshift[fI];
1344 lp[2]=0.0025*0.0025; //SigmaY2
1345 lp[3]=0.110*0.110; //SigmaZ2
1347 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1348 for (Int_t ilab=0;ilab<3;ilab++){
1349 milab[ilab] = pos[ip].GetLabel(ilab);
1350 milab[ilab+3] = neg[j].GetLabel(ilab);
1353 CheckLabels2(milab);
1354 ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1355 milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1356 Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fI]};
1357 AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info);
1359 cl2->SetChargeRatio(ratio);
1362 if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1373 for (Int_t i=0; i<np; i++) {
1374 Float_t ybest=1000,zbest=1000,qbest=0;
1375 Float_t yp=pos[i].GetY()*fYpitchSSD;
1376 if (pos[i].GetQ()<3) continue;
1377 for (Int_t j=0; j<nn; j++) {
1378 // for (Int_t di = 0;di<cpositive[i];di++){
1379 // Int_t j = negativepair[10*i+di];
1380 if (neg[j].GetQ()<3) continue;
1381 if (cused2[j]||cused1[i]) continue;
1382 if (pairs[i][j]>0 &&pairs[i][j]<100) continue;
1383 ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ());
1384 Float_t yn=neg[j].GetY()*fYpitchSSD;
1385 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1386 Float_t yt=yn + tann*zt;
1387 zt-=fHlSSD; yt-=fHwSSD;
1388 if (TMath::Abs(yt)<fHwSSD+0.01)
1389 if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
1391 qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
1392 lp[0]=-(-ybest+fYshift[fI]);
1393 lp[1]= -zbest+fZshift[fI];
1394 lp[2]=0.0025*0.0025; //SigmaY2
1395 lp[3]=0.110*0.110; //SigmaZ2
1398 for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1399 for (Int_t ilab=0;ilab<3;ilab++){
1400 milab[ilab] = pos[i].GetLabel(ilab);
1401 milab[ilab+3] = neg[j].GetLabel(ilab);
1404 CheckLabels2(milab);
1405 milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
1406 Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fI]};
1407 AliITSclusterV2 * cl2 = new (cl[ncl]) AliITSclusterV2(milab,lp,info);
1409 cl2->SetChargeRatio(ratio);
1410 cl2->SetType(100+cpositive[j]+cnegative[i]);
1413 if (pairs[i][j]<100){
1414 printf("problem:- %d\n", pairs[i][j]);
1416 if (cnegative[i]<2&&cpositive[j]<2){
1417 printf("problem:- %d\n", pairs[i][j]);
1424 // for (Int_t i=0; i<1000; i++) delete [] pairs[i];
1430 void AliITSclustererV2::
1431 FindClustersSSD(const TClonesArray *alldigits, TClonesArray *clusters) {
1432 //------------------------------------------------------------
1433 // Actual SSD cluster finder
1434 //------------------------------------------------------------
1435 Int_t smaxall=alldigits->GetEntriesFast();
1436 if (smaxall==0) return;
1437 TObjArray *digits = new TObjArray;
1438 for (Int_t i=0;i<smaxall; i++){
1439 AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i);
1440 if (d->GetSignal()<3) continue;
1443 Int_t smax = digits->GetEntriesFast();
1444 if (smax==0) return;
1446 const Int_t MAX=1000;
1448 Ali1Dcluster pos[MAX], neg[MAX];
1449 Float_t y=0., q=0., qmax=0.;
1450 Int_t lab[4]={-2,-2,-2,-2};
1452 AliITSdigitSSD *d=(AliITSdigitSSD*)digits->UncheckedAt(0);
1453 q += d->GetSignal();
1454 y += d->GetCoord2()*d->GetSignal();
1455 qmax=d->GetSignal();
1456 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
1457 Int_t curr=d->GetCoord2();
1458 Int_t flag=d->GetCoord1();
1460 Ali1Dcluster *c=neg;
1463 for (Int_t ilab=0;ilab<10;ilab++){
1466 milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2);
1468 for (Int_t s=1; s<smax; s++) {
1469 d=(AliITSdigitSSD*)digits->UncheckedAt(s);
1470 Int_t strip=d->GetCoord2();
1471 if ((strip-curr) > 1 || flag!=d->GetCoord1()) {
1475 CheckLabels2(milab);
1476 c[*n].SetLabels(milab);
1477 //Split suspiciously big cluster
1480 c[*n].SetY(y/q-0.3*nd);
1484 Error("FindClustersSSD","Too many 1D clusters !");
1487 c[*n].SetY(y/q-0.0*nd);
1492 Error("FindClustersSSD","Too many 1D clusters !");
1496 c[*n].SetY(y/q+0.3*nd);
1499 c[*n].SetLabels(milab);
1504 c[*n].SetY(y/q-0.25*nd);
1508 Error("FindClustersSSD","Too many 1D clusters !");
1511 c[*n].SetY(y/q+0.25*nd);
1514 c[*n].SetLabels(milab);
1518 Error("FindClustersSSD","Too many 1D clusters !");
1523 lab[0]=lab[1]=lab[2]=-2;
1525 for (Int_t ilab=0;ilab<10;ilab++){
1529 if (flag!=d->GetCoord1()) { n=&np; c=pos; }
1531 flag=d->GetCoord1();
1532 q += d->GetSignal();
1533 y += d->GetCoord2()*d->GetSignal();
1535 if (d->GetSignal()>qmax) {
1536 qmax=d->GetSignal();
1537 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
1539 for (Int_t ilab=0;ilab<10;ilab++) {
1540 if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab)));
1547 c[*n].SetLabels(lab);
1548 //Split suspiciously big cluster
1549 if (nd>4 && nd<25) {
1550 c[*n].SetY(y/q-0.25*nd);
1554 Error("FindClustersSSD","Too many 1D clusters !");
1557 c[*n].SetY(y/q+0.25*nd);
1560 c[*n].SetLabels(lab);
1564 Error("FindClustersSSD","Too many 1D clusters !");
1568 FindClustersSSD(neg, nn, pos, np, clusters);
1571 void AliITSclustererV2::FindClustersSSD(AliITSRawStream* input,
1572 TClonesArray** clusters)
1574 //------------------------------------------------------------
1575 // Actual SSD cluster finder for raw data
1576 //------------------------------------------------------------
1577 Int_t nClustersSSD = 0;
1578 const Int_t MAX = 1000;
1579 Ali1Dcluster clusters1D[2][MAX];
1580 Int_t nClusters[2] = {0, 0};
1581 Int_t lab[3]={-2,-2,-2};
1585 Int_t prevStrip = -1;
1586 Int_t prevFlag = -1;
1587 Int_t prevModule = -1;
1589 // read raw data input stream
1591 Bool_t next = input->Next();
1593 if(input->GetSignal()<3 && next) continue;
1594 // check if a new cluster starts
1595 Int_t strip = input->GetCoord2();
1596 Int_t flag = input->GetCoord1();
1597 if ((!next || (input->GetModuleID() != prevModule)||
1598 (strip-prevStrip > 1) || (flag != prevFlag)) &&
1600 if (nClusters[prevFlag] == MAX) {
1601 Error("FindClustersSSD", "Too many 1D clusters !");
1604 Ali1Dcluster& cluster = clusters1D[prevFlag][nClusters[prevFlag]++];
1607 cluster.SetNd(nDigits);
1608 cluster.SetLabels(lab);
1610 //Split suspiciously big cluster
1611 if (nDigits > 4&&nDigits < 25) {
1612 cluster.SetY(y/q - 0.25*nDigits);
1613 cluster.SetQ(0.5*q);
1614 if (nClusters[prevFlag] == MAX) {
1615 Error("FindClustersSSD", "Too many 1D clusters !");
1618 Ali1Dcluster& cluster2 = clusters1D[prevFlag][nClusters[prevFlag]++];
1619 cluster2.SetY(y/q + 0.25*nDigits);
1620 cluster2.SetQ(0.5*q);
1621 cluster2.SetNd(nDigits);
1622 cluster2.SetLabels(lab);
1628 if (!next || (input->GetModuleID() != prevModule)) {
1629 Int_t iModule = prevModule;
1631 // when all data from a module was read, search for clusters
1632 if (prevFlag >= 0) {
1633 clusters[iModule] = new TClonesArray("AliITSclusterV2");
1635 FindClustersSSD(&clusters1D[0][0], nClusters[0],
1636 &clusters1D[1][0], nClusters[1], clusters[iModule]);
1637 Int_t nClusters = clusters[iModule]->GetEntriesFast();
1638 nClustersSSD += nClusters;
1642 nClusters[0] = nClusters[1] = 0;
1647 // add digit to current cluster
1648 q += input->GetSignal();
1649 y += strip * input->GetSignal();
1653 prevModule = input->GetModuleID();
1657 Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD);
1662 #include "AliITSDetType.h"
1664 #include "AliITSsegmentationSPD.h"
1665 #include "AliITSClusterFinderSPD.h"
1667 #include "AliITSresponseSDD.h"
1668 #include "AliITSsegmentationSDD.h"
1669 #include "AliITSClusterFinderSDD.h"
1671 #include "AliITSsegmentationSSD.h"
1672 #include "AliITSClusterFinderSSD.h"
1675 void AliITSclustererV2::
1676 FindClustersSPD(const TClonesArray *digits, TClonesArray *clusters) {
1677 //------------------------------------------------------------
1678 // Actual SPD cluster finding based on AliITSClusterFinderSPD
1679 //------------------------------------------------------------
1680 static AliITS *its=(AliITS*)gAlice->GetModule("ITS");
1681 static TClonesArray *points=its->RecPoints();
1682 static AliITSsegmentationSPD *seg=
1683 (AliITSsegmentationSPD *)its->DetType(0)->GetSegmentationModel();
1684 static AliITSClusterFinderSPD cf(seg, (TClonesArray*)digits, points);
1686 cf.FindRawClusters(fI);
1687 RecPoints2Clusters(points, fI, clusters);
1688 its->ResetRecPoints();
1692 void AliITSclustererV2::
1693 FindClustersSDD(const TClonesArray *digits, TClonesArray *clusters) {
1694 //------------------------------------------------------------
1695 // Actual SDD cluster finding based on AliITSClusterFinderSDD
1696 //------------------------------------------------------------
1697 static AliITS *its=(AliITS*)gAlice->GetModule("ITS");
1698 static TClonesArray *points=its->RecPoints();
1699 static AliITSresponseSDD *resp=
1700 (AliITSresponseSDD *)its->DetType(1)->GetResponseModel();
1701 static AliITSsegmentationSDD *seg=
1702 (AliITSsegmentationSDD *)its->DetType(1)->GetSegmentationModel();
1703 static AliITSClusterFinderSDD
1704 cf(seg,resp,(TClonesArray*)digits,its->ClustersAddress(1));
1706 cf.FindRawClusters(fI);
1707 Int_t nc=points->GetEntriesFast();
1708 while (nc--) { //To be consistent with the SSD cluster charges
1709 AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(nc);
1710 p->SetQ(p->GetQ()/12.);
1712 RecPoints2Clusters(points, fI, clusters);
1713 its->ResetClusters(1);
1714 its->ResetRecPoints();
1718 void AliITSclustererV2::
1719 FindClustersSSD(const TClonesArray *digits, TClonesArray *clusters) {
1720 //------------------------------------------------------------
1721 // Actual SSD cluster finding based on AliITSClusterFinderSSD
1722 //------------------------------------------------------------
1723 static AliITS *its=(AliITS*)gAlice->GetModule("ITS");
1724 static TClonesArray *points=its->RecPoints();
1725 static AliITSsegmentationSSD *seg=
1726 (AliITSsegmentationSSD *)its->DetType(2)->GetSegmentationModel();
1727 static AliITSClusterFinderSSD cf(seg,(TClonesArray*)digits);
1729 cf.FindRawClusters(fI);
1730 RecPoints2Clusters(points, fI, clusters);
1731 its->ResetRecPoints();