1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /// \class AliMUONSt345SlatSegmentation
19 /// \brief Segmentation classes for slat modules
21 /// This class works with local coordinates
22 /// of the slats via the class AliMUONGeometrySegmentation
23 /// This class contains the size of the slats and the
24 /// and the differents PCB densities.
25 /// (from old AliMUONSegmentationSlatModule)
27 /// Add electronics mapping - Christian, Subatech, Mai 05
29 /// \author Gines Martinez, Subatech, Nov04
33 #include "AliMUONSt345SlatSegmentation.h"
37 ClassImp(AliMUONSt345SlatSegmentation)
40 AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation()
41 : AliMUONVGeometryDESegmentation(),
65 /// Default constructor
66 AliDebug(1,Form("this=%p default (empty) ctor",this));
69 //___________________________________________
70 AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(Bool_t bending)
71 : AliMUONVGeometryDESegmentation(),
96 /// Standard constructor
98 fNsec = 4; // 4 sector densities at most per slat
99 fNDiv = new TArrayI(fNsec);
100 fDpxD = new TArrayF(fNsec);
101 fDpyD = new TArrayF(fNsec);
102 (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
103 (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
104 (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0;
105 AliDebug(1,Form("this=%p ctor for bending=%d",this,fBending));
108 //----------------------------------------------------------------------
109 AliMUONSt345SlatSegmentation::~AliMUONSt345SlatSegmentation()
113 AliDebug(1, Form("dtor this = %p", this));
120 //------------------------------------------------------------------------
121 Float_t AliMUONSt345SlatSegmentation::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y, Int_t * /*dummy*/)
123 /// Returns the square of the distance between 1 pad
124 /// labelled by its Channel numbers and a coordinate
128 return (x-X)*(x-X) + (y-Y)*(y-Y);
130 //____________________________________________________________________________
131 Float_t AliMUONSt345SlatSegmentation::Dpx(Int_t isec) const
133 /// Return x-strip width
135 return (*fDpxD)[isec];
138 //____________________________________________________________________________
139 Float_t AliMUONSt345SlatSegmentation::Dpy(Int_t isec) const
141 /// Return y-strip width
143 return (*fDpyD)[isec];
145 //_____________________________________________________________________________
146 Float_t AliMUONSt345SlatSegmentation::GetAnod(Float_t xhit) const
148 /// Returns for a hit position xhit the position of the nearest anode wire
150 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
154 //_____________________________________________________________________________
155 Bool_t AliMUONSt345SlatSegmentation::HasPad(Int_t ix, Int_t iy)
157 /// Return true if pas with given indices exists
159 if ( ix < 1 || ix > Npx() || iy < 1 || iy > Npy() )
163 Int_t isec = Sector(ix,iy);
168 if ( iy > fNpyS[isec] )
175 //--------------------------------------------------------------------------------
176 void AliMUONSt345SlatSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
178 /// Returns real coordinates (x,y) for given pad coordinates (ix,iy)
180 if (ix < 1 || ix > Npx() || iy < 1 || iy > Npy() ){
181 AliWarning(Form("ix %d or iy %d out of boundaries: Npx=%d and Npy=%d",ix, iy, Npx(), Npy()));
187 Int_t isec = Sector(ix,iy);
188 if (isec == -1) AliWarning(Form("isector = %d with ix %d, iy %d", isec, ix, iy));
189 if (iy > fNpyS[isec]) {
194 x = fCx[isec-1]+(ix-fNpxS[isec-1])*(*fDpxD)[isec];
195 x = x-(*fDpxD)[isec]/2;
196 y = Float_t(iy*(*fDpyD)[isec])-(*fDpyD)[isec]/2.- fCy; // !!!
204 //_____________________________________________________________________________
205 void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
207 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
211 for (Int_t i=fNsec-1; i > 0; i--) {
214 if (TMath::Abs(fCx[isec] - fCx[isec-1]) <0.1 && isec > 1) isec--;
218 if (isec == -1) AliWarning(Form("isector equal to %d with xl %f, yl %f", isec, x, y));
220 ix= Int_t((x-fCx[isec-1])/(*fDpxD)[isec])
222 iy= Int_t((y+fCy)/(*fDpyD)[isec])+1;
223 } else if (isec == 0) {
224 ix= Int_t(x/(*fDpxD)[isec])+1;
225 iy= Int_t((y+fCy)/(*fDpyD)[isec])+1;
231 //-------------------------------------------------------------------------
232 void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
234 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
236 GetPadI(x, y, ix, iy);
240 //_______________________________________________________________
241 void AliMUONSt345SlatSegmentation::SetPadDivision(Int_t ndiv[4])
243 /// Defines the pad size perp. to the anode wire (y) for different sectors.
244 /// Pad sizes are defined as integral fractions ndiv of a basis pad size
247 for (Int_t i=0; i<4; i++) {
252 //____________________________________________________________________________
253 void AliMUONSt345SlatSegmentation::SetPadSize(Float_t p1, Float_t p2)
260 //_______________________________________________________________
261 void AliMUONSt345SlatSegmentation::SetPcbBoards(Int_t n[4])
263 /// Set PcbBoard segmentation zones for each density
264 /// n[0] slat type parameter
265 /// n[1] PcbBoards for highest density sector fNDiv[1] etc ...
269 for (Int_t i=0; i<4; i++) fPcbBoards[i]=n[i];
272 //-------------------------------------------------------------------------
273 void AliMUONSt345SlatSegmentation::SetPad(Int_t ix, Int_t iy)
275 /// Sets virtual pad coordinates, needed for evaluating pad response
276 /// outside the tracking program
278 GetPadC(ix,iy,fX,fY);
279 fSector=Sector(ix,iy);
281 //---------------------------------------------------------------------------
282 void AliMUONSt345SlatSegmentation::SetHit(Float_t x, Float_t y)
289 if (x < fCx[0]) fXhit = fCx[0];
290 if (y < -fDyPCB/2.) fYhit = -fDyPCB/2.;
292 if (x > fCx[fNsec-1]) fXhit = fCx[fNsec-1];
293 if (y > fDyPCB/2.) fYhit = fDyPCB/2.;
296 //----------------------------------------------------------------------------
297 void AliMUONSt345SlatSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
304 //----------------------------------------------------------
305 void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
307 /// Initialises iteration over pads for charge distribution algorithm
310 // Find the wire position (center of charge distribution)
311 Float_t x0a = GetAnod(xhit);
315 // and take fNsigma*sigma around this center
316 Float_t x01 = x0a - dx ;
317 Float_t x02 = x0a + dx;
318 Float_t y01 = yhit - dy;
319 Float_t y02 = yhit + dy;
321 // check the limits after adding (fNsigma*sigma)
322 if (x01 < fCx[0]) x01 = fCx[0];
323 if (y01 < -fDyPCB/2) y01 = -fDyPCB/2;
325 if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1]; // still ok ? (CF)
326 if (y02 >= fDyPCB/2.) y02 = fDyPCB/2.;
330 for (Int_t i=fNsec-1; i > 0; i--) {
331 if (x02 >= fCx[i-1]) {
333 if (TMath::Abs(fCx[isec] - fCx[isec-1]) < 0.1 && isec > 1) isec--;
338 // y02 += Dpy(isec);// why ? (CF)
341 // find the pads over which the charge distributes
342 GetPadI(x01,y01,fIxmin,fIymin);
343 GetPadI(x02,y02,fIxmax,fIymax);
345 if (fIxmax > fNpx) fIxmax=fNpx;
346 if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec];
347 if (fIxmin < 1) fIxmin = 1; // patch for the moment (Ch. Finck)
348 if (fIymin < 1) fIymin = 1;
356 // Set current pad to lower left corner
357 if (fIxmax < fIxmin) fIxmax = fIxmin;
358 if (fIymax < fIymin) fIymax = fIymin;
362 GetPadC(fIx,fIy,fX,fY);
363 fSector = Sector(fIx,fIy);
365 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d",
366 xhit,yhit,dx,dy,fIx,fIy));
369 //----------------------------------------------------------------------
370 void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
372 /// Initialises iteration over pads for charge distribution algorithm
374 FirstPad(xhit, yhit, dx, dy);
376 //----------------------------------------------------------------------
377 void AliMUONSt345SlatSegmentation::NextPad()
379 /// Stepper for the iteration over pads
381 // Step to next pad in the integration region
382 // step from left to right
385 GetPadC(fIx,fIy,fX,fY);
386 fSector=Sector(fIx,fIy);
388 } else if (fIy != fIymax) {
391 GetPadC(fIx,fIy,fX,fY);
392 fSector=Sector(fIx,fIy);
398 //-------------------------------------------------------------------------
399 Int_t AliMUONSt345SlatSegmentation::MorePads()
401 /// Stopping condition for the iterator over pads
403 // Are there more pads in the integration region
405 return (fIx != -999 || fIy != -999);
407 //--------------------------------------------------------------------------
408 Int_t AliMUONSt345SlatSegmentation::Sector(Int_t ix, Int_t iy)
410 /// Determine segmentation zone from pad coordinates
413 for (Int_t i = 0; i < fNsec; i++) {
414 if (ix <= fNpxS[i]) {
419 if (isec == -1) AliWarning(Form("Sector = %d with ix %d and iy %d, Npx %d",
420 isec, ix, iy, fNpx));
425 //-----------------------------------------------------------------------------
426 void AliMUONSt345SlatSegmentation::
427 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
429 /// Returns integration limits for current pad
431 x1=fXhit-fX-Dpx(fSector)/2.;
433 y1=fYhit-fY-Dpy(fSector)/2.;
436 AliDebug(4,Form("xhit,yhit=%e,%e x,y=%e,%e, x1,x2,y1,y2=%e,%e,%e,%e",fXhit,fYhit,fX,fY,x1,x2,y1,y2));
439 //-----------------------------------------------------------------------------
440 void AliMUONSt345SlatSegmentation::
441 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
443 /// Returns list of next neighbours for given Pad (iX, iY)
456 Int_t sector = Sector(iX,iY);
458 if (iY+1 <= fNpyS[sector]) {
470 //--------------------------------------------------------------------------
471 void AliMUONSt345SlatSegmentation::Init(Int_t detectionElementId)
473 /// Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
474 /// These arrays help in converting from real to pad co-ordinates and
477 /// Segmentation is defined by rectangular modules approximating
478 /// concentric circles as shown below
480 // PCB module size in cm
481 // printf("\n Initialise Segmentation SlatModule \n");
484 // printf(" fBending: %d \n",fBending);
486 if (fInitDone) return; // security if init is already done in AliMUONFactory
490 // Calculate padsize along x
491 (*fDpxD)[fNsec-1]=fDpx;
492 (*fDpyD)[fNsec-1]=fDpy;
494 for (Int_t i=fNsec-1; i>=0; i--){ // fNsec-2
497 (*fDpyD)[i]=(*fDpyD)[fNsec-1]/(*fNDiv)[i];
499 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
505 // fill the arrays defining the pad segmentation boundaries
508 // Loop over sectors (isec=0 for secto close to the beam pipe)
509 Float_t totalLength = 0;
510 for (Int_t isec=0; isec<4; isec++) totalLength += fPcbBoards[isec]*fDxPCB; // !!!!
512 fNpy = 0; // maximum number of pads in y
513 for (Int_t isec=0; isec<4; isec++) {
517 fCx[0] = -totalLength/2;
519 fNpxS[isec] = fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]+0.5);
520 fNpyS[isec] = Int_t(fDyPCB/(*fDpyD)[isec]+0.5);
521 if (fNpyS[isec] >= fNpy) fNpy = fNpyS[isec];
522 fCx[isec]= fCx[isec-1] + fPcbBoards[isec]*fDxPCB;
526 fNpx = fNpxS[3]; // maximum number of pads in x
529 fId = detectionElementId;