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