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