1 /**************************************************************************
2 * Copyright(c) 1998-2003, 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 **************************************************************************/
15 ////////////////////////////////////////////////////////////////////////////
16 // Implementation of the ITS clusterer V2 class //
18 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch //
20 ///////////////////////////////////////////////////////////////////////////
24 #include "AliITSClusterFinderV2SDD.h"
25 #include "AliITSRecPoint.h"
26 #include "AliITSDetTypeRec.h"
27 #include "AliRawReader.h"
28 #include "AliITSRawStreamSDD.h"
30 #include <TClonesArray.h>
31 #include "AliITSdigitSDD.h"
33 ClassImp(AliITSClusterFinderV2SDD)
35 extern AliRun *gAlice;
37 AliITSClusterFinderV2SDD::AliITSClusterFinderV2SDD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp){
41 fNySDD=256; fNzSDD=256;
44 fHwSDD=3.5085; fHlSDD=3.7632;
52 void AliITSClusterFinderV2SDD::FindRawClusters(Int_t mod){
56 FindClustersSDD(fDigits);
60 void AliITSClusterFinderV2SDD::FindClustersSDD(TClonesArray *digits) {
61 //------------------------------------------------------------
62 // Actual SDD cluster finder
63 //------------------------------------------------------------
64 Int_t kNzBins = fNzSDD + 2;
65 const Int_t kMAXBIN=kNzBins*(fNySDD+2);
68 bins[0]=new AliBin[kMAXBIN];
69 bins[1]=new AliBin[kMAXBIN];
72 Int_t i, ndigits=digits->GetEntriesFast();
73 for (i=0; i<ndigits; i++) {
74 d=(AliITSdigitSDD*)digits->UncheckedAt(i);
75 Int_t y=d->GetCoord2()+1; //y
76 Int_t z=d->GetCoord1()+1; //z
77 Int_t q=d->GetSignal();
81 bins[0][y*kNzBins+z].SetQ(q);
82 bins[0][y*kNzBins+z].SetMask(1);
83 bins[0][y*kNzBins+z].SetIndex(i);
86 bins[1][y*kNzBins+z].SetQ(q);
87 bins[1][y*kNzBins+z].SetMask(1);
88 bins[1][y*kNzBins+z].SetIndex(i);
92 FindClustersSDD(bins, kMAXBIN, kNzBins, digits);
99 void AliITSClusterFinderV2SDD::
100 FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins,
101 TClonesArray *digits, TClonesArray *clusters) {
102 //------------------------------------------------------------
103 // Actual SDD cluster finder
104 //------------------------------------------------------------
106 TClonesArray &cl=*clusters;
107 for (Int_t s=0; s<2; s++)
108 for (Int_t i=0; i<nMaxBin; i++) {
109 if (bins[s][i].IsUsed()) continue;
110 Int_t idx[32]; UInt_t msk[32]; Int_t npeaks=0;
111 FindPeaks(i, nzBins, bins[s], idx, msk, npeaks);
113 if (npeaks>30) continue;
114 if (npeaks==0) continue;
117 for (k=0; k<npeaks-1; k++){//mark adjacent peaks
118 if (idx[k] < 0) continue; //this peak is already removed
119 for (l=k+1; l<npeaks; l++) {
120 if (idx[l] < 0) continue; //this peak is already removed
121 Int_t ki=idx[k]/nzBins, kj=idx[k] - ki*nzBins;
122 Int_t li=idx[l]/nzBins, lj=idx[l] - li*nzBins;
123 Int_t di=TMath::Abs(ki - li);
124 Int_t dj=TMath::Abs(kj - lj);
125 if (di>1 || dj>1) continue;
126 if (bins[s][idx[k]].GetQ() > bins[s][idx[l]].GetQ()) {
137 for (k=0; k<npeaks; k++) {
138 MarkPeak(TMath::Abs(idx[k]), nzBins, bins[s], msk[k]);
141 for (k=0; k<npeaks; k++) {
142 if (idx[k] < 0) continue; //removed peak
143 AliITSRecPoint c(fDetTypeRec->GetITSgeom());
144 MakeCluster(idx[k], nzBins, bins[s], msk[k], c);
147 for (Int_t ilab=0;ilab<10;ilab++){
150 Int_t maxi=0,mini=0,maxj=0,minj=0;
151 //AliBin *bmax=&bins[s][idx[k]];
152 //Float_t max = TMath::Max(TMath::Abs(bmax->GetQ())/5.,3.);
154 for (Int_t di=-2; di<=2;di++)
155 for (Int_t dj=-3;dj<=3;dj++){
156 Int_t index = idx[k]+di+dj*nzBins;
157 if (index<0) continue;
158 if (index>=nMaxBin) continue;
159 AliBin *b=&bins[s][index];
160 if (TMath::Abs(b->GetQ())>max){
161 if (di>maxi) maxi=di;
162 if (di<mini) mini=di;
163 if (dj>maxj) maxj=dj;
164 if (dj<minj) minj=dj;
167 if (TMath::Abs(di)<2&&TMath::Abs(dj)<2){
168 AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
169 for (Int_t itrack=0;itrack<10;itrack++){
170 Int_t track = (d->GetTracks())[itrack];
172 AddLabel(milab, track);
181 Float_t s2 = c.GetSigmaY2()/c.GetQ() - c.GetY()*c.GetY();
182 Float_t w=par->GetPadPitchWidth(sec);
185 c.SetSigmaY2(c.GetSigmaY2()*0.108);
186 if (sec<par->GetNInnerSector()) c.SetSigmaY2(c.GetSigmaY2()*2.07);
188 s2 = c.GetSigmaZ2()/c.GetQ() - c.GetZ()*c.GetZ();
193 c.SetSigmaZ2(c.GetSigmaZ2()*0.169);
194 if (sec<par->GetNInnerSector()) c.SetSigmaZ2(c.GetSigmaZ2()*1.77);
198 c.SetSigmaY2(0.0030*0.0030);
199 c.SetSigmaZ2(0.0020*0.0020);
200 c.SetDetectorIndex(fNdet[fModule]);
202 Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ();
205 //Float_t s2 = c.GetSigmaY2()/c.GetQ() - y*y;
207 //s2 = c.GetSigmaZ2()/c.GetQ() - z*z;
210 y=(y-0.5)*fYpitchSDD;
212 y-=fYoffSDD; //delay ?
215 z=(z-0.5)*fZpitchSDD;
218 y=-(-y+fYshift[fModule]);
219 z= -z+fZshift[fModule];
222 c.SetYZ(fModule,y,z);
223 c.SetNy(maxj-minj+1);
224 c.SetNz(maxi-mini+1);
226 c.SetQ(q/12.7); //to be consistent with the SSD charges
228 if (c.GetQ() < 20.) continue; //noise cluster
231 // AliBin *b=&bins[s][idx[k]];
232 // AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
235 //lab[0]=(d->GetTracks())[0];
236 //lab[1]=(d->GetTracks())[1];
237 //lab[2]=(d->GetTracks())[2];
240 c.SetLabel(milab[0],0);
241 c.SetLabel(milab[1],1);
242 c.SetLabel(milab[2],2);
243 c.SetLayer(fNlayer[fModule]);
246 if(clusters) new (cl[ncl]) AliITSRecPoint(c);
248 fDetTypeRec->AddRecPoint(c);
257 void AliITSClusterFinderV2SDD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){
258 //------------------------------------------------------------
259 // This function creates ITS clusters from raw data
260 //------------------------------------------------------------
262 AliITSRawStreamSDD inputSDD(rawReader);
263 FindClustersSDD(&inputSDD,clusters);
267 void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input,
268 TClonesArray** clusters)
270 //------------------------------------------------------------
271 // Actual SDD cluster finder for raw data
272 //------------------------------------------------------------
273 Int_t nClustersSDD = 0;
274 Int_t kNzBins = fNzSDD + 2;
275 Int_t kMaxBin = kNzBins * (fNySDD+2);
276 AliBin *binsSDDInit = new AliBin[kMaxBin];
277 AliBin *binsSDD1 = new AliBin[kMaxBin];
278 AliBin *binsSDD2 = new AliBin[kMaxBin];
279 AliBin* bins[2] = {NULL, NULL};
281 // read raw data input stream
283 Bool_t next = input->Next();
284 if (!next || input->IsNewModule()) {
285 Int_t iModule = input->GetPrevModuleID();
287 // when all data from a module was read, search for clusters
289 clusters[iModule] = new TClonesArray("AliITSRecPoint");
291 FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]);
292 Int_t nClusters = clusters[iModule]->GetEntriesFast();
293 nClustersSDD += nClusters;
294 bins[0] = bins[1] = NULL;
301 memcpy(binsSDD1,binsSDDInit,sizeof(AliBin)*kMaxBin);
302 memcpy(binsSDD2,binsSDDInit,sizeof(AliBin)*kMaxBin);
306 // fill the current digit into the bins array
307 if(input->GetSignal()>=3) {
308 Int_t iz = input->GetCoord1()+1;
309 Int_t side = ((iz <= fNzSDD) ? 0 : 1);
311 Int_t index = (input->GetCoord2()+1) * kNzBins + iz;
312 bins[side][index].SetQ(input->GetSignal());
313 bins[side][index].SetMask(1);
314 bins[side][index].SetIndex(index);
319 delete[] binsSDDInit;
321 Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD);