]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSClusterFinderV2SDD.cxx
Adding comments (Laurent)
[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 **************************************************************************/
d76cb3ad 15
16/* $Id$*/
17
04366a57 18////////////////////////////////////////////////////////////////////////////
19// Implementation of the ITS clusterer V2 class //
20// //
21// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch //
22// //
23///////////////////////////////////////////////////////////////////////////
24
25
04366a57 26
27#include "AliITSClusterFinderV2SDD.h"
00a7cc50 28#include "AliITSRecPoint.h"
7d62fb64 29#include "AliITSDetTypeRec.h"
04366a57 30#include "AliRawReader.h"
0599a018 31#include "AliITSRawStreamSDD.h"
5bfe44ce 32#include "AliITSCalibrationSDD.h"
33#include "AliITSDetTypeRec.h"
34#include "AliITSsegmentationSDD.h"
04366a57 35#include <TClonesArray.h>
04366a57 36#include "AliITSdigitSDD.h"
b4704be3 37#include "AliITSgeomTGeo.h"
04366a57 38ClassImp(AliITSClusterFinderV2SDD)
39
e56160b8 40AliITSClusterFinderV2SDD::AliITSClusterFinderV2SDD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp),
41fNySDD(256),
42fNzSDD(256),
e56160b8 43fZpitchSDD(0.02940),
44fHwSDD(3.5085),
45fHlSDD(3.7632),
d76cb3ad 46fTimeOffsetSDD(0.){
04366a57 47
48 //Default constructor
49
d76cb3ad 50 SetTimeOffset();
04366a57 51}
52
53
54void AliITSClusterFinderV2SDD::FindRawClusters(Int_t mod){
55
56 //Find clusters V2
57 SetModule(mod);
58 FindClustersSDD(fDigits);
59
60}
61
62void 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);
68
69 AliBin *bins[2];
70 bins[0]=new AliBin[kMAXBIN];
71 bins[1]=new AliBin[kMAXBIN];
404c1c29 72 AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
0599a018 73 AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse();
74 const char *option=res->ZeroSuppOption();
04366a57 75 AliITSdigitSDD *d=0;
76 Int_t i, ndigits=digits->GetEntriesFast();
77 for (i=0; i<ndigits; i++) {
78 d=(AliITSdigitSDD*)digits->UncheckedAt(i);
79 Int_t y=d->GetCoord2()+1; //y
80 Int_t z=d->GetCoord1()+1; //z
81 Int_t q=d->GetSignal();
0599a018 82 if(!((strstr(option,"1D")) || (strstr(option,"2D")))){
83 Float_t baseline = cal->GetBaseline(d->GetCoord1());
84 if(q>baseline) q-=(Int_t)baseline;
85 else q=0;
86 }
9e4d7193 87 if(q<cal->GetThresholdAnode(d->GetCoord1())) continue;
0599a018 88
404c1c29 89 //if (q<3) continue;
04366a57 90
91 if (z <= fNzSDD) {
92 bins[0][y*kNzBins+z].SetQ(q);
93 bins[0][y*kNzBins+z].SetMask(1);
94 bins[0][y*kNzBins+z].SetIndex(i);
95 } else {
96 z-=fNzSDD;
97 bins[1][y*kNzBins+z].SetQ(q);
98 bins[1][y*kNzBins+z].SetMask(1);
99 bins[1][y*kNzBins+z].SetIndex(i);
100 }
101 }
102
103 FindClustersSDD(bins, kMAXBIN, kNzBins, digits);
104
105 delete[] bins[0];
106 delete[] bins[1];
107
108}
109
110void AliITSClusterFinderV2SDD::
111FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins,
112 TClonesArray *digits, TClonesArray *clusters) {
113 //------------------------------------------------------------
114 // Actual SDD cluster finder
115 //------------------------------------------------------------
b4704be3 116
117 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
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.);
24c98369 167
04366a57 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];
24c98369 174 if (di>maxi) maxi=di;
175 if (di<mini) mini=di;
176 if (dj>maxj) maxj=dj;
177 if (dj<minj) minj=dj;
178 //
179 if(digits) {
180 if (TMath::Abs(di)<2&&TMath::Abs(dj)<2){
181 AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
182 for (Int_t itrack=0;itrack<10;itrack++){
183 Int_t track = (d->GetTracks())[itrack];
184 if (track>=0) {
185 AddLabel(milab, track);
04366a57 186 }
187 }
188 }
24c98369 189 }
04366a57 190 }
191
d76cb3ad 192
04366a57 193
04366a57 194 Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ();
195 y/=q; z/=q;
d76cb3ad 196
404c1c29 197
198 Float_t yyyy = y;
04366a57 199
200 z=(z-0.5)*fZpitchSDD;
201 z-=fHlSDD;
404c1c29 202 Float_t zdet = z;
9e4d7193 203 Float_t timebin = GetSeg()->Dpx(0);
d76cb3ad 204 Float_t driftTime = (yyyy-0.5)*timebin - fTimeOffsetSDD;
205 Float_t xdet = cal->GetDriftPath(driftTime,0);
206 xdet=xdet/10000.-fHwSDD;
404c1c29 207 if (s) xdet=-xdet;
208
209 CorrectPosition(zdet,xdet);
210
b4704be3 211 {
212 Double_t loc[3]={xdet,0.,zdet},trk[3]={0.,0.,0.};
213 mT2L->MasterToLocal(loc,trk);
214 y=trk[1];
215 z=trk[2];
216 }
3a4139a2 217 q/=5.243; //to have MPV 1 MIP = 86.4 KeV --> this must go to calibr.
ecb9da3c 218 Float_t hit[5] = {y, z, 0.0030*0.0030, 0.0020*0.0020, q};
219 Int_t info[3] = {maxj-minj+1, maxi-mini+1, fNlayer[fModule]};
04366a57 220
221 if (digits) {
222 // AliBin *b=&bins[s][idx[k]];
223 // AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
224 {
225 //Int_t lab[3];
226 //lab[0]=(d->GetTracks())[0];
227 //lab[1]=(d->GetTracks())[1];
228 //lab[2]=(d->GetTracks())[2];
229 //CheckLabels(lab);
230 CheckLabels2(milab);
04366a57 231 }
232 }
ecb9da3c 233 milab[3]=fNdet[fModule];
234
235 AliITSRecPoint cc(milab,hit,info);
236 cc.SetType(npeaks);
237
238 if(clusters) new (cl[ncl]) AliITSRecPoint(cc);
04366a57 239 else {
ecb9da3c 240 fDetTypeRec->AddRecPoint(cc);
04366a57 241 }
242 ncl++;
243 }
244 }
24c98369 245
04366a57 246}
247
248
249
250void AliITSClusterFinderV2SDD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){
251 //------------------------------------------------------------
252 // This function creates ITS clusters from raw data
253 //------------------------------------------------------------
254 rawReader->Reset();
0599a018 255 AliITSRawStreamSDD inputSDD(rawReader);
04366a57 256 FindClustersSDD(&inputSDD,clusters);
257
258}
259
260void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input,
261 TClonesArray** clusters)
262{
263 //------------------------------------------------------------
264 // Actual SDD cluster finder for raw data
265 //------------------------------------------------------------
266 Int_t nClustersSDD = 0;
267 Int_t kNzBins = fNzSDD + 2;
268 Int_t kMaxBin = kNzBins * (fNySDD+2);
d7d9347b 269 AliBin *binsSDDInit = new AliBin[kMaxBin];
270 AliBin *binsSDD1 = new AliBin[kMaxBin];
271 AliBin *binsSDD2 = new AliBin[kMaxBin];
04366a57 272 AliBin* bins[2] = {NULL, NULL};
273
274 // read raw data input stream
275 while (kTRUE) {
276 Bool_t next = input->Next();
277 if (!next || input->IsNewModule()) {
278 Int_t iModule = input->GetPrevModuleID();
279
280 // when all data from a module was read, search for clusters
281 if (bins[0]) {
00a7cc50 282 clusters[iModule] = new TClonesArray("AliITSRecPoint");
04366a57 283 fModule = iModule;
284 FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]);
285 Int_t nClusters = clusters[iModule]->GetEntriesFast();
286 nClustersSDD += nClusters;
a97b3678 287 bins[0] = bins[1] = NULL;
04366a57 288 }
289
290 if (!next) break;
d7d9347b 291 bins[0]=binsSDD1;
292 bins[1]=binsSDD2;
293 memcpy(binsSDD1,binsSDDInit,sizeof(AliBin)*kMaxBin);
294 memcpy(binsSDD2,binsSDDInit,sizeof(AliBin)*kMaxBin);
295
04366a57 296 }
297
298 // fill the current digit into the bins array
a97b3678 299 AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(input->GetModuleID());
300 AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse();
301 const char *option=res->ZeroSuppOption();
302 Int_t q=input->GetSignal();
303 if(!((strstr(option,"1D")) || (strstr(option,"2D")))){
304 Float_t baseline = cal->GetBaseline(input->GetCoord1());
305 if(q>baseline) q-=(Int_t)baseline;
306 else q=0;
307 }
308 if(q>=cal->GetThresholdAnode(input->GetCoord1())) {
04366a57 309 Int_t iz = input->GetCoord1()+1;
a97b3678 310 //Int_t side = ((iz <= fNzSDD) ? 0 : 1);
311 Int_t side = ((AliITSRawStreamSDD*)input)->GetChannel();
312 // iz -= side*fNzSDD;
04366a57 313 Int_t index = (input->GetCoord2()+1) * kNzBins + iz;
a97b3678 314 bins[side][index].SetQ(q);
04366a57 315 bins[side][index].SetMask(1);
316 bins[side][index].SetIndex(index);
317 }
318 }
d7d9347b 319 delete[] binsSDD1;
320 delete[] binsSDD2;
321 delete[] binsSDDInit;
04366a57 322
323 Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD);
04366a57 324}
325
326
5bfe44ce 327//_________________________________________________________________________
328void AliITSClusterFinderV2SDD::CorrectPosition(Float_t &z, Float_t&y){
329
330 //correction of coordinates using the maps stored in the DB
331
332 AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
a97b3678 333 static const Int_t knbint = cal->GetMapTimeNBin();
334 static const Int_t knbina = cal->Chips()*cal->Channels();
5bfe44ce 335 Float_t stepa = (GetSeg()->Dpz(0))/10000.; //anode pitch in cm
336 Float_t stept = (GetSeg()->Dx()/cal->GetMapTimeNBin()/2.)/10.;
404c1c29 337
338 Int_t bint = TMath::Abs((Int_t)(y/stept));
a97b3678 339 if(y>=0) bint+=(Int_t)(knbint/2.);
340 if(bint>knbint) AliError("Wrong bin number!");
5bfe44ce 341
404c1c29 342 Int_t bina = TMath::Abs((Int_t)(z/stepa));
a97b3678 343 if(z>=0) bina+=(Int_t)(knbina/2.);
344 if(bina>knbina) AliError("Wrong bin number!");
5bfe44ce 345
346 Float_t devz = cal->GetMapACell(bina,bint)/10000.;
347 Float_t devx = cal->GetMapTCell(bina,bint)/10000.;
404c1c29 348 z+=devz;
349 y+=devx;
5bfe44ce 350
351
352}