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