]>
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 | **************************************************************************/ | |
15 | //////////////////////////////////////////////////////////////////////////// | |
16 | // Implementation of the ITS clusterer V2 class // | |
17 | // // | |
18 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch // | |
d6d232ba | 19 | // Unfolding switch from AliITSRecoParam: D. Elia, INFN Bari // |
04366a57 | 20 | // // |
d6d232ba | 21 | //////////////////////////////////////////////////////////////////////////// |
04366a57 | 22 | |
04366a57 | 23 | |
24 | #include "AliITSClusterFinderV2SPD.h" | |
00a7cc50 | 25 | #include "AliITSRecPoint.h" |
1f3e997f | 26 | #include "AliITSgeomTGeo.h" |
7d62fb64 | 27 | #include "AliITSDetTypeRec.h" |
d6d232ba | 28 | #include "AliITSReconstructor.h" |
04366a57 | 29 | #include "AliRawReader.h" |
30 | #include "AliITSRawStreamSPD.h" | |
04366a57 | 31 | #include <TClonesArray.h> |
04366a57 | 32 | #include "AliITSdigitSPD.h" |
33 | ||
34 | ClassImp(AliITSClusterFinderV2SPD) | |
35 | ||
e56160b8 | 36 | AliITSClusterFinderV2SPD::AliITSClusterFinderV2SPD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp), |
1f3e997f | 37 | fLastSPD1(AliITSgeomTGeo::GetModuleIndex(2,1,1)-1), |
e56160b8 | 38 | fNySPD(256), |
39 | fNzSPD(160), | |
40 | fYpitchSPD(0.0050), | |
41 | fZ1pitchSPD(0.0425), | |
42 | fZ2pitchSPD(0.0625), | |
43 | fHwSPD(0.64), | |
44 | fHlSPD(3.48){ | |
04366a57 | 45 | |
46 | //Default constructor | |
04366a57 | 47 | |
04366a57 | 48 | fYSPD[0]=0.5*fYpitchSPD; |
49 | for (Int_t m=1; m<fNySPD; m++) fYSPD[m]=fYSPD[m-1]+fYpitchSPD; | |
50 | fZSPD[0]=fZ1pitchSPD; | |
51 | for (Int_t m=1; m<fNzSPD; m++) { | |
52 | Double_t dz=fZ1pitchSPD; | |
53 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || | |
54 | m==127 || m==128) dz=fZ2pitchSPD; | |
55 | fZSPD[m]=fZSPD[m-1]+dz; | |
56 | } | |
57 | for (Int_t m=0; m<fNzSPD; m++) { | |
58 | Double_t dz=0.5*fZ1pitchSPD; | |
59 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || | |
60 | m==127 || m==128) dz=0.5*fZ2pitchSPD; | |
61 | fZSPD[m]-=dz; | |
62 | } | |
63 | ||
64 | } | |
65 | ||
66 | ||
67 | void AliITSClusterFinderV2SPD::FindRawClusters(Int_t mod){ | |
68 | ||
69 | //Find clusters V2 | |
70 | SetModule(mod); | |
71 | FindClustersSPD(fDigits); | |
72 | ||
73 | } | |
74 | ||
75 | void AliITSClusterFinderV2SPD::RawdataToClusters(AliRawReader* rawReader, TClonesArray** clusters){ | |
76 | //------------------------------------------------------------ | |
77 | // This function creates ITS clusters from raw data | |
78 | //------------------------------------------------------------ | |
79 | rawReader->Reset(); | |
80 | AliITSRawStreamSPD inputSPD(rawReader); | |
81 | FindClustersSPD(&inputSPD, clusters); | |
82 | ||
83 | } | |
84 | ||
85 | Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,TClonesArray* clusters,Int_t maxBins,Int_t nzbins,Int_t iModule,Bool_t rawdata){ | |
86 | ||
87 | //Cluster finder for SPD (from digits and from rawdata) | |
88 | ||
5c47990a | 89 | static AliITSRecoParam *repa = NULL; |
90 | if(!repa){ | |
91 | repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam(); | |
92 | if(!repa){ | |
93 | repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParamDefault(); | |
94 | AliWarning("Using default AliITSRecoParam class"); | |
95 | } | |
96 | } | |
b4704be3 | 97 | const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(iModule); |
98 | ||
04366a57 | 99 | Int_t nclu=0; |
100 | for(Int_t iBin =0; iBin < maxBins;iBin++){ | |
101 | if(bins[iBin].IsUsed()) continue; | |
102 | Int_t nBins = 0; | |
103 | Int_t idxBins[200]; | |
104 | FindCluster(iBin,nzbins,bins,nBins,idxBins); | |
105 | if (nBins == 200){ | |
106 | Error("ClustersSPD","SPD Too big cluster !\n"); | |
107 | continue; | |
108 | } | |
109 | Int_t milab[10]; | |
110 | for(Int_t ilab=0;ilab<10;ilab++){ | |
111 | milab[ilab]=-2; | |
112 | } | |
113 | if(rawdata){ | |
114 | milab[3]=fNdet[iModule]; | |
115 | } | |
116 | Int_t ymin,ymax,zmin,zmax; | |
117 | if(rawdata){ | |
118 | ymin = (idxBins[0] / nzbins) - 1; | |
119 | ymax = ymin; | |
120 | zmin = (idxBins[0] % nzbins) - 1; | |
121 | zmax = zmin; | |
122 | } | |
123 | else{ | |
124 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[0]); | |
125 | ymin=dig->GetCoord2(); | |
126 | ymax=ymin; | |
127 | zmin=dig->GetCoord1(); | |
128 | zmax=zmin; | |
129 | } | |
130 | for (Int_t idx = 0; idx < nBins; idx++) { | |
131 | Int_t iy; | |
132 | Int_t iz; | |
133 | if(rawdata){ | |
134 | iy = (idxBins[idx] / nzbins) - 1; | |
135 | iz = (idxBins[idx] % nzbins) - 1; | |
136 | } | |
137 | else{ | |
138 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); | |
139 | iy = dig->GetCoord2(); | |
140 | iz = dig->GetCoord1(); | |
141 | } | |
142 | if (ymin > iy) ymin = iy; | |
143 | if (ymax < iy) ymax = iy; | |
144 | if (zmin > iz) zmin = iz; | |
145 | if (zmax < iz) zmax = iz; | |
146 | ||
147 | } | |
148 | if(!rawdata){ | |
149 | for(Int_t l=0;l<nBins;l++){ | |
150 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[l]); | |
151 | for(Int_t dlab=0;dlab<10;dlab++){ | |
152 | Int_t digitlab = (dig->GetTracks())[dlab]; | |
153 | if(digitlab<0) continue; | |
154 | AddLabel(milab,digitlab); | |
155 | } | |
156 | if (milab[9]>0) CheckLabels2(milab); | |
157 | } | |
158 | CheckLabels2(milab); | |
159 | } | |
160 | ||
161 | Int_t idy =0; //max 2 clusters | |
162 | if((iModule <= fLastSPD1) &&idy<3) idy=3; | |
163 | if((iModule > fLastSPD1) &&idy<4) idy=4; | |
164 | Int_t idz=3; | |
d6d232ba | 165 | |
166 | // Switch the unfolding OFF/ON | |
5c47990a | 167 | if(!repa->GetUseUnfoldingInClusterFinderSPD()) { |
d6d232ba | 168 | idy=ymax-ymin+1; |
169 | idz=zmax-zmin+1; | |
170 | } | |
171 | ||
04366a57 | 172 | for(Int_t iiz=zmin; iiz<=zmax;iiz+=idz){ |
173 | for(Int_t iiy=ymin;iiy<=ymax;iiy+=idy){ | |
174 | ||
175 | Int_t ndigits=0; | |
176 | Float_t y=0.,z=0.,q=0.; | |
177 | for(Int_t idx=0;idx<nBins;idx++){ | |
178 | Int_t iy; | |
179 | Int_t iz; | |
180 | if(rawdata){ | |
181 | iy = (idxBins[idx] / nzbins)-1; | |
182 | iz = (idxBins[idx] % nzbins)-1; | |
183 | } | |
184 | else{ | |
185 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); | |
186 | iy = dig->GetCoord2(); | |
187 | iz = dig->GetCoord1(); | |
188 | } | |
189 | if(zmax-zmin>=idz || ymax-ymin>=idy){ | |
190 | if(TMath::Abs(iy-iiy)>0.75*idy) continue; | |
191 | if(TMath::Abs(iz-iiz)>0.75*idz) continue; | |
192 | } | |
193 | ndigits++; | |
194 | Float_t qBin; | |
195 | if(rawdata) qBin = bins[idxBins[idx]].GetQ(); | |
196 | if(!rawdata){ | |
197 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); | |
198 | qBin = (Float_t)dig->GetSignal(); | |
199 | } | |
200 | y+= qBin * fYSPD[iy]; | |
201 | z+= qBin * fZSPD[iz]; | |
202 | q+= qBin; | |
203 | }// for idx | |
204 | if(ndigits==0) continue; | |
205 | y /= q; | |
206 | z /= q; | |
207 | y -= fHwSPD; | |
208 | z -= fHlSPD; | |
1f3e997f | 209 | |
b4704be3 | 210 | Float_t hit[5]; //y,z,sigma(y)^2, sigma(z)^2, charge |
211 | { | |
212 | Double_t loc[3]={y,0.,z},trk[3]={0.,0.,0.}; | |
213 | mT2L->MasterToLocal(loc,trk); | |
214 | hit[0]=trk[1]; | |
215 | hit[1]=trk[2]; | |
216 | } | |
04366a57 | 217 | hit[2] = fYpitchSPD*fYpitchSPD/12.; |
218 | hit[3] = fZ1pitchSPD*fZ1pitchSPD/12.; | |
00a7cc50 | 219 | hit[4] = 1.; |
b4704be3 | 220 | |
04366a57 | 221 | if(!rawdata) milab[3]=fNdet[iModule]; |
222 | Int_t info[3] = {ymax-ymin+1,zmax-zmin+1,fNlayer[iModule]}; | |
223 | if(!rawdata){ | |
75fb37cc | 224 | AliITSRecPoint cl(milab,hit,info); |
00a7cc50 | 225 | fDetTypeRec->AddRecPoint(cl); |
04366a57 | 226 | } |
227 | else{ | |
228 | Int_t label[4]={milab[0],milab[1],milab[2],milab[3]}; | |
229 | new (clusters->AddrAt(nclu)) | |
75fb37cc | 230 | AliITSRecPoint(label, hit,info); |
04366a57 | 231 | } |
232 | nclu++; | |
233 | }// for iiy | |
234 | }// for iiz | |
235 | }//end for iBin | |
236 | return nclu; | |
237 | ||
238 | } | |
239 | ||
240 | ||
241 | ||
242 | ||
243 | void AliITSClusterFinderV2SPD::FindClustersSPD(AliITSRawStream* input, | |
244 | TClonesArray** clusters) | |
245 | { | |
246 | //------------------------------------------------------------ | |
247 | // Actual SPD cluster finder for raw data | |
248 | //------------------------------------------------------------ | |
249 | Int_t nClustersSPD = 0; | |
250 | Int_t kNzBins = fNzSPD + 2; | |
251 | Int_t kNyBins = fNySPD + 2; | |
252 | Int_t kMaxBin = kNzBins * kNyBins; | |
d7d9347b | 253 | AliBin *binsSPD = new AliBin[kMaxBin]; |
254 | AliBin *binsSPDInit = new AliBin[kMaxBin]; | |
04366a57 | 255 | AliBin* bins = NULL; |
256 | ||
257 | // read raw data input stream | |
258 | while (kTRUE) { | |
259 | Bool_t next = input->Next(); | |
260 | if (!next || input->IsNewModule()) { | |
261 | Int_t iModule = input->GetPrevModuleID(); | |
262 | ||
263 | // when all data from a module was read, search for clusters | |
264 | if (bins) { | |
00a7cc50 | 265 | clusters[iModule] = new TClonesArray("AliITSRecPoint"); |
04366a57 | 266 | Int_t nClusters = ClustersSPD(bins,0,clusters[iModule],kMaxBin,kNzBins,iModule,kTRUE); |
267 | nClustersSPD += nClusters; | |
d7d9347b | 268 | bins = NULL; |
04366a57 | 269 | } |
270 | ||
271 | if (!next) break; | |
d7d9347b | 272 | bins = binsSPD; |
273 | memcpy(binsSPD,binsSPDInit,sizeof(AliBin)*kMaxBin); | |
04366a57 | 274 | } |
275 | ||
276 | // fill the current digit into the bins array | |
277 | Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1); | |
278 | bins[index].SetIndex(index); | |
279 | bins[index].SetMask(1); | |
280 | bins[index].SetQ(1); | |
281 | } | |
282 | ||
d7d9347b | 283 | delete [] binsSPDInit; |
284 | delete [] binsSPD; | |
285 | ||
5c47990a | 286 | AliDebug(1,Form("found clusters in ITS SPD: %d", nClustersSPD)); |
04366a57 | 287 | } |
288 | ||
289 | ||
290 | ||
291 | void AliITSClusterFinderV2SPD::FindClustersSPD(TClonesArray *digits) { | |
292 | //------------------------------------------------------------ | |
293 | // Actual SPD cluster finder | |
294 | //------------------------------------------------------------ | |
295 | ||
296 | ||
297 | Int_t kNzBins = fNzSPD + 2; | |
298 | const Int_t kMAXBIN=kNzBins*(fNySPD+2); | |
299 | ||
300 | Int_t ndigits=digits->GetEntriesFast(); | |
301 | AliBin *bins=new AliBin[kMAXBIN]; | |
302 | ||
303 | Int_t k; | |
304 | AliITSdigitSPD *d=0; | |
305 | for (k=0; k<ndigits; k++) { | |
306 | d=(AliITSdigitSPD*)digits->UncheckedAt(k); | |
307 | Int_t i=d->GetCoord2()+1; //y | |
308 | Int_t j=d->GetCoord1()+1; | |
309 | Int_t index=i*kNzBins+j; | |
310 | bins[index].SetIndex(k); | |
311 | bins[index].SetMask(1); | |
312 | } | |
313 | ||
d6d232ba | 314 | Int_t nClustersSPD = ClustersSPD(bins,digits,0,kMAXBIN,kNzBins,fModule,kFALSE); |
04366a57 | 315 | delete [] bins; |
d6d232ba | 316 | |
5c47990a | 317 | AliDebug(1,Form("found clusters in ITS SPD: %d", nClustersSPD)); |
04366a57 | 318 | } |
319 | ||
320 |