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