]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSClusterFinderV2SDD.cxx
31-may-2007 NvE Memberfunctions GetNdevices, GetIdDevice and ShowDevices of AliEvent
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderV2SDD.cxx
CommitLineData
04366a57 1/**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 //
17// //
18// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch //
19// //
20///////////////////////////////////////////////////////////////////////////
21
22
04366a57 23
24#include "AliITSClusterFinderV2SDD.h"
00a7cc50 25#include "AliITSRecPoint.h"
7d62fb64 26#include "AliITSDetTypeRec.h"
04366a57 27#include "AliRawReader.h"
0599a018 28#include "AliITSRawStreamSDD.h"
5bfe44ce 29#include "AliITSCalibrationSDD.h"
30#include "AliITSDetTypeRec.h"
31#include "AliITSsegmentationSDD.h"
04366a57 32#include <TClonesArray.h>
04366a57 33#include "AliITSdigitSDD.h"
b4704be3 34#include "AliITSgeomTGeo.h"
04366a57 35
36ClassImp(AliITSClusterFinderV2SDD)
37
e56160b8 38AliITSClusterFinderV2SDD::AliITSClusterFinderV2SDD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp),
39fNySDD(256),
40fNzSDD(256),
41fYpitchSDD(0.01825),
42fZpitchSDD(0.02940),
43fHwSDD(3.5085),
44fHlSDD(3.7632),
45fYoffSDD(0.0425){
04366a57 46
47 //Default constructor
48
04366a57 49
50}
51
52
53void AliITSClusterFinderV2SDD::FindRawClusters(Int_t mod){
54
55 //Find clusters V2
56 SetModule(mod);
57 FindClustersSDD(fDigits);
58
59}
60
61void 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);
67
68 AliBin *bins[2];
69 bins[0]=new AliBin[kMAXBIN];
70 bins[1]=new AliBin[kMAXBIN];
404c1c29 71 AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
0599a018 72 AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse();
73 const char *option=res->ZeroSuppOption();
04366a57 74 AliITSdigitSDD *d=0;
75 Int_t i, ndigits=digits->GetEntriesFast();
76 for (i=0; i<ndigits; i++) {
77 d=(AliITSdigitSDD*)digits->UncheckedAt(i);
78 Int_t y=d->GetCoord2()+1; //y
79 Int_t z=d->GetCoord1()+1; //z
80 Int_t q=d->GetSignal();
0599a018 81 if(!((strstr(option,"1D")) || (strstr(option,"2D")))){
82 Float_t baseline = cal->GetBaseline(d->GetCoord1());
83 if(q>baseline) q-=(Int_t)baseline;
84 else q=0;
85 }
9e4d7193 86 if(q<cal->GetThresholdAnode(d->GetCoord1())) continue;
0599a018 87
404c1c29 88 //if (q<3) continue;
04366a57 89
90 if (z <= fNzSDD) {
91 bins[0][y*kNzBins+z].SetQ(q);
92 bins[0][y*kNzBins+z].SetMask(1);
93 bins[0][y*kNzBins+z].SetIndex(i);
94 } else {
95 z-=fNzSDD;
96 bins[1][y*kNzBins+z].SetQ(q);
97 bins[1][y*kNzBins+z].SetMask(1);
98 bins[1][y*kNzBins+z].SetIndex(i);
99 }
100 }
101
102 FindClustersSDD(bins, kMAXBIN, kNzBins, digits);
103
104 delete[] bins[0];
105 delete[] bins[1];
106
107}
108
109void AliITSClusterFinderV2SDD::
110FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins,
111 TClonesArray *digits, TClonesArray *clusters) {
112 //------------------------------------------------------------
113 // Actual SDD cluster finder
114 //------------------------------------------------------------
b4704be3 115
116 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
117
404c1c29 118 AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
04366a57 119 Int_t ncl=0;
120 TClonesArray &cl=*clusters;
121 for (Int_t s=0; s<2; s++)
122 for (Int_t i=0; i<nMaxBin; i++) {
123 if (bins[s][i].IsUsed()) continue;
124 Int_t idx[32]; UInt_t msk[32]; Int_t npeaks=0;
125 FindPeaks(i, nzBins, bins[s], idx, msk, npeaks);
126
127 if (npeaks>30) continue;
128 if (npeaks==0) continue;
129
130 Int_t k,l;
131 for (k=0; k<npeaks-1; k++){//mark adjacent peaks
132 if (idx[k] < 0) continue; //this peak is already removed
133 for (l=k+1; l<npeaks; l++) {
134 if (idx[l] < 0) continue; //this peak is already removed
135 Int_t ki=idx[k]/nzBins, kj=idx[k] - ki*nzBins;
136 Int_t li=idx[l]/nzBins, lj=idx[l] - li*nzBins;
137 Int_t di=TMath::Abs(ki - li);
138 Int_t dj=TMath::Abs(kj - lj);
139 if (di>1 || dj>1) continue;
140 if (bins[s][idx[k]].GetQ() > bins[s][idx[l]].GetQ()) {
141 msk[l]=msk[k];
142 idx[l]*=-1;
143 } else {
144 msk[k]=msk[l];
145 idx[k]*=-1;
146 break;
147 }
148 }
149 }
150
151 for (k=0; k<npeaks; k++) {
152 MarkPeak(TMath::Abs(idx[k]), nzBins, bins[s], msk[k]);
153 }
154
155 for (k=0; k<npeaks; k++) {
156 if (idx[k] < 0) continue; //removed peak
75fb37cc 157 AliITSRecPoint c;
04366a57 158 MakeCluster(idx[k], nzBins, bins[s], msk[k], c);
159 //mi change
160 Int_t milab[10];
161 for (Int_t ilab=0;ilab<10;ilab++){
162 milab[ilab]=-2;
163 }
164 Int_t maxi=0,mini=0,maxj=0,minj=0;
165 //AliBin *bmax=&bins[s][idx[k]];
166 //Float_t max = TMath::Max(TMath::Abs(bmax->GetQ())/5.,3.);
167 Float_t max=3;
168 for (Int_t di=-2; di<=2;di++)
169 for (Int_t dj=-3;dj<=3;dj++){
170 Int_t index = idx[k]+di+dj*nzBins;
171 if (index<0) continue;
172 if (index>=nMaxBin) continue;
173 AliBin *b=&bins[s][index];
174 if (TMath::Abs(b->GetQ())>max){
175 if (di>maxi) maxi=di;
176 if (di<mini) mini=di;
177 if (dj>maxj) maxj=dj;
178 if (dj<minj) minj=dj;
179 //
180 if(digits) {
181 if (TMath::Abs(di)<2&&TMath::Abs(dj)<2){
182 AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
183 for (Int_t itrack=0;itrack<10;itrack++){
184 Int_t track = (d->GetTracks())[itrack];
185 if (track>=0) {
186 AddLabel(milab, track);
187 }
188 }
189 }
190 }
191 }
192 }
193
194 /*
195 Float_t s2 = c.GetSigmaY2()/c.GetQ() - c.GetY()*c.GetY();
196 Float_t w=par->GetPadPitchWidth(sec);
197 c.SetSigmaY2(s2);
198 if (s2 != 0.) {
199 c.SetSigmaY2(c.GetSigmaY2()*0.108);
200 if (sec<par->GetNInnerSector()) c.SetSigmaY2(c.GetSigmaY2()*2.07);
201 }
202 s2 = c.GetSigmaZ2()/c.GetQ() - c.GetZ()*c.GetZ();
203 w=par->GetZWidth();
204 c.SetSigmaZ2(s2);
205
206 if (s2 != 0.) {
207 c.SetSigmaZ2(c.GetSigmaZ2()*0.169);
208 if (sec<par->GetNInnerSector()) c.SetSigmaZ2(c.GetSigmaZ2()*1.77);
209 }
210 */
211
04366a57 212 Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ();
213 y/=q; z/=q;
214 //
215 //Float_t s2 = c.GetSigmaY2()/c.GetQ() - y*y;
216 // c.SetSigmaY2(s2);
217 //s2 = c.GetSigmaZ2()/c.GetQ() - z*z;
218 //c.SetSigmaZ2(s2);
219 //
404c1c29 220
221 Float_t yyyy = y;
222 //y=(y-0.5)*fYpitchSDD;
223 //y-=fHwSDD;
224 //y-=fYoffSDD; //delay ?
225 //if (s) y=-y;
04366a57 226
227 z=(z-0.5)*fZpitchSDD;
228 z-=fHlSDD;
404c1c29 229 Float_t zdet = z;
230 // y=-(-y+fYshift[fModule]);
231 // z= -z+fZshift[fModule];
00a7cc50 232 // c.SetY(y);
233 // c.SetZ(z);
9e4d7193 234 Float_t timebin = GetSeg()->Dpx(0);
235 Float_t xdet = cal->GetDriftPath((yyyy-0.5)*timebin,0);
404c1c29 236 xdet=xdet/10000.-fHwSDD-fYoffSDD;
237 if (s) xdet=-xdet;
238
239 CorrectPosition(zdet,xdet);
240
b4704be3 241 {
242 Double_t loc[3]={xdet,0.,zdet},trk[3]={0.,0.,0.};
243 mT2L->MasterToLocal(loc,trk);
244 y=trk[1];
245 z=trk[2];
246 }
3a4139a2 247 q/=5.243; //to have MPV 1 MIP = 86.4 KeV --> this must go to calibr.
ecb9da3c 248 Float_t hit[5] = {y, z, 0.0030*0.0030, 0.0020*0.0020, q};
249 Int_t info[3] = {maxj-minj+1, maxi-mini+1, fNlayer[fModule]};
04366a57 250
0599a018 251 if (c.GetQ() < 20.) continue; //noise cluster
04366a57 252
253 if (digits) {
254 // AliBin *b=&bins[s][idx[k]];
255 // AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
256 {
257 //Int_t lab[3];
258 //lab[0]=(d->GetTracks())[0];
259 //lab[1]=(d->GetTracks())[1];
260 //lab[2]=(d->GetTracks())[2];
261 //CheckLabels(lab);
262 CheckLabels2(milab);
04366a57 263 }
264 }
ecb9da3c 265 milab[3]=fNdet[fModule];
266
267 AliITSRecPoint cc(milab,hit,info);
268 cc.SetType(npeaks);
269
270 if(clusters) new (cl[ncl]) AliITSRecPoint(cc);
04366a57 271 else {
ecb9da3c 272 fDetTypeRec->AddRecPoint(cc);
04366a57 273 }
274 ncl++;
275 }
276 }
277}
278
279
280
281void AliITSClusterFinderV2SDD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){
282 //------------------------------------------------------------
283 // This function creates ITS clusters from raw data
284 //------------------------------------------------------------
285 rawReader->Reset();
0599a018 286 AliITSRawStreamSDD inputSDD(rawReader);
04366a57 287 FindClustersSDD(&inputSDD,clusters);
288
289}
290
291void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input,
292 TClonesArray** clusters)
293{
294 //------------------------------------------------------------
295 // Actual SDD cluster finder for raw data
296 //------------------------------------------------------------
297 Int_t nClustersSDD = 0;
298 Int_t kNzBins = fNzSDD + 2;
299 Int_t kMaxBin = kNzBins * (fNySDD+2);
d7d9347b 300 AliBin *binsSDDInit = new AliBin[kMaxBin];
301 AliBin *binsSDD1 = new AliBin[kMaxBin];
302 AliBin *binsSDD2 = new AliBin[kMaxBin];
04366a57 303 AliBin* bins[2] = {NULL, NULL};
304
305 // read raw data input stream
306 while (kTRUE) {
307 Bool_t next = input->Next();
308 if (!next || input->IsNewModule()) {
309 Int_t iModule = input->GetPrevModuleID();
310
311 // when all data from a module was read, search for clusters
312 if (bins[0]) {
00a7cc50 313 clusters[iModule] = new TClonesArray("AliITSRecPoint");
04366a57 314 fModule = iModule;
315 FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]);
316 Int_t nClusters = clusters[iModule]->GetEntriesFast();
317 nClustersSDD += nClusters;
a97b3678 318 bins[0] = bins[1] = NULL;
04366a57 319 }
320
321 if (!next) break;
d7d9347b 322 bins[0]=binsSDD1;
323 bins[1]=binsSDD2;
324 memcpy(binsSDD1,binsSDDInit,sizeof(AliBin)*kMaxBin);
325 memcpy(binsSDD2,binsSDDInit,sizeof(AliBin)*kMaxBin);
326
04366a57 327 }
328
329 // fill the current digit into the bins array
a97b3678 330 AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(input->GetModuleID());
331 AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse();
332 const char *option=res->ZeroSuppOption();
333 Int_t q=input->GetSignal();
334 if(!((strstr(option,"1D")) || (strstr(option,"2D")))){
335 Float_t baseline = cal->GetBaseline(input->GetCoord1());
336 if(q>baseline) q-=(Int_t)baseline;
337 else q=0;
338 }
339 if(q>=cal->GetThresholdAnode(input->GetCoord1())) {
04366a57 340 Int_t iz = input->GetCoord1()+1;
a97b3678 341 //Int_t side = ((iz <= fNzSDD) ? 0 : 1);
342 Int_t side = ((AliITSRawStreamSDD*)input)->GetChannel();
343 // iz -= side*fNzSDD;
04366a57 344 Int_t index = (input->GetCoord2()+1) * kNzBins + iz;
a97b3678 345 bins[side][index].SetQ(q);
04366a57 346 bins[side][index].SetMask(1);
347 bins[side][index].SetIndex(index);
348 }
349 }
d7d9347b 350 delete[] binsSDD1;
351 delete[] binsSDD2;
352 delete[] binsSDDInit;
04366a57 353
354 Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD);
04366a57 355}
356
357
5bfe44ce 358//_________________________________________________________________________
359void AliITSClusterFinderV2SDD::CorrectPosition(Float_t &z, Float_t&y){
360
361 //correction of coordinates using the maps stored in the DB
362
363 AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
a97b3678 364 static const Int_t knbint = cal->GetMapTimeNBin();
365 static const Int_t knbina = cal->Chips()*cal->Channels();
5bfe44ce 366 Float_t stepa = (GetSeg()->Dpz(0))/10000.; //anode pitch in cm
367 Float_t stept = (GetSeg()->Dx()/cal->GetMapTimeNBin()/2.)/10.;
404c1c29 368
369 Int_t bint = TMath::Abs((Int_t)(y/stept));
a97b3678 370 if(y>=0) bint+=(Int_t)(knbint/2.);
371 if(bint>knbint) AliError("Wrong bin number!");
5bfe44ce 372
404c1c29 373 Int_t bina = TMath::Abs((Int_t)(z/stepa));
a97b3678 374 if(z>=0) bina+=(Int_t)(knbina/2.);
375 if(bina>knbina) AliError("Wrong bin number!");
5bfe44ce 376
377 Float_t devz = cal->GetMapACell(bina,bint)/10000.;
378 Float_t devx = cal->GetMapTCell(bina,bint)/10000.;
404c1c29 379 z+=devz;
380 y+=devx;
5bfe44ce 381
382
383}