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),
126 AliFatal("Not implemented");
128 //----------------------------------------------------------------------
129 AliMUONSt345SlatSegmentation::~AliMUONSt345SlatSegmentation()
133 AliDebug(1, Form("dtor this = %p", this));
139 //----------------------------------------------------------------------
140 AliMUONSt345SlatSegmentation& AliMUONSt345SlatSegmentation::operator=(const AliMUONSt345SlatSegmentation& rhs)
142 // Protected assignement operator
143 if (this == &rhs) return *this;
144 AliFatal("Not implemented.");
149 //------------------------------------------------------------------------
150 Float_t AliMUONSt345SlatSegmentation::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y, Int_t * /*dummy*/)
152 // Returns the square of the distance between 1 pad
153 // labelled by its Channel numbers and a coordinate
156 return (x-X)*(x-X) + (y-Y)*(y-Y);
158 //____________________________________________________________________________
159 Float_t AliMUONSt345SlatSegmentation::Dpx(Int_t isec) const
161 // Return x-strip width
162 return (*fDpxD)[isec];
165 //____________________________________________________________________________
166 Float_t AliMUONSt345SlatSegmentation::Dpy(Int_t isec) const
168 // Return y-strip width
169 return (*fDpyD)[isec];
171 //_____________________________________________________________________________
172 Float_t AliMUONSt345SlatSegmentation::GetAnod(Float_t xhit) const
174 // Returns for a hit position xhit the position of the nearest anode wire
175 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
179 //_____________________________________________________________________________
180 Bool_t AliMUONSt345SlatSegmentation::HasPad(Int_t ix, Int_t iy)
182 if ( ix < 1 || ix > Npx() || iy < 1 || iy > Npy() )
186 Int_t isec = Sector(ix,iy);
191 if ( iy > fNpyS[isec] )
198 //--------------------------------------------------------------------------------
199 void AliMUONSt345SlatSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
201 if (ix < 1 || ix > Npx() || iy < 1 || iy > Npy() ){
202 AliWarning(Form("ix %d or iy %d out of boundaries: Npx=%d and Npy=%d",ix, iy, Npx(), Npy()));
207 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
209 Int_t isec = Sector(ix,iy);
210 if (isec == -1) AliWarning(Form("isector = %d with ix %d, iy %d", isec, ix, iy));
211 if (iy > fNpyS[isec]) {
216 x = fCx[isec-1]+(ix-fNpxS[isec-1])*(*fDpxD)[isec];
217 x = x-(*fDpxD)[isec]/2;
218 y = Float_t(iy*(*fDpyD)[isec])-(*fDpyD)[isec]/2.- fCy; // !!!
226 //_____________________________________________________________________________
227 void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
229 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
233 for (Int_t i=fNsec-1; i > 0; i--) {
236 if (TMath::Abs(fCx[isec] - fCx[isec-1]) <0.1 && isec > 1) isec--;
240 if (isec == -1) AliWarning(Form("isector equal to %d with xl %f, yl %f", isec, x, y));
242 ix= Int_t((x-fCx[isec-1])/(*fDpxD)[isec])
244 iy= Int_t((y+fCy)/(*fDpyD)[isec])+1;
245 } else if (isec == 0) {
246 ix= Int_t(x/(*fDpxD)[isec])+1;
247 iy= Int_t((y+fCy)/(*fDpyD)[isec])+1;
253 //-------------------------------------------------------------------------
254 void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
256 GetPadI(x, y, ix, iy);
260 //_______________________________________________________________
261 void AliMUONSt345SlatSegmentation::SetPadDivision(Int_t ndiv[4])
263 // Defines the pad size perp. to the anode wire (y) for different sectors.
264 // Pad sizes are defined as integral fractions ndiv of a basis pad size
267 for (Int_t i=0; i<4; i++) {
272 //____________________________________________________________________________
273 void AliMUONSt345SlatSegmentation::SetPadSize(Float_t p1, Float_t p2)
279 //_______________________________________________________________
280 void AliMUONSt345SlatSegmentation::SetPcbBoards(Int_t n[4])
283 // Set PcbBoard segmentation zones for each density
284 // n[0] slat type parameter
285 // n[1] PcbBoards for highest density sector fNDiv[1] etc ...
289 for (Int_t i=0; i<4; i++) fPcbBoards[i]=n[i];
292 //-------------------------------------------------------------------------
293 void AliMUONSt345SlatSegmentation::SetPad(Int_t ix, Int_t iy)
296 // Sets virtual pad coordinates, needed for evaluating pad response
297 // outside the tracking program
298 GetPadC(ix,iy,fX,fY);
299 fSector=Sector(ix,iy);
301 //---------------------------------------------------------------------------
302 void AliMUONSt345SlatSegmentation::SetHit(Float_t x, Float_t y)
309 if (x < fCx[0]) fXhit = fCx[0];
310 if (y < -fDyPCB/2.) fYhit = -fDyPCB/2.;
312 if (x > fCx[fNsec-1]) fXhit = fCx[fNsec-1];
313 if (y > fDyPCB/2.) fYhit = fDyPCB/2.;
316 //----------------------------------------------------------------------------
317 void AliMUONSt345SlatSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
322 //----------------------------------------------------------
323 void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
325 // Initialises iteration over pads for charge distribution algorithm
328 // Find the wire position (center of charge distribution)
329 Float_t x0a = GetAnod(xhit);
333 // and take fNsigma*sigma around this center
334 Float_t x01 = x0a - dx ;
335 Float_t x02 = x0a + dx;
336 Float_t y01 = yhit - dy;
337 Float_t y02 = yhit + dy;
339 // check the limits after adding (fNsigma*sigma)
340 if (x01 < fCx[0]) x01 = fCx[0];
341 if (y01 < -fDyPCB/2) y01 = -fDyPCB/2;
343 if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1]; // still ok ? (CF)
344 if (y02 >= fDyPCB/2.) y02 = fDyPCB/2.;
348 for (Int_t i=fNsec-1; i > 0; i--) {
349 if (x02 >= fCx[i-1]) {
351 if (TMath::Abs(fCx[isec] - fCx[isec-1]) < 0.1 && isec > 1) isec--;
356 // y02 += Dpy(isec);// why ? (CF)
359 // find the pads over which the charge distributes
360 GetPadI(x01,y01,fIxmin,fIymin);
361 GetPadI(x02,y02,fIxmax,fIymax);
363 if (fIxmax > fNpx) fIxmax=fNpx;
364 if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec];
365 if (fIxmin < 1) fIxmin = 1; // patch for the moment (Ch. Finck)
366 if (fIymin < 1) fIymin = 1;
374 // Set current pad to lower left corner
375 if (fIxmax < fIxmin) fIxmax = fIxmin;
376 if (fIymax < fIymin) fIymax = fIymin;
380 GetPadC(fIx,fIy,fX,fY);
381 fSector = Sector(fIx,fIy);
383 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d",
384 xhit,yhit,dx,dy,fIx,fIy));
387 //----------------------------------------------------------------------
388 void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
390 FirstPad(xhit, yhit, dx, dy);
392 //----------------------------------------------------------------------
393 void AliMUONSt345SlatSegmentation::NextPad()
395 // Stepper for the iteration over pads
397 // Step to next pad in the integration region
398 // step from left to right
401 GetPadC(fIx,fIy,fX,fY);
402 fSector=Sector(fIx,fIy);
404 } else if (fIy != fIymax) {
407 GetPadC(fIx,fIy,fX,fY);
408 fSector=Sector(fIx,fIy);
414 //-------------------------------------------------------------------------
415 Int_t AliMUONSt345SlatSegmentation::MorePads()
417 // Stopping condition for the iterator over pads
419 // Are there more pads in the integration region
421 return (fIx != -999 || fIy != -999);
423 //--------------------------------------------------------------------------
424 Int_t AliMUONSt345SlatSegmentation::Sector(Int_t ix, Int_t iy)
427 // Determine segmentation zone from pad coordinates
430 for (Int_t i = 0; i < fNsec; i++) {
431 if (ix <= fNpxS[i]) {
436 if (isec == -1) AliWarning(Form("Sector = %d with ix %d and iy %d, Npx %d",
437 isec, ix, iy, fNpx));
442 //-----------------------------------------------------------------------------
443 void AliMUONSt345SlatSegmentation::
444 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
446 // Returns integration limits for current pad
448 x1=fXhit-fX-Dpx(fSector)/2.;
450 y1=fYhit-fY-Dpy(fSector)/2.;
453 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));
456 //-----------------------------------------------------------------------------
457 void AliMUONSt345SlatSegmentation::
458 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
460 // Returns list of next neighbours for given Pad (iX, iY)
472 Int_t sector = Sector(iX,iY);
474 if (iY+1 <= fNpyS[sector]) {
486 //--------------------------------------------------------------------------
487 void AliMUONSt345SlatSegmentation::Init(Int_t detectionElementId)
490 // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
491 // These arrays help in converting from real to pad co-ordinates and
494 // Segmentation is defined by rectangular modules approximating
495 // concentric circles as shown below
497 // PCB module size in cm
498 // printf("\n Initialise Segmentation SlatModule \n");
501 // printf(" fBending: %d \n",fBending);
503 if (fInitDone) return; // security if init is already done in AliMUONFactory
507 // Calculate padsize along x
508 (*fDpxD)[fNsec-1]=fDpx;
509 (*fDpyD)[fNsec-1]=fDpy;
511 for (Int_t i=fNsec-1; i>=0; i--){ // fNsec-2
514 (*fDpyD)[i]=(*fDpyD)[fNsec-1]/(*fNDiv)[i];
516 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
522 // fill the arrays defining the pad segmentation boundaries
525 // Loop over sectors (isec=0 for secto close to the beam pipe)
526 Float_t totalLength = 0;
527 for (Int_t isec=0; isec<4; isec++) totalLength += fPcbBoards[isec]*fDxPCB; // !!!!
529 fNpy = 0; // maximum number of pads in y
530 for (Int_t isec=0; isec<4; isec++) {
534 fCx[0] = -totalLength/2;
536 fNpxS[isec] = fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]+0.5);
537 fNpyS[isec] = Int_t(fDyPCB/(*fDpyD)[isec]+0.5);
538 if (fNpyS[isec] >= fNpy) fNpy = fNpyS[isec];
539 fCx[isec]= fCx[isec-1] + fPcbBoards[isec]*fDxPCB;
543 fNpx = fNpxS[3]; // maximum number of pads in x
546 fId = detectionElementId;