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