]>
Commit | Line | Data |
---|---|---|
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 | |
ae485645 | 27 | #include <TClonesArray.h> |
04366a57 | 28 | #include "AliITSClusterFinderV2SDD.h" |
00a7cc50 | 29 | #include "AliITSRecPoint.h" |
7d62fb64 | 30 | #include "AliITSDetTypeRec.h" |
04366a57 | 31 | #include "AliRawReader.h" |
0599a018 | 32 | #include "AliITSRawStreamSDD.h" |
5bfe44ce | 33 | #include "AliITSCalibrationSDD.h" |
34 | #include "AliITSDetTypeRec.h" | |
35 | #include "AliITSsegmentationSDD.h" | |
04366a57 | 36 | #include "AliITSdigitSDD.h" |
b4704be3 | 37 | #include "AliITSgeomTGeo.h" |
04366a57 | 38 | ClassImp(AliITSClusterFinderV2SDD) |
39 | ||
4952f440 | 40 | AliITSClusterFinderV2SDD::AliITSClusterFinderV2SDD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp) |
a66a0eb6 | 41 | { |
04366a57 | 42 | |
43 | //Default constructor | |
44 | ||
04366a57 | 45 | } |
46 | ||
47 | ||
48 | void AliITSClusterFinderV2SDD::FindRawClusters(Int_t mod){ | |
49 | ||
50 | //Find clusters V2 | |
51 | SetModule(mod); | |
52 | FindClustersSDD(fDigits); | |
53 | ||
54 | } | |
55 | ||
56 | void AliITSClusterFinderV2SDD::FindClustersSDD(TClonesArray *digits) { | |
57 | //------------------------------------------------------------ | |
58 | // Actual SDD cluster finder | |
59 | //------------------------------------------------------------ | |
4952f440 | 60 | Int_t nAnodes = GetSeg()->NpzHalf(); |
61 | Int_t nzBins = nAnodes+2; | |
62 | Int_t nTimeBins = GetSeg()->Npx(); | |
63 | Int_t nxBins = nTimeBins+2; | |
64 | const Int_t kMaxBin=nzBins*(nxBins+2); | |
04366a57 | 65 | |
66 | AliBin *bins[2]; | |
4952f440 | 67 | bins[0]=new AliBin[kMaxBin]; |
68 | bins[1]=new AliBin[kMaxBin]; | |
404c1c29 | 69 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule); |
0599a018 | 70 | AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse(); |
71 | const char *option=res->ZeroSuppOption(); | |
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); | |
76 | Int_t y=d->GetCoord2()+1; //y | |
77 | Int_t z=d->GetCoord1()+1; //z | |
5683bd96 | 78 | Float_t gain=cal->GetChannelGain(d->GetCoord1()); |
79 | Float_t charge=d->GetSignal(); | |
80 | ||
0599a018 | 81 | if(!((strstr(option,"1D")) || (strstr(option,"2D")))){ |
82 | Float_t baseline = cal->GetBaseline(d->GetCoord1()); | |
5683bd96 | 83 | if(charge>baseline) charge-=baseline; |
84 | else charge=0; | |
0599a018 | 85 | } |
5683bd96 | 86 | |
87 | if(gain>0) charge/=gain; | |
88 | if(charge<cal->GetThresholdAnode(d->GetCoord1())) continue; | |
89 | Int_t q=(Int_t)(charge+0.5); | |
04366a57 | 90 | |
4952f440 | 91 | if (z <= nAnodes){ |
92 | bins[0][y*nzBins+z].SetQ(q); | |
93 | bins[0][y*nzBins+z].SetMask(1); | |
94 | bins[0][y*nzBins+z].SetIndex(i); | |
04366a57 | 95 | } else { |
4952f440 | 96 | z-=nAnodes; |
97 | bins[1][y*nzBins+z].SetQ(q); | |
98 | bins[1][y*nzBins+z].SetMask(1); | |
99 | bins[1][y*nzBins+z].SetIndex(i); | |
04366a57 | 100 | } |
101 | } | |
102 | ||
4952f440 | 103 | FindClustersSDD(bins, kMaxBin, nzBins, digits); |
04366a57 | 104 | |
105 | delete[] bins[0]; | |
106 | delete[] bins[1]; | |
107 | ||
108 | } | |
109 | ||
110 | void AliITSClusterFinderV2SDD:: | |
111 | FindClustersSDD(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 | |
5dfa68c5 | 168 | for (Int_t di=-2; di<=2;di++){ |
04366a57 | 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]; | |
5dfa68c5 | 174 | Int_t nAnode=index%nzBins-1; |
175 | Int_t adcSignal=b->GetQ(); | |
176 | if(adcSignal>cal->GetThresholdAnode(nAnode)){ | |
177 | if (di>maxi) maxi=di; | |
178 | if (di<mini) mini=di; | |
179 | if (dj>maxj) maxj=dj; | |
180 | if (dj<minj) minj=dj; | |
181 | } | |
24c98369 | 182 | // |
183 | if(digits) { | |
184 | if (TMath::Abs(di)<2&&TMath::Abs(dj)<2){ | |
185 | AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex()); | |
186 | for (Int_t itrack=0;itrack<10;itrack++){ | |
187 | Int_t track = (d->GetTracks())[itrack]; | |
188 | if (track>=0) { | |
189 | AddLabel(milab, track); | |
04366a57 | 190 | } |
191 | } | |
192 | } | |
5dfa68c5 | 193 | } |
04366a57 | 194 | } |
5dfa68c5 | 195 | } |
d76cb3ad | 196 | |
04366a57 | 197 | |
04366a57 | 198 | Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ(); |
199 | y/=q; z/=q; | |
d76cb3ad | 200 | |
404c1c29 | 201 | |
4952f440 | 202 | const Double_t kMicronTocm = 1.0e-4; |
203 | Float_t timeBinCenter = y-0.5; | |
204 | Float_t zAnode=z-0.5; | |
205 | Float_t zdet = (zAnode*GetSeg()->Dpz(0)-GetSeg()->Dz()/2.)*kMicronTocm; | |
206 | Float_t driftTime = timeBinCenter*GetSeg()->Dpx(0) - cal->GetTimeOffset(); | |
207 | Float_t xdet = cal->GetDriftPath(driftTime,zAnode); | |
208 | xdet=(xdet-GetSeg()->Dx())*kMicronTocm; | |
404c1c29 | 209 | if (s) xdet=-xdet; |
210 | ||
4952f440 | 211 | |
404c1c29 | 212 | CorrectPosition(zdet,xdet); |
213 | ||
4952f440 | 214 | Double_t loc[3]={xdet,0.,zdet},trk[3]={0.,0.,0.}; |
215 | mT2L->MasterToLocal(loc,trk); | |
216 | y=trk[1]; | |
217 | z=trk[2]; | |
218 | ||
a66a0eb6 | 219 | q/=cal->GetADC2keV(); //to have MPV 1 MIP = 86.4 KeV |
ecb9da3c | 220 | Float_t hit[5] = {y, z, 0.0030*0.0030, 0.0020*0.0020, q}; |
221 | Int_t info[3] = {maxj-minj+1, maxi-mini+1, fNlayer[fModule]}; | |
04366a57 | 222 | if (digits) { |
223 | // AliBin *b=&bins[s][idx[k]]; | |
224 | // AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex()); | |
225 | { | |
226 | //Int_t lab[3]; | |
227 | //lab[0]=(d->GetTracks())[0]; | |
228 | //lab[1]=(d->GetTracks())[1]; | |
229 | //lab[2]=(d->GetTracks())[2]; | |
230 | //CheckLabels(lab); | |
231 | CheckLabels2(milab); | |
04366a57 | 232 | } |
233 | } | |
ecb9da3c | 234 | milab[3]=fNdet[fModule]; |
235 | ||
236 | AliITSRecPoint cc(milab,hit,info); | |
237 | cc.SetType(npeaks); | |
238 | ||
239 | if(clusters) new (cl[ncl]) AliITSRecPoint(cc); | |
04366a57 | 240 | else { |
ecb9da3c | 241 | fDetTypeRec->AddRecPoint(cc); |
04366a57 | 242 | } |
243 | ncl++; | |
244 | } | |
245 | } | |
24c98369 | 246 | |
04366a57 | 247 | } |
248 | ||
249 | ||
250 | ||
251 | void AliITSClusterFinderV2SDD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){ | |
252 | //------------------------------------------------------------ | |
253 | // This function creates ITS clusters from raw data | |
254 | //------------------------------------------------------------ | |
255 | rawReader->Reset(); | |
0599a018 | 256 | AliITSRawStreamSDD inputSDD(rawReader); |
04366a57 | 257 | FindClustersSDD(&inputSDD,clusters); |
258 | ||
259 | } | |
260 | ||
261 | void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input, | |
262 | TClonesArray** clusters) | |
263 | { | |
264 | //------------------------------------------------------------ | |
265 | // Actual SDD cluster finder for raw data | |
266 | //------------------------------------------------------------ | |
267 | Int_t nClustersSDD = 0; | |
4952f440 | 268 | Int_t nAnodes = GetSeg()->NpzHalf(); |
269 | Int_t nzBins = nAnodes+2; | |
270 | Int_t nTimeBins = GetSeg()->Npx(); | |
271 | Int_t nxBins = nTimeBins+2; | |
272 | const Int_t kMaxBin=nzBins*(nxBins+2); | |
ae485645 | 273 | AliBin *bins[2]; |
274 | bins[0]=new AliBin[kMaxBin]; | |
275 | bins[1]=new AliBin[kMaxBin]; | |
04366a57 | 276 | |
277 | // read raw data input stream | |
278 | while (kTRUE) { | |
279 | Bool_t next = input->Next(); | |
5dfa68c5 | 280 | if (!next || input->IsCompletedModule()) { |
04366a57 | 281 | // when all data from a module was read, search for clusters |
5dfa68c5 | 282 | Int_t iModule = input->GetModuleID(); |
ebbc4ece | 283 | if (iModule >= 0) { |
284 | clusters[iModule] = new TClonesArray("AliITSRecPoint"); | |
285 | fModule = iModule; | |
286 | FindClustersSDD(bins, kMaxBin, nzBins, NULL, clusters[iModule]); | |
287 | Int_t nClusters = clusters[iModule]->GetEntriesFast(); | |
288 | nClustersSDD += nClusters; | |
289 | for(Int_t iBin=0;iBin<kMaxBin; iBin++){ | |
290 | bins[0][iBin].Reset(); | |
291 | bins[1][iBin].Reset(); | |
292 | } | |
4b59acab | 293 | } |
04366a57 | 294 | if (!next) break; |
5dfa68c5 | 295 | }else{ |
04366a57 | 296 | // fill the current digit into the bins array |
5dfa68c5 | 297 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(input->GetModuleID()); |
298 | AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse(); | |
299 | const char *option=res->ZeroSuppOption(); | |
5683bd96 | 300 | Float_t charge=input->GetSignal(); |
301 | Float_t gain=cal->GetChannelGain(input->GetCoord1()); | |
5dfa68c5 | 302 | if(!((strstr(option,"1D")) || (strstr(option,"2D")))){ |
303 | Float_t baseline = cal->GetBaseline(input->GetCoord1()); | |
5683bd96 | 304 | if(charge>baseline) charge-=baseline; |
305 | else charge=0; | |
5dfa68c5 | 306 | } |
5683bd96 | 307 | if(gain>0) charge/=gain; |
308 | Int_t q=(Int_t)(charge+0.5); | |
5dfa68c5 | 309 | if(q>=cal->GetThresholdAnode(input->GetCoord1())) { |
310 | Int_t iz = input->GetCoord1()+1; | |
5dfa68c5 | 311 | Int_t side = ((AliITSRawStreamSDD*)input)->GetChannel(); |
4952f440 | 312 | Int_t index = (input->GetCoord2()+1) * nzBins + iz; |
5dfa68c5 | 313 | bins[side][index].SetQ(q); |
314 | bins[side][index].SetMask(1); | |
315 | bins[side][index].SetIndex(index); | |
316 | } | |
04366a57 | 317 | } |
318 | } | |
4b59acab | 319 | delete [] bins[0]; |
320 | delete [] bins[1]; | |
04366a57 | 321 | |
322 | Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD); | |
04366a57 | 323 | } |
324 | ||
325 | ||
5bfe44ce | 326 | //_________________________________________________________________________ |
327 | void AliITSClusterFinderV2SDD::CorrectPosition(Float_t &z, Float_t&y){ | |
328 | ||
329 | //correction of coordinates using the maps stored in the DB | |
330 | ||
331 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule); | |
a97b3678 | 332 | static const Int_t knbint = cal->GetMapTimeNBin(); |
333 | static const Int_t knbina = cal->Chips()*cal->Channels(); | |
4952f440 | 334 | const Double_t kMicronTocm = 1.0e-4; |
335 | Float_t stepa = (GetSeg()->Dpz(0))*kMicronTocm; //anode pitch in cm | |
5bfe44ce | 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 | |
4952f440 | 346 | Float_t devz = cal->GetMapACell(bina,bint)*kMicronTocm; |
347 | Float_t devx = cal->GetMapTCell(bina,bint)*kMicronTocm; | |
404c1c29 | 348 | z+=devz; |
349 | y+=devx; | |
5bfe44ce | 350 | |
351 | ||
352 | } |