// and the differents PCB densities.
// (from old AliMUONSegmentationSlatModule)
// Gines, Subatech, Nov04
+// Add electronics mapping
+// Christian, Subatech, Mai 05
//*********************************************************
#include <TArrayI.h>
AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation()
- : AliMUONVGeometryDESegmentation(),
+ : AliMUONVGeometryDESegmentation(),
fBending(0),
fId(0),
fNsec(0),
fIxmin(0),
fIxmax(0),
fIymin(0),
- fIymax(0)
+ fIymax(0),
+ fInitDone(kFALSE)
{
// default constructor
-
+ AliDebug(1,Form("this=%p default (empty) ctor",this));
}
//___________________________________________
fIxmin(0),
fIxmax(0),
fIymin(0),
- fIymax(0)
+ fIymax(0),
+ fInitDone(kFALSE)
+
{
// Non default constructor
fNsec = 4; // 4 sector densities at most per slat
fDpyD = new TArrayF(fNsec);
(*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
(*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
- (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0;
+ (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0;
+ AliDebug(1,Form("this=%p ctor for bending=%d",this,fBending));
+
}
//----------------------------------------------------------------------
AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(const AliMUONSt345SlatSegmentation& rhs)
fIymin(0),
fIymax(0)
{
- // default constructor
+// Copy constructor
+ AliFatal("Not implemented");
}
//----------------------------------------------------------------------
AliMUONSt345SlatSegmentation::~AliMUONSt345SlatSegmentation()
{
// Destructor
- if (fNDiv) delete fNDiv;
- if (fDpxD) delete fDpxD;
- if (fDpyD) delete fDpyD;
+
+ AliDebug(1, Form("dtor this = %p", this));
+
+ delete fNDiv;
+ delete fDpxD;
+ delete fDpyD;
}
//----------------------------------------------------------------------
AliMUONSt345SlatSegmentation& AliMUONSt345SlatSegmentation::operator=(const AliMUONSt345SlatSegmentation& rhs)
return fWireD*wire;
}
+//_____________________________________________________________________________
+Bool_t AliMUONSt345SlatSegmentation::HasPad(Int_t ix, Int_t iy)
+{
+// Return true if pas with given indices exists
+ if ( ix < 1 || ix > Npx() || iy < 1 || iy > Npy() )
+ {
+ return kFALSE;
+ }
+ Int_t isec = Sector(ix,iy);
+ if ( isec == -1 )
+ {
+ return kFALSE;
+ }
+ if ( iy > fNpyS[isec] )
+ {
+ return kFALSE;
+ }
+ return kTRUE;
+}
//--------------------------------------------------------------------------------
void AliMUONSt345SlatSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
{
- if (ix<1 || ix>Npx() || iy<1 || iy>Npy() ){
- AliWarning(Form("ix or iy out of boundaries: Npx=%d and Npy=%d",Npx(),Npy()));
- x=-99999.; y=-99999.;
- }
- else {
// Returns real coordinates (x,y) for given pad coordinates (ix,iy)
+
+ if (ix < 1 || ix > Npx() || iy < 1 || iy > Npy() ){
+ AliWarning(Form("ix %d or iy %d out of boundaries: Npx=%d and Npy=%d",ix, iy, Npx(), Npy()));
+ x = y= 0.;
+
+ } else {
+
// Find sector isec
Int_t isec = Sector(ix,iy);
- if (isec == -1) printf("\n PadC %d %d %d %d \n ", isec, fId, ix, iy);
+ if (isec == -1) AliWarning(Form("isector = %d with ix %d, iy %d", isec, ix, iy));
if (iy > fNpyS[isec]) {
- x=-99999.; y=-99999.;
+ x = y = 0.;
return;
}
if (isec>0) {
x = x-(*fDpxD)[isec]/2;
y = Float_t(iy*(*fDpyD)[isec])-(*fDpyD)[isec]/2.- fCy; // !!!
} else {
- x=y=0;
+ x = y = 0;
}
}
}
void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
{
// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
-
+
// Find sector isec
Int_t isec=-1;
for (Int_t i=fNsec-1; i > 0; i--) {
if (x >= fCx[i-1]) {
isec=i;
- if (fCx[isec] == fCx[isec-1] && isec > 1) isec--;
+ if (TMath::Abs(fCx[isec] - fCx[isec-1]) <0.1 && isec > 1) isec--;
break;
}
}
-
+ if (isec == -1) AliWarning(Form("isector equal to %d with xl %f, yl %f", isec, x, y));
if (isec>0) {
ix= Int_t((x-fCx[isec-1])/(*fDpxD)[isec])
+fNpxS[isec-1]+1;
//-------------------------------------------------------------------------
void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
{
+// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
+
GetPadI(x, y, ix, iy);
}
+
+
//_______________________________________________________________
void AliMUONSt345SlatSegmentation::SetPadDivision(Int_t ndiv[4])
{
{
//
// Set PcbBoard segmentation zones for each density
- // n[0] PcbBoards for maximum density sector fNDiv[0]
- // n[1] PcbBoards for next density sector fNDiv[1] etc ...
+ // n[0] slat type parameter
+ // n[1] PcbBoards for highest density sector fNDiv[1] etc ...
+
+ fRtype = n[0];
+ n[0] = 0;
for (Int_t i=0; i<4; i++) fPcbBoards[i]=n[i];
+
}
//-------------------------------------------------------------------------
void AliMUONSt345SlatSegmentation::SetPad(Int_t ix, Int_t iy)
fXhit = x;
fYhit = y;
- if (x < 0) fXhit = 0;
- if (y < 0) fYhit = 0;
+ if (x < fCx[0]) fXhit = fCx[0];
+ if (y < -fDyPCB/2.) fYhit = -fDyPCB/2.;
- if (x >= fCx[fNsec-1]) fXhit = fCx[fNsec-1];
- if (y >= fDyPCB) fYhit = fDyPCB;
+ if (x > fCx[fNsec-1]) fXhit = fCx[fNsec-1];
+ if (y > fDyPCB/2.) fYhit = fDyPCB/2.;
}
//----------------------------------------------------------------------------
void AliMUONSt345SlatSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
{
+ // Set current hit
+
SetHit(xhit, yhit);
}
//
//
// Find the wire position (center of charge distribution)
- Float_t x0a=GetAnod(xhit);
- fXhit=x0a;
- fYhit=yhit;
+ Float_t x0a = GetAnod(xhit);
+ fXhit = x0a;
+ fYhit = yhit;
//
// and take fNsigma*sigma around this center
- Float_t x01=x0a - dx;
- Float_t x02=x0a + dx;
- Float_t y01=yhit - dy;
- Float_t y02=yhit + dy;
- if (x01 < 0) x01 = 0;
- if (y01 < 0) y01 = 0;
+ Float_t x01 = x0a - dx ;
+ Float_t x02 = x0a + dx;
+ Float_t y01 = yhit - dy;
+ Float_t y02 = yhit + dy;
- if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1];
+ // check the limits after adding (fNsigma*sigma)
+ if (x01 < fCx[0]) x01 = fCx[0];
+ if (y01 < -fDyPCB/2) y01 = -fDyPCB/2;
+
+ if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1]; // still ok ? (CF)
+ if (y02 >= fDyPCB/2.) y02 = fDyPCB/2.;
Int_t isec=-1;
for (Int_t i=fNsec-1; i > 0; i--) {
- if (x02 >= fCx[i-1]) {
- isec=i;
- if (fCx[isec] == fCx[isec-1] && isec > 1) isec--;
- break;
- }
+ if (x02 >= fCx[i-1]) {
+ isec=i;
+ if (TMath::Abs(fCx[isec] - fCx[isec-1]) < 0.1 && isec > 1) isec--;
+ break;
+ }
}
- y02 += Dpy(isec);
- if (y02 >= fDyPCB) y02 = fDyPCB;
+
+ // y02 += Dpy(isec);// why ? (CF)
//
// find the pads over which the charge distributes
if (fIxmax > fNpx) fIxmax=fNpx;
if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec];
+ if (fIxmin < 1) fIxmin = 1; // patch for the moment (Ch. Finck)
+ if (fIymin < 1) fIymin = 1;
- fXmin=x01;
- fXmax=x02;
- fYmin=y01;
- fYmax=y02;
+ fXmin = x01;
+ fXmax = x02;
+ fYmin = y01;
+ fYmax = y02;
//
// Set current pad to lower left corner
- if (fIxmax < fIxmin) fIxmax=fIxmin;
- if (fIymax < fIymin) fIymax=fIymin;
- fIx=fIxmin;
- fIy=fIymin;
+ if (fIxmax < fIxmin) fIxmax = fIxmin;
+ if (fIymax < fIymin) fIymax = fIymin;
+ fIx = fIxmin;
+ fIy = fIymin;
GetPadC(fIx,fIy,fX,fY);
- fSector=Sector(fIx,fIy);
-/*
- printf("\n \n First Pad: %d %d %f %f %d %d %d %f" ,
- fIxmin, fIxmax, fXmin, fXmax, fNpx, fId, isec, Dpy(isec));
- printf("\n \n First Pad: %d %d %f %f %d %d %d %f",
- fIymin, fIymax, fYmin, fYmax, fNpyS[isec], fId, isec, Dpy(isec));
-*/
+ fSector = Sector(fIx,fIy);
+
+ AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d",
+ xhit,yhit,dx,dy,fIx,fIy));
}
-
-
//----------------------------------------------------------------------
void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
{
+// Initialises iteration over pads for charge distribution algorithm
+
FirstPad(xhit, yhit, dx, dy);
}
//----------------------------------------------------------------------
fIy++;
GetPadC(fIx,fIy,fX,fY);
fSector=Sector(fIx,fIy);
-
} else {
- fIx=-1;
- fIy=-1;
+ fIx=-999;
+ fIy=-999;
}
- // printf("\n Next Pad %d %d %f %f %d %d %d %d %d ",
}
//-------------------------------------------------------------------------
Int_t AliMUONSt345SlatSegmentation::MorePads()
//
// Are there more pads in the integration region
- return (fIx != -1 || fIy != -1);
+ return (fIx != -999 || fIy != -999);
}
//--------------------------------------------------------------------------
Int_t AliMUONSt345SlatSegmentation::Sector(Int_t ix, Int_t iy)
//
// Determine segmentation zone from pad coordinates
//
- Int_t isec=-1;
- for (Int_t i=0; i < fNsec; i++) {
+ Int_t isec = -1;
+ for (Int_t i = 0; i < fNsec; i++) {
if (ix <= fNpxS[i]) {
- isec=i;
+ isec = i;
break;
}
}
- if (isec == -1) printf("\n Sector: Attention isec ! %d %d %d %d \n",
- fId, ix, iy,fNpxS[3]);
+ if (isec == -1) AliWarning(Form("Sector = %d with ix %d and iy %d, Npx %d",
+ isec, ix, iy, fNpx));
return isec;
x2=x1+Dpx(fSector);
y1=fYhit-fY-Dpy(fSector)/2.;
y2=y1+Dpy(fSector);
- // printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector));
+
+ 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));
}
//-----------------------------------------------------------------------------
// printf(" fBending: %d \n",fBending);
+ if (fInitDone) return; // security if init is already done in AliMUONFactory
fDxPCB=40;
fDyPCB=40;
fNpyS[0] = 0;
fCx[0] = -totalLength/2;
} else {
- fNpxS[isec] = fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]);
- fNpyS[isec] = Int_t(fDyPCB/(*fDpyD)[isec]);
+ fNpxS[isec] = fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]+0.5);
+ fNpyS[isec] = Int_t(fDyPCB/(*fDpyD)[isec]+0.5);
if (fNpyS[isec] >= fNpy) fNpy = fNpyS[isec];
fCx[isec]= fCx[isec-1] + fPcbBoards[isec]*fDxPCB;
}
fCy = fDyPCB/2.;
//
fId = detectionElementId;
-}
-
-
-
-
-
-
-
-
-
-
+ fInitDone = kTRUE;
+}