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