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