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