]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegmentationSlatModule.cxx
Removing warnings ...
[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
88cb7938 16/* $Id$ */
4c503756 17
18/////////////////////////////////////////////////////
19// Segmentation classes for slat modules //
20// to be used with AluMUONSegmentationSlat //
21/////////////////////////////////////////////////////
22
23
24#include "AliMUONSegmentationSlatModule.h"
aaf4addd 25#include "AliRun.h"
26#include "AliMUON.h"
4c503756 27#include <TMath.h>
70479d0e 28#include <Riostream.h>
4c503756 29
30#include "AliMUONSegmentationV01.h"
31
32//___________________________________________
33ClassImp(AliMUONSegmentationSlatModule)
34
35AliMUONSegmentationSlatModule::AliMUONSegmentationSlatModule()
36{
37// Default constructor
81a0c7bd 38 fNDiv = 0;
39 fDpxD = 0;
e9e4cdf2 40}
41
42AliMUONSegmentationSlatModule::AliMUONSegmentationSlatModule(Int_t nsec)
43{
44// Non default constructor
45 fNsec = nsec;
4c503756 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;
e9e4cdf2 50}
51
52AliMUONSegmentationSlatModule::~AliMUONSegmentationSlatModule()
53{
54// Destructor
55 if (fNDiv) delete fNDiv;
56 if (fDpxD) delete fDpxD;
4c503756 57}
58
59void 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
67void 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
80Float_t AliMUONSegmentationSlatModule::Dpx(Int_t isec) const
81{
82// Return x-strip width
83 return (*fDpxD)[isec];
84}
85
86
87Float_t AliMUONSegmentationSlatModule::Dpy(Int_t isec) const
88{
89// Return y-strip width
90
91 return fDpy;
92}
93
94
95void AliMUONSegmentationSlatModule::
96GetPadI(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;
f30dea32 109 if (fCx[isec] == fCx[isec-1] && isec > 1) isec--;
4c503756 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
125void AliMUONSegmentationSlatModule::
126GetPadC(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);
de2f6d11 134 if (isec == -1) printf("\n PadC %d %d %d %d \n ", isec, fId, ix, iy);
4c503756 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
144void AliMUONSegmentationSlatModule::
145SetPad(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
154void AliMUONSegmentationSlatModule::
155SetHit(Float_t x, Float_t y)
156{
de05461e 157// Set current hit
158//
4c503756 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
172void AliMUONSegmentationSlatModule::
173FirstPad(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;
4c503756 188 if (x01 < 0) x01 = 0;
189 if (y01 < 0) y01 = 0;
f30dea32 190
191 if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1];
d4ee3c3e 192
4c503756 193
f30dea32 194
4c503756 195 Int_t isec=-1;
196 for (Int_t i=fNsec-1; i > 0; i--) {
197 if (x02 >= fCx[i-1]) {
198 isec=i;
f30dea32 199 if (fCx[isec] == fCx[isec-1] && isec > 1) isec--;
4c503756 200 break;
201 }
202 }
d4ee3c3e 203 y02 += Dpy(isec);
204 if (y02 >= fDyPCB) y02 = fDyPCB;
4c503756 205
4c503756 206 //
207 // find the pads over which the charge distributes
208 GetPadI(x01,y01,fIxmin,fIymin);
209 GetPadI(x02,y02,fIxmax,fIymax);
f30dea32 210
4c503756 211 if (fIxmax > fNpx) fIxmax=fNpx;
212 if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec];
d4ee3c3e 213
4c503756 214 fXmin=x01;
d4ee3c3e 215 fXmax=x02;
4c503756 216 fYmin=y01;
d4ee3c3e 217 fYmax=y02;
218
4c503756 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);
d4ee3c3e 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*/
4c503756 234}
235
236void 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
261Int_t AliMUONSegmentationSlatModule::MorePads()
de05461e 262{
4c503756 263// Stopping condition for the iterator over pads
264//
265// Are there more pads in the integration region
4c503756 266
267 return (fIx != -1 || fIy != -1);
268}
269
270
271Int_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
290void AliMUONSegmentationSlatModule::
291IntegrationLimits(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
304void AliMUONSegmentationSlatModule::
305Neighbours(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
341void AliMUONSegmentationSlatModule::Init(Int_t chamber)
342{
4c503756 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
9e1a0ddb 352 // printf("\n Initialise Segmentation SlatModule \n");
de05461e 353
4c503756 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];
4c503756 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];
de2f6d11 390//
391 fId = chamber;
4c503756 392}
393
394
395
396
397
398
399
400
401
402
403
404