]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpSectorSegmentation.cxx
Fix for the problem during PbPb run of Nov 2010 (Indra)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSectorSegmentation.cxx
index 3c1945fb5c544a77f7fe735dce32a69bad2e2c72..e601555785d288158de0e9fc00b24cbd4f965e46 100755 (executable)
@@ -16,7 +16,8 @@
 // $Id$
 // $MpId: AliMpSectorSegmentation.cxx,v 1.15 2006/05/24 13:58:46 ivana Exp $
 // Category: sector
-//
+
+//-----------------------------------------------------------------------------
 // Class AliMpSectorSegmentation
 // -----------------------------
 // Class describing the segmentation of the sector.        
@@ -25,6 +26,7 @@
 // finding pad neighbour.
 //
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+//-----------------------------------------------------------------------------
 
 #include "AliMpSectorSegmentation.h"
 #include "AliMpSector.h"
 #include "AliMpVMotif.h"
 #include "AliMpMotifPosition.h"
 #include "AliMpConnection.h"
-#include "AliMpNeighboursPadIterator.h"
 #include "AliMpSectorAreaHPadIterator.h"
 #include "AliMpSectorAreaVPadIterator.h"
-#include "AliMpIntPair.h"
+#include "AliMpSectorPadIterator.h"
 #include "AliMpArea.h"
 #include "AliMpConstants.h"
+#include "AliMpEncodePair.h"
 
 #include "AliLog.h"
 
 ClassImp(AliMpSectorSegmentation)
 /// \endcond
 
-#ifdef WITH_ROOT
-const Double_t AliMpSectorSegmentation::fgkS1 = 100000.;
-const Double_t AliMpSectorSegmentation::fgkS2 = 1000.;
-#endif
-
 //______________________________________________________________________________
-AliMpSectorSegmentation::AliMpSectorSegmentation(const AliMpSector* sector) 
+AliMpSectorSegmentation::AliMpSectorSegmentation(
+                            const AliMpSector* sector, Bool_t own) 
   : AliMpVSegmentation(),
     fkSector(sector),
+    fIsOwner(own),
+    fPadBuffer(0),
     fMaxIndexInX(0),
     fMaxIndexInY(0)
 {
 /// Standard constructor
 
+  AliDebugStream(1) << "this = " << this << endl;
+
   fPadBuffer = new AliMpPad(AliMpPad::Invalid());
   
-  FillPadDimensionsMap();
+  //FillPadDimensionsMap();
 }
 
 //______________________________________________________________________________
 AliMpSectorSegmentation::AliMpSectorSegmentation() 
   : AliMpVSegmentation(),
     fkSector(0),
+    fIsOwner(false),
     fPadBuffer(0),
-    fPadDimensionsMap(),      
     fMaxIndexInX(0),
     fMaxIndexInY(0)
 {
 /// Default constructor
-}
-
-//_____________________________________________________________________________
-AliMpSectorSegmentation::AliMpSectorSegmentation(
-                                    const AliMpSectorSegmentation& right) 
-  : AliMpVSegmentation(right) 
-{
-/// Protected copy constructor (not provided) 
 
-  Fatal("AliMpSectorSegmentation", "Copy constructor not provided.");
+  AliDebugStream(1) << "this = " << this << endl;
 }
 
 //______________________________________________________________________________
@@ -98,135 +92,45 @@ AliMpSectorSegmentation::~AliMpSectorSegmentation()
 {
 /// Destructor 
 
-  delete fPadBuffer;
-}
-
-//
-// operators
-//
-
-//_____________________________________________________________________________
-AliMpSectorSegmentation& 
-AliMpSectorSegmentation::operator=(const AliMpSectorSegmentation& right)
-{
-/// Protected assignment operator (not provided)
+  AliDebugStream(1) << "this = " << this << endl;
 
-  // check assignment to self
-  if (this == &right) return *this;
+  if ( fIsOwner ) delete fkSector;
 
-  Fatal("operator =", "Assignment operator not provided.");
-    
-  return *this;  
-}    
+  delete fPadBuffer;
+  
+}
 
 //
 // private methods
 //
 
-//_____________________________________________________________________________
-void 
-AliMpSectorSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
-{
-  GetSector()->GetAllMotifPositionsIDs(ecn);
-}
-
-#ifdef WITH_ROOT
-//______________________________________________________________________________
-Long_t AliMpSectorSegmentation::GetIndex(const TVector2& vector2) const
-{
-/// Convert the two vector to long.
-
-  return Long_t(TMath::Floor((vector2.X()*fgkS1 + vector2.Y())*fgkS2));
-}  
-
-//______________________________________________________________________________
-TVector2  AliMpSectorSegmentation::GetVector(Long_t index) const
-{
-/// Convert the long index to twovector.
-
-  return TVector2( TMath::Floor(index/fgkS1)/fgkS2,
-                   (index - TMath::Floor(index/fgkS1)*fgkS1)/fgkS2 );
-}  
-#endif
-
-//______________________________________________________________________________
-void AliMpSectorSegmentation::FillPadDimensionsMap()
-{
-/// Fill the maps between zone ids and pad dimensions.
-
-  for (Int_t i=0; i<fkSector->GetNofZones(); i++) {
-    AliMpZone* zone   = fkSector->GetZone(i+1);
-    Int_t  zoneID = zone->GetID();
-    
-    if (!AliMpConstants::IsEqual(zone->GetPadDimensions(), TVector2())) {
-
-      // regular zone
-#ifdef WITH_STL
-      fPadDimensionsMap[zoneID*10] = zone->GetPadDimensions();
-#endif
-#ifdef WITH_ROOT
-     AliDebug(1,Form("Filling fPadDimensions[%d]=(%e,%e)",
-                     zoneID*10,zone->GetPadDimensions().X(),
-                     zone->GetPadDimensions().Y()));
-     fPadDimensionsMap.Add((Long_t)(zoneID*10), 
-                            GetIndex(zone->GetPadDimensions()));
-#endif
-    }
-    else {
-      // special zone
-      Int_t subIndex = 0;
-      for (Int_t j=0; j<zone->GetNofSubZones(); j++) {
-        AliMpSubZone* subZone = zone->GetSubZone(j);
-       AliMpVMotif*  motif = subZone->GetMotif();
-       
-       for (Int_t k=0; k<motif->GetNofPadDimensions(); k++) {
-         Int_t index = zoneID*10 +  subIndex++;
-#ifdef WITH_STL
-          fPadDimensionsMap[index] = motif->GetPadDimensions(k);
-#endif
-#ifdef WITH_ROOT
-          AliDebug(1,Form("Filling fPadDimensions[%d]=(%e,%e) motif %s-%d",
-                          index,
-                          motif->GetPadDimensions(k).X(),
-                          motif->GetPadDimensions(k).Y(),
-                          motif->GetID().Data(),k));
-          
-          fPadDimensionsMap.Add((Long_t)(index), 
-                            GetIndex(motif->GetPadDimensions(k)));
-#endif
-       }
-      }          
-    }    
-  }      
-}
-
 //______________________________________________________________________________
 AliMpMotifPosition* 
-AliMpSectorSegmentation::FindMotifPosition(const AliMpIntPair& indices) const
+AliMpSectorSegmentation::FindMotifPosition(Int_t ix, Int_t iy) const
 {
 /// Find the motif position which contains the given pad indices
 /// return 0 if not found
 
-  switch (fkSector->GetDirection()) {
-    case kX : {
+  switch ( fkSector->GetDirection() ) {
+    case AliMp::kX : {
     // Case where all the pads have the same size along X direction
 
-      for (Int_t irow=0; irow<fkSector->GetNofRows(); ++irow) {
+      for ( Int_t irow=0; irow<fkSector->GetNofRows(); ++irow ) {
         AliMpRow* row = fkSector->GetRow(irow);
-        if (row->GetLowIndicesLimit().GetFirst()<=indices.GetFirst() &&
-            row->GetHighIndicesLimit().GetFirst()>=indices.GetFirst()) {
+        if ( row->GetLowLimitIx() <= ix &&
+             row->GetHighLimitIx()>= ix ) {
             
-           for (Int_t iseg=0;iseg<row->GetNofRowSegments();++iseg){
+          for ( Int_t iseg=0;iseg<row->GetNofRowSegments();++iseg ) {
             AliMpVRowSegment* seg = row->GetRowSegment(iseg);
-            if (seg->GetLowIndicesLimit().GetFirst()<=indices.GetFirst() &&
-                seg->GetHighIndicesLimit().GetFirst()>=indices.GetFirst()) {
+            if ( seg->GetLowLimitIx() <= ix &&
+                 seg->GetHighLimitIx() >= ix ) {
 
               AliMpMotifPosition* motifPos;
-              for (Int_t imot=0;imot<seg->GetNofMotifs();++imot) {
+              for ( Int_t imot=0;imot<seg->GetNofMotifs();++imot ) {
                 motifPos 
                  = fkSector->GetMotifMap()
                    ->FindMotifPosition(seg->GetMotifPositionId(imot));
-                if (motifPos && motifPos->HasPad(indices)) return motifPos;
+                if (motifPos && motifPos->HasPadByIndices(AliMp::Pair(ix,iy))) return motifPos;
               }
             }
           }
@@ -236,37 +140,37 @@ AliMpSectorSegmentation::FindMotifPosition(const AliMpIntPair& indices) const
     }
     break;
     ////////////////////////////////////////////////////////////////////////////////
-    case kY : {
+    case AliMp::kY : {
       // Case where all the pads have the same size along Y direction   
       // look for the row which contains the indices
       AliMpRow* row=0;
       Int_t irow;
-      for (irow=0; irow<fkSector->GetNofRows(); ++irow) {
+      for ( irow=0; irow<fkSector->GetNofRows(); ++irow ) {
         row = fkSector->GetRow(irow);
         AliMpVRowSegment* lastSeg = row->GetRowSegment(row->GetNofRowSegments()-1);
-        if (lastSeg->GetLowIndicesLimit().GetSecond()<=indices.GetSecond() &&
-            lastSeg->GetHighIndicesLimit().GetSecond()>=indices.GetSecond()) break;
+        if ( lastSeg->GetLowLimitIy() <= iy &&
+             lastSeg->GetHighLimitIy() >= iy ) break;
         // NOTE : We use the last row segment in order to ensure that
         // we are not on a special motif
       }
-      if (irow==fkSector->GetNofRows()) return 0;
+      if ( irow==fkSector->GetNofRows() ) return 0;
       // look for the row segment, in the found row, which contains the indices
       AliMpVRowSegment* seg=0;
       Int_t iseg;
-      for (iseg=0;iseg<row->GetNofRowSegments();++iseg){
+      for ( iseg=0;iseg<row->GetNofRowSegments();++iseg ) {
         seg = row->GetRowSegment(iseg);
-        if (seg->HasIndices(indices)) break;
+        if (seg->HasIndices(AliMp::Pair(ix, iy))) break;
       }
-      if (iseg==row->GetNofRowSegments()) return 0;
+      if ( iseg==row->GetNofRowSegments() ) return 0;
   
       // look for the motif position which contains the indices
       AliMpMotifPosition* motifPos=0;
       Int_t imot=0;
-      for (imot=0;imot<seg->GetNofMotifs();++imot) {
+      for ( imot=0;imot<seg->GetNofMotifs();++imot ) {
         motifPos 
          = fkSector->GetMotifMap()
            ->FindMotifPosition(seg->GetMotifPositionId(imot));
-        if (motifPos && motifPos->HasPad(indices)) break;
+        if (motifPos && motifPos->HasPadByIndices(AliMp::Pair(ix, iy))) break;
       }      
       if (imot==seg->GetNofMotifs()) return 0;
    
@@ -278,26 +182,27 @@ AliMpSectorSegmentation::FindMotifPosition(const AliMpIntPair& indices) const
 
 //______________________________________________________________________________
 AliMpPad 
-AliMpSectorSegmentation::PadByXDirection(const TVector2& startPosition
+AliMpSectorSegmentation::PadByXDirection(Double_t startx, Double_t starty
                                          Double_t maxX) const
 {
 /// Find the first valid pad from starting position in the
 /// direction of pad lines up to distance dx.
 
   // Define step limits
-  Double_t  stepX = fkSector->GetMinPadDimensions().X();
+  Double_t  stepX = fkSector->GetMinPadDimensionX();
  
   // Search in X direction
   AliMpPad pad;
-  TVector2 position(startPosition);    
+  Double_t posx = startx;
   do {
-    pad = PadByPosition(position, false);
-    position += TVector2(stepX, 0.);
+    pad = PadByPosition(posx, starty, false);
+    posx += stepX;
   }   
-  while ( !pad.IsValid() && position.X() < maxX ); 
+  while ( ! pad.IsValid() && 
+            posx - fkSector->GetMaxPadDimensionX() < maxX ); 
   
   // Invalidate pad if it is outside limits
-  if ((pad.Position().X() - pad.Dimensions().X()) > maxX
+  if ( ( pad.GetPositionX() - pad.GetDimensionX()) > maxX 
     pad = AliMpPad::Invalid();
 
   return pad;
@@ -305,26 +210,27 @@ AliMpSectorSegmentation::PadByXDirection(const TVector2& startPosition,
 
 //______________________________________________________________________________
 AliMpPad 
-AliMpSectorSegmentation::PadByYDirection(const TVector2& startPosition
+AliMpSectorSegmentation::PadByYDirection(Double_t startx, Double_t starty
                                          Double_t maxY) const
 {
 /// Find the first valid pad from starting position in the
 /// direction of pad columns up to distance dx.
   
   // Define step limits
-  Double_t stepY = fkSector->GetMinPadDimensions().Y();
+  Double_t stepY = fkSector->GetMinPadDimensionY();
  
   // Search in Y direction
   AliMpPad pad;
-  TVector2 position(startPosition);    
+  Double_t posy = starty;
   do {
-    pad = PadByPosition(position, false);
-    position += TVector2(0., stepY);
+    pad = PadByPosition(startx, posy, false);
+    posy += stepY;
   }   
-  while ( !pad.IsValid() && position.Y() < maxY ); 
+  while ( ! pad.IsValid() && 
+            posy - fkSector->GetMaxPadDimensionY()< maxY ); 
   
   // Invalidate pad if it is outside limits
-  if ((pad.Position().Y() - pad.Dimensions().Y()) > maxY
+  if (( pad.GetPositionY() - pad.GetDimensionY()) > maxY 
     pad = AliMpPad::Invalid();
 
   return pad;
@@ -342,9 +248,9 @@ AliMpSectorSegmentation::CreateIterator(const AliMpArea& area) const
 
   switch (fkSector->GetDirection()) {
   
-    case kX: return new AliMpSectorAreaVPadIterator(this, area);
+    case AliMp::kX: return new AliMpSectorAreaVPadIterator(this, area);
              ;;
-    case kY: return new AliMpSectorAreaHPadIterator(this, area);
+    case AliMp::kY: return new AliMpSectorAreaHPadIterator(this, area);
              ;;
   }
   
@@ -354,68 +260,71 @@ AliMpSectorSegmentation::CreateIterator(const AliMpArea& area) const
   
 //______________________________________________________________________________
 AliMpVPadIterator* 
-AliMpSectorSegmentation::CreateIterator(const AliMpPad& centerPad,
-                                        Bool_t includeCenter) const
+AliMpSectorSegmentation::CreateIterator() const
 {
-/// Create the neighbours pad iterator.
+/// Create the sector iterator
 
-  return new AliMpNeighboursPadIterator(this, centerPad, includeCenter);
-}   
-  
-//______________________________________________________________________________
-TVector2
-AliMpSectorSegmentation::Dimensions() const
-{
-  return GetSector()->Dimensions();
+  return new AliMpSectorPadIterator(fkSector);
 }
 
 //______________________________________________________________________________
-AliMpPlaneType
-AliMpSectorSegmentation::PlaneType() const
+Int_t 
+AliMpSectorSegmentation::GetNeighbours(const AliMpPad& pad, TObjArray& neighbours,
+                                       Bool_t includeSelf,
+                                       Bool_t includeVoid) const
 {
-  return GetSector()->GetPlaneType();
+  /// Uses default implementation
+  return AliMpVSegmentation::GetNeighbours(pad,neighbours,includeSelf,includeVoid);
 }
 
 //______________________________________________________________________________
 AliMpPad 
-AliMpSectorSegmentation::PadByLocation(const AliMpIntPair& location
+AliMpSectorSegmentation::PadByLocation(Int_t manuId, Int_t manuChannel
                                        Bool_t warning) const
 {
 /// Find the pad which corresponds to the given location
-  
-  if ((*fPadBuffer).GetLocation()==location) return (*fPadBuffer);
+  if ( fPadBuffer->GetManuId() == manuId &&
+       fPadBuffer->GetManuChannel() == manuChannel ) return (*fPadBuffer);
   
   AliMpMotifPosition* motifPos = 
-    fkSector->GetMotifMap()->FindMotifPosition(location.GetFirst());
+    fkSector->GetMotifMap()->FindMotifPosition(manuId);
   if (!motifPos){
     if (warning) Warning("PadByLocation","The pad motif position ID doesn't exists");
     return AliMpPad::Invalid();
   }
   
   AliMpVMotif* motif = motifPos->GetMotif();
-  AliMpIntPair localIndices = 
-    motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
-  if (! localIndices.IsValid()) {
+  MpPair_t localIndices = 
+    motif->GetMotifType()->FindLocalIndicesByGassiNum(manuChannel);
+  if ( localIndices < 0 ) {
     if (warning) Warning("PadByLocation","The pad number doesn't exists");
     return AliMpPad::Invalid();
   }
-  TVector2 delta = motif->PadPositionLocal(localIndices);
-  return (*fPadBuffer) = AliMpPad(location,
-              motifPos->GlobalIndices(localIndices),
-              motifPos->Position()+delta,
-              motif->GetPadDimensions(localIndices));
 
+  Double_t posx, posy;
+  motif->PadPositionLocal(localIndices, posx, posy);
+  posx += motifPos->GetPositionX();
+  posy += motifPos->GetPositionY();
+
+  Double_t dx, dy;
+  motif->GetPadDimensionsByIndices(localIndices, dx, dy);
+
+  return (*fPadBuffer) = AliMpPad(manuId, manuChannel,
+              motifPos->GlobalIndices(localIndices),
+              posx, posy, dx, dy);
 }
 //______________________________________________________________________________
 AliMpPad 
-AliMpSectorSegmentation::PadByIndices(const AliMpIntPair& indices,
-                                      Bool_t warning ) const
+AliMpSectorSegmentation::PadByIndices(Int_t ix, Int_t iy, Bool_t warning ) const
 {
 /// Find the pad which corresponds to the given indices  
 
-  if ((*fPadBuffer).GetIndices()==indices) return (*fPadBuffer);    
-   
-  AliMpMotifPosition* motifPos = FindMotifPosition(indices);
+  if ( fPadBuffer->GetIx() == ix &&
+       fPadBuffer->GetIy() == iy ) return (*fPadBuffer);    
+       
+  MpPair_t indices = AliMp::Pair(ix, iy);     
+  AliMpMotifPosition* motifPos = FindMotifPosition(ix, iy);
   if (!motifPos) {    
     if (warning) 
       Warning("PadByIndices","Pad indices not contained in any motif!");
@@ -424,7 +333,7 @@ AliMpSectorSegmentation::PadByIndices(const AliMpIntPair& indices,
   
   // retrieve the local indices in the found motif
   AliMpVMotif* motif = motifPos->GetMotif();
-  AliMpIntPair localIndices = indices - motifPos->GetLowIndicesLimit();
+  MpPair_t localIndices = indices - motifPos->GetLowIndicesLimit();
   
   AliMpConnection* connection=
     motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
@@ -434,26 +343,30 @@ AliMpSectorSegmentation::PadByIndices(const AliMpIntPair& indices,
     return AliMpPad::Invalid();
   }
 
-  TVector2 localPos = motif->PadPositionLocal(localIndices);
+  Double_t posx, posy;
+  motif->PadPositionLocal(localIndices, posx, posy);
+  posx += motifPos->GetPositionX();
+  posy += motifPos->GetPositionY();
 
-  return (*fPadBuffer) 
-    = AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
-               indices,
-               motifPos->Position()+localPos,
-               motif->GetPadDimensions(localIndices)); 
+  Double_t dx, dy;
+  motif->GetPadDimensionsByIndices(localIndices, dx, dy);
 
+  return (*fPadBuffer) 
+    = AliMpPad(motifPos->GetID(),connection->GetManuChannel(),
+               ix, iy, posx, posy, dx, dy);
 }
+
 //______________________________________________________________________________
 AliMpPad 
-AliMpSectorSegmentation::PadByPosition(const TVector2& position,
+AliMpSectorSegmentation::PadByPosition(Double_t x, Double_t y,
                                        Bool_t warning) const
 {
 /// Find the pad which corresponds to the given position
 
-  if ((*fPadBuffer).Position().X()==position.X() && 
-      (*fPadBuffer).Position().Y()==position.Y()) return (*fPadBuffer);  
+  if (fPadBuffer->GetPositionX()==x && 
+      fPadBuffer->GetPositionY()==y) return (*fPadBuffer);  
 
-  Int_t motifPosID = fkSector->FindMotifPositionId(position);
+  Int_t motifPosID = fkSector->FindMotifPositionId(x,y);
   AliMpMotifPosition* motifPos 
     = fkSector->GetMotifMap()
         ->FindMotifPosition(motifPosID);
@@ -464,28 +377,40 @@ AliMpSectorSegmentation::PadByPosition(const TVector2& position,
   }
 
   AliMpVMotif* motif =  motifPos->GetMotif();  
-  AliMpIntPair localIndices 
-    = motif->PadIndicesLocal(position-motifPos->Position());
+  MpPair_t localIndices 
+    = motif->PadIndicesLocal(x-motifPos->GetPositionX(),
+                             y-motifPos->GetPositionY());
+
+  if ( localIndices < 0 ) {
+    if (warning) Warning("PadByPosition","Position outside motif limits");
+    return AliMpPad::Invalid();
+  }
     
   AliMpConnection* connect = 
     motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
 
-   if (!connect){
+  if ( ! connect ) {
     if (warning) Warning("PadByPosition","Position outside motif limits");
     return AliMpPad::Invalid();
   }
+
+  Double_t posx, posy;
+  motif->PadPositionLocal(localIndices, posx, posy);
+  posx += motifPos->GetPositionX();
+  posy += motifPos->GetPositionY();
+
+  Double_t dx, dy;
+  motif->GetPadDimensionsByIndices(localIndices, dx, dy);
   
   return (*fPadBuffer)
-    = AliMpPad(AliMpIntPair(motifPosID,connect->GetGassiNum()),
+    = AliMpPad(motifPosID, connect->GetManuChannel(),
                motifPos->GlobalIndices(localIndices),
-               motifPos->Position()+motif->PadPositionLocal(localIndices),
-               motif->GetPadDimensions(localIndices));
-
+               posx, posy, dx, dy);
 }
 
 //______________________________________________________________________________
 AliMpPad 
-AliMpSectorSegmentation::PadByDirection(const TVector2& startPosition
+AliMpSectorSegmentation::PadByDirection(Double_t startx, Double_t starty
                                         Double_t distance) const
 {
 /// Find the first valid pad from starting position in the
@@ -495,9 +420,9 @@ AliMpSectorSegmentation::PadByDirection(const TVector2& startPosition,
 
   switch (fkSector->GetDirection()) {
   
-    case kX: return PadByYDirection(startPosition, distance);
+    case AliMp::kX: return PadByYDirection(startx, starty, distance);
              ;;
-    case kY: return PadByXDirection(startPosition, distance);
+    case AliMp::kY: return PadByXDirection(startx, starty, distance);
              ;;
   }
   
@@ -505,12 +430,41 @@ AliMpSectorSegmentation::PadByDirection(const TVector2& startPosition,
   return AliMpPad::Invalid();  
 }
 
+//_____________________________________________________________________________
+Bool_t 
+AliMpSectorSegmentation::HasPadByIndices(Int_t ix, Int_t iy) const
+{
+  ///  Whether or not we have a pad at indices=(ix,iy) 
+  
+  MpPair_t indices = AliMp::Pair(ix, iy);
+
+  AliMpMotifPosition* motifPos = FindMotifPosition(ix, iy);
+  
+  if (motifPos) return motifPos->HasPadByIndices(indices);
+  
+  return kFALSE;
+}
+
+//_____________________________________________________________________________
+Bool_t 
+AliMpSectorSegmentation::HasPadByLocation(Int_t manuId, Int_t manuChannel) const
+{
+  /// Whether or not we have a pad at location=(manuId,manuChannel)
+  
+  AliMpMotifPosition* motifPos 
+    = fkSector->GetMotifMap()->FindMotifPosition(manuId);
+  
+  if ( motifPos ) return motifPos->HasPadByManuChannel(manuChannel);
+  
+  return kFALSE;
+}
+
 //______________________________________________________________________________
 Int_t  AliMpSectorSegmentation::MaxPadIndexX() const
 {
 /// Return maximum pad index in x
 
-  return fkSector->GetMaxPadIndices().GetFirst();
+  return AliMp::PairFirst(fkSector->GetMaxPadIndices());
 }
 
 //______________________________________________________________________________
@@ -518,7 +472,7 @@ Int_t  AliMpSectorSegmentation::MaxPadIndexY() const
 {
 /// Return maximum pad index in y
 
-  return fkSector->GetMaxPadIndices().GetSecond();
+  return AliMp::PairSecond(fkSector->GetMaxPadIndices());
 }
 
 //______________________________________________________________________________
@@ -529,164 +483,147 @@ Int_t  AliMpSectorSegmentation::NofPads() const
   return fkSector->GetNofPads();
 }
 
-//______________________________________________________________________________
-Bool_t AliMpSectorSegmentation::HasPad(const AliMpIntPair& indices) const
+//_____________________________________________________________________________
+void 
+AliMpSectorSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
 {
-/// Does the pad specified by \a indices exist ?
+  /// Fill the array ecn with all manuIds
 
-  return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
+  GetSector()->GetAllMotifPositionsIDs(ecn);
 }
 
-//______________________________________________________________________________
-Bool_t AliMpSectorSegmentation::HasMotifPosition(Int_t motifPositionID) const
+//_____________________________________________________________________________
+Int_t 
+AliMpSectorSegmentation::GetNofElectronicCards() const
+{
+  /// Get the number of manus of this sector
+  
+  return fkSector->GetNofMotifPositions();  
+}
+
+//_____________________________________________________________________________
+Bool_t 
+AliMpSectorSegmentation::HasMotifPosition(Int_t manuId) const
 {
-/// Does the motif position specified by motifPositionID exist ?
+  /// Whether we get a given manu. Uses default implementation
+  return (AliMpVSegmentation::HasMotifPosition(manuId) != 0x0);
+}
 
-  return (fkSector->GetMotifMap()->FindMotifPosition(motifPositionID) != 0);
+//_____________________________________________________________________________
+AliMpMotifPosition* 
+AliMpSectorSegmentation::MotifPosition(Int_t manuId) const
+{
+  /// Return a given manu
+  return fkSector->GetMotifMap()->FindMotifPosition(manuId);
 }
 
 //______________________________________________________________________________
-TVector2  AliMpSectorSegmentation::GetMinPadDimensions() const
+AliMp::PlaneType
+AliMpSectorSegmentation::PlaneType() const
 {
-/// Returne the dimensions of the smallest pad.
+  return GetSector()->GetPlaneType();
+}
 
-  return fkSector->GetMinPadDimensions();
-}  
+//_____________________________________________________________________________
+Double_t  
+AliMpSectorSegmentation::GetDimensionX() const
+{
+/// Return sector x dimensions
+  return GetSector()->GetDimensionX();
+}
+
+//_____________________________________________________________________________
+Double_t  
+AliMpSectorSegmentation::GetDimensionY() const
+{
+/// Return sector y dimensions
+  return GetSector()->GetDimensionY();
+}
+
+//_____________________________________________________________________________
+Double_t  
+AliMpSectorSegmentation::GetPositionX() const
+{
+/// Return x position 
+  return 0.;
+}
+
+//_____________________________________________________________________________
+Double_t  
+AliMpSectorSegmentation::GetPositionY() const
+{
+/// Return y position 
+  return 0.;
+}
 
 //______________________________________________________________________________
-Int_t AliMpSectorSegmentation::Zone(const AliMpPad& pad, Bool_t warning) const
+void
+AliMpSectorSegmentation::Print(Option_t* opt) const
 {
-/// Return the zone index of the zone containing the specified pad.
-/// This zone index is different from the zone ID,
-/// as it is unique for each pad dimensions.
-/// It is composed in this way:
-///   zoneID*10 + specific index 
-/// Specific index is present only for zones containing special motifs.
-
-  if (!pad.IsValid()) {
-    if (warning) Warning("Zone(AliMpPad)", "Invalid pad");
-    return 0;
-  }  
-
-#ifdef WITH_STL
-  PadDimensionsMapCIterator it;
-  for (it = fPadDimensionsMap.begin(); it != fPadDimensionsMap.end(); ++it) {
-    if (AliMpConstants::IsEqual(it->second, pad.Dimensions()))
-      return it->first;
-  }
-#endif
-
-#ifdef WITH_ROOT
-  PadDimensionsMapCIterator it(&fPadDimensionsMap);
-  Long_t key, value;
-  while ( it.Next(key, value) ) {
-    TVector2 dimensions =  GetVector(value);
-    if (AliMpConstants::IsEqual(dimensions, pad.Dimensions()))
-      return (Int_t)key;
-  } 
-  
-  AliError(Form("fPadDimensionsMap size is %d",fPadDimensionsMap.GetSize()));
-  
-#endif
+/// Print the sector
 
-  // Should never happen
-  AliErrorStream() 
-    << "Zone(AliMpPad pad) not found, where pad is: " << pad << endl;
-  return 0;
-}  
+  fkSector->Print(opt);
+}
 
 //______________________________________________________________________________
-TVector2 
-AliMpSectorSegmentation::PadDimensions(Int_t zone, Bool_t warning) const
+Double_t AliMpSectorSegmentation::GetMinPadDimensionX() const
 {
-/// Return the pad dimensions for the zone with the specified zone index.
+/// Return the x dimension of the smallest pad.
+
+  return fkSector->GetMinPadDimensionX();
+}  
 
-#ifdef WITH_STL
-  PadDimensionsMapCIterator it = fPadDimensionsMap.find(zone);
-  if (it != fPadDimensionsMap.end()) return it->second;
-#endif
 
-#ifdef WITH_ROOT
-  Long_t value = fPadDimensionsMap.GetValue(zone);
-  if (value) return GetVector(value);
-#endif
+//______________________________________________________________________________
+Double_t AliMpSectorSegmentation::GetMinPadDimensionY() const
+{
+/// Return the y dimension of the smallest pad.
 
-  if (warning) Warning("PadDimensions(zone)", "not found");
-  return TVector2();
+  return fkSector->GetMinPadDimensionY();
 }  
 
+
 //______________________________________________________________________________
-Bool_t AliMpSectorSegmentation::CircleTest(const AliMpIntPair& indices) const
+Bool_t AliMpSectorSegmentation::CircleTest(Int_t ix, Int_t iy) const
 {
 /// Verify that all methods for retrieving pads are consistents between them.
 /// Return true if the pad with specified indices was found and verified,
 /// false otherwise.
 
-  if (!HasPad(indices)) return false;
+  if ( ! HasPadByIndices(ix, iy) ) return false;
 
   // Verify the indice->location->position->indice way
-  AliMpIntPair location = PadByIndices(indices).GetLocation();
-  TVector2 position = PadByLocation(location).Position();
-  AliMpIntPair retIndices = PadByPosition(position).GetIndices();
+  AliMpPad pad1 = PadByIndices(ix, iy);  
+  AliMpPad pad2 = PadByLocation(pad1.GetManuId(), pad1.GetManuChannel());
+  AliMpPad pad3 = PadByPosition(pad2.GetPositionX(),pad2.GetPositionY());
+                                      
+  MpPair_t retIndices = pad3.GetIndices();
     
-  if (retIndices != indices) {
-    cout << "Pad " << indices << " lead to inconsistency" << endl;
+  if ( retIndices != AliMp::Pair(ix, iy) ) {
+    cout << "Pad (" << ix << ',' << iy << ") lead to inconsistency" << endl;
     cout << "in indice->location->position->indice way..." << endl;
-    cout << "starting from " << indices << "-->" << location << "-->" 
-         << '(' << position.X() << ',' << position.Y() << ')'
-         << " and retIndices: " << retIndices << endl;
+    cout << "starting from indices " << pad1 << endl
+         << "--> location " << pad2 << endl
+         << "--> position " 
+         << '(' << pad3.GetPositionX() << ',' << pad3.GetPositionY() << ')'
+         <<  endl << endl;
   }
     
-    
-  // Verify the indice->position->location->indice way    
-  position = PadByIndices(indices).Position();
-  location = PadByPosition(position).GetLocation();
-  retIndices = PadByLocation(location).GetIndices();
-
-  if (retIndices != indices) {
-    cout << "Pad " << indices << " lead to inconsistency" << endl;
-    cout << "in indice->position->location->indice way..." <<endl;
-    cout << "starting from " << indices 
-         << " and retIndices: " << retIndices << endl;
+  // Verify the indice->position->location->indice way  
+  AliMpPad pad2bis = PadByPosition(pad1.GetPositionX(),pad1.GetPositionY());
+  AliMpPad pad3bis = PadByLocation(pad2bis.GetManuId(), pad2bis.GetManuChannel());
+  
+  retIndices = pad3bis.GetIndices();
+
+  if ( retIndices != AliMp::Pair(ix, iy) ) {
+    cout << "Pad (" << ix << ',' << iy << ") lead to inconsistency" << endl;
+    cout << "in indice->position->location->indice way..." << endl;
+    cout << "starting from indices " << pad1 << endl
+         << "--> position " 
+         << '(' << pad2bis.GetPositionX() << ',' << pad2bis.GetPositionY() << ')' << endl
+         << "--> location " << pad3bis
+         << endl << endl;
   }
   
   return true;
 }
-
-//______________________________________________________________________________
-void
-AliMpSectorSegmentation::Print(Option_t* opt) const
-{
-  fkSector->Print(opt);
-}
-
-//______________________________________________________________________________
-void AliMpSectorSegmentation::PrintZones() const
-{
-/// Print all zones and pads dimensions from the map.
-
-  cout << "Zones: " << endl;
-
-#ifdef WITH_STL
-  PadDimensionsMapCIterator it;
-  for (it = fPadDimensionsMap.begin(); it != fPadDimensionsMap.end(); ++it) {
-    cout << "    zone: " <<   setw(4) << it->first;
-    cout << "    pad dimensions: ( " 
-         << it->second.X() << ", " << it->second.Y() << ")" << endl; 
-  }
-#endif
-
-#ifdef WITH_ROOT
-  PadDimensionsMapCIterator it(&fPadDimensionsMap);
-  Long_t key, value;
-  while ( it.Next(key, value) ) {
-    //cout << "Iterating over: " << key << ", " << value << endl;
-    TVector2 dimensions =  GetVector(value);
-
-    cout << "    zone: " <<   setw(4) << key;
-    cout << "    pad dimensions: ( " 
-         << dimensions.X() << ", " << dimensions.Y() << ")" << endl; 
-  }
-#endif
-}
-