]>
Commit | Line | Data |
---|---|---|
4c503756 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | /* | |
17 | $Log$ | |
70479d0e | 18 | Revision 1.11 2001/11/28 16:34:01 morsch |
19 | In DC, fNDiv, fDpxD set to 0. | |
20 | ||
81a0c7bd | 21 | Revision 1.10 2001/05/16 14:57:17 alibrary |
22 | New files for folders and Stack | |
23 | ||
9e1a0ddb | 24 | Revision 1.9 2001/01/26 21:25:48 morsch |
25 | Empty default constructors and. | |
26 | ||
e9e4cdf2 | 27 | Revision 1.8 2001/01/17 20:53:40 hristov |
28 | Destructors corrected to avoid memory leaks | |
29 | ||
c2c0190f | 30 | Revision 1.7 2000/12/21 22:12:41 morsch |
31 | Clean-up of coding rule violations, | |
32 | ||
de05461e | 33 | Revision 1.6 2000/11/06 09:20:43 morsch |
34 | AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the | |
35 | Draw() method. This avoids code and parameter replication. | |
36 | ||
aaf4addd | 37 | Revision 1.5 2000/10/26 19:32:04 morsch |
38 | Problem with iteration over y-pads for 2nd cathode corrected. | |
39 | ||
d4ee3c3e | 40 | Revision 1.4 2000/10/25 19:56:55 morsch |
41 | Handle correctly slats with less than 3 segmentation zones. | |
42 | ||
f30dea32 | 43 | Revision 1.3 2000/10/22 16:56:32 morsch |
44 | - Store chamber number as slat id. | |
45 | ||
de2f6d11 | 46 | Revision 1.2 2000/10/18 11:42:06 morsch |
47 | - AliMUONRawCluster contains z-position. | |
48 | - Some clean-up of useless print statements during initialisations. | |
49 | ||
3e1872ed | 50 | Revision 1.1 2000/10/06 08:59:03 morsch |
51 | Segmentation classes for bending and non bending plane slat modules (A. de Falco, A. Morsch) | |
52 | ||
4c503756 | 53 | */ |
54 | ||
55 | ///////////////////////////////////////////////////// | |
56 | // Segmentation classes for slat modules // | |
57 | // to be used with AluMUONSegmentationSlat // | |
58 | ///////////////////////////////////////////////////// | |
59 | ||
60 | ||
61 | #include "AliMUONSegmentationSlatModule.h" | |
aaf4addd | 62 | #include "AliRun.h" |
63 | #include "AliMUON.h" | |
4c503756 | 64 | #include <TMath.h> |
70479d0e | 65 | #include <Riostream.h> |
4c503756 | 66 | |
67 | #include "AliMUONSegmentationV01.h" | |
68 | ||
69 | //___________________________________________ | |
70 | ClassImp(AliMUONSegmentationSlatModule) | |
71 | ||
72 | AliMUONSegmentationSlatModule::AliMUONSegmentationSlatModule() | |
73 | { | |
74 | // Default constructor | |
81a0c7bd | 75 | fNDiv = 0; |
76 | fDpxD = 0; | |
e9e4cdf2 | 77 | } |
78 | ||
79 | AliMUONSegmentationSlatModule::AliMUONSegmentationSlatModule(Int_t nsec) | |
80 | { | |
81 | // Non default constructor | |
82 | fNsec = nsec; | |
4c503756 | 83 | fNDiv = new TArrayI(fNsec); |
84 | fDpxD = new TArrayF(fNsec); | |
85 | (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0; | |
86 | (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0; | |
e9e4cdf2 | 87 | } |
88 | ||
89 | AliMUONSegmentationSlatModule::~AliMUONSegmentationSlatModule() | |
90 | { | |
91 | // Destructor | |
92 | if (fNDiv) delete fNDiv; | |
93 | if (fDpxD) delete fDpxD; | |
4c503756 | 94 | } |
95 | ||
96 | void AliMUONSegmentationSlatModule::SetPcbBoards(Int_t n[4]) | |
97 | { | |
98 | // | |
99 | // Set Pcb Board segmentation zones | |
100 | for (Int_t i=0; i<4; i++) fPcbBoards[i]=n[i]; | |
101 | } | |
102 | ||
103 | ||
104 | void AliMUONSegmentationSlatModule::SetPadDivision(Int_t ndiv[4]) | |
105 | { | |
106 | // | |
107 | // Defines the pad size perp. to the anode wire (y) for different sectors. | |
108 | // Pad sizes are defined as integral fractions ndiv of a basis pad size | |
109 | // fDpx | |
110 | // | |
111 | for (Int_t i=0; i<4; i++) { | |
112 | (*fNDiv)[i]=ndiv[i]; | |
113 | } | |
114 | ndiv[0]=ndiv[1]; | |
115 | } | |
116 | ||
117 | Float_t AliMUONSegmentationSlatModule::Dpx(Int_t isec) const | |
118 | { | |
119 | // Return x-strip width | |
120 | return (*fDpxD)[isec]; | |
121 | } | |
122 | ||
123 | ||
124 | Float_t AliMUONSegmentationSlatModule::Dpy(Int_t isec) const | |
125 | { | |
126 | // Return y-strip width | |
127 | ||
128 | return fDpy; | |
129 | } | |
130 | ||
131 | ||
132 | void AliMUONSegmentationSlatModule:: | |
133 | GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy) | |
134 | { | |
135 | // Returns pad coordinates (ix,iy) for given real coordinates (x,y) | |
136 | // | |
137 | iy = Int_t(y/fDpy)+1; | |
138 | if (iy > fNpy) iy= fNpy; | |
139 | // | |
140 | // Find sector isec | |
141 | ||
142 | Int_t isec=-1; | |
143 | for (Int_t i=fNsec-1; i > 0; i--) { | |
144 | if (x >= fCx[i-1]) { | |
145 | isec=i; | |
f30dea32 | 146 | if (fCx[isec] == fCx[isec-1] && isec > 1) isec--; |
4c503756 | 147 | break; |
148 | } | |
149 | } | |
150 | ||
151 | if (isec>0) { | |
152 | ix= Int_t((x-fCx[isec-1])/(*fDpxD)[isec]) | |
153 | +fNpxS[isec-1]+1; | |
154 | } else if (isec == 0) { | |
155 | ix= Int_t(x/(*fDpxD)[isec])+1; | |
156 | } else { | |
157 | ix=0; | |
158 | iy=0; | |
159 | } | |
160 | } | |
161 | ||
162 | void AliMUONSegmentationSlatModule:: | |
163 | GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y) | |
164 | { | |
165 | // Returns real coordinates (x,y) for given pad coordinates (ix,iy) | |
166 | // | |
167 | y = Float_t(iy*fDpy)-fDpy/2.; | |
168 | // | |
169 | // Find sector isec | |
170 | Int_t isec=AliMUONSegmentationSlatModule::Sector(ix,iy); | |
de2f6d11 | 171 | if (isec == -1) printf("\n PadC %d %d %d %d \n ", isec, fId, ix, iy); |
4c503756 | 172 | // |
173 | if (isec>0) { | |
174 | x = fCx[isec-1]+(ix-fNpxS[isec-1])*(*fDpxD)[isec]; | |
175 | x = x-(*fDpxD)[isec]/2; | |
176 | } else { | |
177 | x=y=0; | |
178 | } | |
179 | } | |
180 | ||
181 | void AliMUONSegmentationSlatModule:: | |
182 | SetPad(Int_t ix, Int_t iy) | |
183 | { | |
184 | // | |
185 | // Sets virtual pad coordinates, needed for evaluating pad response | |
186 | // outside the tracking program | |
187 | GetPadC(ix,iy,fX,fY); | |
188 | fSector=Sector(ix,iy); | |
189 | } | |
190 | ||
191 | void AliMUONSegmentationSlatModule:: | |
192 | SetHit(Float_t x, Float_t y) | |
193 | { | |
de05461e | 194 | // Set current hit |
195 | // | |
4c503756 | 196 | fXhit = x; |
197 | fYhit = y; | |
198 | ||
199 | if (x < 0) fXhit = 0; | |
200 | if (y < 0) fYhit = 0; | |
201 | ||
202 | if (x >= fCx[fNsec-1]) fXhit = fCx[fNsec-1]; | |
203 | if (y >= fDyPCB) fYhit = fDyPCB; | |
204 | ||
205 | ||
206 | } | |
207 | ||
208 | ||
209 | void AliMUONSegmentationSlatModule:: | |
210 | FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy) | |
211 | { | |
212 | // Initialises iteration over pads for charge distribution algorithm | |
213 | // | |
214 | // | |
215 | // Find the wire position (center of charge distribution) | |
216 | Float_t x0a=GetAnod(xhit); | |
217 | fXhit=x0a; | |
218 | fYhit=yhit; | |
219 | // | |
220 | // and take fNsigma*sigma around this center | |
221 | Float_t x01=x0a - dx; | |
222 | Float_t x02=x0a + dx; | |
223 | Float_t y01=yhit - dy; | |
224 | Float_t y02=yhit + dy; | |
4c503756 | 225 | if (x01 < 0) x01 = 0; |
226 | if (y01 < 0) y01 = 0; | |
f30dea32 | 227 | |
228 | if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1]; | |
d4ee3c3e | 229 | |
4c503756 | 230 | |
f30dea32 | 231 | |
4c503756 | 232 | Int_t isec=-1; |
233 | for (Int_t i=fNsec-1; i > 0; i--) { | |
234 | if (x02 >= fCx[i-1]) { | |
235 | isec=i; | |
f30dea32 | 236 | if (fCx[isec] == fCx[isec-1] && isec > 1) isec--; |
4c503756 | 237 | break; |
238 | } | |
239 | } | |
d4ee3c3e | 240 | y02 += Dpy(isec); |
241 | if (y02 >= fDyPCB) y02 = fDyPCB; | |
4c503756 | 242 | |
4c503756 | 243 | // |
244 | // find the pads over which the charge distributes | |
245 | GetPadI(x01,y01,fIxmin,fIymin); | |
246 | GetPadI(x02,y02,fIxmax,fIymax); | |
f30dea32 | 247 | |
4c503756 | 248 | if (fIxmax > fNpx) fIxmax=fNpx; |
249 | if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec]; | |
d4ee3c3e | 250 | |
4c503756 | 251 | fXmin=x01; |
d4ee3c3e | 252 | fXmax=x02; |
4c503756 | 253 | fYmin=y01; |
d4ee3c3e | 254 | fYmax=y02; |
255 | ||
4c503756 | 256 | // |
257 | // Set current pad to lower left corner | |
258 | if (fIxmax < fIxmin) fIxmax=fIxmin; | |
259 | if (fIymax < fIymin) fIymax=fIymin; | |
260 | fIx=fIxmin; | |
261 | fIy=fIymin; | |
262 | ||
263 | GetPadC(fIx,fIy,fX,fY); | |
264 | fSector=Sector(fIx,fIy); | |
d4ee3c3e | 265 | /* |
266 | printf("\n \n First Pad: %d %d %f %f %d %d %d %f" , | |
267 | fIxmin, fIxmax, fXmin, fXmax, fNpx, fId, isec, Dpy(isec)); | |
268 | printf("\n \n First Pad: %d %d %f %f %d %d %d %f", | |
269 | fIymin, fIymax, fYmin, fYmax, fNpyS[isec], fId, isec, Dpy(isec)); | |
270 | */ | |
4c503756 | 271 | } |
272 | ||
273 | void AliMUONSegmentationSlatModule::NextPad() | |
274 | { | |
275 | // Stepper for the iteration over pads | |
276 | // | |
277 | // Step to next pad in the integration region | |
278 | // step from left to right | |
279 | if (fIx != fIxmax) { | |
280 | fIx++; | |
281 | GetPadC(fIx,fIy,fX,fY); | |
282 | fSector=Sector(fIx,fIy); | |
283 | // step up | |
284 | } else if (fIy != fIymax) { | |
285 | fIx=fIxmin; | |
286 | fIy++; | |
287 | GetPadC(fIx,fIy,fX,fY); | |
288 | fSector=Sector(fIx,fIy); | |
289 | ||
290 | } else { | |
291 | fIx=-1; | |
292 | fIy=-1; | |
293 | } | |
294 | // printf("\n Next Pad %d %d %f %f %d %d %d %d %d ", | |
295 | } | |
296 | ||
297 | ||
298 | Int_t AliMUONSegmentationSlatModule::MorePads() | |
de05461e | 299 | { |
4c503756 | 300 | // Stopping condition for the iterator over pads |
301 | // | |
302 | // Are there more pads in the integration region | |
4c503756 | 303 | |
304 | return (fIx != -1 || fIy != -1); | |
305 | } | |
306 | ||
307 | ||
308 | Int_t AliMUONSegmentationSlatModule::Sector(Int_t ix, Int_t iy) | |
309 | { | |
310 | // | |
311 | // Determine segmentation zone from pad coordinates | |
312 | // | |
313 | Int_t isec=-1; | |
314 | for (Int_t i=0; i < fNsec; i++) { | |
315 | if (ix <= fNpxS[i]) { | |
316 | isec=i; | |
317 | break; | |
318 | } | |
319 | } | |
320 | if (isec == -1) printf("\n Sector: Attention isec ! %d %d %d %d \n", | |
321 | fId, ix, iy,fNpxS[3]); | |
322 | ||
323 | return isec; | |
324 | ||
325 | } | |
326 | ||
327 | void AliMUONSegmentationSlatModule:: | |
328 | IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2) | |
329 | { | |
330 | // Returns integration limits for current pad | |
331 | // | |
332 | ||
333 | x1=fXhit-fX-Dpx(fSector)/2.; | |
334 | x2=x1+Dpx(fSector); | |
335 | y1=fYhit-fY-Dpy(fSector)/2.; | |
336 | y2=y1+Dpy(fSector); | |
337 | // printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector)); | |
338 | ||
339 | } | |
340 | ||
341 | void AliMUONSegmentationSlatModule:: | |
342 | Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]) | |
343 | { | |
344 | // Returns list of next neighbours for given Pad (iX, iY) | |
345 | // | |
346 | // | |
347 | Int_t i=0; | |
348 | // | |
349 | // step right | |
350 | if (iX+1 <= fNpx) { | |
351 | Xlist[i]=iX+1; | |
352 | Ylist[i++]=iY; | |
353 | } | |
354 | // | |
355 | // step left | |
356 | if (iX-1 > 0) { | |
357 | Xlist[i]=iX-1; | |
358 | Ylist[i++]=iY; | |
359 | } | |
360 | ||
361 | // | |
362 | // step up | |
363 | if (iY+1 <= fNpy) { | |
364 | Xlist[i]=iX; | |
365 | Ylist[i++]=iY+1; | |
366 | } | |
367 | // | |
368 | // step down | |
369 | if (iY-1 > 0) { | |
370 | Xlist[i]=iX; | |
371 | Ylist[i++]=iY-1; | |
372 | } | |
373 | ||
374 | *Nlist=i; | |
375 | } | |
376 | ||
377 | ||
378 | void AliMUONSegmentationSlatModule::Init(Int_t chamber) | |
379 | { | |
4c503756 | 380 | // |
381 | // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector | |
382 | // These arrays help in converting from real to pad co-ordinates and | |
383 | // vice versa | |
384 | // | |
385 | // Segmentation is defined by rectangular modules approximating | |
386 | // concentric circles as shown below | |
387 | // | |
388 | // PCB module size in cm | |
9e1a0ddb | 389 | // printf("\n Initialise Segmentation SlatModule \n"); |
de05461e | 390 | |
4c503756 | 391 | fDxPCB=40; |
392 | fDyPCB=40; | |
393 | // | |
394 | // number of pad rows per PCB | |
395 | // | |
396 | Int_t nPyPCB=Int_t(fDyPCB/fDpy); | |
397 | // | |
398 | // maximum number of pad rows | |
399 | fNpy=nPyPCB; | |
400 | // | |
401 | // Calculate padsize along x | |
402 | (*fDpxD)[fNsec-1]=fDpx; | |
403 | if (fNsec > 1) { | |
404 | for (Int_t i=fNsec-2; i>=0; i--){ | |
405 | (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i]; | |
4c503756 | 406 | } |
407 | } | |
408 | // | |
409 | // fill the arrays defining the pad segmentation boundaries | |
410 | // | |
411 | // | |
412 | // Loop over sectors (isec=0 is the dead space surounding the beam pipe) | |
413 | for (Int_t isec=0; isec<4; isec++) { | |
414 | if (isec==0) { | |
415 | fNpxS[0] = 0; | |
416 | fNpyS[0] = 0; | |
417 | fCx[0] = 0; | |
418 | } else { | |
419 | fNpxS[isec]=fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]); | |
420 | fNpyS[isec]=fNpy; | |
421 | fCx[isec]=fCx[isec-1] + fPcbBoards[isec]*fDxPCB; | |
422 | } | |
423 | } // sectors | |
424 | // maximum number of pad rows | |
425 | fNpy=nPyPCB; | |
426 | fNpx=fNpxS[3]; | |
de2f6d11 | 427 | // |
428 | fId = chamber; | |
4c503756 | 429 | } |
430 | ||
431 | ||
432 | ||
433 | ||
434 | ||
435 | ||
436 | ||
437 | ||
438 | ||
439 | ||
440 | ||
441 |