]>
Commit | Line | Data |
---|---|---|
cc4dcfb0 | 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 | /* $Id$ */ | |
17 | ||
18 | //********************************************************* | |
19 | // Segmentation classes for slat modules | |
20 | // This class works with local coordinates | |
21 | // of the slats via the class AliMUONGeometrySegmentation | |
22 | // This class contains the size of the slats and the | |
23 | // and the differents PCB densities. | |
24 | // (from old AliMUONSegmentationSlatModule) | |
25 | // Gines, Subatech, Nov04 | |
26 | //********************************************************* | |
27 | ||
28 | #include <TArrayI.h> | |
29 | #include <TArrayF.h> | |
30 | #include "AliMUONSt345SlatSegmentation.h" | |
31 | #include "AliLog.h" | |
32 | ||
cc4dcfb0 | 33 | ClassImp(AliMUONSt345SlatSegmentation) |
34 | ||
35 | ||
a713db22 | 36 | AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation() |
37 | : AliMUONVGeometryDESegmentation(), | |
38 | fBending(0), | |
39 | fId(0), | |
40 | fDpx(0), | |
41 | fDpy(0), | |
42 | fNpx(999999), | |
43 | fNpy(999999), | |
44 | fWireD(0.0), | |
45 | fXhit(0.), | |
46 | fYhit(0.), | |
47 | fIx(0), | |
48 | fIy(0), | |
49 | fX(0.), | |
50 | fY(0.), | |
51 | fIxmin(0), | |
52 | fIxmax(0), | |
53 | fIymin(0), | |
54 | fIymax(0) | |
55 | { | |
56 | // default constructor | |
57 | ||
58 | } | |
59 | ||
60 | //___________________________________________ | |
f48459ab | 61 | AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(Bool_t bending) |
fed772f3 | 62 | : AliMUONVGeometryDESegmentation(), |
f48459ab | 63 | fBending(bending), |
64 | fId(0), | |
65 | fDpx(0), | |
66 | fDpy(0), | |
67 | fNpx(999999), | |
68 | fNpy(999999), | |
69 | fWireD(0.25), | |
70 | fXhit(0.), | |
71 | fYhit(0.), | |
72 | fIx(0), | |
73 | fIy(0), | |
74 | fX(0.), | |
75 | fY(0.), | |
76 | fIxmin(0), | |
77 | fIxmax(0), | |
78 | fIymin(0), | |
79 | fIymax(0) | |
cc4dcfb0 | 80 | { |
f48459ab | 81 | // Non default constructor |
cc4dcfb0 | 82 | fNsec = 4; // 4 sector densities at most per slat |
83 | fNDiv = new TArrayI(fNsec); | |
84 | fDpxD = new TArrayF(fNsec); | |
f48459ab | 85 | fDpyD = new TArrayF(fNsec); |
cc4dcfb0 | 86 | (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0; |
87 | (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0; | |
f48459ab | 88 | (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0; |
cc4dcfb0 | 89 | } |
90 | //---------------------------------------------------------------------- | |
fed772f3 | 91 | AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(const AliMUONSt345SlatSegmentation& rhs) |
92 | : AliMUONVGeometryDESegmentation(rhs), | |
93 | fBending(0), | |
94 | fId(0), | |
95 | fDpx(0), | |
96 | fDpy(0), | |
97 | fNpx(999999), | |
98 | fNpy(999999), | |
99 | fWireD(0.25), | |
100 | fXhit(0.), | |
101 | fYhit(0.), | |
102 | fIx(0), | |
103 | fIy(0), | |
104 | fX(0.), | |
105 | fY(0.), | |
106 | fIxmin(0), | |
107 | fIxmax(0), | |
108 | fIymin(0), | |
109 | fIymax(0) | |
cc4dcfb0 | 110 | { |
fed772f3 | 111 | // default constructor |
cc4dcfb0 | 112 | } |
113 | //---------------------------------------------------------------------- | |
114 | AliMUONSt345SlatSegmentation::~AliMUONSt345SlatSegmentation() | |
115 | { | |
f48459ab | 116 | // Destructor |
117 | if (fNDiv) delete fNDiv; | |
118 | if (fDpxD) delete fDpxD; | |
119 | if (fDpyD) delete fDpyD; | |
cc4dcfb0 | 120 | } |
121 | //---------------------------------------------------------------------- | |
122 | AliMUONSt345SlatSegmentation& AliMUONSt345SlatSegmentation::operator=(const AliMUONSt345SlatSegmentation& rhs) | |
123 | { | |
f48459ab | 124 | // Protected assignement operator |
cc4dcfb0 | 125 | if (this == &rhs) return *this; |
126 | AliFatal("Not implemented."); | |
127 | return *this; | |
128 | } | |
129 | ||
130 | ||
131 | //------------------------------------------------------------------------ | |
132 | Float_t AliMUONSt345SlatSegmentation::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y, Int_t * /*dummy*/) | |
133 | { | |
f48459ab | 134 | // Returns the square of the distance between 1 pad |
135 | // labelled by its Channel numbers and a coordinate | |
cc4dcfb0 | 136 | Float_t x,y; |
137 | GetPadC(iX,iY,x,y); | |
138 | return (x-X)*(x-X) + (y-Y)*(y-Y); | |
139 | } | |
140 | //____________________________________________________________________________ | |
141 | Float_t AliMUONSt345SlatSegmentation::Dpx(Int_t isec) const | |
142 | { | |
f48459ab | 143 | // Return x-strip width |
144 | return (*fDpxD)[isec]; | |
cc4dcfb0 | 145 | } |
146 | ||
147 | //____________________________________________________________________________ | |
f48459ab | 148 | Float_t AliMUONSt345SlatSegmentation::Dpy(Int_t isec) const |
cc4dcfb0 | 149 | { |
150 | // Return y-strip width | |
f48459ab | 151 | return (*fDpyD)[isec]; |
cc4dcfb0 | 152 | } |
153 | //_____________________________________________________________________________ | |
154 | Float_t AliMUONSt345SlatSegmentation::GetAnod(Float_t xhit) const | |
155 | { | |
f48459ab | 156 | // Returns for a hit position xhit the position of the nearest anode wire |
157 | Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5; | |
158 | return fWireD*wire; | |
cc4dcfb0 | 159 | } |
cc4dcfb0 | 160 | |
cc4dcfb0 | 161 | |
f48459ab | 162 | |
cc4dcfb0 | 163 | //-------------------------------------------------------------------------------- |
164 | void AliMUONSt345SlatSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y) | |
165 | { | |
166 | if (ix<1 || ix>Npx() || iy<1 || iy>Npy() ){ | |
167 | AliWarning(Form("ix or iy out of boundaries: Npx=%d and Npy=%d",Npx(),Npy())); | |
168 | x=-99999.; y=-99999.; | |
169 | } | |
170 | else { | |
171 | // Returns real coordinates (x,y) for given pad coordinates (ix,iy) | |
cc4dcfb0 | 172 | // Find sector isec |
173 | Int_t isec = Sector(ix,iy); | |
174 | if (isec == -1) printf("\n PadC %d %d %d %d \n ", isec, fId, ix, iy); | |
f48459ab | 175 | if (iy > fNpyS[isec]) { |
176 | x=-99999.; y=-99999.; | |
177 | return; | |
178 | } | |
cc4dcfb0 | 179 | if (isec>0) { |
180 | x = fCx[isec-1]+(ix-fNpxS[isec-1])*(*fDpxD)[isec]; | |
181 | x = x-(*fDpxD)[isec]/2; | |
f48459ab | 182 | y = Float_t(iy*(*fDpyD)[isec])-(*fDpyD)[isec]/2.- fCy; // !!! |
cc4dcfb0 | 183 | } else { |
184 | x=y=0; | |
185 | } | |
186 | } | |
187 | } | |
f48459ab | 188 | |
189 | ||
190 | //_____________________________________________________________________________ | |
191 | void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy) | |
192 | { | |
193 | // Returns pad coordinates (ix,iy) for given real coordinates (x,y) | |
194 | ||
195 | // Find sector isec | |
196 | Int_t isec=-1; | |
197 | for (Int_t i=fNsec-1; i > 0; i--) { | |
198 | if (x >= fCx[i-1]) { | |
199 | isec=i; | |
200 | if (fCx[isec] == fCx[isec-1] && isec > 1) isec--; | |
201 | break; | |
202 | } | |
203 | } | |
204 | ||
205 | if (isec>0) { | |
206 | ix= Int_t((x-fCx[isec-1])/(*fDpxD)[isec]) | |
207 | +fNpxS[isec-1]+1; | |
208 | iy= Int_t((y+fCy)/(*fDpyD)[isec])+1; | |
209 | } else if (isec == 0) { | |
210 | ix= Int_t(x/(*fDpxD)[isec])+1; | |
211 | iy= Int_t((y+fCy)/(*fDpyD)[isec])+1; | |
212 | } else { | |
213 | ix=0; | |
214 | iy=0; | |
215 | } | |
216 | } | |
cc4dcfb0 | 217 | //------------------------------------------------------------------------- |
218 | void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy) | |
219 | { | |
220 | GetPadI(x, y, ix, iy); | |
221 | } | |
222 | //_______________________________________________________________ | |
223 | void AliMUONSt345SlatSegmentation::SetPadDivision(Int_t ndiv[4]) | |
224 | { | |
f48459ab | 225 | // Defines the pad size perp. to the anode wire (y) for different sectors. |
226 | // Pad sizes are defined as integral fractions ndiv of a basis pad size | |
227 | // fDpx | |
228 | // | |
229 | for (Int_t i=0; i<4; i++) { | |
230 | (*fNDiv)[i]=ndiv[i]; | |
231 | } | |
232 | ndiv[0]=ndiv[1]; | |
cc4dcfb0 | 233 | } |
234 | //____________________________________________________________________________ | |
235 | void AliMUONSt345SlatSegmentation::SetPadSize(Float_t p1, Float_t p2) | |
236 | { | |
f48459ab | 237 | // Sets the padsize |
238 | fDpx=p1; | |
239 | fDpy=p2; | |
cc4dcfb0 | 240 | } |
241 | //_______________________________________________________________ | |
242 | void AliMUONSt345SlatSegmentation::SetPcbBoards(Int_t n[4]) | |
243 | { | |
f48459ab | 244 | // |
245 | // Set PcbBoard segmentation zones for each density | |
246 | // n[0] PcbBoards for maximum density sector fNDiv[0] | |
247 | // n[1] PcbBoards for next density sector fNDiv[1] etc ... | |
248 | for (Int_t i=0; i<4; i++) fPcbBoards[i]=n[i]; | |
cc4dcfb0 | 249 | } |
250 | //------------------------------------------------------------------------- | |
251 | void AliMUONSt345SlatSegmentation::SetPad(Int_t ix, Int_t iy) | |
252 | { | |
f48459ab | 253 | // |
254 | // Sets virtual pad coordinates, needed for evaluating pad response | |
255 | // outside the tracking program | |
256 | GetPadC(ix,iy,fX,fY); | |
257 | fSector=Sector(ix,iy); | |
cc4dcfb0 | 258 | } |
259 | //--------------------------------------------------------------------------- | |
260 | void AliMUONSt345SlatSegmentation::SetHit(Float_t x, Float_t y) | |
261 | { | |
f48459ab | 262 | // Set current hit |
263 | // | |
264 | fXhit = x; | |
265 | fYhit = y; | |
cc4dcfb0 | 266 | |
f48459ab | 267 | if (x < 0) fXhit = 0; |
268 | if (y < 0) fYhit = 0; | |
cc4dcfb0 | 269 | |
f48459ab | 270 | if (x >= fCx[fNsec-1]) fXhit = fCx[fNsec-1]; |
271 | if (y >= fDyPCB) fYhit = fDyPCB; | |
cc4dcfb0 | 272 | |
273 | } | |
274 | //---------------------------------------------------------------------------- | |
275 | void AliMUONSt345SlatSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/) | |
276 | { | |
277 | SetHit(xhit, yhit); | |
278 | } | |
f48459ab | 279 | |
cc4dcfb0 | 280 | //---------------------------------------------------------- |
281 | void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy) | |
282 | { | |
283 | // Initialises iteration over pads for charge distribution algorithm | |
284 | // | |
285 | // | |
286 | // Find the wire position (center of charge distribution) | |
287 | Float_t x0a=GetAnod(xhit); | |
288 | fXhit=x0a; | |
289 | fYhit=yhit; | |
290 | // | |
291 | // and take fNsigma*sigma around this center | |
292 | Float_t x01=x0a - dx; | |
293 | Float_t x02=x0a + dx; | |
294 | Float_t y01=yhit - dy; | |
295 | Float_t y02=yhit + dy; | |
296 | if (x01 < 0) x01 = 0; | |
297 | if (y01 < 0) y01 = 0; | |
298 | ||
299 | if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1]; | |
300 | ||
301 | ||
302 | Int_t isec=-1; | |
303 | for (Int_t i=fNsec-1; i > 0; i--) { | |
304 | if (x02 >= fCx[i-1]) { | |
305 | isec=i; | |
306 | if (fCx[isec] == fCx[isec-1] && isec > 1) isec--; | |
307 | break; | |
308 | } | |
309 | } | |
310 | y02 += Dpy(isec); | |
311 | if (y02 >= fDyPCB) y02 = fDyPCB; | |
312 | ||
313 | // | |
314 | // find the pads over which the charge distributes | |
315 | GetPadI(x01,y01,fIxmin,fIymin); | |
316 | GetPadI(x02,y02,fIxmax,fIymax); | |
317 | ||
318 | if (fIxmax > fNpx) fIxmax=fNpx; | |
319 | if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec]; | |
320 | ||
321 | fXmin=x01; | |
322 | fXmax=x02; | |
323 | fYmin=y01; | |
324 | fYmax=y02; | |
325 | ||
326 | // | |
327 | // Set current pad to lower left corner | |
328 | if (fIxmax < fIxmin) fIxmax=fIxmin; | |
329 | if (fIymax < fIymin) fIymax=fIymin; | |
330 | fIx=fIxmin; | |
331 | fIy=fIymin; | |
332 | ||
333 | GetPadC(fIx,fIy,fX,fY); | |
334 | fSector=Sector(fIx,fIy); | |
335 | /* | |
336 | printf("\n \n First Pad: %d %d %f %f %d %d %d %f" , | |
337 | fIxmin, fIxmax, fXmin, fXmax, fNpx, fId, isec, Dpy(isec)); | |
338 | printf("\n \n First Pad: %d %d %f %f %d %d %d %f", | |
339 | fIymin, fIymax, fYmin, fYmax, fNpyS[isec], fId, isec, Dpy(isec)); | |
340 | */ | |
341 | } | |
f48459ab | 342 | |
343 | ||
344 | ||
cc4dcfb0 | 345 | //---------------------------------------------------------------------- |
346 | void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy) | |
347 | { | |
348 | FirstPad(xhit, yhit, dx, dy); | |
349 | } | |
350 | //---------------------------------------------------------------------- | |
351 | void AliMUONSt345SlatSegmentation::NextPad() | |
352 | { | |
f48459ab | 353 | // Stepper for the iteration over pads |
354 | // | |
355 | // Step to next pad in the integration region | |
356 | // step from left to right | |
357 | if (fIx != fIxmax) { | |
358 | fIx++; | |
359 | GetPadC(fIx,fIy,fX,fY); | |
360 | fSector=Sector(fIx,fIy); | |
361 | // step up | |
362 | } else if (fIy != fIymax) { | |
363 | fIx=fIxmin; | |
364 | fIy++; | |
365 | GetPadC(fIx,fIy,fX,fY); | |
366 | fSector=Sector(fIx,fIy); | |
cc4dcfb0 | 367 | |
f48459ab | 368 | } else { |
369 | fIx=-1; | |
370 | fIy=-1; | |
371 | } | |
372 | // printf("\n Next Pad %d %d %f %f %d %d %d %d %d ", | |
cc4dcfb0 | 373 | } |
374 | //------------------------------------------------------------------------- | |
375 | Int_t AliMUONSt345SlatSegmentation::MorePads() | |
376 | { | |
f48459ab | 377 | // Stopping condition for the iterator over pads |
378 | // | |
379 | // Are there more pads in the integration region | |
cc4dcfb0 | 380 | |
f48459ab | 381 | return (fIx != -1 || fIy != -1); |
cc4dcfb0 | 382 | } |
383 | //-------------------------------------------------------------------------- | |
384 | Int_t AliMUONSt345SlatSegmentation::Sector(Int_t ix, Int_t iy) | |
385 | { | |
f48459ab | 386 | // |
387 | // Determine segmentation zone from pad coordinates | |
388 | // | |
389 | Int_t isec=-1; | |
390 | for (Int_t i=0; i < fNsec; i++) { | |
391 | if (ix <= fNpxS[i]) { | |
392 | isec=i; | |
393 | break; | |
cc4dcfb0 | 394 | } |
f48459ab | 395 | } |
396 | if (isec == -1) printf("\n Sector: Attention isec ! %d %d %d %d \n", | |
397 | fId, ix, iy,fNpxS[3]); | |
cc4dcfb0 | 398 | |
f48459ab | 399 | return isec; |
cc4dcfb0 | 400 | |
401 | } | |
402 | //----------------------------------------------------------------------------- | |
403 | void AliMUONSt345SlatSegmentation:: | |
404 | IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2) | |
405 | { | |
f48459ab | 406 | // Returns integration limits for current pad |
407 | // | |
408 | x1=fXhit-fX-Dpx(fSector)/2.; | |
409 | x2=x1+Dpx(fSector); | |
410 | y1=fYhit-fY-Dpy(fSector)/2.; | |
411 | y2=y1+Dpy(fSector); | |
412 | // printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector)); | |
cc4dcfb0 | 413 | |
414 | } | |
415 | //----------------------------------------------------------------------------- | |
416 | void AliMUONSt345SlatSegmentation:: | |
417 | Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]) | |
418 | { | |
f48459ab | 419 | // Returns list of next neighbours for given Pad (iX, iY) |
420 | Int_t i=0; | |
421 | // step right | |
422 | if (iX+1 <= fNpx) { | |
423 | Xlist[i]=iX+1; | |
424 | Ylist[i++]=iY; | |
425 | } | |
426 | // step left | |
427 | if (iX-1 > 0) { | |
428 | Xlist[i]=iX-1; | |
429 | Ylist[i++]=iY; | |
430 | } | |
431 | Int_t sector = Sector(iX,iY); | |
432 | // step up | |
433 | if (iY+1 <= fNpyS[sector]) { | |
434 | Xlist[i]=iX; | |
435 | Ylist[i++]=iY+1; | |
436 | } | |
437 | // step down | |
438 | if (iY-1 > 0) { | |
439 | Xlist[i]=iX; | |
440 | Ylist[i++]=iY-1; | |
441 | } | |
442 | *Nlist=i; | |
cc4dcfb0 | 443 | } |
f48459ab | 444 | |
cc4dcfb0 | 445 | //-------------------------------------------------------------------------- |
446 | void AliMUONSt345SlatSegmentation::Init(Int_t detectionElementId) | |
447 | { | |
f48459ab | 448 | // |
449 | // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector | |
450 | // These arrays help in converting from real to pad co-ordinates and | |
451 | // vice versa | |
452 | // | |
453 | // Segmentation is defined by rectangular modules approximating | |
454 | // concentric circles as shown below | |
455 | // | |
456 | // PCB module size in cm | |
457 | // printf("\n Initialise Segmentation SlatModule \n"); | |
cc4dcfb0 | 458 | |
f48459ab | 459 | |
a713db22 | 460 | // printf(" fBending: %d \n",fBending); |
f48459ab | 461 | |
462 | fDxPCB=40; | |
463 | fDyPCB=40; | |
464 | ||
465 | // Calculate padsize along x | |
466 | (*fDpxD)[fNsec-1]=fDpx; | |
467 | (*fDpyD)[fNsec-1]=fDpy; | |
468 | if (fNsec > 1) { | |
469 | for (Int_t i=fNsec-1; i>=0; i--){ // fNsec-2 | |
470 | if (!fBending) { | |
471 | (*fDpxD)[i]=fDpx; | |
472 | (*fDpyD)[i]=(*fDpyD)[fNsec-1]/(*fNDiv)[i]; | |
473 | } else { | |
cc4dcfb0 | 474 | (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i]; |
f48459ab | 475 | (*fDpyD)[i]=fDpy; |
cc4dcfb0 | 476 | } |
477 | } | |
f48459ab | 478 | } |
479 | // | |
480 | // fill the arrays defining the pad segmentation boundaries | |
481 | // | |
482 | // | |
483 | // Loop over sectors (isec=0 for secto close to the beam pipe) | |
484 | Float_t totalLength = 0; | |
485 | for (Int_t isec=0; isec<4; isec++) totalLength += fPcbBoards[isec]*fDxPCB; // !!!! | |
486 | ||
487 | fNpy = 0; // maximum number of pads in y | |
488 | for (Int_t isec=0; isec<4; isec++) { | |
489 | if (isec==0) { | |
490 | fNpxS[0] = 0; | |
491 | fNpyS[0] = 0; | |
492 | fCx[0] = -totalLength/2; | |
493 | } else { | |
494 | fNpxS[isec] = fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]); | |
495 | fNpyS[isec] = Int_t(fDyPCB/(*fDpyD)[isec]); | |
496 | if (fNpyS[isec] >= fNpy) fNpy = fNpyS[isec]; | |
497 | fCx[isec]= fCx[isec-1] + fPcbBoards[isec]*fDxPCB; | |
498 | } | |
499 | } // sectors | |
cc4dcfb0 | 500 | |
f48459ab | 501 | fNpx = fNpxS[3]; // maximum number of pads in x |
502 | fCy = fDyPCB/2.; | |
503 | // | |
504 | fId = detectionElementId; | |
505 | } | |
cc4dcfb0 | 506 | |
507 | ||
508 | ||
509 | ||
510 | ||
511 | ||
512 | ||
513 | ||
514 | ||
515 | ||
516 |