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