/* $Id$ */
-//**********************************************************************
-// Segmentation classe for trigger chambers.
-// In the present version the method use global strip coordinates except
-// HasPad. The conversion is made via GetPadLoc2Glo.
-// To be improved in the future.
-//**********************************************************************
+// -------------------------------------
+// Class AliMUONTriggerSegmentation
+// -------------------------------------
+// Segmentation for MUON trigger stations using
+// the mapping package
#include "AliMUONTriggerSegmentation.h"
+
+#include "AliMpPCB.h"
+#include "AliMpTrigger.h"
+#include "AliMpTriggerSegmentation.h"
+#include "AliMpSlat.h"
+
#include "AliLog.h"
+
#include "Riostream.h"
+#include "TClass.h"
+#include "TString.h"
-//___________________________________________
+/// \cond CLASSIMP
ClassImp(AliMUONTriggerSegmentation)
+/// \endcond
-AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
- : AliMUONVGeometryDESegmentation(),
- fBending(0),
- fId(0),
- fNsec(7),
- fNpx(999999),
- fNpy(999999),
- fXhit(0.),
- fYhit(0.),
- fIx(0),
- fIy(0),
- fX(0.),
- fY(0.),
-// add to St345SlatSegmentation
- fLineNumber(0),
- fRpcHalfXsize(0),
- fRpcHalfYsize(0)
-{
-// Default constructor
-
-// add to St345SlatSegmentation
- for (Int_t i=0; i<7; i++) {
- fNstrip[i]=0;
- fStripYsize[i]=0.;
- fStripXsize[i]=0.;
- fModuleXmin[i]=0.;
- fModuleXmax[i]=0.;
- fModuleYmin[i]=0.;
+namespace
+{
+// Int_t SPECIAL_SECTOR = 8;
+ Int_t fgIntOffset(1);
+ Float_t FMAX(1E9);
+ Int_t CODEMAKER(1000);
+
+ Int_t Code(Int_t ixLA, Int_t iyLA)
+ {
+ return iyLA*CODEMAKER + ixLA;
+ }
+
+ void Decode(Int_t code, Int_t& ixLA, Int_t& iyLA)
+ {
+ iyLA = code/CODEMAKER;
+ ixLA = code - iyLA*CODEMAKER;
}
+}
- AliDebug(1, Form("default (empty) ctor this = %p", this));
-}
-
-
-//___________________________________________
-AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
- : AliMUONVGeometryDESegmentation(),
- fBending(bending),
- fId(0),
- fNpx(999999),
- fNpy(999999),
- fXhit(0.),
- fYhit(0.),
- fIx(0),
- fIy(0),
- fX(0.),
- fY(0.),
-// add to St345SlatSegmentation
- fLineNumber(0),
- fRpcHalfXsize(0),
- fRpcHalfYsize(0)
-{
- // Non default constructor
- fNsec = 7;
-// add to St345SlatSegmentation
- for (Int_t i=0; i<7; i++) {
- fNstrip[i]=0;
- fStripYsize[i]=0.;
- fStripXsize[i]=0.;
- fModuleXmin[i]=0.;
- fModuleXmax[i]=0.;
- fModuleYmin[i]=0.;
+//_____________________________________________________________________________
+AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
+: AliMUONVGeometryDESegmentation(),
+ fDetElemId(-1),
+ fPlaneType(AliMp::kBendingPlane),
+ fSlat(0),
+ fSlatSegmentation(0),
+ fCurrentPad(),
+ fXhit(FMAX),
+ fYhit(FMAX),
+ fLineNumber(-1)
+{
+/// Default ctor (empty).
+
+ AliDebug(1,Form("this=%p default (empty) ctor",this));
+}
+
+//_____________________________________________________________________________
+AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(
+ AliMpVSegmentation* segmentation,
+ Int_t detElemId, AliMp::PlaneType bendingOrNonBending)
+ : AliMUONVGeometryDESegmentation(),
+ fDetElemId(detElemId),
+ fPlaneType(bendingOrNonBending),
+ fSlat(0),
+ fSlatSegmentation(0),
+ fCurrentPad(),
+ fXhit(FMAX),
+ fYhit(FMAX),
+ fLineNumber(-1)
+{
+/// Normal ctor.
+
+ fSlatSegmentation = dynamic_cast<AliMpTriggerSegmentation*>(segmentation);
+ if (fSlatSegmentation)
+ fSlat = fSlatSegmentation->Slat();
+ else
+ AliFatal("Wrong mapping segmentation type");
+
+ TString id(fSlat->GetID());
+ Ssiz_t pos = id.Last('L');
+ if ( pos <= 0 )
+ {
+ AliFatal(Form("Cannot infer line number for slat %s",id.Data()));
}
+ fLineNumber = TString(id(pos+1),1).Atoi();
+
+ AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
+ ( (bendingOrNonBending==AliMp::kBendingPlane)?"Bending":"NonBending" ),
+ fSlatSegmentation));
+}
+
+//_____________________________________________________________________________
+AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
+{
+/// Destructor
- AliDebug(1, Form("ctor this = %p", this) );
+ AliDebug(1,Form("this=%p",this));
}
-//----------------------------------------------------------------------
-AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(const AliMUONTriggerSegmentation& rhs) : AliMUONVGeometryDESegmentation(rhs)
+//_____________________________________________________________________________
+TF1*
+AliMUONTriggerSegmentation::CorrFunc(Int_t) const
{
-// Copy constructor
+/// Not implemented
- AliFatal("Not implemented.");
+ AliFatal("Not implemented");
+ return 0x0;
}
-//----------------------------------------------------------------------
-AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
+
+//_____________________________________________________________________________
+Float_t
+AliMUONTriggerSegmentation::Distance2AndOffset(Int_t, Int_t,
+ Float_t, Float_t, Int_t*)
{
- // Destructor
-
- AliDebug(1, Form("dtor this = %p", this) );
-}
-//----------------------------------------------------------------------
-AliMUONTriggerSegmentation& AliMUONTriggerSegmentation::operator=(const AliMUONTriggerSegmentation& rhs)
-{
-// Protected assignement operator
- if (this == &rhs) return *this;
- AliFatal("Not implemented.");
- return *this;
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ix)
-{
-// returns column number (from 0 to 6) in which the (global) module
-// ix is sitting (could return 7 if ix=isec)
- return TMath::Abs(ix)-Int_t(TMath::Abs(ix)/10)*10-1;
-}
-//----------------------------------------------------------------------
-Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
-{
-// check if steping outside the limits (iy=1,2... iy=0,1...)
- Bool_t hasPad = true;
- Int_t ixGlo = 0;
- Int_t iyGlo = 0;
- GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
- if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
- return hasPad;
-}
-//____________________________________________________________________________
-Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
-{
-// return x-strip width in sector isec
- Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
- return size;
-}
-//____________________________________________________________________________
-Float_t AliMUONTriggerSegmentation::Dpy(Int_t isec) const
-{
-// return y-strip width in sector isec
- Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
- return size;
-}
-//----------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc,
- Int_t &ixGlo, Int_t &iyGlo)
-{
-// converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
- ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
- iyGlo = 0; // from 0 to (fNtrip-1) in module
- if (fBending) {
- ixGlo = 10*fLineNumber + ixLoc;
- iyGlo = iyLoc - 1;
- } else if (!fBending) {
- Int_t iCountStrip = 0;
- for (Int_t iModule=0; iModule<fNsec; iModule++) {
- for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
- if ((ixLoc-1)==iCountStrip) {
- ixGlo = 10*fLineNumber + iModule + 1;
- iyGlo = iStrip;
- }
- iCountStrip++;
- }
- }
- }
-// printf(" in GetPadLoc2Glo fbending ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",fBending,ixLoc,iyLoc,ixGlo,iyGlo);
-}
-
-//----------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
- Int_t &ixLoc, Int_t &iyLoc)
-{
-// converts ixGlo & iyGlo into ixLoc & iyLoc
- ixLoc = 0;
- iyLoc = 0;
- if (fBending) {
- ixLoc = ModuleColNum(ixGlo) + 1;
- iyLoc = iyGlo + 1;
- } else if (!fBending) {
- Int_t iCountStrip = 1;
- for (Int_t iModule=0; iModule<fNsec; iModule++) {
- for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
- if ((iModule==ModuleColNum(ixGlo))&&(iStrip==iyGlo)) {
- iyLoc = 1;
- ixLoc = iCountStrip;
- }
- iCountStrip++;
- }
- }
- }
-// printf(" in GetPadGlo2Loc fBending ixGlo iyGlo ixLoc iyLoc %i %i %i %i %i \n",fBending,ixGlo,iyGlo,ixLoc,iyLoc);
+/// Not implemented
+
+ AliFatal("Not implemented");
+ return 0;
}
-//----------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::Draw(Option_t*)
+{
+/// Not implemented
+
+ AliFatal("Not Implemented");
+}
+
+//_____________________________________________________________________________
+Float_t
+AliMUONTriggerSegmentation::Dpx() const
+{
+/// Not implemented
+
+ AliFatal("Not Implemented");
+ return 0.0;
+}
+
+//_____________________________________________________________________________
+Float_t
+AliMUONTriggerSegmentation::Dpy() const
+{
+/// Not implemented
+
+ AliFatal("Not Implemented");
+ return 0.0;
+}
+
+//_____________________________________________________________________________
+Float_t
+AliMUONTriggerSegmentation::Dpx(Int_t sectorCode) const
+{
+/// Get pad size in x
+
+ Int_t ixLA, iyLA;
+ Decode(sectorCode,ixLA,iyLA);
+ AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
+ if ( !pad.IsValid() ) return 0.0;
+ return pad.Dimensions().X()*2.0;
+}
+
+//_____________________________________________________________________________
+Float_t
+AliMUONTriggerSegmentation::Dpy(Int_t sectorCode) const
+{
+/// Get pad size in y
+
+ Int_t ixLA, iyLA;
+ Decode(sectorCode,ixLA,iyLA);
+ AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
+ if ( !pad.IsValid() ) return 0.0;
+ return pad.Dimensions().Y()*2.0;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::FirstPad(Float_t /*xhit*/, Float_t /*yhit*/, Float_t /*zhit*/,
+ Float_t /*dx*/, Float_t /*dy*/)
+{
+/// Not implemented
+
+ AliFatal("Not implemented");
+}
+
+//_____________________________________________________________________________
+Float_t
+AliMUONTriggerSegmentation::GetAnod(Float_t) const
+{
+/// Not implemented
+
+ AliFatal("Not implemented");
+ return 0.0;
+}
+
+//_____________________________________________________________________________
+AliMUONGeometryDirection
+AliMUONTriggerSegmentation::GetDirection()
+{
+/// Not implemented
+
+ //AliWarning("Not Implemented");
+ return kDirUndefined;
+}
+
+//______________________________________________________________________________
+const AliMpVSegmentation*
+AliMUONTriggerSegmentation::GetMpSegmentation() const
+{
+/// Returns the mapping segmentation
+/// (provides access to electronics info)
+
+ return fSlatSegmentation;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
{
-// Returns local real coordinates (x,y) for local pad coordinates (ix,iy)
+/// Not implemented
- x = 0.;
- y = 0.;
- Int_t iModule = ModuleColNum(ix); // find column number (0-6)
- if (fBending) {
- if (iModule==0) {
- x = fStripXsize[iModule]/ 2.;
- } else {
- x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
+ AliFatal("Not Implemented");
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy,
+ Float_t& x, Float_t& y, Float_t& z)
+{
+/// Transform from pad to real coordinates
+
+ z = 0;
+ GetPadC(ix,iy,x,y);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::GetPadC(Int_t ixGlo, Int_t iyGlo,
+ Float_t& x, Float_t& y)
+{
+/// Transform from pad to real coordinates
+
+ Int_t ixLA,iyLA;
+ IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
+ AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
+ x = pad.Position().X();
+ y = pad.Position().Y();
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Float_t,
+ Int_t& ix, Int_t& iy)
+{
+/// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
+
+ GetPadI(x,y,ix,iy);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y,
+ Int_t& ixGlo, Int_t& iyGlo)
+{
+/// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
+
+ AliDebug(2,Form("%s x=%e y=%e ixGlo,iyGlo=%d,%d\n",
+ fSlatSegmentation->GetName(),
+ x,y,ixGlo,iyGlo));
+
+ AliMpPad pad =
+ fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
+
+ if ( pad != AliMpPad::Invalid() )
+ {
+ Int_t ix = pad.GetIndices().GetFirst();
+ Int_t iy = pad.GetIndices().GetSecond();
+ ILoc2IGlo(ix,iy,ixGlo,iyGlo);
}
- y = fModuleYmin[iModule] +
- iy*fStripYsize[iModule] + fStripYsize[iModule]/2.;
- } else if (!fBending) {
- if (ModuleColNum(ix)==6 && iy>7) {
- x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
- (iy-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
- } else {
- x = fModuleXmin[iModule] +
- iy*fStripXsize[iModule] + fStripXsize[iModule]/2.;
+ else
+ {
+ ixGlo=iyGlo=-1;
}
- y = fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
- }
- x = x - fRpcHalfXsize;
- y = y - fRpcHalfYsize;
+ AliDebug(2,Form("ixGlo,iyGlo=%d,%d\n",ixGlo,iyGlo));
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ix, Int_t iy,
+ Int_t& ixGlo, Int_t& iyGlo) const
+{
+/// Converts from local (in PC convention) to (ix,iy) to global (ix,iy)
-// printf(" in GetPadC fBending ix iy x y %i %i %i %f %f \n",fBending,ix,iy,x,y);
+ ixGlo=iyGlo=-1; // starts with invalid values
+
+ if ( fPlaneType == AliMp::kBendingPlane )
+ {
+ ixGlo = 10*LineNumber() + ix;
+ iyGlo = iy - fgIntOffset;
+ }
+ else if ( fPlaneType == AliMp::kNonBendingPlane )
+ {
+ Int_t i = fSlat->GetLayer(0)->FindPCBIndex(ix-fgIntOffset);
+ if (i<0)
+ {
+ AliError(Form("Invalid local (ix=%d,iy=%d) ?",ix,iy));
+ return ;
+ }
+ AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ix-fgIntOffset);
+ iyGlo = ix - pcb->Ixmin() - fgIntOffset;
+ if ( LineNumber() == 5 ) ++i;
+ ixGlo = 10*LineNumber() + i + fgIntOffset;
+ }
}
//_____________________________________________________________________________
-void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
+void
+AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
+ Int_t& ix, Int_t& iy) const
{
-// Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
- ix = -1;
- iy = -1;
+/// Converts from global (ix,iy) to local (ix,iy) (in PC convention)
+
+ ix=iy=-1; // starts with invalid values
- x = x + fRpcHalfXsize;
- y = y + fRpcHalfYsize;
-// find module number
- Int_t modNum=0;
- for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
- if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
- ix = 10*fLineNumber + iModule + 1;
- modNum = iModule;
- }
+ if ( abs(ixGlo) == 51 ) return;
+
+ Int_t column = ModuleColNum(ixGlo);
+
+ if ( fPlaneType == AliMp::kBendingPlane )
+ {
+ ix = column + fgIntOffset;
+ iy = iyGlo + fgIntOffset;
+ }
+ else if ( fPlaneType == AliMp::kNonBendingPlane )
+ {
+ if ( LineNumber()==5 ) --column;
+ AliMpPCB* pcb = fSlat->GetLayer(0)->GetPCB(column);
+ if (!pcb)
+ {
+ AliError(Form("Invalid global (ix=%d,iy=%d)",ixGlo,iyGlo));
+ return;
}
+ ix = pcb->Ixmin() + iyGlo + fgIntOffset;
+ iy = fgIntOffset;
+ }
+}
-// find strip number
- Float_t yMin = 0.;
- Float_t yMax = fModuleYmin[modNum];
- Float_t xMin = 0.;
- Float_t xMax = fModuleXmin[modNum];
- if (ix!=0) {
- for (Int_t iStrip=0; iStrip<fNstrip[modNum]; iStrip++) {
- if (fBending) {
- yMin = yMax;
- yMax = yMin + fStripYsize[modNum];
- if (y > yMin && y < yMax) iy = iStrip;
- } else if (!fBending) {
- xMin = xMax;
- if (modNum==6 && iStrip>7) {
- xMax = xMin + fStripXsize[modNum]/2.;
- } else {
- xMax = xMin + fStripXsize[modNum];
- }
- if (x > xMin && x < xMax) iy = iStrip;
- } //
- } // loop on strips
- } // if ix!=0
-// printf("in GetPadI fBending x y ix iy %i %f %f %i %i \n",fBending,x,y,ix,iy);
-}
-//-------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
-{
-// Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
- GetPadI(x, y, ix, iy);
-}
-
-//-------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
-// Set line number
- fLineNumber = iLineNumber;
-}
-//-------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
-{
- // Sets virtual pad coordinates, needed for evaluating pad response
- // outside the tracking program
- GetPadC(ix,iy,fX,fY);
- fIx = ix; // used in IntegrationLimits
- fIy = iy;
- fSector=Sector(ix,iy);
-}
-//---------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
-{
- // Set current hit
- fXhit = x;
- fYhit = y;
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::GiveTestPoints(Int_t& /*n*/,
+ Float_t* /*x*/, Float_t*/*y*/) const
+{
+/// Not implemented
+
+ AliFatal("Not Implemented");
}
-//----------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
+
+//_____________________________________________________________________________
+Bool_t
+AliMUONTriggerSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
{
- // Set current hit
- SetHit(xhit, yhit);
+/// Returns true if a pad exists in the given position
+///
+/// Well, 2 implementations are possible here
+/// Either reuse HasPad(int,int), or get it from scratch using
+/// underlying fSlatSegmentation.
+/// Took second option, but w/o checking whether this is the faster.
+/// The second option is commented out below, for the record.
+
+// Int_t ix, iy;
+// GetPadI(x,y,z,ix,iy);
+// Int_t ixLA, iyLA;
+// IGlo2ILoc(ix,iy,ixLA,iyLA);
+// Int_t ixPC, iyPC;
+// LA2PC(ixLA,iyLA,ixPC,iyPC);
+// Bool_t ok1 = HasPad(ixPC,iyPC);
+
+ AliMpPad pad =
+ fSlatSegmentation->PadByPosition(TVector2(x,y),kFALSE);
+ return pad.IsValid();
}
-//--------------------------------------------------------------------------
-Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
+//_____________________________________________________________________________
+Bool_t
+AliMUONTriggerSegmentation::HasPad(Int_t ixGlo, Int_t iyGlo)
{
-// determine segmentation zone from pad coordinates (from 1 to 8)
- if (!fBending && ModuleColNum(ix)==6 && iy>7) {
- return 8; // sector 8: diff. strip width within same module
- } else {
- return ModuleColNum(ix)+1;
- }
+/// Returns true if a pad with given indices exists
+
+ Int_t ixLA, iyLA;
+ IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
+ return fSlatSegmentation->HasPad(AliMpIntPair(ixLA,iyLA));
}
-//-----------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,
- Float_t& x3, Float_t& x4)
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::IGlo2ILoc(Int_t ixGlo, Int_t iyGlo,
+ Int_t& ixLA, Int_t& iyLA) const
{
-// need to return (only) x4 = dist. betwwen the hit and the closest border of
-// the current strip
+/// \todo FIXME: add comment
- Int_t ix,iy;
- Float_t xstrip,ystrip;
- GetPadI(fXhit,fYhit,ix,iy);
- GetPadC(ix,iy,xstrip,ystrip);
+ Int_t ixPC, iyPC;
+ GetPadGlo2Loc(ixGlo,iyGlo,ixPC,iyPC);
+ PC2LA(ixPC,iyPC,ixLA,iyLA);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::ILoc2IGlo(Int_t ixLA, Int_t iyLA,
+ Int_t& ixGlo, Int_t& iyGlo) const
+{
+/// \todo FIXME: add comment
+
+ Int_t ixPC, iyPC;
+ LA2PC(ixLA,iyLA,ixPC,iyPC);
+ GetPadLoc2Glo(ixPC,iyPC,ixGlo,iyGlo);
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::ISector()
+{
+/// \todo FIXME: remove the usage of ISector from all the code.
+
+ return -10;
+}
+
+//_____________________________________________________________________________
+void AliMUONTriggerSegmentation::IntegrationLimits(Float_t& x1,
+ Float_t& x2,
+ Float_t& x3,
+ Float_t& x4)
+{
+/// \param x1 : hit x(y) position
+/// \param x2 : x(y) coordinate of the main strip
+/// \param x3 : current strip real x(y) coordinate
+/// \param x4 : dist. between x(y) hit pos. and the closest border of the current strip
+///
+/// Note : need to return (only) x4.
+
+ AliFatal("Check me before usage. ResponseTrigger does not use me, while"
+ "ResponseTriggerV1 does ?");
+
+ AliMpPad strip =
+ fSlatSegmentation->PadByPosition(TVector2(fXhit,fYhit),kFALSE);
+ if ( !strip.IsValid() )
+ {
+ AliWarning(Form("%s got invalid fXhit,fYhit=%e,%e\n",
+ fSlatSegmentation->GetName(),fXhit,fYhit));
+ x1=x2=x3=x4=0;
+ }
+ else
+ {
+ Double_t xstrip = strip.Position().X();
+ Double_t ystrip = strip.Position().Y();
AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
fXhit,fYhit,xstrip,ystrip));
- x1= (fBending) ? fYhit : fXhit; // hit y (bending) / x (!bending) position
- x2= (fBending) ? ystrip : xstrip; // y or x coord. of the main strip
- x3= (fBending) ? fY : fX; // current strip real y or x coord.
- Int_t modNum = ModuleColNum(fIx);
-
- // find the position of the 2 borders of the current strip
- Float_t min = 0.;
- Float_t max = 0.;
- if (fBending) {
- min = x3 - fStripYsize[modNum]/2.;
- max = x3 + fStripYsize[modNum]/2.;
- } else {
- if (modNum==6 && fIy>7) { // equivalent to fSector == 8
- min = x3 - fStripXsize[modNum]/4.;
- max = x3 + fStripXsize[modNum]/4.;
- } else
- min = x3 - fStripXsize[modNum]/2.;
- max = x3 + fStripXsize[modNum]/2.;
- }
+ x1 = (fPlaneType==AliMp::kBendingPlane) ? fYhit : fXhit;
+ x2 = (fPlaneType==AliMp::kBendingPlane) ? ystrip : xstrip;
+ x3 = (fPlaneType==AliMp::kBendingPlane) ?
+ fCurrentPad.Position().Y() : fCurrentPad.Position().X();
+ Double_t xmin = 0.0;
+ Double_t xmax = 0.0;
+ if (fPlaneType==AliMp::kBendingPlane)
+ {
+ xmin = x3 - fCurrentPad.Dimensions().X();
+ xmax = x3 + fCurrentPad.Dimensions().X();
+ }
+ else
+ {
+ xmin = x3 - fCurrentPad.Dimensions().Y();
+ xmax = x3 + fCurrentPad.Dimensions().Y();
+ }
// dist. between the hit and the closest border of the current strip
- x4 = (TMath::Abs(max-x1) > TMath::Abs(min-x1)) ?
- TMath::Abs(min-x1):TMath::Abs(max-x1);
-
- AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
- fBending,x1,x2,x3,x4,min,max));
-}
-
-
-//-----------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::
-Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
-{
-//-----------------BENDING-----------------------------------------
-// Returns list of 10 next neighbours for given X strip (ix, iy)
-// neighbour number 4 in the list -
-// neighbour number 3 in the list |
-// neighbour number 2 in the list |_ Upper part
-// neighbour number 1 in the list |
-// neighbour number 0 in the list -
-// X strip (ix, iy)
-// neighbour number 5 in the list -
-// neighbour number 6 in the list | _ Lower part
-// neighbour number 7 in the list |
-// neighbour number 8 in the list |
-// neighbour number 9 in the list -
-
-//-----------------NON-BENDING-------------------------------------
-// Returns list of 10 next neighbours for given Y strip (ix, iy)
-// neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
-// \_______/ \_______/
-// left right
-
- Int_t absiX = TMath::Abs(iX);
- Int_t modNum = ModuleColNum(absiX); // from 0 to 6
- Int_t nStrip = fNstrip[modNum];
-
- if (fBending) {
- Int_t iCandidateUp, iCandidateDo;
- Int_t j;
-
- *Nlist = 10;
- for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
-
- if (iY < nStrip) {
- for (Int_t i=0; i<5; i++) {
- j = i + 5;
- iCandidateUp = iY + (i + 1);
- iCandidateDo = iY - (i + 1);
- if (iCandidateUp < nStrip) {
- Xlist[i] = iX;
- Ylist[i] = iCandidateUp;
- }
- if (iCandidateDo >= 0) {
- Xlist[j] = iX;
- Ylist[j] = iCandidateDo;
- }
- }
- } // iY < nStrip
-
- } else { // non-bending
-
- Int_t iCandidateLeft, iCandidateRight;
- Int_t iNewCandidateRight=0;
- Int_t iNewCandidateLeft=0;
-// first strip number on the right of the left module
- if ( modNum!=0 && absiX!=52 )
- iNewCandidateLeft = fNstrip[modNum-1]-1;
- Int_t j;
-
- *Nlist = 10;
- for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
-
- if (iY < nStrip) {
-
- for (Int_t i=0; i<5; i++) {
- j = i + 5;
- iCandidateRight = iY + (i + 1);
- iCandidateLeft = iY - (i + 1);
- if (iCandidateRight < nStrip) { // strip in same module
- Xlist[i] = absiX;
- Ylist[i] = iCandidateRight;
- } else if (modNum!=6) { // need to scan the module on the right
- Xlist[i] = absiX+1;
- Ylist[i] = iNewCandidateRight;
- iNewCandidateRight++;
- }
-
- if (iCandidateLeft >=0 ) { // strip in same module
- Xlist[j] = absiX;
- Ylist[j] = iCandidateLeft;
- } else if ( iNewCandidateLeft !=0) {
- Xlist[j] = absiX-1;
- Ylist[j] = iNewCandidateLeft;
- iNewCandidateLeft--;
- }
- }
-
- if (iX<0) { // left side of chamber
- for (Int_t i=0; i<10; i++) {
- if (Xlist[i]!=0) Xlist[i]=-Xlist[i];
- }
- }
-
- } // iY < nStrip
- } // non-bending
-
-// for (Int_t i=0; i<10; i++) {
-// printf("AliMUONTriggerSegmentation LOC fBending i ix iy = %i %i %i %i \n",fBending,i,Xlist[i],Ylist[i]);
-// }
-}
-
-//--------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
- Int_t nStrip[7],
- Float_t stripYsize[7],
- Float_t stripXsize[7],
- Float_t offset)
-{
-// printf(" fBending: %d \n",fBending);
-
- Int_t nStripMax = 0;
- if (fBending) nStripMax = nStrip[0];
+ x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ?
+ TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);
- for (Int_t i=0; i<7; i++) {
- fNstrip[i]=nStrip[i];
- fStripYsize[i]=stripYsize[i];
- fStripXsize[i]=stripXsize[i];
- fModuleYmin[0]=0.;
+ AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
+ fPlaneType,x1,x2,x3,x4,xmin,xmax));
+
+ }
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::Ix()
+{
+/// Current pad cursor during disintegration
+/// x, y-coordinate
+
+ if ( fCurrentPad.IsValid() )
+ {
+ Int_t ixGlo,iyGlo;
+ ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
+ fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
+ return ixGlo;
+ }
+ return -1;
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::Iy()
+{
+/// Current pad cursor during disintegration
+/// x, y-coordinate
+
+ if ( fCurrentPad.IsValid() )
+ {
+ Int_t ixGlo,iyGlo;
+ ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
+ fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
+ return iyGlo;
+ }
+ return -1;
+}
+
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::LA2PC(Int_t ixLA, Int_t iyLA,
+ Int_t& ixPC, Int_t& iyPC) const
+{
+/// From LA to PC conventions for integers indices.
+
+ ixPC=iyPC=-1;
+
+ if ( ixLA<0 || iyLA<0 ) return;
+
+ ixPC = ixLA + 1;
+ iyPC = iyLA + 1;
+
+ if ( fPlaneType == AliMp::kBendingPlane )
+ {
+ if ( LineNumber()==5 )
+ {
+ ++ixPC;
+ }
+ if ( LineNumber()==4 && ixLA==0 )
+ {
+ iyPC -= 16;
+ }
+ }
+
+ AliDebug(3,Form("ix,iy LA (%d,%d) -> PC (%d,%d)",ixLA,iyLA,ixPC,iyPC));
+
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::LineNumber() const
+{
+/// \todo FIXME: add comment
+
+ return 10-fLineNumber;
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::ModuleColNum(Int_t ixGlo) const
+{
+/// returns column number (from 0 to 6) in which the (global) module
+/// ix is sitting (could return 7 if ix=isec)
+
+ return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::MorePads()
+{
+/// Not implemented
+
+ AliFatal("Not implemented");
+ return 0;
+}
+
+//_____________________________________________________________________________
+void AliMUONTriggerSegmentation::Neighbours(Int_t /*iX*/, Int_t /*iY*/,
+ Int_t* /*Nlist*/,
+ Int_t /*Xlist*/[10],
+ Int_t /*Ylist*/[10])
+{
+/// Not implemented
+
+ //-----------------BENDING-----------------------------------------
+ // Returns list of 10 next neighbours for given X strip (ix, iy)
+ // neighbour number 4 in the list -
+ // neighbour number 3 in the list |
+ // neighbour number 2 in the list |_ Upper part
+ // neighbour number 1 in the list |
+ // neighbour number 0 in the list -
+ // X strip (ix, iy)
+ // neighbour number 5 in the list -
+ // neighbour number 6 in the list | _ Lower part
+ // neighbour number 7 in the list |
+ // neighbour number 8 in the list |
+ // neighbour number 9 in the list -
+
+ //-----------------NON-BENDING-------------------------------------
+ // Returns list of 10 next neighbours for given Y strip (ix, iy)
+ // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
+ // \_______/ \_______/
+ // left right
+ AliFatal("Please implement me");
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::NextPad()
+{
+/// Not implemented
+
+ AliFatal("Not implemented");
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::Npx() const
+{
+/// Maximum number of Pads in x
+/// hard coded for the time being
+
+ return 124;// FIXME: this should not have to be done, if only we'd stick
+ // to a local (ix,iy) convention !!!
+ // return fSlatSegmentation->MaxPadIndexX()+1;
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::Npy() const
+{
+/// Maximum number of Pads in y
+/// hard coded for the time being
+
+ return 64;
+// return fSlatSegmentation->MaxPadIndexY()+1;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::PC2LA(Int_t ixPC, Int_t iyPC,
+ Int_t& ixLA, Int_t& iyLA) const
+{
+/// From PC to LA conventions for integers indices.
+
+ ixLA=iyLA=-1;
+
+ if ( ixPC<0 || iyPC<0 ) return;
+
+ ixLA = ixPC - 1;
+ iyLA = iyPC - 1;
+
+ if ( fPlaneType == AliMp::kBendingPlane )
+ {
+ if ( LineNumber()==5 )
+ {
+ --ixLA;
+ }
+ if ( LineNumber()==4 && ixLA==0 )
+ {
+ iyLA += 16;
}
-// take care of offset in Y in chamber 5, first module
- fModuleYmin[0] = offset;
-
- Float_t tmp = 0.;
- Int_t npad = 0; // number of pad in x and y
- for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
- fModuleXmin[iModule] = tmp;
- npad = npad + fNstrip[iModule];
- if (fBending) {
- fModuleXmax[iModule] =
- fModuleXmin[iModule] + fStripXsize[iModule];
- } else if (!fBending) {
- if (iModule<6) {
- fModuleXmax[iModule] =
- fModuleXmin[iModule] +
- fStripXsize[iModule]*fNstrip[iModule];
- } else if (iModule==6) {
- fModuleXmax[iModule] =
- fModuleXmin[iModule] +
- (fStripXsize[iModule]*fNstrip[iModule]/2) +
- (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
- }
- }
- tmp = fModuleXmax[iModule];
-
-// calculate nStripMax in x & y
- if (fBending) {
- if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
- } else if (!fBending) {
- for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
- }
- } // loop on modules
-
-// associate nStripMax
-// fNpx = (fBending) ? fNsec : nStripMax;
-// fNpy = (fBending) ? nStripMax : 1;
- fNpx = 124; // tot num of modules (like with old segmentation)
- fNpy = 64; // max number of y strips within one module
-
-// calculate half size in x & y (to shift local coordinate ref. system)
- fRpcHalfXsize = 0;
- fRpcHalfYsize = 0;
- if (fBending) {
- for (Int_t iModule=0; iModule<fNsec; iModule++)
- fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];
- fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
- } else if (!fBending) {
- fRpcHalfXsize = fModuleXmax[6];
- fRpcHalfYsize = fStripYsize[1];
}
- fRpcHalfXsize = fRpcHalfXsize / 2.;
- fRpcHalfYsize = fRpcHalfYsize / 2.;
-
-/*
- printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
- fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
-
- for (Int_t iModule=0; iModule<fNsec; iModule++) {
- printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
- iModule,fModuleXmin[iModule],fModuleXmax[iModule],
- fModuleYmin[iModule],
- fStripXsize[iModule],fStripYsize[iModule]);
- }
-
- for (Int_t iModule=0; iModule<fNsec; iModule++) {
- printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
- iModule,fNstrip[iModule],
- fStripXsize[iModule],fStripYsize[iModule]);
+
+ AliDebug(3,Form("ix,iy PC (%d,%d) -> LA (%d,%d)",ixPC,iyPC,ixLA,iyLA));
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::Print(Option_t* opt) const
+{
+/// Printing
+
+ TString sopt(opt);
+
+ cout << "DetElemId=" << fDetElemId << " PlaneType="
+ << fPlaneType << " Npx=" << Npx() << " Npy=" << Npy() << endl;
+ if ( ( sopt.Contains("SEG") || sopt.Contains("ALL") ) && fSlatSegmentation )
+ {
+ fSlatSegmentation->Print();
}
-*/
+ if ( sopt.Contains("ALL") && fSlat )
+ {
+ fSlat->Print();
+ }
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
+{
+/// Calculate sector from pad coordinates
+
+ Int_t ixLA, iyLA;
+ IGlo2ILoc(ix,iy,ixLA,iyLA);
+ AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
+ if ( !pad.IsValid() ) return -1;
+ return Code(ixLA,iyLA);
+
+// AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ixLA);
+// if (!pcb)
+// {
+// AliError(Form("Could not find a pcb at (%d,%d) for slat %s",
+// ix,iy,fSlat->GetName()));
+// return -1;
+// }
+// if ( pcb->PadSizeX()==-1.0 )
+// {
+// // special case of column 7 non-bending.
+// return SPECIAL_SECTOR;
+// }
+// return fSlat->GetLayer(0)->FindPCBIndex(ixLA);
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::Sector(Float_t, Float_t)
+{
+/// Not implemented
+
+ AliFatal("Not implemented");
+ return 0;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::SetCorrFunc(Int_t,TF1*)
+{
+/// Not implemented
+
+ AliFatal("Not Implemented");
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::SetDAnod(Float_t)
+{
+/// Not implemented
- fId = detectionElementId;
+ AliFatal("Not Implemented");
}
//_____________________________________________________________________________
void
-AliMUONTriggerSegmentation::Print(Option_t*) const
+AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
{
-// Printing
+/// Set hit position
+/// Sets virtual hit position, needed for evaluating pad response
+/// outside the tracking program
- cout << "fId=" << fId << " fBending=" << fBending << " fNsec="
- << fNsec << " Nx,Ny=" << fNpx << "," << fNpy
- << " LineNumber=" << fLineNumber
- << " fRpcHalfSize(X,Y)=" << fRpcHalfXsize << "," << fRpcHalfYsize
- << endl;
+ fXhit = x;
+ fYhit = y;
+
+ //
+ // insure we're within the slat limits. If not, issue an error and sets
+ // the current hit to slat center.
+ // FIXME: this should probably a) not happen at all b) be a fatal error
+ //
+ if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
+ fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
+ {
+ AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
+ " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
+ fXhit = 0.0;
+ fYhit = 0.0;
+ }
- for (Int_t iModule=0; iModule<fNsec; iModule++)
- {
- cout << "Module " << iModule
- << " xmin,xmax=" << fModuleXmin[iModule]
- << "," << fModuleXmax[iModule]
- << " ymin=" << fModuleYmin[iModule]
- << " StripSize(X,Y)=(" << fStripXsize[iModule] << ","
- << fStripYsize[iModule] << ")"
- << endl;
- }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y, Float_t)
+{
+/// Set hit position
+/// Sets virtual hit position, needed for evaluating pad response
+/// outside the tracking program
+
+ SetHit(x,y);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
+{
+/// Set pad position.
+/// Sets virtual pad coordinates, needed for evaluating pad response
+/// outside the tracking program.
+
+ Int_t ixLA, iyLA;
+ IGlo2ILoc(ix,iy,ixLA,iyLA);
+ fCurrentPad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
+ if ( !fCurrentPad.IsValid() )
+ {
+ AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
+ }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::SetPadSize(Float_t,Float_t)
+{
+/// Not implemented
+
+ AliFatal("Not Implemented");
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMUONTriggerSegmentation::SigGenCond(Float_t,Float_t,Float_t)
+{
+/// Not implemented
+
+ AliFatal("Not Implemented");
+ return 0;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::SigGenInit(Float_t,Float_t,Float_t)
+{
+/// Not implemented
+
+ AliFatal("Not Implemented");
}