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