]>
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 | ||
b4704be3 | 87 | const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(iModule); |
88 | ||
04366a57 | 89 | Int_t nclu=0; |
90 | for(Int_t iBin =0; iBin < maxBins;iBin++){ | |
91 | if(bins[iBin].IsUsed()) continue; | |
92 | Int_t nBins = 0; | |
93 | Int_t idxBins[200]; | |
94 | FindCluster(iBin,nzbins,bins,nBins,idxBins); | |
95 | if (nBins == 200){ | |
96 | Error("ClustersSPD","SPD Too big cluster !\n"); | |
97 | continue; | |
98 | } | |
99 | Int_t milab[10]; | |
100 | for(Int_t ilab=0;ilab<10;ilab++){ | |
101 | milab[ilab]=-2; | |
102 | } | |
103 | if(rawdata){ | |
104 | milab[3]=fNdet[iModule]; | |
105 | } | |
106 | Int_t ymin,ymax,zmin,zmax; | |
107 | if(rawdata){ | |
108 | ymin = (idxBins[0] / nzbins) - 1; | |
109 | ymax = ymin; | |
110 | zmin = (idxBins[0] % nzbins) - 1; | |
111 | zmax = zmin; | |
112 | } | |
113 | else{ | |
114 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[0]); | |
115 | ymin=dig->GetCoord2(); | |
116 | ymax=ymin; | |
117 | zmin=dig->GetCoord1(); | |
118 | zmax=zmin; | |
119 | } | |
120 | for (Int_t idx = 0; idx < nBins; idx++) { | |
121 | Int_t iy; | |
122 | Int_t iz; | |
123 | if(rawdata){ | |
124 | iy = (idxBins[idx] / nzbins) - 1; | |
125 | iz = (idxBins[idx] % nzbins) - 1; | |
126 | } | |
127 | else{ | |
128 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); | |
129 | iy = dig->GetCoord2(); | |
130 | iz = dig->GetCoord1(); | |
131 | } | |
132 | if (ymin > iy) ymin = iy; | |
133 | if (ymax < iy) ymax = iy; | |
134 | if (zmin > iz) zmin = iz; | |
135 | if (zmax < iz) zmax = iz; | |
136 | ||
137 | } | |
138 | if(!rawdata){ | |
139 | for(Int_t l=0;l<nBins;l++){ | |
140 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[l]); | |
141 | for(Int_t dlab=0;dlab<10;dlab++){ | |
142 | Int_t digitlab = (dig->GetTracks())[dlab]; | |
143 | if(digitlab<0) continue; | |
144 | AddLabel(milab,digitlab); | |
145 | } | |
146 | if (milab[9]>0) CheckLabels2(milab); | |
147 | } | |
148 | CheckLabels2(milab); | |
149 | } | |
150 | ||
151 | Int_t idy =0; //max 2 clusters | |
152 | if((iModule <= fLastSPD1) &&idy<3) idy=3; | |
153 | if((iModule > fLastSPD1) &&idy<4) idy=4; | |
154 | Int_t idz=3; | |
155 | for(Int_t iiz=zmin; iiz<=zmax;iiz+=idz){ | |
156 | for(Int_t iiy=ymin;iiy<=ymax;iiy+=idy){ | |
157 | ||
158 | Int_t ndigits=0; | |
159 | Float_t y=0.,z=0.,q=0.; | |
160 | for(Int_t idx=0;idx<nBins;idx++){ | |
161 | Int_t iy; | |
162 | Int_t iz; | |
163 | if(rawdata){ | |
164 | iy = (idxBins[idx] / nzbins)-1; | |
165 | iz = (idxBins[idx] % nzbins)-1; | |
166 | } | |
167 | else{ | |
168 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); | |
169 | iy = dig->GetCoord2(); | |
170 | iz = dig->GetCoord1(); | |
171 | } | |
172 | if(zmax-zmin>=idz || ymax-ymin>=idy){ | |
173 | if(TMath::Abs(iy-iiy)>0.75*idy) continue; | |
174 | if(TMath::Abs(iz-iiz)>0.75*idz) continue; | |
175 | } | |
176 | ndigits++; | |
177 | Float_t qBin; | |
178 | if(rawdata) qBin = bins[idxBins[idx]].GetQ(); | |
179 | if(!rawdata){ | |
180 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); | |
181 | qBin = (Float_t)dig->GetSignal(); | |
182 | } | |
183 | y+= qBin * fYSPD[iy]; | |
184 | z+= qBin * fZSPD[iz]; | |
185 | q+= qBin; | |
186 | }// for idx | |
187 | if(ndigits==0) continue; | |
188 | y /= q; | |
189 | z /= q; | |
190 | y -= fHwSPD; | |
191 | z -= fHlSPD; | |
1f3e997f | 192 | |
b4704be3 | 193 | Float_t hit[5]; //y,z,sigma(y)^2, sigma(z)^2, charge |
194 | { | |
195 | Double_t loc[3]={y,0.,z},trk[3]={0.,0.,0.}; | |
196 | mT2L->MasterToLocal(loc,trk); | |
197 | hit[0]=trk[1]; | |
198 | hit[1]=trk[2]; | |
199 | } | |
04366a57 | 200 | hit[2] = fYpitchSPD*fYpitchSPD/12.; |
201 | hit[3] = fZ1pitchSPD*fZ1pitchSPD/12.; | |
00a7cc50 | 202 | hit[4] = 1.; |
b4704be3 | 203 | |
04366a57 | 204 | if(!rawdata) milab[3]=fNdet[iModule]; |
205 | Int_t info[3] = {ymax-ymin+1,zmax-zmin+1,fNlayer[iModule]}; | |
206 | if(!rawdata){ | |
75fb37cc | 207 | AliITSRecPoint cl(milab,hit,info); |
00a7cc50 | 208 | fDetTypeRec->AddRecPoint(cl); |
04366a57 | 209 | } |
210 | else{ | |
211 | Int_t label[4]={milab[0],milab[1],milab[2],milab[3]}; | |
212 | new (clusters->AddrAt(nclu)) | |
75fb37cc | 213 | AliITSRecPoint(label, hit,info); |
04366a57 | 214 | } |
215 | nclu++; | |
216 | }// for iiy | |
217 | }// for iiz | |
218 | }//end for iBin | |
219 | return nclu; | |
220 | ||
221 | } | |
222 | ||
223 | ||
224 | ||
225 | ||
226 | void AliITSClusterFinderV2SPD::FindClustersSPD(AliITSRawStream* input, | |
227 | TClonesArray** clusters) | |
228 | { | |
229 | //------------------------------------------------------------ | |
230 | // Actual SPD cluster finder for raw data | |
231 | //------------------------------------------------------------ | |
232 | Int_t nClustersSPD = 0; | |
233 | Int_t kNzBins = fNzSPD + 2; | |
234 | Int_t kNyBins = fNySPD + 2; | |
235 | Int_t kMaxBin = kNzBins * kNyBins; | |
d7d9347b | 236 | AliBin *binsSPD = new AliBin[kMaxBin]; |
237 | AliBin *binsSPDInit = new AliBin[kMaxBin]; | |
04366a57 | 238 | AliBin* bins = NULL; |
239 | ||
240 | // read raw data input stream | |
241 | while (kTRUE) { | |
242 | Bool_t next = input->Next(); | |
243 | if (!next || input->IsNewModule()) { | |
244 | Int_t iModule = input->GetPrevModuleID(); | |
245 | ||
246 | // when all data from a module was read, search for clusters | |
247 | if (bins) { | |
00a7cc50 | 248 | clusters[iModule] = new TClonesArray("AliITSRecPoint"); |
04366a57 | 249 | Int_t nClusters = ClustersSPD(bins,0,clusters[iModule],kMaxBin,kNzBins,iModule,kTRUE); |
250 | nClustersSPD += nClusters; | |
d7d9347b | 251 | bins = NULL; |
04366a57 | 252 | } |
253 | ||
254 | if (!next) break; | |
d7d9347b | 255 | bins = binsSPD; |
256 | memcpy(binsSPD,binsSPDInit,sizeof(AliBin)*kMaxBin); | |
04366a57 | 257 | } |
258 | ||
259 | // fill the current digit into the bins array | |
260 | Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1); | |
261 | bins[index].SetIndex(index); | |
262 | bins[index].SetMask(1); | |
263 | bins[index].SetQ(1); | |
264 | } | |
265 | ||
d7d9347b | 266 | delete [] binsSPDInit; |
267 | delete [] binsSPD; | |
268 | ||
04366a57 | 269 | Info("FindClustersSPD", "found clusters in ITS SPD: %d", nClustersSPD); |
270 | } | |
271 | ||
272 | ||
273 | ||
274 | void AliITSClusterFinderV2SPD::FindClustersSPD(TClonesArray *digits) { | |
275 | //------------------------------------------------------------ | |
276 | // Actual SPD cluster finder | |
277 | //------------------------------------------------------------ | |
278 | ||
279 | ||
280 | Int_t kNzBins = fNzSPD + 2; | |
281 | const Int_t kMAXBIN=kNzBins*(fNySPD+2); | |
282 | ||
283 | Int_t ndigits=digits->GetEntriesFast(); | |
284 | AliBin *bins=new AliBin[kMAXBIN]; | |
285 | ||
286 | Int_t k; | |
287 | AliITSdigitSPD *d=0; | |
288 | for (k=0; k<ndigits; k++) { | |
289 | d=(AliITSdigitSPD*)digits->UncheckedAt(k); | |
290 | Int_t i=d->GetCoord2()+1; //y | |
291 | Int_t j=d->GetCoord1()+1; | |
292 | Int_t index=i*kNzBins+j; | |
293 | bins[index].SetIndex(k); | |
294 | bins[index].SetMask(1); | |
295 | } | |
296 | ||
297 | ClustersSPD(bins,digits,0,kMAXBIN,kNzBins,fModule,kFALSE); | |
298 | delete [] bins; | |
299 | } | |
300 | ||
301 |