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