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 //*********************************************************
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 // Add electronics mapping
27 // Christian, Subatech, Mai 05
28 //*********************************************************
32 #include "AliMUONSt345SlatSegmentation.h"
35 ClassImp(AliMUONSt345SlatSegmentation)
38 AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation()
39 : AliMUONVGeometryDESegmentation(),
63 // default constructor
64 AliDebug(1,Form("this=%p default (empty) ctor",this));
67 //___________________________________________
68 AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(Bool_t bending)
69 : AliMUONVGeometryDESegmentation(),
94 // Non default constructor
95 fNsec = 4; // 4 sector densities at most per slat
96 fNDiv = new TArrayI(fNsec);
97 fDpxD = new TArrayF(fNsec);
98 fDpyD = new TArrayF(fNsec);
99 (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
100 (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
101 (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0;
102 AliDebug(1,Form("this=%p ctor for bending=%d",this,fBending));
105 //----------------------------------------------------------------------
106 AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(const AliMUONSt345SlatSegmentation& rhs)
107 : AliMUONVGeometryDESegmentation(rhs),
127 AliFatal("Not implemented");
129 //----------------------------------------------------------------------
130 AliMUONSt345SlatSegmentation::~AliMUONSt345SlatSegmentation()
134 AliDebug(1, Form("dtor this = %p", this));
140 //----------------------------------------------------------------------
141 AliMUONSt345SlatSegmentation& AliMUONSt345SlatSegmentation::operator=(const AliMUONSt345SlatSegmentation& rhs)
143 // Protected assignement operator
144 if (this == &rhs) return *this;
145 AliFatal("Not implemented.");
150 //------------------------------------------------------------------------
151 Float_t AliMUONSt345SlatSegmentation::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y, Int_t * /*dummy*/)
153 // Returns the square of the distance between 1 pad
154 // labelled by its Channel numbers and a coordinate
157 return (x-X)*(x-X) + (y-Y)*(y-Y);
159 //____________________________________________________________________________
160 Float_t AliMUONSt345SlatSegmentation::Dpx(Int_t isec) const
162 // Return x-strip width
163 return (*fDpxD)[isec];
166 //____________________________________________________________________________
167 Float_t AliMUONSt345SlatSegmentation::Dpy(Int_t isec) const
169 // Return y-strip width
170 return (*fDpyD)[isec];
172 //_____________________________________________________________________________
173 Float_t AliMUONSt345SlatSegmentation::GetAnod(Float_t xhit) const
175 // Returns for a hit position xhit the position of the nearest anode wire
176 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
180 //_____________________________________________________________________________
181 Bool_t AliMUONSt345SlatSegmentation::HasPad(Int_t ix, Int_t iy)
183 // Return true if pas with given indices exists
185 if ( ix < 1 || ix > Npx() || iy < 1 || iy > Npy() )
189 Int_t isec = Sector(ix,iy);
194 if ( iy > fNpyS[isec] )
201 //--------------------------------------------------------------------------------
202 void AliMUONSt345SlatSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
204 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
206 if (ix < 1 || ix > Npx() || iy < 1 || iy > Npy() ){
207 AliWarning(Form("ix %d or iy %d out of boundaries: Npx=%d and Npy=%d",ix, iy, Npx(), Npy()));
213 Int_t isec = Sector(ix,iy);
214 if (isec == -1) AliWarning(Form("isector = %d with ix %d, iy %d", isec, ix, iy));
215 if (iy > fNpyS[isec]) {
220 x = fCx[isec-1]+(ix-fNpxS[isec-1])*(*fDpxD)[isec];
221 x = x-(*fDpxD)[isec]/2;
222 y = Float_t(iy*(*fDpyD)[isec])-(*fDpyD)[isec]/2.- fCy; // !!!
230 //_____________________________________________________________________________
231 void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
233 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
237 for (Int_t i=fNsec-1; i > 0; i--) {
240 if (TMath::Abs(fCx[isec] - fCx[isec-1]) <0.1 && isec > 1) isec--;
244 if (isec == -1) AliWarning(Form("isector equal to %d with xl %f, yl %f", isec, x, y));
246 ix= Int_t((x-fCx[isec-1])/(*fDpxD)[isec])
248 iy= Int_t((y+fCy)/(*fDpyD)[isec])+1;
249 } else if (isec == 0) {
250 ix= Int_t(x/(*fDpxD)[isec])+1;
251 iy= Int_t((y+fCy)/(*fDpyD)[isec])+1;
257 //-------------------------------------------------------------------------
258 void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
260 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
262 GetPadI(x, y, ix, iy);
266 //_______________________________________________________________
267 void AliMUONSt345SlatSegmentation::SetPadDivision(Int_t ndiv[4])
269 // Defines the pad size perp. to the anode wire (y) for different sectors.
270 // Pad sizes are defined as integral fractions ndiv of a basis pad size
273 for (Int_t i=0; i<4; i++) {
278 //____________________________________________________________________________
279 void AliMUONSt345SlatSegmentation::SetPadSize(Float_t p1, Float_t p2)
285 //_______________________________________________________________
286 void AliMUONSt345SlatSegmentation::SetPcbBoards(Int_t n[4])
289 // Set PcbBoard segmentation zones for each density
290 // n[0] slat type parameter
291 // n[1] PcbBoards for highest density sector fNDiv[1] etc ...
295 for (Int_t i=0; i<4; i++) fPcbBoards[i]=n[i];
298 //-------------------------------------------------------------------------
299 void AliMUONSt345SlatSegmentation::SetPad(Int_t ix, Int_t iy)
302 // Sets virtual pad coordinates, needed for evaluating pad response
303 // outside the tracking program
304 GetPadC(ix,iy,fX,fY);
305 fSector=Sector(ix,iy);
307 //---------------------------------------------------------------------------
308 void AliMUONSt345SlatSegmentation::SetHit(Float_t x, Float_t y)
315 if (x < fCx[0]) fXhit = fCx[0];
316 if (y < -fDyPCB/2.) fYhit = -fDyPCB/2.;
318 if (x > fCx[fNsec-1]) fXhit = fCx[fNsec-1];
319 if (y > fDyPCB/2.) fYhit = fDyPCB/2.;
322 //----------------------------------------------------------------------------
323 void AliMUONSt345SlatSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
330 //----------------------------------------------------------
331 void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
333 // Initialises iteration over pads for charge distribution algorithm
336 // Find the wire position (center of charge distribution)
337 Float_t x0a = GetAnod(xhit);
341 // and take fNsigma*sigma around this center
342 Float_t x01 = x0a - dx ;
343 Float_t x02 = x0a + dx;
344 Float_t y01 = yhit - dy;
345 Float_t y02 = yhit + dy;
347 // check the limits after adding (fNsigma*sigma)
348 if (x01 < fCx[0]) x01 = fCx[0];
349 if (y01 < -fDyPCB/2) y01 = -fDyPCB/2;
351 if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1]; // still ok ? (CF)
352 if (y02 >= fDyPCB/2.) y02 = fDyPCB/2.;
356 for (Int_t i=fNsec-1; i > 0; i--) {
357 if (x02 >= fCx[i-1]) {
359 if (TMath::Abs(fCx[isec] - fCx[isec-1]) < 0.1 && isec > 1) isec--;
364 // y02 += Dpy(isec);// why ? (CF)
367 // find the pads over which the charge distributes
368 GetPadI(x01,y01,fIxmin,fIymin);
369 GetPadI(x02,y02,fIxmax,fIymax);
371 if (fIxmax > fNpx) fIxmax=fNpx;
372 if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec];
373 if (fIxmin < 1) fIxmin = 1; // patch for the moment (Ch. Finck)
374 if (fIymin < 1) fIymin = 1;
382 // Set current pad to lower left corner
383 if (fIxmax < fIxmin) fIxmax = fIxmin;
384 if (fIymax < fIymin) fIymax = fIymin;
388 GetPadC(fIx,fIy,fX,fY);
389 fSector = Sector(fIx,fIy);
391 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d",
392 xhit,yhit,dx,dy,fIx,fIy));
395 //----------------------------------------------------------------------
396 void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
398 // Initialises iteration over pads for charge distribution algorithm
400 FirstPad(xhit, yhit, dx, dy);
402 //----------------------------------------------------------------------
403 void AliMUONSt345SlatSegmentation::NextPad()
405 // Stepper for the iteration over pads
407 // Step to next pad in the integration region
408 // step from left to right
411 GetPadC(fIx,fIy,fX,fY);
412 fSector=Sector(fIx,fIy);
414 } else if (fIy != fIymax) {
417 GetPadC(fIx,fIy,fX,fY);
418 fSector=Sector(fIx,fIy);
424 //-------------------------------------------------------------------------
425 Int_t AliMUONSt345SlatSegmentation::MorePads()
427 // Stopping condition for the iterator over pads
429 // Are there more pads in the integration region
431 return (fIx != -999 || fIy != -999);
433 //--------------------------------------------------------------------------
434 Int_t AliMUONSt345SlatSegmentation::Sector(Int_t ix, Int_t iy)
437 // Determine segmentation zone from pad coordinates
440 for (Int_t i = 0; i < fNsec; i++) {
441 if (ix <= fNpxS[i]) {
446 if (isec == -1) AliWarning(Form("Sector = %d with ix %d and iy %d, Npx %d",
447 isec, ix, iy, fNpx));
452 //-----------------------------------------------------------------------------
453 void AliMUONSt345SlatSegmentation::
454 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
456 // Returns integration limits for current pad
458 x1=fXhit-fX-Dpx(fSector)/2.;
460 y1=fYhit-fY-Dpy(fSector)/2.;
463 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));
466 //-----------------------------------------------------------------------------
467 void AliMUONSt345SlatSegmentation::
468 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
470 // Returns list of next neighbours for given Pad (iX, iY)
482 Int_t sector = Sector(iX,iY);
484 if (iY+1 <= fNpyS[sector]) {
496 //--------------------------------------------------------------------------
497 void AliMUONSt345SlatSegmentation::Init(Int_t detectionElementId)
500 // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
501 // These arrays help in converting from real to pad co-ordinates and
504 // Segmentation is defined by rectangular modules approximating
505 // concentric circles as shown below
507 // PCB module size in cm
508 // printf("\n Initialise Segmentation SlatModule \n");
511 // printf(" fBending: %d \n",fBending);
513 if (fInitDone) return; // security if init is already done in AliMUONFactory
517 // Calculate padsize along x
518 (*fDpxD)[fNsec-1]=fDpx;
519 (*fDpyD)[fNsec-1]=fDpy;
521 for (Int_t i=fNsec-1; i>=0; i--){ // fNsec-2
524 (*fDpyD)[i]=(*fDpyD)[fNsec-1]/(*fNDiv)[i];
526 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
532 // fill the arrays defining the pad segmentation boundaries
535 // Loop over sectors (isec=0 for secto close to the beam pipe)
536 Float_t totalLength = 0;
537 for (Int_t isec=0; isec<4; isec++) totalLength += fPcbBoards[isec]*fDxPCB; // !!!!
539 fNpy = 0; // maximum number of pads in y
540 for (Int_t isec=0; isec<4; isec++) {
544 fCx[0] = -totalLength/2;
546 fNpxS[isec] = fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]+0.5);
547 fNpyS[isec] = Int_t(fDyPCB/(*fDpyD)[isec]+0.5);
548 if (fNpyS[isec] >= fNpy) fNpy = fNpyS[isec];
549 fCx[isec]= fCx[isec-1] + fPcbBoards[isec]*fDxPCB;
553 fNpx = fNpxS[3]; // maximum number of pads in x
556 fId = detectionElementId;