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"
29 #include "AliITSCalibrationSDD.h"
30 #include "AliITSDetTypeRec.h"
31 #include "AliITSsegmentationSDD.h"
32 #include <TClonesArray.h>
33 #include "AliITSdigitSDD.h"
34 #include "AliAlignObj.h"
36 ClassImp(AliITSClusterFinderV2SDD)
38 AliITSClusterFinderV2SDD::AliITSClusterFinderV2SDD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp),
53 void AliITSClusterFinderV2SDD::FindRawClusters(Int_t mod){
57 FindClustersSDD(fDigits);
61 void AliITSClusterFinderV2SDD::FindClustersSDD(TClonesArray *digits) {
62 //------------------------------------------------------------
63 // Actual SDD cluster finder
64 //------------------------------------------------------------
65 Int_t kNzBins = fNzSDD + 2;
66 const Int_t kMAXBIN=kNzBins*(fNySDD+2);
69 bins[0]=new AliBin[kMAXBIN];
70 bins[1]=new AliBin[kMAXBIN];
73 Int_t i, ndigits=digits->GetEntriesFast();
74 for (i=0; i<ndigits; i++) {
75 d=(AliITSdigitSDD*)digits->UncheckedAt(i);
76 Int_t y=d->GetCoord2()+1; //y
77 Int_t z=d->GetCoord1()+1; //z
78 Int_t q=d->GetSignal();
82 bins[0][y*kNzBins+z].SetQ(q);
83 bins[0][y*kNzBins+z].SetMask(1);
84 bins[0][y*kNzBins+z].SetIndex(i);
87 bins[1][y*kNzBins+z].SetQ(q);
88 bins[1][y*kNzBins+z].SetMask(1);
89 bins[1][y*kNzBins+z].SetIndex(i);
93 FindClustersSDD(bins, kMAXBIN, kNzBins, digits);
100 void AliITSClusterFinderV2SDD::
101 FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins,
102 TClonesArray *digits, TClonesArray *clusters) {
103 //------------------------------------------------------------
104 // Actual SDD cluster finder
105 //------------------------------------------------------------
107 TClonesArray &cl=*clusters;
108 for (Int_t s=0; s<2; s++)
109 for (Int_t i=0; i<nMaxBin; i++) {
110 if (bins[s][i].IsUsed()) continue;
111 Int_t idx[32]; UInt_t msk[32]; Int_t npeaks=0;
112 FindPeaks(i, nzBins, bins[s], idx, msk, npeaks);
114 if (npeaks>30) continue;
115 if (npeaks==0) continue;
118 for (k=0; k<npeaks-1; k++){//mark adjacent peaks
119 if (idx[k] < 0) continue; //this peak is already removed
120 for (l=k+1; l<npeaks; l++) {
121 if (idx[l] < 0) continue; //this peak is already removed
122 Int_t ki=idx[k]/nzBins, kj=idx[k] - ki*nzBins;
123 Int_t li=idx[l]/nzBins, lj=idx[l] - li*nzBins;
124 Int_t di=TMath::Abs(ki - li);
125 Int_t dj=TMath::Abs(kj - lj);
126 if (di>1 || dj>1) continue;
127 if (bins[s][idx[k]].GetQ() > bins[s][idx[l]].GetQ()) {
138 for (k=0; k<npeaks; k++) {
139 MarkPeak(TMath::Abs(idx[k]), nzBins, bins[s], msk[k]);
142 for (k=0; k<npeaks; k++) {
143 if (idx[k] < 0) continue; //removed peak
145 MakeCluster(idx[k], nzBins, bins[s], msk[k], c);
148 for (Int_t ilab=0;ilab<10;ilab++){
151 Int_t maxi=0,mini=0,maxj=0,minj=0;
152 //AliBin *bmax=&bins[s][idx[k]];
153 //Float_t max = TMath::Max(TMath::Abs(bmax->GetQ())/5.,3.);
155 for (Int_t di=-2; di<=2;di++)
156 for (Int_t dj=-3;dj<=3;dj++){
157 Int_t index = idx[k]+di+dj*nzBins;
158 if (index<0) continue;
159 if (index>=nMaxBin) continue;
160 AliBin *b=&bins[s][index];
161 if (TMath::Abs(b->GetQ())>max){
162 if (di>maxi) maxi=di;
163 if (di<mini) mini=di;
164 if (dj>maxj) maxj=dj;
165 if (dj<minj) minj=dj;
168 if (TMath::Abs(di)<2&&TMath::Abs(dj)<2){
169 AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
170 for (Int_t itrack=0;itrack<10;itrack++){
171 Int_t track = (d->GetTracks())[itrack];
173 AddLabel(milab, track);
182 Float_t s2 = c.GetSigmaY2()/c.GetQ() - c.GetY()*c.GetY();
183 Float_t w=par->GetPadPitchWidth(sec);
186 c.SetSigmaY2(c.GetSigmaY2()*0.108);
187 if (sec<par->GetNInnerSector()) c.SetSigmaY2(c.GetSigmaY2()*2.07);
189 s2 = c.GetSigmaZ2()/c.GetQ() - c.GetZ()*c.GetZ();
194 c.SetSigmaZ2(c.GetSigmaZ2()*0.169);
195 if (sec<par->GetNInnerSector()) c.SetSigmaZ2(c.GetSigmaZ2()*1.77);
199 c.SetSigmaY2(0.0030*0.0030);
200 c.SetSigmaZ2(0.0020*0.0020);
201 c.SetDetectorIndex(fNdet[fModule]);
203 Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ();
206 //Float_t s2 = c.GetSigmaY2()/c.GetQ() - y*y;
208 //s2 = c.GetSigmaZ2()/c.GetQ() - z*z;
211 y=(y-0.5)*fYpitchSDD;
213 y-=fYoffSDD; //delay ?
216 z=(z-0.5)*fZpitchSDD;
219 y=-(-y+fYshift[fModule]);
220 z= -z+fZshift[fModule];
223 CorrectPosition(z,y);
226 c.SetNy(maxj-minj+1);
227 c.SetNz(maxi-mini+1);
229 c.SetQ(q/12.7); //to be consistent with the SSD charges
231 if (c.GetQ() < 20.) continue; //noise cluster
234 // AliBin *b=&bins[s][idx[k]];
235 // AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
238 //lab[0]=(d->GetTracks())[0];
239 //lab[1]=(d->GetTracks())[1];
240 //lab[2]=(d->GetTracks())[2];
243 c.SetLabel(milab[0],0);
244 c.SetLabel(milab[1],1);
245 c.SetLabel(milab[2],2);
246 c.SetLayer(fNlayer[fModule]);
247 UShort_t id=AliAlignObj::LayerToVolUID(fNlayer[fModule]+AliAlignObj::kSPD1,fNdet[fModule]);
251 if(clusters) new (cl[ncl]) AliITSRecPoint(c);
253 fDetTypeRec->AddRecPoint(c);
262 void AliITSClusterFinderV2SDD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){
263 //------------------------------------------------------------
264 // This function creates ITS clusters from raw data
265 //------------------------------------------------------------
267 AliITSRawStreamSDD inputSDD(rawReader);
268 FindClustersSDD(&inputSDD,clusters);
272 void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input,
273 TClonesArray** clusters)
275 //------------------------------------------------------------
276 // Actual SDD cluster finder for raw data
277 //------------------------------------------------------------
278 Int_t nClustersSDD = 0;
279 Int_t kNzBins = fNzSDD + 2;
280 Int_t kMaxBin = kNzBins * (fNySDD+2);
281 AliBin *binsSDDInit = new AliBin[kMaxBin];
282 AliBin *binsSDD1 = new AliBin[kMaxBin];
283 AliBin *binsSDD2 = new AliBin[kMaxBin];
284 AliBin* bins[2] = {NULL, NULL};
286 // read raw data input stream
288 Bool_t next = input->Next();
289 if (!next || input->IsNewModule()) {
290 Int_t iModule = input->GetPrevModuleID();
292 // when all data from a module was read, search for clusters
294 clusters[iModule] = new TClonesArray("AliITSRecPoint");
296 FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]);
297 Int_t nClusters = clusters[iModule]->GetEntriesFast();
298 nClustersSDD += nClusters;
299 bins[0] = bins[1] = NULL;
306 memcpy(binsSDD1,binsSDDInit,sizeof(AliBin)*kMaxBin);
307 memcpy(binsSDD2,binsSDDInit,sizeof(AliBin)*kMaxBin);
311 // fill the current digit into the bins array
312 if(input->GetSignal()>=3) {
313 Int_t iz = input->GetCoord1()+1;
314 Int_t side = ((iz <= fNzSDD) ? 0 : 1);
316 Int_t index = (input->GetCoord2()+1) * kNzBins + iz;
317 bins[side][index].SetQ(input->GetSignal());
318 bins[side][index].SetMask(1);
319 bins[side][index].SetIndex(index);
324 delete[] binsSDDInit;
326 Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD);
331 //_________________________________________________________________________
332 void AliITSClusterFinderV2SDD::CorrectPosition(Float_t &z, Float_t&y){
334 //correction of coordinates using the maps stored in the DB
336 AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
337 static const Int_t nbint = cal->GetMapTimeNBin();
338 static const Int_t nbina = cal->Chips()*cal->Channels();
339 Float_t stepa = (GetSeg()->Dpz(0))/10000.; //anode pitch in cm
340 Float_t stept = (GetSeg()->Dx()/cal->GetMapTimeNBin()/2.)/10.;
342 fDetTypeRec->GetITSgeom()->TrackingV2ToDetL(fModule,y,z,xdet,zdet);
344 Int_t bint = TMath::Abs((Int_t)(xdet/stept));
345 if(xdet>=0) bint+=(Int_t)(nbint/2.);
346 if(bint>nbint) AliError("Wrong bin number!");
348 Int_t bina = TMath::Abs((Int_t)(zdet/stepa));
349 if(zdet>=0) bina+=(Int_t)(nbina/2.);
350 if(bina>nbina) AliError("Wrong bin number!");
352 Float_t devz = cal->GetMapACell(bina,bint)/10000.;
353 Float_t devx = cal->GetMapTCell(bina,bint)/10000.;
356 fDetTypeRec->GetITSgeom()->DetLToTrackingV2(fModule,xdet,zdet,y,z);