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