]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegmentationSlatModule.cxx
Redefinition of data member corrected.
[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
d9a3473d 87Float_t AliMUONSegmentationSlatModule::Dpy(Int_t /*isec*/) const
4c503756 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}
d9a3473d 143//-------------------------------------------------------------------------
144void AliMUONSegmentationSlatModule::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
145{
146 GetPadI(x, y, ix, iy);
147}
148//-------------------------------------------------------------------------
4c503756 149void AliMUONSegmentationSlatModule::
150SetPad(Int_t ix, Int_t iy)
151{
152 //
153 // Sets virtual pad coordinates, needed for evaluating pad response
154 // outside the tracking program
155 GetPadC(ix,iy,fX,fY);
156 fSector=Sector(ix,iy);
157}
158
159void AliMUONSegmentationSlatModule::
160SetHit(Float_t x, Float_t y)
161{
de05461e 162// Set current hit
163//
4c503756 164 fXhit = x;
165 fYhit = y;
166
167 if (x < 0) fXhit = 0;
168 if (y < 0) fYhit = 0;
169
170 if (x >= fCx[fNsec-1]) fXhit = fCx[fNsec-1];
171 if (y >= fDyPCB) fYhit = fDyPCB;
172
173
174}
d9a3473d 175//----------------------------------------------------------
176void AliMUONSegmentationSlatModule::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
177{
178 SetHit(xhit, yhit);
179}
180//----------------------------------------------------------
4c503756 181void AliMUONSegmentationSlatModule::
182FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
183{
184// Initialises iteration over pads for charge distribution algorithm
185//
186 //
187 // Find the wire position (center of charge distribution)
188 Float_t x0a=GetAnod(xhit);
189 fXhit=x0a;
190 fYhit=yhit;
191 //
192 // and take fNsigma*sigma around this center
193 Float_t x01=x0a - dx;
194 Float_t x02=x0a + dx;
195 Float_t y01=yhit - dy;
196 Float_t y02=yhit + dy;
4c503756 197 if (x01 < 0) x01 = 0;
198 if (y01 < 0) y01 = 0;
f30dea32 199
200 if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1];
d4ee3c3e 201
4c503756 202
f30dea32 203
4c503756 204 Int_t isec=-1;
205 for (Int_t i=fNsec-1; i > 0; i--) {
206 if (x02 >= fCx[i-1]) {
207 isec=i;
f30dea32 208 if (fCx[isec] == fCx[isec-1] && isec > 1) isec--;
4c503756 209 break;
210 }
211 }
d4ee3c3e 212 y02 += Dpy(isec);
213 if (y02 >= fDyPCB) y02 = fDyPCB;
4c503756 214
4c503756 215 //
216 // find the pads over which the charge distributes
217 GetPadI(x01,y01,fIxmin,fIymin);
218 GetPadI(x02,y02,fIxmax,fIymax);
f30dea32 219
4c503756 220 if (fIxmax > fNpx) fIxmax=fNpx;
221 if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec];
d4ee3c3e 222
4c503756 223 fXmin=x01;
d4ee3c3e 224 fXmax=x02;
4c503756 225 fYmin=y01;
d4ee3c3e 226 fYmax=y02;
227
4c503756 228 //
229 // Set current pad to lower left corner
230 if (fIxmax < fIxmin) fIxmax=fIxmin;
231 if (fIymax < fIymin) fIymax=fIymin;
232 fIx=fIxmin;
233 fIy=fIymin;
234
235 GetPadC(fIx,fIy,fX,fY);
236 fSector=Sector(fIx,fIy);
d4ee3c3e 237/*
238 printf("\n \n First Pad: %d %d %f %f %d %d %d %f" ,
239 fIxmin, fIxmax, fXmin, fXmax, fNpx, fId, isec, Dpy(isec));
240 printf("\n \n First Pad: %d %d %f %f %d %d %d %f",
241 fIymin, fIymax, fYmin, fYmax, fNpyS[isec], fId, isec, Dpy(isec));
242*/
4c503756 243}
d9a3473d 244//----------------------------------------------------------------------
245void AliMUONSegmentationSlatModule::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
246{
247 FirstPad(xhit, yhit, dx, dy);
248}
249//----------------------------------------------------------------------
4c503756 250void AliMUONSegmentationSlatModule::NextPad()
251{
252// Stepper for the iteration over pads
253//
254// Step to next pad in the integration region
255// step from left to right
256 if (fIx != fIxmax) {
257 fIx++;
258 GetPadC(fIx,fIy,fX,fY);
259 fSector=Sector(fIx,fIy);
260// step up
261 } else if (fIy != fIymax) {
262 fIx=fIxmin;
263 fIy++;
264 GetPadC(fIx,fIy,fX,fY);
265 fSector=Sector(fIx,fIy);
266
267 } else {
268 fIx=-1;
269 fIy=-1;
270 }
271// printf("\n Next Pad %d %d %f %f %d %d %d %d %d ",
272}
273
274
275Int_t AliMUONSegmentationSlatModule::MorePads()
de05461e 276{
4c503756 277// Stopping condition for the iterator over pads
278//
279// Are there more pads in the integration region
4c503756 280
281 return (fIx != -1 || fIy != -1);
282}
283
284
285Int_t AliMUONSegmentationSlatModule::Sector(Int_t ix, Int_t iy)
286{
287//
288// Determine segmentation zone from pad coordinates
289//
290 Int_t isec=-1;
291 for (Int_t i=0; i < fNsec; i++) {
292 if (ix <= fNpxS[i]) {
293 isec=i;
294 break;
295 }
296 }
297 if (isec == -1) printf("\n Sector: Attention isec ! %d %d %d %d \n",
298 fId, ix, iy,fNpxS[3]);
299
300 return isec;
301
302}
303
304void AliMUONSegmentationSlatModule::
305IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
306{
307// Returns integration limits for current pad
308//
309
310 x1=fXhit-fX-Dpx(fSector)/2.;
311 x2=x1+Dpx(fSector);
312 y1=fYhit-fY-Dpy(fSector)/2.;
313 y2=y1+Dpy(fSector);
314// printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector));
315
316}
317
318void AliMUONSegmentationSlatModule::
319Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
320{
321// Returns list of next neighbours for given Pad (iX, iY)
322//
323//
324 Int_t i=0;
325//
326// step right
327 if (iX+1 <= fNpx) {
328 Xlist[i]=iX+1;
329 Ylist[i++]=iY;
330 }
331//
332// step left
333 if (iX-1 > 0) {
334 Xlist[i]=iX-1;
335 Ylist[i++]=iY;
336 }
337
338//
339// step up
340 if (iY+1 <= fNpy) {
341 Xlist[i]=iX;
342 Ylist[i++]=iY+1;
343 }
344//
345// step down
346 if (iY-1 > 0) {
347 Xlist[i]=iX;
348 Ylist[i++]=iY-1;
349 }
350
351 *Nlist=i;
352}
353
354
355void AliMUONSegmentationSlatModule::Init(Int_t chamber)
356{
4c503756 357//
358// Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
359// These arrays help in converting from real to pad co-ordinates and
360// vice versa
361//
362// Segmentation is defined by rectangular modules approximating
363// concentric circles as shown below
364//
365// PCB module size in cm
9e1a0ddb 366 // printf("\n Initialise Segmentation SlatModule \n");
de05461e 367
4c503756 368 fDxPCB=40;
369 fDyPCB=40;
370//
371// number of pad rows per PCB
372//
373 Int_t nPyPCB=Int_t(fDyPCB/fDpy);
374//
375// maximum number of pad rows
376 fNpy=nPyPCB;
377//
378// Calculate padsize along x
379 (*fDpxD)[fNsec-1]=fDpx;
380 if (fNsec > 1) {
381 for (Int_t i=fNsec-2; i>=0; i--){
382 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
4c503756 383 }
384 }
385//
386// fill the arrays defining the pad segmentation boundaries
387//
388//
389// Loop over sectors (isec=0 is the dead space surounding the beam pipe)
390 for (Int_t isec=0; isec<4; isec++) {
391 if (isec==0) {
392 fNpxS[0] = 0;
393 fNpyS[0] = 0;
394 fCx[0] = 0;
395 } else {
396 fNpxS[isec]=fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]);
397 fNpyS[isec]=fNpy;
398 fCx[isec]=fCx[isec-1] + fPcbBoards[isec]*fDxPCB;
399 }
400 } // sectors
401// maximum number of pad rows
402 fNpy=nPyPCB;
403 fNpx=fNpxS[3];
de2f6d11 404//
405 fId = chamber;
4c503756 406}
407
408
409
410
411
412
413
414
415
416
417
418