]>
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 | ||
e56160b8 | 40 | AliITSClusterFinderV2SDD::AliITSClusterFinderV2SDD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp), |
41 | fNySDD(256), | |
42 | fNzSDD(256), | |
e56160b8 | 43 | fZpitchSDD(0.02940), |
44 | fHwSDD(3.5085), | |
45 | fHlSDD(3.7632), | |
d76cb3ad | 46 | fTimeOffsetSDD(0.){ |
04366a57 | 47 | |
48 | //Default constructor | |
49 | ||
d76cb3ad | 50 | SetTimeOffset(); |
04366a57 | 51 | } |
52 | ||
53 | ||
54 | void AliITSClusterFinderV2SDD::FindRawClusters(Int_t mod){ | |
55 | ||
56 | //Find clusters V2 | |
57 | SetModule(mod); | |
58 | FindClustersSDD(fDigits); | |
59 | ||
60 | } | |
61 | ||
62 | void 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; |
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 | ||
109 | void AliITSClusterFinderV2SDD:: | |
110 | FindClustersSDD(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); | |
404c1c29 | 117 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule); |
04366a57 | 118 | Int_t ncl=0; |
119 | TClonesArray &cl=*clusters; | |
120 | for (Int_t s=0; s<2; s++) | |
121 | for (Int_t i=0; i<nMaxBin; i++) { | |
122 | if (bins[s][i].IsUsed()) continue; | |
123 | Int_t idx[32]; UInt_t msk[32]; Int_t npeaks=0; | |
124 | FindPeaks(i, nzBins, bins[s], idx, msk, npeaks); | |
125 | ||
126 | if (npeaks>30) continue; | |
127 | if (npeaks==0) continue; | |
128 | ||
129 | Int_t k,l; | |
130 | for (k=0; k<npeaks-1; k++){//mark adjacent peaks | |
131 | if (idx[k] < 0) continue; //this peak is already removed | |
132 | for (l=k+1; l<npeaks; l++) { | |
133 | if (idx[l] < 0) continue; //this peak is already removed | |
134 | Int_t ki=idx[k]/nzBins, kj=idx[k] - ki*nzBins; | |
135 | Int_t li=idx[l]/nzBins, lj=idx[l] - li*nzBins; | |
136 | Int_t di=TMath::Abs(ki - li); | |
137 | Int_t dj=TMath::Abs(kj - lj); | |
138 | if (di>1 || dj>1) continue; | |
139 | if (bins[s][idx[k]].GetQ() > bins[s][idx[l]].GetQ()) { | |
140 | msk[l]=msk[k]; | |
141 | idx[l]*=-1; | |
142 | } else { | |
143 | msk[k]=msk[l]; | |
144 | idx[k]*=-1; | |
145 | break; | |
146 | } | |
147 | } | |
148 | } | |
149 | ||
150 | for (k=0; k<npeaks; k++) { | |
151 | MarkPeak(TMath::Abs(idx[k]), nzBins, bins[s], msk[k]); | |
152 | } | |
153 | ||
154 | for (k=0; k<npeaks; k++) { | |
155 | if (idx[k] < 0) continue; //removed peak | |
75fb37cc | 156 | AliITSRecPoint c; |
04366a57 | 157 | MakeCluster(idx[k], nzBins, bins[s], msk[k], c); |
158 | //mi change | |
159 | Int_t milab[10]; | |
160 | for (Int_t ilab=0;ilab<10;ilab++){ | |
161 | milab[ilab]=-2; | |
162 | } | |
163 | Int_t maxi=0,mini=0,maxj=0,minj=0; | |
164 | //AliBin *bmax=&bins[s][idx[k]]; | |
165 | //Float_t max = TMath::Max(TMath::Abs(bmax->GetQ())/5.,3.); | |
24c98369 | 166 | |
5dfa68c5 | 167 | for (Int_t di=-2; di<=2;di++){ |
04366a57 | 168 | for (Int_t dj=-3;dj<=3;dj++){ |
169 | Int_t index = idx[k]+di+dj*nzBins; | |
170 | if (index<0) continue; | |
171 | if (index>=nMaxBin) continue; | |
172 | AliBin *b=&bins[s][index]; | |
5dfa68c5 | 173 | Int_t nAnode=index%nzBins-1; |
174 | Int_t adcSignal=b->GetQ(); | |
175 | if(adcSignal>cal->GetThresholdAnode(nAnode)){ | |
176 | if (di>maxi) maxi=di; | |
177 | if (di<mini) mini=di; | |
178 | if (dj>maxj) maxj=dj; | |
179 | if (dj<minj) minj=dj; | |
180 | } | |
24c98369 | 181 | // |
182 | if(digits) { | |
183 | if (TMath::Abs(di)<2&&TMath::Abs(dj)<2){ | |
184 | AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex()); | |
185 | for (Int_t itrack=0;itrack<10;itrack++){ | |
186 | Int_t track = (d->GetTracks())[itrack]; | |
187 | if (track>=0) { | |
188 | AddLabel(milab, track); | |
04366a57 | 189 | } |
190 | } | |
191 | } | |
5dfa68c5 | 192 | } |
04366a57 | 193 | } |
5dfa68c5 | 194 | } |
d76cb3ad | 195 | |
04366a57 | 196 | |
04366a57 | 197 | Float_t y=c.GetY(),z=c.GetZ(), q=c.GetQ(); |
198 | y/=q; z/=q; | |
d76cb3ad | 199 | |
404c1c29 | 200 | |
201 | Float_t yyyy = y; | |
04366a57 | 202 | |
203 | z=(z-0.5)*fZpitchSDD; | |
204 | z-=fHlSDD; | |
404c1c29 | 205 | Float_t zdet = z; |
9e4d7193 | 206 | Float_t timebin = GetSeg()->Dpx(0); |
d76cb3ad | 207 | Float_t driftTime = (yyyy-0.5)*timebin - fTimeOffsetSDD; |
208 | Float_t xdet = cal->GetDriftPath(driftTime,0); | |
209 | xdet=xdet/10000.-fHwSDD; | |
404c1c29 | 210 | if (s) xdet=-xdet; |
211 | ||
212 | CorrectPosition(zdet,xdet); | |
213 | ||
b4704be3 | 214 | { |
215 | Double_t loc[3]={xdet,0.,zdet},trk[3]={0.,0.,0.}; | |
216 | mT2L->MasterToLocal(loc,trk); | |
217 | y=trk[1]; | |
218 | z=trk[2]; | |
219 | } | |
3a4139a2 | 220 | q/=5.243; //to have MPV 1 MIP = 86.4 KeV --> this must go to calibr. |
ecb9da3c | 221 | Float_t hit[5] = {y, z, 0.0030*0.0030, 0.0020*0.0020, q}; |
222 | Int_t info[3] = {maxj-minj+1, maxi-mini+1, fNlayer[fModule]}; | |
04366a57 | 223 | if (digits) { |
224 | // AliBin *b=&bins[s][idx[k]]; | |
225 | // AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex()); | |
226 | { | |
227 | //Int_t lab[3]; | |
228 | //lab[0]=(d->GetTracks())[0]; | |
229 | //lab[1]=(d->GetTracks())[1]; | |
230 | //lab[2]=(d->GetTracks())[2]; | |
231 | //CheckLabels(lab); | |
232 | CheckLabels2(milab); | |
04366a57 | 233 | } |
234 | } | |
ecb9da3c | 235 | milab[3]=fNdet[fModule]; |
236 | ||
237 | AliITSRecPoint cc(milab,hit,info); | |
238 | cc.SetType(npeaks); | |
239 | ||
240 | if(clusters) new (cl[ncl]) AliITSRecPoint(cc); | |
04366a57 | 241 | else { |
ecb9da3c | 242 | fDetTypeRec->AddRecPoint(cc); |
04366a57 | 243 | } |
244 | ncl++; | |
245 | } | |
246 | } | |
24c98369 | 247 | |
04366a57 | 248 | } |
249 | ||
250 | ||
251 | ||
252 | void AliITSClusterFinderV2SDD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){ | |
253 | //------------------------------------------------------------ | |
254 | // This function creates ITS clusters from raw data | |
255 | //------------------------------------------------------------ | |
256 | rawReader->Reset(); | |
0599a018 | 257 | AliITSRawStreamSDD inputSDD(rawReader); |
04366a57 | 258 | FindClustersSDD(&inputSDD,clusters); |
259 | ||
260 | } | |
261 | ||
262 | void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input, | |
263 | TClonesArray** clusters) | |
264 | { | |
265 | //------------------------------------------------------------ | |
266 | // Actual SDD cluster finder for raw data | |
267 | //------------------------------------------------------------ | |
268 | Int_t nClustersSDD = 0; | |
269 | Int_t kNzBins = fNzSDD + 2; | |
270 | Int_t kMaxBin = kNzBins * (fNySDD+2); | |
ae485645 | 271 | AliBin *bins[2]; |
272 | bins[0]=new AliBin[kMaxBin]; | |
273 | bins[1]=new AliBin[kMaxBin]; | |
04366a57 | 274 | |
275 | // read raw data input stream | |
276 | while (kTRUE) { | |
277 | Bool_t next = input->Next(); | |
5dfa68c5 | 278 | if (!next || input->IsCompletedModule()) { |
04366a57 | 279 | // when all data from a module was read, search for clusters |
5dfa68c5 | 280 | Int_t iModule = input->GetModuleID(); |
ae485645 | 281 | clusters[iModule] = new TClonesArray("AliITSRecPoint"); |
282 | fModule = iModule; | |
283 | FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]); | |
284 | Int_t nClusters = clusters[iModule]->GetEntriesFast(); | |
285 | nClustersSDD += nClusters; | |
4b59acab | 286 | for(Int_t iBin=0;iBin<kMaxBin; iBin++){ |
287 | bins[0][iBin].Reset(); | |
288 | bins[1][iBin].Reset(); | |
289 | } | |
04366a57 | 290 | if (!next) break; |
5dfa68c5 | 291 | }else{ |
04366a57 | 292 | // fill the current digit into the bins array |
5dfa68c5 | 293 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(input->GetModuleID()); |
294 | AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse(); | |
295 | const char *option=res->ZeroSuppOption(); | |
296 | Int_t q=input->GetSignal(); | |
297 | if(!((strstr(option,"1D")) || (strstr(option,"2D")))){ | |
298 | Float_t baseline = cal->GetBaseline(input->GetCoord1()); | |
299 | if(q>baseline) q-=(Int_t)baseline; | |
300 | else q=0; | |
301 | } | |
302 | if(q>=cal->GetThresholdAnode(input->GetCoord1())) { | |
303 | Int_t iz = input->GetCoord1()+1; | |
304 | //Int_t side = ((iz <= fNzSDD) ? 0 : 1); | |
305 | Int_t side = ((AliITSRawStreamSDD*)input)->GetChannel(); | |
306 | // iz -= side*fNzSDD; | |
307 | Int_t index = (input->GetCoord2()+1) * kNzBins + iz; | |
308 | bins[side][index].SetQ(q); | |
309 | bins[side][index].SetMask(1); | |
310 | bins[side][index].SetIndex(index); | |
311 | } | |
04366a57 | 312 | } |
313 | } | |
4b59acab | 314 | delete [] bins[0]; |
315 | delete [] bins[1]; | |
04366a57 | 316 | |
317 | Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD); | |
04366a57 | 318 | } |
319 | ||
320 | ||
5bfe44ce | 321 | //_________________________________________________________________________ |
322 | void AliITSClusterFinderV2SDD::CorrectPosition(Float_t &z, Float_t&y){ | |
323 | ||
324 | //correction of coordinates using the maps stored in the DB | |
325 | ||
326 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule); | |
a97b3678 | 327 | static const Int_t knbint = cal->GetMapTimeNBin(); |
328 | static const Int_t knbina = cal->Chips()*cal->Channels(); | |
5bfe44ce | 329 | Float_t stepa = (GetSeg()->Dpz(0))/10000.; //anode pitch in cm |
330 | Float_t stept = (GetSeg()->Dx()/cal->GetMapTimeNBin()/2.)/10.; | |
404c1c29 | 331 | |
332 | Int_t bint = TMath::Abs((Int_t)(y/stept)); | |
a97b3678 | 333 | if(y>=0) bint+=(Int_t)(knbint/2.); |
334 | if(bint>knbint) AliError("Wrong bin number!"); | |
5bfe44ce | 335 | |
404c1c29 | 336 | Int_t bina = TMath::Abs((Int_t)(z/stepa)); |
a97b3678 | 337 | if(z>=0) bina+=(Int_t)(knbina/2.); |
338 | if(bina>knbina) AliError("Wrong bin number!"); | |
5bfe44ce | 339 | |
340 | Float_t devz = cal->GetMapACell(bina,bint)/10000.; | |
341 | Float_t devx = cal->GetMapTCell(bina,bint)/10000.; | |
404c1c29 | 342 | z+=devz; |
343 | y+=devx; | |
5bfe44ce | 344 | |
345 | ||
346 | } |