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