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 "AliITSRawStreamSPD.h"
14 #include "AliITSRawStreamSDD.h"
15 #include "AliITSRawStreamSSD.h"
19 #include <TClonesArray.h>
20 #include "AliITSgeom.h"
21 #include "AliITSdigit.h"
23 ClassImp(AliITSclustererV2)
25 extern AliRun *gAlice;
27 AliITSclustererV2::AliITSclustererV2(const AliITSgeom *geom) {
28 //------------------------------------------------------------
29 // Standard constructor
30 //------------------------------------------------------------
31 AliITSgeom *g=(AliITSgeom*)geom;
36 Int_t mmax=geom->GetIndexMax();
38 Error("AliITSclustererV2","Too many ITS subdetectors !");
42 for (m=0; m<mmax; m++) {
43 Int_t lay,lad,det; g->GetModuleId(m,lay,lad,det);
44 Float_t x,y,z; g->GetTrans(lay,lad,det,x,y,z);
45 Double_t rot[9]; g->GetRotMatrix(lay,lad,det,rot);
46 fYshift[m] = x*rot[0] + y*rot[1];
47 fZshift[m] = (Double_t)z;
48 fNdet[m] = (lad-1)*g->GetNdetectors(lay) + (det-1);
50 fNModules = g->GetIndexMax();
53 fLastSPD1=g->GetModuleIndex(2,1,1)-1;
54 fNySPD=256; fNzSPD=160;
56 fZ1pitchSPD=0.0425; fZ2pitchSPD=0.0625;
57 fHwSPD=0.64; fHlSPD=3.48;
58 fYSPD[0]=0.5*fYpitchSPD;
59 for (m=1; m<fNySPD; m++) fYSPD[m]=fYSPD[m-1]+fYpitchSPD;
61 for (m=1; m<fNzSPD; m++) {
62 Double_t dz=fZ1pitchSPD;
63 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
64 m==127 || m==128) dz=fZ2pitchSPD;
65 fZSPD[m]=fZSPD[m-1]+dz;
67 for (m=0; m<fNzSPD; m++) {
68 Double_t dz=0.5*fZ1pitchSPD;
69 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
70 m==127 || m==128) dz=0.5*fZ2pitchSPD;
75 fNySDD=256; fNzSDD=256;
78 fHwSDD=3.5085; fHlSDD=3.7632;
82 fLastSSD1=g->GetModuleIndex(6,1,1)-1;
90 Int_t AliITSclustererV2::Digits2Clusters(TTree *dTree, TTree *cTree) {
91 //------------------------------------------------------------
92 // This function creates ITS clusters
93 //------------------------------------------------------------
97 Error("Digits2Clusters","Can't get the tree with digits !");
101 TClonesArray *digitsSPD=new TClonesArray("AliITSdigitSPD",3000);
102 dTree->SetBranchAddress("ITSDigitsSPD",&digitsSPD);
103 TClonesArray *digitsSDD=new TClonesArray("AliITSdigitSDD",3000);
104 dTree->SetBranchAddress("ITSDigitsSDD",&digitsSDD);
105 TClonesArray *digitsSSD=new TClonesArray("AliITSdigitSSD",3000);
106 dTree->SetBranchAddress("ITSDigitsSSD",&digitsSSD);
108 TClonesArray *clusters=new TClonesArray("AliITSclusterV2",1000);
109 TBranch *branch=cTree->GetBranch("Clusters");
110 if (!branch) cTree->Branch("Clusters",&clusters);
111 else branch->SetAddress(&clusters);
113 Int_t mmax=(Int_t)dTree->GetEntries();
115 for (fI=0; fI<mmax; fI++) {
118 if (digitsSPD->GetEntriesFast()!=0)
119 FindClustersSPD(digitsSPD,clusters);
120 else if(digitsSDD->GetEntriesFast()!=0)
121 FindClustersSDD(digitsSDD,clusters);
122 else if(digitsSSD->GetEntriesFast()!=0)
123 FindClustersSSD(digitsSSD,clusters);
125 ncl+=clusters->GetEntriesFast();
143 Info("Digits2Clusters","Number of found clusters : %d",ncl);
148 void AliITSclustererV2::Digits2Clusters(TFile *out) {
149 //------------------------------------------------------------
150 // This function creates ITS clusters from raw data
151 //------------------------------------------------------------
152 TDirectory *savedir=gDirectory;
153 if (!out->IsOpen()) {
154 Error("Digits2Clusters","Output file not open !");
160 sprintf(name,"TreeC_ITS_%d",fEvent);
161 TTree cTree(name,"ITS clusters V2");
162 TClonesArray *array=new TClonesArray("AliITSclusterV2",1000);
163 cTree.Branch("Clusters",&array);
166 TClonesArray** clusters = new TClonesArray*[fNModules];
167 // one TClonesArray per module
169 AliITSRawStreamSPD inputSPD;
170 FindClustersSPD(&inputSPD, clusters);
171 AliITSRawStreamSDD inputSDD;
172 FindClustersSDD(&inputSDD, clusters);
173 AliITSRawStreamSSD inputSSD;
174 FindClustersSSD(&inputSSD, clusters);
176 // write all clusters to the tree
178 for (Int_t iModule = 0; iModule < fNModules; iModule++) {
179 TClonesArray* array = clusters[iModule];
181 Error("Digits2Clusters", "data for module %d missing!", iModule);
182 array = new TClonesArray("AliITSclusterV2");
184 cTree.SetBranchAddress("Clusters", &array);
186 nClusters += array->GetEntriesFast();
193 Info("Digits2Clusters", "total number of found clusters in ITS: %d\n",
197 //**** Fast clusters *******************************
198 #include "TParticle.h"
201 #include "AliITSmodule.h"
202 #include "AliITSRecPoint.h"
203 #include "AliITSsimulationFastPoints.h"
204 #include "AliITSRecPoint.h"
206 static void CheckLabels(Int_t lab[3]) {
207 //------------------------------------------------------------
208 // Tries to find mother's labels
209 //------------------------------------------------------------
212 TParticle *part=(TParticle*)gAlice->Particle(label);
214 while (part->P() < 0.005) {
215 Int_t m=part->GetFirstMother();
217 Info("CheckLabels","Primary momentum: %f",part->P());
220 if (part->GetStatusCode()>0) {
221 Info("CheckLabels","Primary momentum: %f",part->P());
225 part=(TParticle*)gAlice->Particle(label);
227 if (lab[1]<0) lab[1]=label;
228 else if (lab[2]<0) lab[2]=label;
229 else ;//cerr<<"CheckLabels : No empty labels !\n";
233 void AliITSclustererV2::RecPoints2Clusters
234 (const TClonesArray *points, Int_t idx, TClonesArray *clusters) {
235 //------------------------------------------------------------
236 // Conversion AliITSRecPoint -> AliITSclusterV2 for the ITS
237 // subdetector indexed by idx
238 //------------------------------------------------------------
239 TClonesArray &cl=*clusters;
240 Int_t ncl=points->GetEntriesFast();
241 for (Int_t i=0; i<ncl; i++) {
242 AliITSRecPoint *p = (AliITSRecPoint *)points->UncheckedAt(i);
244 lp[0]=-p->GetX()-fYshift[idx]; if (idx<=fLastSPD1) lp[0]*=-1; //SPD1
245 lp[1]=p->GetZ()+fZshift[idx];
246 lp[2]=p->GetSigmaX2();
247 lp[3]=p->GetSigmaZ2();
250 lab[0]=p->GetLabel(0); lab[1]=p->GetLabel(1); lab[2]=p->GetLabel(2);
253 new (cl[i]) AliITSclusterV2(lab,lp);
257 Int_t AliITSclustererV2::Hits2Clusters(TTree *hTree, TTree *cTree) {
258 //------------------------------------------------------------
259 // This function creates ITS clusters
260 //------------------------------------------------------------
262 Error("Hits2Clusters","gAlice==0 !");
266 AliITS *its = (AliITS*)gAlice->GetModule("ITS");
268 Error("Hits2Clusters","Can't find the ITS !");
271 AliITSgeom *geom=its->GetITSgeom();
272 Int_t mmax=geom->GetIndexMax();
274 its->InitModules(-1,mmax);
275 its->FillModules(hTree,0);
277 TClonesArray *clusters=new TClonesArray("AliITSclusterV2",1000);
278 TBranch *branch=cTree->GetBranch("Clusters");
279 if (!branch) cTree->Branch("Clusters",&clusters);
280 else branch->SetAddress(&clusters);
282 static TClonesArray *points=its->RecPoints();
283 AliITSsimulationFastPoints sim;
285 for (Int_t m=0; m<mmax; m++) {
286 AliITSmodule *mod=its->GetModule(m);
287 sim.CreateFastRecPoints(mod,m,gRandom);
289 RecPoints2Clusters(points, m, clusters);
290 its->ResetRecPoints();
292 ncl+=clusters->GetEntriesFast();
297 Info("Hits2Clusters","Number of found fast clusters : %d",ncl);
306 //***********************************
310 void AliITSclustererV2::
311 FindCluster(Int_t k,Int_t maxz,AliBin *bins,Int_t &n,Int_t *idx) {
312 //------------------------------------------------------------
313 // returns an array of indices of digits belonging to the cluster
314 // (needed when the segmentation is not regular)
315 //------------------------------------------------------------
316 if (n<200) idx[n++]=bins[k].GetIndex();
319 if (bins[k-maxz].IsNotUsed()) FindCluster(k-maxz,maxz,bins,n,idx);
320 if (bins[k-1 ].IsNotUsed()) FindCluster(k-1 ,maxz,bins,n,idx);
321 if (bins[k+maxz].IsNotUsed()) FindCluster(k+maxz,maxz,bins,n,idx);
322 if (bins[k+1 ].IsNotUsed()) FindCluster(k+1 ,maxz,bins,n,idx);
324 if (bins[k-maxz-1].IsNotUsed()) FindCluster(k-maxz-1,maxz,bins,n,idx);
325 if (bins[k-maxz+1].IsNotUsed()) FindCluster(k-maxz+1,maxz,bins,n,idx);
326 if (bins[k+maxz-1].IsNotUsed()) FindCluster(k+maxz-1,maxz,bins,n,idx);
327 if (bins[k+maxz+1].IsNotUsed()) FindCluster(k+maxz+1,maxz,bins,n,idx);
331 void AliITSclustererV2::
332 FindClustersSPD(const TClonesArray *digits, TClonesArray *clusters) {
333 //------------------------------------------------------------
334 // Actual SPD cluster finder
335 //------------------------------------------------------------
336 Int_t kNzBins = fNzSPD + 2;
337 const Int_t kMAXBIN=kNzBins*(fNySPD+2);
339 Int_t ndigits=digits->GetEntriesFast();
340 AliBin *bins=new AliBin[kMAXBIN];
344 for (k=0; k<ndigits; k++) {
345 d=(AliITSdigitSPD*)digits->UncheckedAt(k);
346 Int_t i=d->GetCoord2()+1; //y
347 Int_t j=d->GetCoord1()+1;
348 bins[i*kNzBins+j].SetIndex(k);
349 bins[i*kNzBins+j].SetMask(1);
352 Int_t n=0; TClonesArray &cl=*clusters;
353 for (k=0; k<kMAXBIN; k++) {
354 if (!bins[k].IsNotUsed()) continue;
355 Int_t ni=0, idx[200];
356 FindCluster(k,kNzBins,bins,ni,idx);
358 Info("FindClustersSPD","Too big cluster !");
367 d=(AliITSdigitSPD*)digits->UncheckedAt(idx[0]);
368 Int_t ymin=d->GetCoord2(),ymax=ymin;
369 Int_t zmin=d->GetCoord1(),zmax=zmin;
370 Float_t y=0.,z=0.,q=0.;
371 for (Int_t l=0; l<ni; l++) {
372 d=(AliITSdigitSPD*)digits->UncheckedAt(idx[l]);
374 if (ymin > d->GetCoord2()) ymin=d->GetCoord2();
375 if (ymax < d->GetCoord2()) ymax=d->GetCoord2();
376 if (zmin > d->GetCoord1()) zmin=d->GetCoord1();
377 if (zmax < d->GetCoord1()) zmax=d->GetCoord1();
379 Int_t lab0=(d->GetTracks())[0];
383 } else if (lab[1]<0) {
384 if (lab0!=lab[0]) lab[1]=lab0;
385 } else if (lab[2]<0) {
387 if (lab0!=lab[1]) lab[2]=lab0;
390 Float_t qq=d->GetSignal();
391 y+=qq*fYSPD[d->GetCoord2()]; z+=qq*fZSPD[d->GetCoord1()]; q+=qq;
394 y-=fHwSPD; z-=fHlSPD;
397 lp[0]=-y-fYshift[fI]; if (fI<=fLastSPD1) lp[0]=-lp[0];
398 lp[1]= z+fZshift[fI];
399 lp[2]= fYpitchSPD*fYpitchSPD/12.;
400 lp[3]= fZ1pitchSPD*fZ1pitchSPD/12.;
402 lp[4]= (zmax-zmin+1)*100 + (ymax-ymin+1);
405 d=(AliITSdigitSPD*)digits->UncheckedAt(idx[0]);
406 new (cl[n]) AliITSclusterV2(lab,lp); n++;
412 void AliITSclustererV2::FindClustersSPD(AliITSRawStream* input,
413 TClonesArray** clusters)
415 //------------------------------------------------------------
416 // Actual SPD cluster finder for raw data
417 //------------------------------------------------------------
419 Int_t nClustersSPD = 0;
420 Int_t kNzBins = fNzSPD + 2;
421 Int_t kNyBins = fNySPD + 2;
422 Int_t kMaxBin = kNzBins * kNyBins;
425 // read raw data input stream
427 Bool_t next = input->Next();
428 if (!next || input->IsNewModule()) {
429 Int_t iModule = input->GetPrevModuleID();
431 // when all data from a module was read, search for clusters
433 clusters[iModule] = new TClonesArray("AliITSclusterV2");
436 for (Int_t iBin = 0; iBin < kMaxBin; iBin++) {
437 if (bins[iBin].IsUsed()) continue;
440 FindCluster(iBin, kNzBins, bins, nBins, idxBins);
442 Error("FindClustersSPD", "SPD: Too big cluster !\n");
450 // label[3] = iModule;
451 label[3] = fNdet[iModule];
453 Int_t ymin = (idxBins[0] / kNzBins) - 1;
455 Int_t zmin = (idxBins[0] % kNzBins) - 1;
460 for (Int_t idx = 0; idx < nBins; idx++) {
461 Int_t iy = (idxBins[idx] / kNzBins) - 1;
462 Int_t iz = (idxBins[idx] % kNzBins) - 1;
463 if (ymin > iy) ymin = iy;
464 if (ymax < iy) ymax = iy;
465 if (zmin > iz) zmin = iz;
466 if (zmax < iz) zmax = iz;
468 Float_t qBin = bins[idxBins[idx]].GetQ();
469 y += qBin * fYSPD[iy];
470 z += qBin * fZSPD[iz];
478 Float_t hit[5]; // y, z, sigma(y)^2, sigma(z)^2, charge
479 hit[0] = -y-fYshift[iModule];
480 if (iModule <= fLastSPD1) hit[0] = -hit[0];
481 hit[1] = z+fZshift[iModule];
482 hit[2] = fYpitchSPD*fYpitchSPD/12.;
483 hit[3] = fZ1pitchSPD*fZ1pitchSPD/12.;
485 hit[4] = (zmax-zmin+1)*100 + (ymax-ymin+1);
487 //CheckLabels(label);
488 new (clusters[iModule]->AddrAt(nClusters))
489 AliITSclusterV2(label, hit);
493 nClustersSPD += nClusters;
498 bins = new AliBin[kMaxBin];
501 // fill the current digit into the bins array
502 Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1);
503 bins[index].SetIndex(index);
504 bins[index].SetMask(1);
508 Info("FindClustersSPD", "found clusters in ITS SPD: %d", nClustersSPD);
512 Bool_t AliITSclustererV2::IsMaximum(Int_t k,Int_t max,const AliBin *bins) {
513 //------------------------------------------------------------
514 //is this a local maximum ?
515 //------------------------------------------------------------
516 UShort_t q=bins[k].GetQ();
517 if (q==1023) return kFALSE;
518 if (bins[k-max].GetQ() > q) return kFALSE;
519 if (bins[k-1 ].GetQ() > q) return kFALSE;
520 if (bins[k+max].GetQ() > q) return kFALSE;
521 if (bins[k+1 ].GetQ() > q) return kFALSE;
522 if (bins[k-max-1].GetQ() > q) return kFALSE;
523 if (bins[k+max-1].GetQ() > q) return kFALSE;
524 if (bins[k+max+1].GetQ() > q) return kFALSE;
525 if (bins[k-max+1].GetQ() > q) return kFALSE;
529 void AliITSclustererV2::
530 FindPeaks(Int_t k,Int_t max,AliBin *b,Int_t *idx,UInt_t *msk,Int_t& n) {
531 //------------------------------------------------------------
533 //------------------------------------------------------------
535 if (IsMaximum(k,max,b)) {
536 idx[n]=k; msk[n]=(2<<n);
540 if (b[k-max].GetMask()&1) FindPeaks(k-max,max,b,idx,msk,n);
541 if (b[k-1 ].GetMask()&1) FindPeaks(k-1 ,max,b,idx,msk,n);
542 if (b[k+max].GetMask()&1) FindPeaks(k+max,max,b,idx,msk,n);
543 if (b[k+1 ].GetMask()&1) FindPeaks(k+1 ,max,b,idx,msk,n);
546 void AliITSclustererV2::
547 MarkPeak(Int_t k, Int_t max, AliBin *bins, UInt_t m) {
548 //------------------------------------------------------------
550 //------------------------------------------------------------
551 UShort_t q=bins[k].GetQ();
553 bins[k].SetMask(bins[k].GetMask()|m);
555 if (bins[k-max].GetQ() <= q)
556 if ((bins[k-max].GetMask()&m) == 0) MarkPeak(k-max,max,bins,m);
557 if (bins[k-1 ].GetQ() <= q)
558 if ((bins[k-1 ].GetMask()&m) == 0) MarkPeak(k-1 ,max,bins,m);
559 if (bins[k+max].GetQ() <= q)
560 if ((bins[k+max].GetMask()&m) == 0) MarkPeak(k+max,max,bins,m);
561 if (bins[k+1 ].GetQ() <= q)
562 if ((bins[k+1 ].GetMask()&m) == 0) MarkPeak(k+1 ,max,bins,m);
565 void AliITSclustererV2::
566 MakeCluster(Int_t k,Int_t max,AliBin *bins,UInt_t m,AliITSclusterV2 &c) {
567 //------------------------------------------------------------
568 //make cluster using digits of this peak
569 //------------------------------------------------------------
570 Float_t q=(Float_t)bins[k].GetQ();
571 Int_t i=k/max, j=k-i*max;
574 c.SetY(c.GetY()+i*q);
575 c.SetZ(c.GetZ()+j*q);
576 c.SetSigmaY2(c.GetSigmaY2()+i*i*q);
577 c.SetSigmaZ2(c.GetSigmaZ2()+j*j*q);
579 bins[k].SetMask(0xFFFFFFFE);
581 if (bins[k-max].GetMask() == m) MakeCluster(k-max,max,bins,m,c);
582 if (bins[k-1 ].GetMask() == m) MakeCluster(k-1 ,max,bins,m,c);
583 if (bins[k+max].GetMask() == m) MakeCluster(k+max,max,bins,m,c);
584 if (bins[k+1 ].GetMask() == m) MakeCluster(k+1 ,max,bins,m,c);
587 void AliITSclustererV2::
588 FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins,
589 const TClonesArray *digits, TClonesArray *clusters) {
590 //------------------------------------------------------------
591 // Actual SDD cluster finder
592 //------------------------------------------------------------
593 Int_t ncl=0; TClonesArray &cl=*clusters;
594 for (Int_t s=0; s<2; s++)
595 for (Int_t i=0; i<nMaxBin; i++) {
596 if (bins[s][i].IsUsed()) continue;
597 Int_t idx[32]; UInt_t msk[32]; Int_t npeaks=0;
598 FindPeaks(i, nzBins, bins[s], idx, msk, npeaks);
600 if (npeaks>30) continue;
603 for (k=0; k<npeaks-1; k++){//mark adjacent peaks
604 if (idx[k] < 0) continue; //this peak is already removed
605 for (l=k+1; l<npeaks; l++) {
606 if (idx[l] < 0) continue; //this peak is already removed
607 Int_t ki=idx[k]/nzBins, kj=idx[k] - ki*nzBins;
608 Int_t li=idx[l]/nzBins, lj=idx[l] - li*nzBins;
609 Int_t di=TMath::Abs(ki - li);
610 Int_t dj=TMath::Abs(kj - lj);
611 if (di>1 || dj>1) continue;
612 if (bins[s][idx[k]].GetQ() > bins[s][idx[l]].GetQ()) {
623 for (k=0; k<npeaks; k++) {
624 MarkPeak(TMath::Abs(idx[k]), nzBins, bins[s], msk[k]);
627 for (k=0; k<npeaks; k++) {
628 if (idx[k] < 0) continue; //removed peak
630 MakeCluster(idx[k], nzBins, bins[s], msk[k], c);
632 //if (c.GetQ() < 200) continue; //noise cluster
635 Float_t s2 = c.GetSigmaY2()/c.GetQ() - c.GetY()*c.GetY();
636 Float_t w=par->GetPadPitchWidth(sec);
637 c.SetSigmaY2((s2 + 1./12.)*w*w);
639 c.SetSigmaY2(c.GetSigmaY2()*0.108);
640 if (sec<par->GetNInnerSector()) c.SetSigmaY2(c.GetSigmaY2()*2.07);
643 s2 = c.GetSigmaZ2()/c.GetQ() - c.GetZ()*c.GetZ();
645 c.SetSigmaZ2((s2 + 1./12.)*w*w);
647 c.SetSigmaZ2(c.GetSigmaZ2()*0.169);
648 if (sec<par->GetNInnerSector()) c.SetSigmaZ2(c.GetSigmaZ2()*1.77);
652 c.SetSigmaY2(0.0030*0.0030);
653 c.SetSigmaZ2(0.0020*0.0020);
654 c.SetDetectorIndex(fNdet[fI]);
656 Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ();
659 y=(y-0.5)*fYpitchSDD;
661 y-=fYoffSDD; //delay ?
664 z=(z-0.5)*fZpitchSDD;
672 c.SetQ(q/20.); //to be consistent with the SSD charges
675 AliBin *b=&bins[s][idx[k]];
676 AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
677 Int_t l0=(d->GetTracks())[0];
679 b=&bins[s][idx[k]-1];
681 d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
682 l0=(d->GetTracks())[0];
686 b=&bins[s][idx[k]+1];
688 d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
689 l0=(d->GetTracks())[0];
693 b=&bins[s][idx[k]-nzBins];
695 d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
696 l0=(d->GetTracks())[0];
700 b=&bins[s][idx[k]+nzBins];
702 d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
703 l0=(d->GetTracks())[0];
708 b=&bins[s][idx[k]+nzBins+1];
710 d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
711 l0=(d->GetTracks())[0];
715 b=&bins[s][idx[k]+nzBins-1];
717 d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
718 l0=(d->GetTracks())[0];
722 b=&bins[s][idx[k]-nzBins+1];
724 d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
725 l0=(d->GetTracks())[0];
729 b=&bins[s][idx[k]-nzBins-1];
731 d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
732 l0=(d->GetTracks())[0];
738 lab[0]=(d->GetTracks())[0];
739 lab[1]=(d->GetTracks())[1];
740 lab[2]=(d->GetTracks())[2];
742 c.SetLabel(lab[0],0);
743 c.SetLabel(lab[1],1);
744 c.SetLabel(lab[2],2);
748 new (cl[ncl]) AliITSclusterV2(c); ncl++;
753 void AliITSclustererV2::
754 FindClustersSDD(const TClonesArray *digits, TClonesArray *clusters) {
755 //------------------------------------------------------------
756 // Actual SDD cluster finder
757 //------------------------------------------------------------
758 Int_t kNzBins = fNzSDD + 2;
759 const Int_t kMAXBIN=kNzBins*(fNySDD+2);
762 bins[0]=new AliBin[kMAXBIN];
763 bins[1]=new AliBin[kMAXBIN];
766 Int_t i, ndigits=digits->GetEntriesFast();
767 for (i=0; i<ndigits; i++) {
768 d=(AliITSdigitSDD*)digits->UncheckedAt(i);
769 Int_t y=d->GetCoord2()+1; //y
770 Int_t z=d->GetCoord1()+1; //z
771 Int_t q=d->GetSignal();
773 bins[0][y*kNzBins+z].SetQ(q);
774 bins[0][y*kNzBins+z].SetMask(1);
775 bins[0][y*kNzBins+z].SetIndex(i);
778 bins[1][y*kNzBins+z].SetQ(q);
779 bins[1][y*kNzBins+z].SetMask(1);
780 bins[1][y*kNzBins+z].SetIndex(i);
784 FindClustersSDD(bins, kMAXBIN, kNzBins, digits, clusters);
790 void AliITSclustererV2::FindClustersSDD(AliITSRawStream* input,
791 TClonesArray** clusters)
793 //------------------------------------------------------------
794 // Actual SDD cluster finder for raw data
795 //------------------------------------------------------------
796 Int_t nClustersSDD = 0;
797 Int_t kNzBins = fNzSDD + 2;
798 Int_t kMaxBin = kNzBins * (fNySDD+2);
799 AliBin* bins[2] = {NULL, NULL};
801 // read raw data input stream
803 Bool_t next = input->Next();
804 if (!next || input->IsNewModule()) {
805 Int_t iModule = input->GetPrevModuleID();
807 // when all data from a module was read, search for clusters
809 clusters[iModule] = new TClonesArray("AliITSclusterV2");
811 FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]);
812 Int_t nClusters = clusters[iModule]->GetEntriesFast();
813 nClustersSDD += nClusters;
819 bins[0] = new AliBin[kMaxBin];
820 bins[1] = new AliBin[kMaxBin];
823 // fill the current digit into the bins array
824 Int_t iz = input->GetCoord1()+1;
825 Int_t side = ((iz <= fNzSDD) ? 0 : 1);
827 Int_t index = (input->GetCoord2()+1) * kNzBins + iz;
828 bins[side][index].SetQ(input->GetSignal());
829 bins[side][index].SetMask(1);
830 bins[side][index].SetIndex(index);
833 Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD);
836 void AliITSclustererV2::
837 FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
838 Ali1Dcluster* pos, Int_t np,
839 TClonesArray *clusters) {
840 //------------------------------------------------------------
841 // Actual SSD cluster finder
842 //------------------------------------------------------------
843 TClonesArray &cl=*clusters;
845 Int_t lab[4]={-2,-2,-2,-2};
846 Float_t tanp=fTanP, tann=fTanN;
847 if (fI>fLastSSD1) {tann=fTanP; tanp=fTanN;}
849 Int_t idet=fNdet[fI];
851 for (Int_t i=0; i<np; i++) {
852 //Float_t dq_min=1.e+33;
853 Float_t ybest=1000,zbest=1000,qbest=0;
854 Float_t yp=pos[i].GetY()*fYpitchSSD;
855 for (Int_t j=0; j<nn; j++) {
856 //if (pos[i].fTracks[0] != neg[j].fTracks[0]) continue;
857 Float_t yn=neg[j].GetY()*fYpitchSSD;
858 Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
859 Float_t yt=yn + tann*zt;
860 zt-=fHlSSD; yt-=fHwSSD;
861 if (TMath::Abs(yt)<fHwSSD+0.01)
862 if (TMath::Abs(zt)<fHlSSD+0.01) {
863 //if (TMath::Abs(pos[i].GetQ()-neg[j].GetQ())<dq_min) {
864 //dq_min=TMath::Abs(pos[i].GetQ()-neg[j].GetQ());
866 qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
868 lab[0]=pos[i].GetLabel(0);
869 lab[1]=pos[i].GetLabel(1);
870 lab[2]=neg[i].GetLabel(0);
871 lab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
873 lp[0]=-ybest-fYshift[fI];
874 lp[1]= zbest+fZshift[fI];
875 lp[2]=0.0025*0.0025; //SigmaY2
876 lp[3]=0.110*0.110; //SigmaZ2
877 if (pos[i].GetNd()+neg[j].GetNd() > 4) {
884 new (cl[ncl]) AliITSclusterV2(lab,lp); ncl++;
891 lp[0]=-ybest-fYshift[fI];
892 lp[1]= zbest+fZshift[fI];
893 lp[2]=0.002*0.002; //SigmaY2
894 lp[3]=0.080*0.080; //SigmaZ2
897 new (cl[ncl]) AliITSclusterV2(lab,lp); ncl++;
903 void AliITSclustererV2::
904 FindClustersSSD(const TClonesArray *digits, TClonesArray *clusters) {
905 //------------------------------------------------------------
906 // Actual SSD cluster finder
907 //------------------------------------------------------------
908 Int_t smax=digits->GetEntriesFast();
911 const Int_t MAX=1000;
913 Ali1Dcluster pos[MAX], neg[MAX];
914 Float_t y=0., q=0., qmax=0.;
915 Int_t lab[4]={-2,-2,-2,-2};
917 AliITSdigitSSD *d=(AliITSdigitSSD*)digits->UncheckedAt(0);
919 y += d->GetCoord2()*d->GetSignal();
921 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
922 Int_t curr=d->GetCoord2();
923 Int_t flag=d->GetCoord1();
927 for (Int_t s=1; s<smax; s++) {
928 d=(AliITSdigitSSD*)digits->UncheckedAt(s);
929 Int_t strip=d->GetCoord2();
930 if ((strip-curr) > 1 || flag!=d->GetCoord1()) {
934 c[*n].SetLabels(lab);
935 //Split suspiciously big cluster
937 c[*n].SetY(y/q-0.5*nd);
941 Error("FindClustersSSD","Too many 1D clusters !");
944 c[*n].SetY(y/q+0.5*nd);
947 c[*n].SetLabels(lab);
951 Error("FindClustersSSD","Too many 1D clusters !");
956 lab[0]=lab[1]=lab[2]=-2;
957 if (flag!=d->GetCoord1()) { n=&np; c=pos; }
961 y += d->GetCoord2()*d->GetSignal();
963 if (d->GetSignal()>qmax) {
965 lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
972 c[*n].SetLabels(lab);
973 //Split suspiciously big cluster
975 c[*n].SetY(y/q-0.5*nd);
979 Error("FindClustersSSD","Too many 1D clusters !");
982 c[*n].SetY(y/q+0.5*nd);
985 c[*n].SetLabels(lab);
989 Error("FindClustersSSD","Too many 1D clusters !");
993 FindClustersSSD(neg, nn, pos, np, clusters);
996 void AliITSclustererV2::FindClustersSSD(AliITSRawStream* input,
997 TClonesArray** clusters)
999 //------------------------------------------------------------
1000 // Actual SSD cluster finder for raw data
1001 //------------------------------------------------------------
1002 Int_t nClustersSSD = 0;
1003 const Int_t MAX = 1000;
1004 Ali1Dcluster clusters1D[2][MAX];
1005 Int_t nClusters[2] = {0, 0};
1009 Int_t prevStrip = -1;
1010 Int_t prevFlag = -1;
1012 // read raw data input stream
1014 Bool_t next = input->Next();
1016 // check if a new cluster starts
1017 Int_t strip = input->GetCoord2();
1018 Int_t flag = input->GetCoord1();
1019 if ((!next || input->IsNewModule() ||
1020 (strip-prevStrip > 1) || (flag != prevFlag)) &&
1022 if (nClusters[prevFlag] == MAX) {
1023 Error("FindClustersSSD", "Too many 1D clusters !");
1026 Ali1Dcluster& cluster = clusters1D[prevFlag][nClusters[prevFlag]++];
1029 cluster.SetNd(nDigits);
1031 //Split suspiciously big cluster
1033 cluster.SetY(y/q - 0.5*nDigits);
1034 cluster.SetQ(0.5*q);
1035 if (nClusters[prevFlag] == MAX) {
1036 Error("FindClustersSSD", "Too many 1D clusters !");
1039 Ali1Dcluster& cluster2 = clusters1D[prevFlag][nClusters[prevFlag]++];
1040 cluster2.SetY(y/q + 0.5*nDigits);
1041 cluster2.SetQ(0.5*q);
1042 cluster2.SetNd(nDigits);
1048 if (!next || input->IsNewModule()) {
1049 Int_t iModule = input->GetPrevModuleID();
1051 // when all data from a module was read, search for clusters
1052 if (prevFlag >= 0) {
1053 clusters[iModule] = new TClonesArray("AliITSclusterV2");
1055 FindClustersSSD(&clusters1D[0][0], nClusters[0],
1056 &clusters1D[1][0], nClusters[1], clusters[iModule]);
1057 Int_t nClusters = clusters[iModule]->GetEntriesFast();
1058 nClustersSSD += nClusters;
1062 nClusters[0] = nClusters[1] = 0;
1067 // add digit to current cluster
1068 q += input->GetSignal();
1069 y += strip * input->GetSignal();
1075 Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD);
1080 #include "AliITSDetType.h"
1082 #include "AliITSsegmentationSPD.h"
1083 #include "AliITSClusterFinderSPD.h"
1085 #include "AliITSresponseSDD.h"
1086 #include "AliITSsegmentationSDD.h"
1087 #include "AliITSClusterFinderSDD.h"
1089 #include "AliITSsegmentationSSD.h"
1090 #include "AliITSClusterFinderSSD.h"
1093 void AliITSclustererV2::
1094 FindClustersSPD(const TClonesArray *digits, TClonesArray *clusters) {
1095 //------------------------------------------------------------
1096 // Actual SPD cluster finding based on AliITSClusterFinderSPD
1097 //------------------------------------------------------------
1098 static AliITS *its=(AliITS*)gAlice->GetModule("ITS");
1099 static TClonesArray *points=its->RecPoints();
1100 static AliITSsegmentationSPD *seg=
1101 (AliITSsegmentationSPD *)its->DetType(0)->GetSegmentationModel();
1102 static AliITSClusterFinderSPD cf(seg, (TClonesArray*)digits, points);
1104 cf.FindRawClusters(fI);
1105 RecPoints2Clusters(points, fI, clusters);
1106 its->ResetRecPoints();
1110 void AliITSclustererV2::
1111 FindClustersSDD(const TClonesArray *digits, TClonesArray *clusters) {
1112 //------------------------------------------------------------
1113 // Actual SDD cluster finding based on AliITSClusterFinderSDD
1114 //------------------------------------------------------------
1115 static AliITS *its=(AliITS*)gAlice->GetModule("ITS");
1116 static TClonesArray *points=its->RecPoints();
1117 static AliITSresponseSDD *resp=
1118 (AliITSresponseSDD *)its->DetType(1)->GetResponseModel();
1119 static AliITSsegmentationSDD *seg=
1120 (AliITSsegmentationSDD *)its->DetType(1)->GetSegmentationModel();
1121 static AliITSClusterFinderSDD
1122 cf(seg,resp,(TClonesArray*)digits,its->ClustersAddress(1));
1124 cf.FindRawClusters(fI);
1125 Int_t nc=points->GetEntriesFast();
1126 while (nc--) { //To be consistent with the SSD cluster charges
1127 AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(nc);
1128 p->SetQ(p->GetQ/12.);
1130 RecPoints2Clusters(points, fI, clusters);
1131 its->ResetClusters(1);
1132 its->ResetRecPoints();
1136 void AliITSclustererV2::
1137 FindClustersSSD(const TClonesArray *digits, TClonesArray *clusters) {
1138 //------------------------------------------------------------
1139 // Actual SSD cluster finding based on AliITSClusterFinderSSD
1140 //------------------------------------------------------------
1141 static AliITS *its=(AliITS*)gAlice->GetModule("ITS");
1142 static TClonesArray *points=its->RecPoints();
1143 static AliITSsegmentationSSD *seg=
1144 (AliITSsegmentationSSD *)its->DetType(2)->GetSegmentationModel();
1145 static AliITSClusterFinderSSD cf(seg,(TClonesArray*)digits);
1147 cf.FindRawClusters(fI);
1148 RecPoints2Clusters(points, fI, clusters);
1149 its->ResetRecPoints();