// $Id$
// $MpId: AliMpSlatSegmentation.cxx,v 1.12 2006/05/24 13:58:50 ivana Exp $
+//-----------------------------------------------------------------------------
// Caution !!
// Implementation note.
// The position(s) used in the interface are supposed to be relative
// to the slat center (AliMpSlat::Position()), whereas internally
// the x,y are relative to bottom-left corner.
+//-----------------------------------------------------------------------------
#include "AliMpSlatSegmentation.h"
#include "AliLog.h"
#include "AliMpArea.h"
#include "AliMpConnection.h"
+#include "AliMpConstants.h"
+#include "AliLog.h"
#include "AliMpMotif.h"
#include "AliMpMotifPosition.h"
#include "AliMpMotifType.h"
#include "AliMpSlat.h"
#include "AliMpSlatPadIterator.h"
+#include "AliMpEncodePair.h"
/// \cond CLASSIMP
ClassImp(AliMpSlatSegmentation)
//_____________________________________________________________________________
AliMpSlatSegmentation::AliMpSlatSegmentation()
: AliMpVSegmentation(),
-fkSlat(0)
+ fkSlat(0),
+ fIsOwner(false)
{
- //
- // Default ctor. Not to be used really.
- //
+ ///
+ /// Default ctor. Not to be used really.
+ ///
AliDebug(1,Form("this=%p Empty ctor",this));
}
//_____________________________________________________________________________
-AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat)
+AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat, Bool_t own)
: AliMpVSegmentation(),
-fkSlat(slat)
+ fkSlat(slat),
+ fIsOwner(own)
{
- //
- // Normal ctor.
- //
+ ///
+ /// Normal ctor.
+ ///
AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
}
-//______________________________________________________________________________
-AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlatSegmentation& right)
- : AliMpVSegmentation(right)
-{
-/// Protected copy constructor (not implemented)
-
- AliFatal("Copy constructor not provided.");
-}
-
//_____________________________________________________________________________
AliMpSlatSegmentation::~AliMpSlatSegmentation()
{
- //
- // Dtor (empty).
- //
+ ///
+ /// Dtor (empty).
+ ///
+
+ if ( fIsOwner ) delete fkSlat;
+
// Int_t i(0);//just to be able to put a breakpoint in gdb
AliDebug(1,Form("this=%p",this));
}
-//______________________________________________________________________________
-AliMpSlatSegmentation&
-AliMpSlatSegmentation::operator=(const AliMpSlatSegmentation& right)
-{
-/// Protected assignement operator (not implemented)
-
- // check assignement to self
- if (this == &right) return *this;
-
- AliFatal("Assignement operator not provided.");
-
- return *this;
-}
-
//_____________________________________________________________________________
AliMpVPadIterator*
AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
{
- //
- // Returns an iterator to loop over the pad contained within given area.
- //
- AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions());
+ ///
+ /// Returns an iterator to loop over the pad contained within given area.
+ ///
+ AliMpArea a(area.GetPositionX()+fkSlat->GetPositionX(),
+ area.GetPositionY()+fkSlat->GetPositionY(),
+ area.GetDimensionX(),
+ area.GetDimensionY());
AliDebug(3,Form("Converted input area wrt to slat center : "
"%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : "
"%7.2f,%7.2f->%7.2f,%7.2f ",
}
//_____________________________________________________________________________
-TVector2
-AliMpSlatSegmentation::Dimensions() const
+AliMpVPadIterator*
+AliMpSlatSegmentation::CreateIterator() const
+{
+ /// Returns an iterator to loop over all pads of that segmentation
+ ///
+ /// FIXME: we currently just forward this to the other CreateIterator,
+ /// with the proper region. Might be more efficient to write a dedicated
+ /// iterator ? Test that idea.
+
+ AliMpArea area(0.0,0.0,fkSlat->DX(),fkSlat->DY());
+ return CreateIterator(area);
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMpSlatSegmentation::GetNeighbours(const AliMpPad& pad,
+ TObjArray& neighbours,
+ Bool_t includeSelf,
+ Bool_t includeVoid) const
+{
+ /// Uses default implementation
+ return AliMpVSegmentation::GetNeighbours(pad,neighbours,includeSelf,includeVoid);
+}
+
+//_____________________________________________________________________________
+Double_t
+AliMpSlatSegmentation::GetDimensionX() const
{
- return Slat()->Dimensions();
+/// Return slat x dimensions
+ return Slat()->DX();
+}
+
+//_____________________________________________________________________________
+Double_t
+AliMpSlatSegmentation::GetDimensionY() const
+{
+/// Return slat y dimensions
+ return Slat()->DY();
}
//_____________________________________________________________________________
void
AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
{
+ /// Fill the array ecn with all manuIds
+
Slat()->GetAllMotifPositionsIDs(ecn);
}
const char*
AliMpSlatSegmentation::GetName() const
{
- // The name of this segmentation is "SlatSegmentation"+slatName
+ /// The name of this segmentation is "SlatSegmentation"+slatName
TString name("SlatSegmentation");
if ( fkSlat)
return name.Data();
}
-//_____________________________________________________________________________
-Bool_t
-AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
-{
- //
- // Test if this slat has a pad located at the position referenced
- // by the integer indices.
- //
-
- return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
-}
-
//_____________________________________________________________________________
Int_t
AliMpSlatSegmentation::MaxPadIndexX() const
{
- //
- // Returns the value of the largest pad index in x-direction.
- //
+ ///
+ /// Returns the value of the largest pad index in x-direction.
+ ///
return fkSlat->GetMaxPadIndexX();
}
Int_t
AliMpSlatSegmentation::MaxPadIndexY() const
{
- //
- // Returns the value of the largest pad index in y-direction.
- //
+ ///
+ /// Returns the value of the largest pad index in y-direction.
+ ///
return fkSlat->GetMaxNofPadsY()-1;
}
//_____________________________________________________________________________
AliMpPad
-AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
+AliMpSlatSegmentation::PadByLocation(Int_t manuId, Int_t manuChannel,
Bool_t warning) const
{
- //
- // Returns the pad specified by its location, where location is the
- // pair (ManuID,ManuChannel).
- // If warning=kTRUE and the pad does not exist, a warning message is
- // printed.
- //
- // AliMpPad::Invalid() is returned if there's no pad at the given location.
- //
- Int_t manuID = location.GetFirst();
-
- AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
+ ///
+ /// Returns the pad specified by its location, where location is the
+ /// pair (ManuID,ManuChannel).
+ /// If warning=kTRUE and the pad does not exist, a warning message is
+ /// printed.
+ ///
+ /// AliMpPad::Invalid() is returned if there's no pad at the given location.
+ ///
+ AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuId);
if (!motifPos)
- {
- if (warning)
- {
- AliWarning(Form("Manu ID %d not found in slat %s",
- manuID, fkSlat->GetID()));
+ {
+ if (warning)
+ {
+ AliWarning(Form("Manu ID %d not found in slat %s",
+ manuId, fkSlat->GetID()));
}
return AliMpPad::Invalid();
- }
+ }
AliMpVMotif* motif = motifPos->GetMotif();
- AliMpIntPair localIndices =
- motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
+ MpPair_t localIndices =
+ motif->GetMotifType()->FindLocalIndicesByGassiNum(manuChannel);
- if (!localIndices.IsValid())
- {
- if (warning)
- {
- AliWarning(Form("The pad number %d doesn't exists",
- location.GetSecond()));
- }
- return AliMpPad::Invalid();
- }
+ if ( localIndices < 0 )
+ {
+ if (warning)
+ {
+ AliWarning(Form("The pad number %d doesn't exists",
+ manuChannel));
+ }
+ return AliMpPad::Invalid();
+ }
+
+ Double_t posx, posy;
+ motif->PadPositionLocal(localIndices, posx, posy);
+ posx += motifPos->GetPositionX() - fkSlat->GetPositionX();
+ posy += motifPos->GetPositionY() - fkSlat->GetPositionY();
+
+ Double_t dx, dy;
+ motif->GetPadDimensionsByIndices(localIndices, dx, dy);
- return AliMpPad(location,
+ return AliMpPad(manuId, manuChannel,
motifPos->GlobalIndices(localIndices),
- motifPos->Position()
- + motif->PadPositionLocal(localIndices)
- - fkSlat->Position(),
- motif->GetPadDimensions(localIndices));
+ posx, posy, dx, dy);
}
//_____________________________________________________________________________
AliMpPad
-AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
+AliMpSlatSegmentation::PadByIndices(Int_t ix, Int_t iy,
Bool_t warning) const
{
- //
- // Returns the pad specified by its integer indices.
- // If warning=kTRUE and the pad does not exist, a warning message is
- // printed.
- //
- // AliMpPad::Invalid() is returned if there's no pad at the given location.
- //
- //
- // FIXME: except for the FindMotifPosition below, this method
- // is exactly as the one in AliMpSectorSegmentation.
- // See if we can merge them somehow.
+ ///
+ /// Returns the pad specified by its integer indices.
+ /// If warning=kTRUE and the pad does not exist, a warning message is
+ /// printed.
+ ///
+ /// AliMpPad::Invalid() is returned if there's no pad at the given location.
+ ///
+ ///
+ /// FIXME: except for the FindMotifPosition below, this method
+ /// is exactly as the one in AliMpSectorSegmentation.
+ /// See if we can merge them somehow.
- AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
- indices.GetSecond());
+ AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(ix,iy);
+
if (!motifPos)
- {
- if ( warning )
- {
- AliWarning(Form("No motif found containing pad location (%d,%d)",
- indices.GetFirst(),indices.GetSecond()));
- }
- return AliMpPad::Invalid();
- }
+ {
+ if ( warning )
+ {
+ AliWarning(Form("No motif found containing pad location (%d,%d)",ix,iy));
+ }
+ return AliMpPad::Invalid();
+ }
AliMpVMotif* motif = motifPos->GetMotif();
AliMpMotifType* motifType = motif->GetMotifType();
- AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
- AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices);
+ MpPair_t localIndices = AliMp::Pair(ix,iy) - motifPos->GetLowIndicesLimit();
+ AliMpConnection* connection
+ = motifType->FindConnectionByLocalIndices(localIndices);
if (!connection)
- {
- if ( warning )
- {
- AliWarning(Form("No connection for pad location (%d,%d)",
- indices.GetFirst(),indices.GetSecond()));
+ {
+ if ( warning )
+ {
+ AliWarning(Form("No connection for pad location (%d,%d)",ix,iy));
}
return AliMpPad::Invalid();
- }
-
- return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
- indices,
- motifPos->Position()
- + motif->PadPositionLocal(localIndices)
- - fkSlat->Position(),
- motif->GetPadDimensions(localIndices));
+ }
+
+ Double_t posx, posy;
+ motif->PadPositionLocal(localIndices, posx, posy);
+ posx += motifPos->GetPositionX() - fkSlat->GetPositionX();
+ posy += motifPos->GetPositionY() - fkSlat->GetPositionY();
+
+ Double_t dx, dy;
+ motif->GetPadDimensionsByIndices(localIndices, dx, dy);
+
+ return AliMpPad(motifPos->GetID(),connection->GetManuChannel(),
+ ix, iy, posx, posy, dx, dy);
}
//_____________________________________________________________________________
AliMpPad
-AliMpSlatSegmentation::PadByPosition(const TVector2& position,
+AliMpSlatSegmentation::PadByPosition(Double_t x, Double_t y,
Bool_t warning) const
{
- //
- // Returns the pad specified by its (floating point) position.
- // If warning=kTRUE and the pad does not exist, a warning message is
- // printed.
- //
- // AliMpPad::Invalid() is returned if there's no pad at the given location.
- //
+ ///
+ /// Returns the pad specified by its (floating point) position.
+ /// If warning=kTRUE and the pad does not exist, a warning message is
+ /// printed.
+ ///
+ /// AliMpPad::Invalid() is returned if there's no pad at the given location.
+ ///
+
+ Double_t blPosX(x);
+ Double_t blPosY(y);
- TVector2 blPos(position+fkSlat->Position()); // position relative to
- // bottom-left of the slat.
+ blPosX += fkSlat->GetPositionX();
+ blPosY += fkSlat->GetPositionY(); // position relative to bottom-left of the slat.
- AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
+ AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPosX,blPosY);
if (!motifPos)
- {
- if (warning)
- {
- AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
- " outside limits",fkSlat->GetID(),
- position.X(),position.Y(),
- blPos.X(),blPos.Y()));
- }
- return AliMpPad::Invalid();
- }
+ {
+ if (warning)
+ {
+ AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
+ " outside limits",fkSlat->GetID(),x,y,
+ blPosX,blPosY));
+ }
+ return AliMpPad::Invalid();
+ }
AliMpVMotif* motif = motifPos->GetMotif();
- AliMpIntPair localIndices
- = motif->PadIndicesLocal(blPos-motifPos->Position());
+
+ blPosX -= motifPos->GetPositionX();
+ blPosY -= motifPos->GetPositionY();
+ MpPair_t localIndices = motif->PadIndicesLocal(blPosX, blPosY);
AliMpConnection* connect =
motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
if (!connect)
- {
- if (warning)
- {
- AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
- fkSlat->GetID(),localIndices.GetFirst(),
- localIndices.GetSecond(),motif->GetID().Data()));
- }
- return AliMpPad::Invalid();
- }
-
- return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
+ {
+ if (warning)
+ {
+ AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
+ fkSlat->GetID(),AliMp::PairFirst(localIndices),
+ AliMp::PairSecond(localIndices),motif->GetID().Data()));
+ }
+ return AliMpPad::Invalid();
+ }
+
+ Double_t posx, posy;
+ motif->PadPositionLocal(localIndices, posx, posy);
+ posx += motifPos->GetPositionX() - fkSlat->GetPositionX();
+ posy += motifPos->GetPositionY() - fkSlat->GetPositionY();
+
+ Double_t dx, dy;
+ motif->GetPadDimensionsByIndices(localIndices, dx, dy);
+
+ return AliMpPad(motifPos->GetID(),connect->GetManuChannel(),
motifPos->GlobalIndices(localIndices),
- motifPos->Position()
- + motif->PadPositionLocal(localIndices)
- - fkSlat->Position(),
- motif->GetPadDimensions(localIndices));
+ posx, posy, dx, dy);
}
//_____________________________________________________________________________
-AliMpPlaneType
+AliMp::PlaneType
AliMpSlatSegmentation::PlaneType() const
{
return Slat()->PlaneType();
void
AliMpSlatSegmentation::Print(Option_t* opt) const
{
+/// Printing
+
fkSlat->Print(opt);
}
const AliMpSlat*
AliMpSlatSegmentation::Slat() const
{
- //
- // Returns the pointer to the referenced slat.
- //
+ ///
+ /// Returns the pointer to the referenced slat.
+ ///
return fkSlat;
}
+
+//_____________________________________________________________________________
+Bool_t
+AliMpSlatSegmentation::HasPadByIndices(Int_t ix, Int_t iy) const
+{
+ /// Tell whether we have a pad at indices=(ix,iy)
+
+ AliMpMotifPosition* motifPos = Slat()->FindMotifPosition(ix, iy);
+
+ if (motifPos) return motifPos->HasPadByIndices(AliMp::Pair(ix, iy));
+
+ return kFALSE;
+}
+
+//_____________________________________________________________________________
+Bool_t
+AliMpSlatSegmentation::HasPadByLocation(Int_t manuId, Int_t manuChannel) const
+{
+ /// Tell whether we have a pad at location=(manuId,manuChannel)
+
+ AliMpMotifPosition* motifPos = Slat()->FindMotifPosition(manuId);
+
+ if ( motifPos ) return motifPos->HasPadByManuChannel(manuChannel);
+
+ return kFALSE;
+}
+
+
+//_____________________________________________________________________________
+Int_t
+AliMpSlatSegmentation::GetNofElectronicCards() const
+{
+ /// Get the number of manus of this slat
+ return Slat()->GetNofElectronicCards();
+
+}
+
+//_____________________________________________________________________________
+Double_t
+AliMpSlatSegmentation::GetPositionX() const
+{
+/// Return x position of slat origin
+ return Slat()->GetPositionX();
+}
+
+//_____________________________________________________________________________
+Double_t
+AliMpSlatSegmentation::GetPositionY() const
+{
+/// Return y position of slat origin
+
+ return Slat()->GetPositionY();
+}
+
+//_____________________________________________________________________________
+Bool_t
+AliMpSlatSegmentation::HasMotifPosition(Int_t manuId) const
+{
+ /// Use default implementation
+ return AliMpVSegmentation::HasMotifPosition(manuId);
+}
+
+//_____________________________________________________________________________
+AliMpMotifPosition*
+AliMpSlatSegmentation::MotifPosition(Int_t manuId) const
+{
+ /// Get back a given manu
+ return Slat()->FindMotifPosition(manuId);
+}
+