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 ///////////////////////////////////////////////////////////////////////////
25 #include "AliITSClusterFinderV2SDD.h"
26 #include "AliITSclusterV2.h"
27 #include "AliRawReader.h"
28 #include "AliITSRawStreamSDD.h"
30 #include <TClonesArray.h>
32 #include "AliITSgeom.h"
33 #include "AliITSdigitSDD.h"
35 ClassImp(AliITSClusterFinderV2SDD)
37 extern AliRun *gAlice;
39 AliITSClusterFinderV2SDD::AliITSClusterFinderV2SDD():AliITSClusterFinderV2(){
43 fNySDD=256; fNzSDD=256;
46 fHwSDD=3.5085; fHlSDD=3.7632;
54 void AliITSClusterFinderV2SDD::FindRawClusters(Int_t mod){
58 FindClustersSDD(fDigits);
62 void AliITSClusterFinderV2SDD::FindClustersSDD(TClonesArray *digits) {
63 //------------------------------------------------------------
64 // Actual SDD cluster finder
65 //------------------------------------------------------------
66 Int_t kNzBins = fNzSDD + 2;
67 const Int_t kMAXBIN=kNzBins*(fNySDD+2);
70 bins[0]=new AliBin[kMAXBIN];
71 bins[1]=new AliBin[kMAXBIN];
74 Int_t i, ndigits=digits->GetEntriesFast();
75 for (i=0; i<ndigits; i++) {
76 d=(AliITSdigitSDD*)digits->UncheckedAt(i);
77 Int_t y=d->GetCoord2()+1; //y
78 Int_t z=d->GetCoord1()+1; //z
79 Int_t q=d->GetSignal();
83 bins[0][y*kNzBins+z].SetQ(q);
84 bins[0][y*kNzBins+z].SetMask(1);
85 bins[0][y*kNzBins+z].SetIndex(i);
88 bins[1][y*kNzBins+z].SetQ(q);
89 bins[1][y*kNzBins+z].SetMask(1);
90 bins[1][y*kNzBins+z].SetIndex(i);
94 FindClustersSDD(bins, kMAXBIN, kNzBins, digits);
101 void AliITSClusterFinderV2SDD::
102 FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins,
103 TClonesArray *digits, TClonesArray *clusters) {
104 //------------------------------------------------------------
105 // Actual SDD cluster finder
106 //------------------------------------------------------------
108 TClonesArray &cl=*clusters;
109 for (Int_t s=0; s<2; s++)
110 for (Int_t i=0; i<nMaxBin; i++) {
111 if (bins[s][i].IsUsed()) continue;
112 Int_t idx[32]; UInt_t msk[32]; Int_t npeaks=0;
113 FindPeaks(i, nzBins, bins[s], idx, msk, npeaks);
115 if (npeaks>30) continue;
116 if (npeaks==0) continue;
119 for (k=0; k<npeaks-1; k++){//mark adjacent peaks
120 if (idx[k] < 0) continue; //this peak is already removed
121 for (l=k+1; l<npeaks; l++) {
122 if (idx[l] < 0) continue; //this peak is already removed
123 Int_t ki=idx[k]/nzBins, kj=idx[k] - ki*nzBins;
124 Int_t li=idx[l]/nzBins, lj=idx[l] - li*nzBins;
125 Int_t di=TMath::Abs(ki - li);
126 Int_t dj=TMath::Abs(kj - lj);
127 if (di>1 || dj>1) continue;
128 if (bins[s][idx[k]].GetQ() > bins[s][idx[l]].GetQ()) {
139 for (k=0; k<npeaks; k++) {
140 MarkPeak(TMath::Abs(idx[k]), nzBins, bins[s], msk[k]);
143 for (k=0; k<npeaks; k++) {
144 if (idx[k] < 0) continue; //removed peak
146 MakeCluster(idx[k], nzBins, bins[s], msk[k], c);
149 for (Int_t ilab=0;ilab<10;ilab++){
152 Int_t maxi=0,mini=0,maxj=0,minj=0;
153 //AliBin *bmax=&bins[s][idx[k]];
154 //Float_t max = TMath::Max(TMath::Abs(bmax->GetQ())/5.,3.);
156 for (Int_t di=-2; di<=2;di++)
157 for (Int_t dj=-3;dj<=3;dj++){
158 Int_t index = idx[k]+di+dj*nzBins;
159 if (index<0) continue;
160 if (index>=nMaxBin) continue;
161 AliBin *b=&bins[s][index];
162 if (TMath::Abs(b->GetQ())>max){
163 if (di>maxi) maxi=di;
164 if (di<mini) mini=di;
165 if (dj>maxj) maxj=dj;
166 if (dj<minj) minj=dj;
169 if (TMath::Abs(di)<2&&TMath::Abs(dj)<2){
170 AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
171 for (Int_t itrack=0;itrack<10;itrack++){
172 Int_t track = (d->GetTracks())[itrack];
174 AddLabel(milab, track);
183 Float_t s2 = c.GetSigmaY2()/c.GetQ() - c.GetY()*c.GetY();
184 Float_t w=par->GetPadPitchWidth(sec);
187 c.SetSigmaY2(c.GetSigmaY2()*0.108);
188 if (sec<par->GetNInnerSector()) c.SetSigmaY2(c.GetSigmaY2()*2.07);
190 s2 = c.GetSigmaZ2()/c.GetQ() - c.GetZ()*c.GetZ();
195 c.SetSigmaZ2(c.GetSigmaZ2()*0.169);
196 if (sec<par->GetNInnerSector()) c.SetSigmaZ2(c.GetSigmaZ2()*1.77);
200 c.SetSigmaY2(0.0030*0.0030);
201 c.SetSigmaZ2(0.0020*0.0020);
202 c.SetDetectorIndex(fNdet[fModule]);
204 Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ();
207 //Float_t s2 = c.GetSigmaY2()/c.GetQ() - y*y;
209 //s2 = c.GetSigmaZ2()/c.GetQ() - z*z;
212 y=(y-0.5)*fYpitchSDD;
214 y-=fYoffSDD; //delay ?
217 z=(z-0.5)*fZpitchSDD;
220 y=-(-y+fYshift[fModule]);
221 z= -z+fZshift[fModule];
224 c.SetNy(maxj-minj+1);
225 c.SetNz(maxi-mini+1);
227 c.SetQ(q/12.7); //to be consistent with the SSD charges
229 if (c.GetQ() < 20.) continue; //noise cluster
232 // AliBin *b=&bins[s][idx[k]];
233 // AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
236 //lab[0]=(d->GetTracks())[0];
237 //lab[1]=(d->GetTracks())[1];
238 //lab[2]=(d->GetTracks())[2];
241 c.SetLabel(milab[0],0);
242 c.SetLabel(milab[1],1);
243 c.SetLabel(milab[2],2);
244 c.SetLayer(fNlayer[fModule]);
247 if(clusters) new (cl[ncl]) AliITSclusterV2(c);
249 fITS->AddClusterV2(c);
258 void AliITSClusterFinderV2SDD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){
259 //------------------------------------------------------------
260 // This function creates ITS clusters from raw data
261 //------------------------------------------------------------
263 AliITSRawStreamSDD inputSDD(rawReader);
264 FindClustersSDD(&inputSDD,clusters);
268 void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input,
269 TClonesArray** clusters)
271 //------------------------------------------------------------
272 // Actual SDD cluster finder for raw data
273 //------------------------------------------------------------
274 Int_t nClustersSDD = 0;
275 Int_t kNzBins = fNzSDD + 2;
276 Int_t kMaxBin = kNzBins * (fNySDD+2);
277 AliBin* bins[2] = {NULL, NULL};
279 // read raw data input stream
281 Bool_t next = input->Next();
282 if (!next || input->IsNewModule()) {
283 Int_t iModule = input->GetPrevModuleID();
285 // when all data from a module was read, search for clusters
287 clusters[iModule] = new TClonesArray("AliITSclusterV2");
289 FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]);
290 Int_t nClusters = clusters[iModule]->GetEntriesFast();
291 nClustersSDD += nClusters;
297 bins[0] = new AliBin[kMaxBin];
298 bins[1] = new AliBin[kMaxBin];
301 // fill the current digit into the bins array
302 if(input->GetSignal()>=3) {
303 Int_t iz = input->GetCoord1()+1;
304 Int_t side = ((iz <= fNzSDD) ? 0 : 1);
306 Int_t index = (input->GetCoord2()+1) * kNzBins + iz;
307 bins[side][index].SetQ(input->GetSignal());
308 bins[side][index].SetMask(1);
309 bins[side][index].SetIndex(index);
313 Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD);