]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Update for station2:
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Sep 2003 10:26:15 +0000 (10:26 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Sep 2003 10:26:15 +0000 (10:26 +0000)
   Initial version
   (I.Hrivnacova)

13 files changed:
MUON/mapping/AliMpPadRowLSegment.cxx [new file with mode: 0755]
MUON/mapping/AliMpPadRowLSegment.h [new file with mode: 0755]
MUON/mapping/AliMpPadRowRSegment.cxx [new file with mode: 0644]
MUON/mapping/AliMpPadRowRSegment.h [new file with mode: 0644]
MUON/mapping/AliMpRowSegmentLSpecial.cxx [new file with mode: 0755]
MUON/mapping/AliMpRowSegmentLSpecial.h [new file with mode: 0755]
MUON/mapping/AliMpRowSegmentRSpecial.cxx [new file with mode: 0644]
MUON/mapping/AliMpRowSegmentRSpecial.h [new file with mode: 0644]
MUON/mapping/AliMpVPadRowSegment.cxx [new file with mode: 0755]
MUON/mapping/AliMpVPadRowSegment.h [new file with mode: 0755]
MUON/mapping/AliMpVRowSegmentSpecial.cxx [new file with mode: 0644]
MUON/mapping/AliMpVRowSegmentSpecial.h [new file with mode: 0644]
MUON/mapping/AliMpXDirection.h [new file with mode: 0644]

diff --git a/MUON/mapping/AliMpPadRowLSegment.cxx b/MUON/mapping/AliMpPadRowLSegment.cxx
new file mode 100755 (executable)
index 0000000..839eee1
--- /dev/null
@@ -0,0 +1,112 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpPadRowLSegment
+// -------------------------
+// Class describing a pad row segment composed of the 
+// the identic pads;
+// the pads are placed from the offset (defined in the base class)
+// to the left.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#include <TError.h>
+
+#include "AliMpPadRowLSegment.h"
+#include "AliMpPadRow.h"
+#include "AliMpMotif.h"
+#include "AliMpMotifType.h"
+
+ClassImp(AliMpPadRowLSegment)
+
+//_____________________________________________________________________________
+AliMpPadRowLSegment::AliMpPadRowLSegment(
+                          AliMpPadRow* padRow, AliMpMotif* motif, 
+                          Int_t motifPositionId, Int_t nofPads)
+  : AliMpVPadRowSegment(padRow, motif, motifPositionId, nofPads)
+{
+// 
+}
+
+//_____________________________________________________________________________
+AliMpPadRowLSegment::AliMpPadRowLSegment() 
+  : AliMpVPadRowSegment()
+{
+//
+}
+
+//_____________________________________________________________________________
+AliMpPadRowLSegment::~AliMpPadRowLSegment() {
+//  
+}
+
+//
+// private methods  
+//
+
+//_____________________________________________________________________________
+Double_t AliMpPadRowLSegment::FirstPadCenterX() const
+{
+// Returns the x coordinate of the first (the most right) pad center
+// in global coordinate system.
+// ---
+
+  return GetOffsetX() - GetMotif()->GetPadDimensions().X();
+}  
+
+//_____________________________________________________________________________
+Double_t AliMpPadRowLSegment::LastPadCenterX() const
+{
+// Returns the x coordinate of the last (the most left) pad center
+// in global coordinate system.
+// !! numbering of pads is in (-x) direction
+// ---
+
+  return GetOffsetX() - (2.*GetNofPads() - 1)*GetMotif()->GetPadDimensions().X();
+}
+
+//_____________________________________________________________________________
+Double_t AliMpPadRowLSegment::FirstPadBorderX() const
+{
+// Returns the x coordinate of the right border of the first (the most right) 
+// pad in global coordinate system.
+// ---
+
+  return GetOffsetX();
+         // Also could be
+         // return FirstPadCenterX() + GetMotif()->GetPadDimensions().X();
+}  
+
+//_____________________________________________________________________________
+Double_t AliMpPadRowLSegment::LastPadBorderX() const
+{
+// Returns the x coordinate of the left border of the last (the most left)
+// pad in global coordinate system.
+// ---
+
+  return LastPadCenterX() - GetMotif()->GetPadDimensions().X();
+}  
+
+//
+// public methods  
+//
+
+//_____________________________________________________________________________
+Double_t  AliMpPadRowLSegment::LeftBorderX() const
+{
+// Returns the x coordinate of the left row segment border
+// in global coordinate system.
+// ---
+
+  return LastPadBorderX();
+}
+
+//_____________________________________________________________________________
+Double_t  AliMpPadRowLSegment::RightBorderX() const
+{
+// Returns the x coordinate of the right row segment border
+// in global coordinate system.
+// ---
+
+  return FirstPadBorderX();
+}
diff --git a/MUON/mapping/AliMpPadRowLSegment.h b/MUON/mapping/AliMpPadRowLSegment.h
new file mode 100755 (executable)
index 0000000..788a32f
--- /dev/null
@@ -0,0 +1,46 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpPadRowLSegment
+// -------------------------
+// Class describing a pad row segment composed of the 
+// the identic pads;
+// the pads are placed from the offset (defined in the base class)
+// to the left.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#ifndef ALI_MP_PAD_ROW_L_SEGMENT_H
+#define ALI_MP_PAD_ROW_L_SEGMENT_H
+
+#include <TObject.h>
+
+#include "AliMpVPadRowSegment.h"
+
+class AliMpPadRow;
+class AliMpMotif;
+
+class AliMpPadRowLSegment : public AliMpVPadRowSegment
+{
+  public:
+    AliMpPadRowLSegment(AliMpPadRow* padRow, AliMpMotif* motif, Int_t motifPositionId,
+                   Int_t nofPads);
+    AliMpPadRowLSegment();
+    virtual ~AliMpPadRowLSegment();
+
+    // methods
+    virtual Double_t  LeftBorderX() const;
+    virtual Double_t  RightBorderX() const;
+
+  private:
+    // methods
+    Double_t  FirstPadCenterX() const;
+    Double_t  LastPadCenterX() const;
+    Double_t  FirstPadBorderX() const;
+    Double_t  LastPadBorderX() const;
+    
+  ClassDef(AliMpPadRowLSegment,1)  //Row segment
+};
+
+#endif //ALI_MP_PAD_ROW_L_SEGMENT_H
+
diff --git a/MUON/mapping/AliMpPadRowRSegment.cxx b/MUON/mapping/AliMpPadRowRSegment.cxx
new file mode 100644 (file)
index 0000000..c6acd91
--- /dev/null
@@ -0,0 +1,112 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpPadRowRSegment
+// -------------------------
+// Class describing a pad row segment composed of the 
+// the identic pads;
+// the pads are placed from the offset (defined in the base class)
+// to the right.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#include <TError.h>
+
+#include "AliMpPadRowRSegment.h"
+#include "AliMpPadRow.h"
+#include "AliMpMotif.h"
+#include "AliMpMotifType.h"
+
+ClassImp(AliMpPadRowRSegment)
+
+//______________________________________________________________________________
+AliMpPadRowRSegment::AliMpPadRowRSegment(AliMpPadRow* padRow, AliMpMotif* motif, 
+                                         Int_t motifPositionId, Int_t nofPads)
+  : AliMpVPadRowSegment(padRow, motif, motifPositionId, nofPads)
+{
+// 
+}
+
+//______________________________________________________________________________
+AliMpPadRowRSegment::AliMpPadRowRSegment() 
+  : AliMpVPadRowSegment()
+{
+//
+}
+
+//______________________________________________________________________________
+AliMpPadRowRSegment::~AliMpPadRowRSegment() {
+//  
+}
+
+//
+// private methods  
+//
+
+//______________________________________________________________________________
+Double_t AliMpPadRowRSegment::FirstPadCenterX() const
+{
+// Returns the x coordinate of the first (the most left) pad center
+// in global coordinate system.
+// ---
+
+  return GetOffsetX() + GetMotif()->GetPadDimensions().X();
+}  
+
+//______________________________________________________________________________
+Double_t AliMpPadRowRSegment::LastPadCenterX() const
+{
+// Returns the x coordinate of the last (the most right) pad center
+// in global coordinate system.
+// !! numbering of pads is in (-x) direction
+// ---
+
+  return GetOffsetX() + (2.*GetNofPads() - 1)*GetMotif()->GetPadDimensions().X();
+}
+
+//______________________________________________________________________________
+Double_t AliMpPadRowRSegment::FirstPadBorderX() const
+{
+// Returns the x coordinate of the left border of the first (the most left) 
+// pad in global coordinate system.
+// ---
+
+  return GetOffsetX();
+         // Also could be
+         // return FirstPadCenterX() + GetMotif()->GetPadDimensions().X();
+}  
+
+//______________________________________________________________________________
+Double_t AliMpPadRowRSegment::LastPadBorderX() const
+{
+// Returns the x coordinate of the right border of the last (the most right)
+// pad in global coordinate system.
+// ---
+
+  return LastPadCenterX() + GetMotif()->GetPadDimensions().X();
+}  
+
+//
+// public methods  
+//
+
+//______________________________________________________________________________
+Double_t  AliMpPadRowRSegment::LeftBorderX() const
+{
+// Returns the x coordinate of the left row segment border
+// in global coordinate system.
+// ---
+
+  return FirstPadBorderX();
+}
+
+//______________________________________________________________________________
+Double_t  AliMpPadRowRSegment::RightBorderX() const
+{
+// Returns the x coordinate of the right row segment border
+// in global coordinate system.
+// ---
+
+  return LastPadBorderX();
+}
+
diff --git a/MUON/mapping/AliMpPadRowRSegment.h b/MUON/mapping/AliMpPadRowRSegment.h
new file mode 100644 (file)
index 0000000..052b671
--- /dev/null
@@ -0,0 +1,46 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpPadRowRSegment
+// -------------------------
+// Class describing a pad row segment composed of the 
+// the identic pads;
+// the pads are placed from the offset (defined in the base class)
+// to the right.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#ifndef ALI_MP_PAD_ROW_R_SEGMENT_H
+#define ALI_MP_PAD_ROW_R_SEGMENT_H
+
+#include <TObject.h>
+
+#include "AliMpVPadRowSegment.h"
+
+class AliMpPadRow;
+class AliMpMotif;
+
+class AliMpPadRowRSegment : public AliMpVPadRowSegment
+{
+  public:
+    AliMpPadRowRSegment(AliMpPadRow* padRow, AliMpMotif* motif, Int_t motifPositionId,
+                   Int_t nofPads);
+    AliMpPadRowRSegment();
+    virtual ~AliMpPadRowRSegment();
+
+    // methods
+    virtual Double_t  LeftBorderX() const;
+    virtual Double_t  RightBorderX() const;
+
+  private:
+    // methods
+    Double_t  FirstPadCenterX() const;
+    Double_t  LastPadCenterX() const;
+    Double_t  FirstPadBorderX() const;
+    Double_t  LastPadBorderX() const;
+    
+  ClassDef(AliMpPadRowRSegment,1)  //Row segment
+};
+
+#endif //ALI_MP_PAD_ROW_R_SEGMENT_H
+
diff --git a/MUON/mapping/AliMpRowSegmentLSpecial.cxx b/MUON/mapping/AliMpRowSegmentLSpecial.cxx
new file mode 100755 (executable)
index 0000000..1320b5c
--- /dev/null
@@ -0,0 +1,257 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpRowSegmentLSpecial
+// -----------------------------
+// Class describing a special inner row segment composed of the 
+// pad rows.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#include <TError.h>
+
+#include "AliMpRowSegmentLSpecial.h"
+#include "AliMpRow.h"
+#include "AliMpPadRow.h"
+#include "AliMpVPadRowSegment.h"
+#include "AliMpMotif.h"
+#include "AliMpMotifType.h"
+#include "AliMpMotifMap.h"
+#include "AliMpMotifPosition.h"
+#include "AliMpConstants.h"
+
+ClassImp(AliMpRowSegmentLSpecial)
+
+//______________________________________________________________________________
+AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
+  : AliMpVRowSegmentSpecial(row, offsetX)
+{
+// 
+}
+
+//______________________________________________________________________________
+AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial() 
+  : AliMpVRowSegmentSpecial()
+{
+//
+}
+
+//______________________________________________________________________________
+AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial() 
+{
+//  
+}
+
+//
+// private methods  
+//
+
+//______________________________________________________________________________
+AliMpVPadRowSegment*  
+AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
+{
+// Find the most right pad row segment with this motifPositionId.
+// ---
+
+  AliMpVPadRowSegment* found = 0;
+
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    AliMpPadRow* padRow = GetPadRow(i);    
+
+    for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { 
+      AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
+
+      if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
+           (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
+          
+        found = padRowSegment;  
+    }
+  }
+
+  return found;        
+}
+
+//
+// protected methods  
+//
+
+//______________________________________________________________________________
+TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
+{
+// Returns the coordinates of the motif specified with
+// the given position identifier.
+// !! Applicable only for motifs that have their most down pad in
+// this row segment.
+// ---
+
+  // Find the first (left, down) pad row segment with this motifPositionId.
+  AliMpVPadRowSegment* downPadRowSegment 
+    = FindPadRowSegment(motifPositionId);
+  AliMpVPadRowSegment* rightPadRowSegment 
+    = FindMostRightPadRowSegment(motifPositionId);
+  
+  // Check if the motifPositionId is present 
+  if (!downPadRowSegment || !rightPadRowSegment) {
+    Error("MotifCenter", "Outside row segment region");
+    return 0;
+  }
+
+  // Check if both pad row segments have the same motif 
+  if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
+    Fatal("MotifCenter", "Outside row segment region");
+    return 0;
+  }
+
+  // Get position of found row segment
+  Double_t x = rightPadRowSegment->RightBorderX();       
+  Double_t y = GetRow()->LowBorderY()  ;   
+  
+  for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
+    y += GetPadRow(i)->HalfSizeY()*2.;
+    
+  // Add motifs dimensions
+  x -= downPadRowSegment->GetMotif()->Dimensions().X();
+  y += downPadRowSegment->GetMotif()->Dimensions().Y();
+  
+  return TVector2(x, y);
+}
+
+//
+// public methods  
+//
+
+//______________________________________________________________________________
+void AliMpRowSegmentLSpecial::UpdatePadsOffset()
+{
+// Sets low indices limit to the pad offset calculated
+// from the neighbour normal segment.
+// ---
+
+  // Get the neighbour row segment
+  // (the first normal segment)
+  AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
+
+  // Get the the pads offset of the neighbour row segment
+  // (the first normal segment)
+  AliMpIntPair offset = neighbour->GetLowIndicesLimit();
+  
+  // Find max nof pads in a row
+  Int_t maxNofPads = MaxNofPadsInRow();
+
+  // Set limits
+  SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
+
+  // Reset limits in the neighbour row segment
+  // (pad offset is now included in the special segment)  
+  neighbour->SetLowIndicesLimit(
+    AliMpIntPair(0, neighbour->GetLowIndicesLimit().GetSecond()));
+}
+
+//______________________________________________________________________________
+Double_t  AliMpRowSegmentLSpecial::LeftBorderX() const
+{
+// Returns the x coordinate of the left row segment border
+// in global coordinate system.
+// ---
+
+  Double_t leftBorder = DBL_MAX;
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    AliMpPadRow* padRow = GetPadRow(i);
+    Double_t border 
+      = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
+      
+    if (border < leftBorder) leftBorder =  border;
+  }  
+  
+  return leftBorder;
+}
+
+//______________________________________________________________________________
+Double_t  AliMpRowSegmentLSpecial::RightBorderX() const
+{
+// Returns the x coordinate of the right row segment border
+// in global coordinate system.
+// ---
+
+  Double_t sameBorder = GetOffsetX();
+
+  // Consistence check  
+  Double_t rightBorder = -DBL_MAX;
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    AliMpPadRow* padRow = GetPadRow(i);
+    Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
+    if (border > rightBorder) rightBorder =  border;
+  }  
+
+  if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04)  {
+    Error("RightBorderX", "WrongBorder");
+    return sameBorder;
+  }  
+  
+  return rightBorder;
+}
+
+//______________________________________________________________________________
+TVector2 AliMpRowSegmentLSpecial::Position() const
+{
+// Returns the position of the row segment centre.
+// The centre is defined as the centre of the rectangular
+// row segment envelope.
+// ---
+
+  Double_t x = GetOffsetX() - Dimensions().X();                    
+  Double_t y = GetRow()->Position().Y();  
+    
+  return TVector2(x, y);   
+}
+
+//______________________________________________________________________________
+Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i, 
+                                         const AliMpIntPair& indices)
+{
+// Sets global indices to i-th motif position and returns next index in x.
+// ---
+
+  // Get motif position
+  AliMpMotifPosition* motifPosition
+    = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
+
+  // Low limit
+  AliMpIntPair low 
+    = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(), 
+              indices.GetSecond())
+      + FindRelativeLowIndicesOf(GetMotifPositionId(i));
+            
+  if (! motifPosition->GetHighIndicesLimit().IsValid()) {   
+     motifPosition->SetLowIndicesLimit(low);
+  } 
+  else {
+    if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
+      motifPosition->SetLowIndicesLimit(
+                        AliMpIntPair(low.GetFirst(),
+                                 motifPosition->GetLowIndicesLimit().GetSecond()));
+
+    if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
+       motifPosition->SetLowIndicesLimit(
+                         AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
+                                  low.GetSecond()));
+  }
+             
+  // High limit             
+  AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();  
+  AliMpIntPair high 
+    = motifPosition->GetLowIndicesLimit()
+      + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);            
+  motifPosition->SetHighIndicesLimit(high);
+  
+  // Increment index only if last motif position is processed 
+  if (i != GetNofMotifs()-1) 
+    return indices.GetFirst();
+    //return 0;
+  else
+    return indices.GetFirst() + MaxNofPadsInRow();  
+    //return MaxNofPadsInRow();  
+}
+
+
+
diff --git a/MUON/mapping/AliMpRowSegmentLSpecial.h b/MUON/mapping/AliMpRowSegmentLSpecial.h
new file mode 100755 (executable)
index 0000000..a4d5f7b
--- /dev/null
@@ -0,0 +1,54 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpRowSegmentLSpecial
+// -----------------------------
+// Class describing a special inner row segment composed of the 
+// pad rows.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#ifndef ALI_MP_ROW_SEGMENT_L_SPECIAL_H
+#define ALI_MP_ROW_SEGMENT_L_SPECIAL_H
+
+#include <TVector2.h>
+
+#include "AliMpSectorTypes.h"
+#include "AliMpVRowSegmentSpecial.h"
+
+class AliMpRow;
+class AliMpPadRow;
+class AliMpVPadRowSegment;
+class AliMpIntPair;
+
+class AliMpRowSegmentLSpecial : public AliMpVRowSegmentSpecial
+{
+  public:
+    AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX);
+    AliMpRowSegmentLSpecial();
+    virtual ~AliMpRowSegmentLSpecial();
+    
+    // methods
+    virtual void  UpdatePadsOffset();
+    virtual Double_t  LeftBorderX() const;
+    virtual Double_t  RightBorderX() const;
+
+    // geometry
+    virtual TVector2  Position() const;
+
+    // set methods
+    virtual Int_t  SetIndicesToMotifPosition(Int_t i, 
+                             const AliMpIntPair& indices);
+
+  protected:
+    // methods
+    virtual TVector2  MotifCenterSlow(Int_t motifPositionId) const;
+    
+  private:
+    // methods
+    AliMpVPadRowSegment* FindMostRightPadRowSegment(Int_t motifPositionId) const;
+    
+  ClassDef(AliMpRowSegmentLSpecial,1)  //Row segment
+};
+
+#endif //ALI_MP_ROW_SEGMENT_L_SPECIAL_H
diff --git a/MUON/mapping/AliMpRowSegmentRSpecial.cxx b/MUON/mapping/AliMpRowSegmentRSpecial.cxx
new file mode 100644 (file)
index 0000000..3c71b44
--- /dev/null
@@ -0,0 +1,250 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpRowSegmentRSpecial
+// -----------------------------
+// Class describing a special outer row segment composed of the 
+// pad rows.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#include <TError.h>
+#include <Riostream.h>
+
+#include "AliMpRowSegmentRSpecial.h"
+#include "AliMpRow.h"
+#include "AliMpPadRow.h"
+#include "AliMpVPadRowSegment.h"
+#include "AliMpMotif.h"
+#include "AliMpMotifType.h"
+#include "AliMpMotifMap.h"
+#include "AliMpMotifPosition.h"
+
+ClassImp(AliMpRowSegmentRSpecial)
+
+//______________________________________________________________________________
+AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial(AliMpRow* row, Double_t offsetX)
+  : AliMpVRowSegmentSpecial(row, offsetX)
+{
+// 
+}
+
+//______________________________________________________________________________
+AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial() 
+  : AliMpVRowSegmentSpecial()
+{
+//
+}
+
+//______________________________________________________________________________
+AliMpRowSegmentRSpecial::~AliMpRowSegmentRSpecial() 
+{
+//  
+}
+
+//
+// private methods  
+//
+
+//______________________________________________________________________________
+AliMpVPadRowSegment*  
+AliMpRowSegmentRSpecial::FindMostLeftPadRowSegment(Int_t motifPositionId) const
+{
+// Find the most left pad row segment with this motifPositionId.
+// ---
+
+  AliMpVPadRowSegment* found = 0;
+
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    AliMpPadRow* padRow = GetPadRow(i);    
+
+    for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { 
+      AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
+
+      if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
+           (!found || padRowSegment->LeftBorderX() < found->LeftBorderX()))
+          
+        found = padRowSegment;  
+    }
+  }
+
+  return found;        
+}
+
+//______________________________________________________________________________
+void AliMpRowSegmentRSpecial::SetGlobalIndicesLow()
+{
+// ...
+   
+  // Last normal row segment in the row
+  // (preceding this special row segment)
+  AliMpVRowSegment* rowSegment 
+    =  GetRow()->GetRowSegment(GetRow()->GetNofRowSegments()-2);
+    
+  // Set low indices limit to continue indices of the
+  // preceding row segment  
+  Int_t ix = rowSegment->GetHighIndicesLimit().GetFirst() + 1;
+  Int_t iy = rowSegment->GetLowIndicesLimit().GetSecond();
+  
+  SetLowIndicesLimit(AliMpIntPair(ix, iy));
+}
+
+//
+// protected methods  
+//
+
+//______________________________________________________________________________
+TVector2 AliMpRowSegmentRSpecial::MotifCenterSlow(Int_t motifPositionId) const
+{
+// Returns the coordinates of the motif specified with
+// the given position identifier.
+// !! Applicable only for motifs that have their most down pad in
+// this row segment.
+// ---
+
+  // Find the first (left, down) pad row segment with this motifPositionId.
+  AliMpVPadRowSegment* downPadRowSegment 
+    = FindPadRowSegment(motifPositionId);
+  AliMpVPadRowSegment* leftPadRowSegment 
+    = FindMostLeftPadRowSegment(motifPositionId);
+  
+  // Check if the motifPositionId is present 
+  if (!downPadRowSegment || !leftPadRowSegment) {
+    Error("MotifCenter", "Outside row segment region");
+    return 0;
+  }
+
+  // Check if both pad row segments have the same motif 
+  if (downPadRowSegment->GetMotif() != leftPadRowSegment->GetMotif()) {
+    Fatal("MotifCenter", "Outside row segment region");
+    return 0;
+  }
+
+  // Get position of found row segment
+  Double_t x = leftPadRowSegment->LeftBorderX();       
+  Double_t y = GetRow()->LowBorderY()  ;   
+  
+  for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
+    y += GetPadRow(i)->HalfSizeY()*2.;
+    
+  // Add motifs dimensions
+  x += downPadRowSegment->GetMotif()->Dimensions().X();
+  y += downPadRowSegment->GetMotif()->Dimensions().Y();
+  
+  return TVector2(x, y);
+}
+
+//
+// public methods  
+//
+
+//______________________________________________________________________________
+Double_t  AliMpRowSegmentRSpecial::LeftBorderX() const
+{
+// Returns the x coordinate of the left row segment border
+// in global coordinate system.
+// ---
+
+  // The right edge of the last normal segment
+  Double_t sameBorder = GetOffsetX();
+
+  // Consistence check  
+  Double_t leftBorder = DBL_MAX;
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    AliMpPadRow* padRow = GetPadRow(i);
+    Double_t border = padRow->GetPadRowSegment(0)->LeftBorderX();
+    if (border < leftBorder) leftBorder =  border;
+  }  
+
+  if (TMath::Abs(sameBorder - leftBorder) > 1.e-04)  {
+    Error("LeftBorderX", "WrongBorder");
+    return sameBorder;
+  }  
+  
+  return leftBorder;
+
+}
+
+//______________________________________________________________________________
+Double_t  AliMpRowSegmentRSpecial::RightBorderX() const
+{
+// Returns the x coordinate of the right row segment border
+// in global coordinate system.
+// ---
+
+  Double_t rightBorder = -DBL_MAX;
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    AliMpPadRow* padRow = GetPadRow(i);
+    Double_t border 
+      = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)
+        ->RightBorderX();
+      
+    if (border > rightBorder) rightBorder =  border;
+  }  
+  
+  return rightBorder;
+}
+
+//______________________________________________________________________________
+TVector2 AliMpRowSegmentRSpecial::Position() const
+{
+// Returns the position of the row segment centre.
+// The centre is defined as the centre of the rectangular
+// row segment envelope.
+// ---
+
+  // The right edge of the last normal segment
+  Double_t x = GetOffsetX()  + Dimensions().X();
+  Double_t y = GetRow()->Position().Y();  
+    
+  return TVector2(x, y);   
+}
+
+//______________________________________________________________________________
+Int_t AliMpRowSegmentRSpecial::SetIndicesToMotifPosition(Int_t i, 
+                                         const AliMpIntPair& indices)
+{
+// Sets global indices to i-th motif position and returns next index in x.
+// ---
+
+  // Update low indices limit for this row segment
+  SetGlobalIndicesLow();
+  
+  // Check for consistence
+  if (GetLowIndicesLimit().GetFirst() != indices.GetFirst()) 
+    Fatal("SetIndicesToMotifPosition", "Inconsistent indices");
+
+  // Get motif position
+  AliMpMotifPosition* motifPosition
+    = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
+
+  // Low limit
+  AliMpIntPair low = GetLowIndicesLimit();
+         
+  if (! motifPosition->GetHighIndicesLimit().IsValid()) {   
+     motifPosition->SetLowIndicesLimit(low);
+  } 
+  else {
+    if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
+      motifPosition->SetLowIndicesLimit(
+                        AliMpIntPair(low.GetFirst(),
+                                 motifPosition->GetLowIndicesLimit().GetSecond()));
+
+    if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
+       motifPosition->SetLowIndicesLimit(
+                         AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
+                                  low.GetSecond()));
+  }
+
+  // High limit             
+  AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();  
+  AliMpIntPair high 
+    = motifPosition->GetLowIndicesLimit()
+      + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);            
+  motifPosition->SetHighIndicesLimit(high);
+  
+  // No increment index needed (this is always the last element)
+  return indices.GetFirst();
+}
+
+
diff --git a/MUON/mapping/AliMpRowSegmentRSpecial.h b/MUON/mapping/AliMpRowSegmentRSpecial.h
new file mode 100644 (file)
index 0000000..d0423bc
--- /dev/null
@@ -0,0 +1,55 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpRowSegmentRSpecial
+// -----------------------------
+// Class describing a special outer row segment composed of the 
+// pad rows.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#ifndef ALI_MP_ROW_SEGMENT_R_SPECIAL_H
+#define ALI_MP_ROW_SEGMENT_R_SPECIAL_H
+
+#include <TVector2.h>
+
+#include "AliMpSectorTypes.h"
+#include "AliMpVRowSegmentSpecial.h"
+
+class AliMpRow;
+class AliMpPadRow;
+class AliMpVPadRowSegment;
+class AliMpIntPair;
+
+class AliMpRowSegmentRSpecial : public AliMpVRowSegmentSpecial
+{
+  public:
+    AliMpRowSegmentRSpecial(AliMpRow* row, Double_t offsetX);
+    AliMpRowSegmentRSpecial();
+    virtual ~AliMpRowSegmentRSpecial();
+    
+    // methods
+     virtual void  UpdatePadsOffset() {}
+    virtual Double_t  LeftBorderX() const;
+    virtual Double_t  RightBorderX() const;
+
+    // geometry
+    virtual TVector2  Position() const;
+
+    // set methods
+    virtual Int_t  SetIndicesToMotifPosition(Int_t i, 
+                             const AliMpIntPair& indices);
+
+  protected:
+    // methods
+    virtual TVector2  MotifCenterSlow(Int_t motifPositionId) const;
+    
+  private:
+    // methods
+    AliMpVPadRowSegment* FindMostLeftPadRowSegment(Int_t motifPositionId) const;
+    void SetGlobalIndicesLow();
+    
+  ClassDef(AliMpRowSegmentRSpecial,1)  //Row segment
+};
+
+#endif //ALI_MP_ROW_SEGMENT_R_SPECIAL_H
diff --git a/MUON/mapping/AliMpVPadRowSegment.cxx b/MUON/mapping/AliMpVPadRowSegment.cxx
new file mode 100755 (executable)
index 0000000..406ca7c
--- /dev/null
@@ -0,0 +1,98 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpVPadRowSegment
+// --------------------
+// The abstract base class for a pad row segment composed of the 
+// the identic pads.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#include <TError.h>
+
+#include "AliMpVPadRowSegment.h"
+#include "AliMpPadRow.h"
+#include "AliMpMotif.h"
+#include "AliMpMotifType.h"
+
+ClassImp(AliMpVPadRowSegment)
+
+//_____________________________________________________________________________
+AliMpVPadRowSegment::AliMpVPadRowSegment(AliMpPadRow* padRow, AliMpMotif* motif, 
+                                       Int_t motifPositionId, Int_t nofPads)
+  : TObject(),
+    fNofPads(nofPads),
+    fOffsetX(0.),
+    fPadRow(padRow),
+    fMotif(motif),
+    fMotifPositionId(motifPositionId)
+{
+// 
+}
+
+//_____________________________________________________________________________
+AliMpVPadRowSegment::AliMpVPadRowSegment() 
+  : TObject(),
+    fNofPads(0),
+    fOffsetX(0.),
+    fPadRow(0),
+    fMotif(0),
+    fMotifPositionId(0)
+{
+//
+}
+
+//_____________________________________________________________________________
+AliMpVPadRowSegment::~AliMpVPadRowSegment() {
+//  
+}
+
+//
+// public methods  
+//
+
+//_____________________________________________________________________________
+Double_t  AliMpVPadRowSegment::HalfSizeY() const
+{
+// Returns the size in y of this row segment.
+// ---
+
+  return fMotif->GetPadDimensions().Y();
+}
+
+//_____________________________________________________________________________
+AliMpPadRow*  AliMpVPadRowSegment::GetPadRow() const
+{
+// Returns the pad row.which this pad row segment belongs to.
+// ---
+
+  return fPadRow;
+}  
+
+//_____________________________________________________________________________
+AliMpMotif*  AliMpVPadRowSegment::GetMotif() const
+{
+// Returns the motif of this pad row segment. 
+// ---
+
+  return fMotif;
+}  
+
+//_____________________________________________________________________________
+Int_t  AliMpVPadRowSegment::GetMotifPositionId() const
+{
+// Returns the motif of this pad row segment. 
+// ---
+
+  return fMotifPositionId;
+}  
+
+//_____________________________________________________________________________
+void  AliMpVPadRowSegment::SetOffsetX(Double_t offsetX)
+{
+// Sets the x offset.
+// ---
+
+  fOffsetX = offsetX;
+}    
+
diff --git a/MUON/mapping/AliMpVPadRowSegment.h b/MUON/mapping/AliMpVPadRowSegment.h
new file mode 100755 (executable)
index 0000000..ef45712
--- /dev/null
@@ -0,0 +1,57 @@
+// $Id$
+// ---------------------------------------------------------------
+// Category: sector
+//
+// Class AliMpVPadRowSegment
+// -------------------------
+// The abstract base class for a pad row segment composed of the 
+// the identic pads.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#ifndef ALI_MP_V_PAD_ROW_SEGMENT_H
+#define ALI_MP_V_PAD_ROW_SEGMENT_H
+
+#include <TObject.h>
+
+class AliMpPadRow;
+class AliMpMotif;
+
+class AliMpVPadRowSegment : public TObject
+{
+  public:
+    AliMpVPadRowSegment(AliMpPadRow* padRow, AliMpMotif* motif, 
+                       Int_t motifPositionId, Int_t nofPads);
+    AliMpVPadRowSegment();
+    virtual ~AliMpVPadRowSegment();
+
+    // methods
+    virtual Double_t  LeftBorderX() const = 0;
+    virtual Double_t  RightBorderX() const = 0;
+    virtual Double_t  HalfSizeY() const;
+
+    // get methods
+    virtual AliMpPadRow*  GetPadRow() const;
+    virtual AliMpMotif*   GetMotif() const;    
+    virtual Int_t     GetMotifPositionId() const;
+            Int_t     GetNofPads() const {return fNofPads;}     
+
+    // set methods
+    void  SetOffsetX(Double_t offsetX);  
+
+  protected:
+    Double_t  GetOffsetX() const { return fOffsetX; }
+
+  private:
+    // data members
+    Int_t         fNofPads;  //number of pads
+    Double_t      fOffsetX;  //the x position of the right/left border
+    AliMpPadRow*  fPadRow;   //the pad row containing this segment 
+    AliMpMotif*   fMotif;    //the motif 
+    Int_t         fMotifPositionId;  // the motif position id
+    
+  ClassDef(AliMpVPadRowSegment,1)  //Row segment
+};
+
+#endif //ALI_MP_V_PAD_ROW_SEGMENT_H
+
diff --git a/MUON/mapping/AliMpVRowSegmentSpecial.cxx b/MUON/mapping/AliMpVRowSegmentSpecial.cxx
new file mode 100644 (file)
index 0000000..5f52683
--- /dev/null
@@ -0,0 +1,398 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpVRowSegmentSpecial
+// ----------------------------
+// Class describing a special row segment composed of the 
+// pad rows.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#include <TError.h>
+#include <Riostream.h>
+
+#include "AliMpVRowSegmentSpecial.h"
+#include "AliMpRow.h"
+#include "AliMpPadRow.h"
+#include "AliMpVPadRowSegment.h"
+#include "AliMpMotif.h"
+#include "AliMpMotifType.h"
+#include "AliMpMotifMap.h"
+#include "AliMpMotifPosition.h"
+#include "AliMpConstants.h"
+
+ClassImp(AliMpVRowSegmentSpecial)
+
+//______________________________________________________________________________
+AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial(AliMpRow* row, Double_t offsetX)
+  : AliMpVRowSegment(),
+    fRow(row),
+    fOffsetX(offsetX),
+    fPadRows(),
+    fMotifs(),
+    fMotifPositionIds()
+{
+// 
+}
+
+//______________________________________________________________________________
+AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial() 
+  : AliMpVRowSegment(),
+    fRow(0),
+    fOffsetX(0.),
+    fPadRows(),
+    fMotifs(),
+    fMotifPositionIds()
+{
+//
+}
+
+//______________________________________________________________________________
+AliMpVRowSegmentSpecial::~AliMpVRowSegmentSpecial() 
+{
+//  
+  for (Int_t i=0; i<GetNofPadRows(); i++)
+    delete fPadRows[i];
+}
+
+//
+// protected methods  
+//
+
+//______________________________________________________________________________
+AliMpPadRow*  AliMpVRowSegmentSpecial::FindPadRow(Double_t y) const
+{
+// Finds the pad row in the given y coordinate.
+// ---
+
+  Double_t lowBorder =  fRow->LowBorderY();
+  Double_t highBorder = fRow->LowBorderY();
+  
+  for (Int_t i=0; i<GetNofPadRows(); i++) {    
+
+    AliMpPadRow* padRow = GetPadRow(i);
+    highBorder += 2.*padRow->HalfSizeY();
+
+    if ( y >= lowBorder &&  y <= highBorder)
+      return padRow;
+
+    lowBorder = highBorder;
+  }
+  
+  return 0;    
+}
+
+//______________________________________________________________________________
+AliMpVPadRowSegment*  
+AliMpVRowSegmentSpecial::FindPadRowSegment(Int_t motifPositionId) const
+{
+// Find the most down pad row segment with this motifPositionId.
+// ---
+
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    AliMpPadRow* padRow = GetPadRow(i);    
+
+    for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { 
+      AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
+
+      if (padRowSegment->GetMotifPositionId() == motifPositionId) 
+        return padRowSegment;
+    }
+  }
+  return 0;    
+}
+
+//______________________________________________________________________________
+AliMpIntPair 
+AliMpVRowSegmentSpecial::FindRelativeLowIndicesOf(Int_t motifPositionId) const 
+{ 
+// Returns the lowest pad indices where the motif of the given position ID
+// exists in this segment.
+// ---
+
+  AliMpIntPair ans(0,1000);
+  AliMpIntPair ans0 = ans;
+  Int_t maxNofPadsX=0;
+  
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    AliMpPadRow* padRow = GetPadRow(i);
+
+    Int_t nofPadsX=0;
+    for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
+      AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
+      nofPadsX += padRowSegment->GetNofPads();
+      if (padRowSegment->GetMotifPositionId() == motifPositionId) {
+         if (ans.GetFirst() < nofPadsX) ans.SetFirst(nofPadsX);
+         if (ans.GetSecond()>i) ans.SetSecond(i);
+                  // ans.First = max (nof pads of this pos ID)
+                  // ans.Second = min of pad row number
+      }
+    }  
+    if (nofPadsX > maxNofPadsX) maxNofPadsX = nofPadsX;
+  }    
+  if (ans == ans0) return AliMpIntPair::Invalid();
+  
+  return AliMpIntPair(maxNofPadsX-ans.GetFirst(), ans.GetSecond());
+}
+//______________________________________________________________________________
+Int_t  AliMpVRowSegmentSpecial::MaxNofPadsInRow() const 
+{ 
+// Returns the maximum number of pads in this row segment along the X direction
+// ---
+
+  Int_t maxNofPads = 0;    
+
+  for (Int_t i=0; i<GetNofPadRows(); i++){
+    Int_t nofPads = GetPadRow(i)->GetNofPads(); 
+
+    // Find maximum
+    if (nofPads > maxNofPads) maxNofPads = nofPads;
+  }
+    
+  return maxNofPads;
+}
+
+//______________________________________________________________________________
+Bool_t AliMpVRowSegmentSpecial::HasMotif(const AliMpVMotif* motif) const
+{
+// Returns true if the specified motif is already in fMotifs vector,
+// returns false otherwise.
+// ---
+
+  for (UInt_t i=0; i<fMotifs.size(); i++)
+    if (fMotifs[i] == motif) return true;
+
+  return false;         
+}
+
+//______________________________________________________________________________
+Int_t AliMpVRowSegmentSpecial::GetNofPadRows() const
+{
+// Returns number of pad rows.
+// ---
+
+  return fPadRows.size();
+}  
+
+//______________________________________________________________________________
+AliMpPadRow* AliMpVRowSegmentSpecial::GetPadRow(Int_t i) const
+{
+// Returns number of pad rows.
+// ---
+
+  return fPadRows[i];
+}  
+
+//
+// public methods  
+//
+
+//______________________________________________________________________________
+void  AliMpVRowSegmentSpecial::AddPadRow(AliMpPadRow* padRow)
+{
+// Adds a pad row.
+// ---
+
+  padRow->SetOffsetX(fOffsetX);
+  padRow->SetID(GetNofPadRows());
+  fPadRows.push_back(padRow);
+}  
+
+//______________________________________________________________________________
+void AliMpVRowSegmentSpecial::UpdateMotifVector()
+{
+// Add motifs associated with the pad row segments in the specified
+// pad row in the fMotifs vector.
+// ---
+
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    AliMpPadRow* padRow = GetPadRow(i);
+    for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
+      AliMpVMotif* motif = padRow->GetPadRowSegment(j)->GetMotif();            
+
+      if (!HasMotif(motif)) {
+        fMotifs.push_back(motif);       
+        fMotifPositionIds.push_back(
+          padRow->GetPadRowSegment(j)->GetMotifPositionId());
+      }
+    }  
+  }
+}
+
+//______________________________________________________________________________
+Double_t  AliMpVRowSegmentSpecial::HalfSizeY() const
+{
+// Returns the size in y of this row segment.
+// ---
+
+  Double_t halfSizeY = 0.;
+  for (Int_t i=0; i<GetNofPadRows(); i++) {
+    halfSizeY += GetPadRow(i)->HalfSizeY();
+  }  
+  
+  return halfSizeY;
+}
+
+//______________________________________________________________________________
+AliMpVMotif*  AliMpVRowSegmentSpecial::FindMotif(const TVector2& position) const
+{
+// Returns the motif of this row; 
+// ---
+
+  AliMpPadRow* padRow 
+    = FindPadRow(position.Y());
+  
+  if (!padRow) return 0;
+
+  AliMpVPadRowSegment* padRowSegment 
+    = padRow->FindPadRowSegment(position.X());
+    
+  if (!padRowSegment) return 0;
+
+  return padRowSegment->GetMotif();
+}  
+
+//______________________________________________________________________________
+Int_t AliMpVRowSegmentSpecial::FindMotifPositionId(const TVector2& position) const
+{
+// Returns the motif position identified for the given
+// geometric position.
+// ---
+
+  AliMpPadRow* padRow 
+    = FindPadRow(position.Y());
+  
+  if (!padRow) return 0;
+
+  AliMpVPadRowSegment* padRowSegment 
+    = padRow->FindPadRowSegment(position.X());
+    
+  if (!padRowSegment) return 0;
+
+  return padRowSegment->GetMotifPositionId();
+}
+
+//______________________________________________________________________________
+Bool_t AliMpVRowSegmentSpecial::HasMotifPosition(Int_t motifPositionId) const
+{
+// Returns true if the motif specified with the given position identifier
+// is in this segment.
+// ---
+
+  if (FindPadRowSegment(motifPositionId))
+    return true;
+  else  
+    return false;      
+}
+
+//______________________________________________________________________________
+TVector2 AliMpVRowSegmentSpecial::MotifCenter(Int_t motifPositionId) const
+{
+// Returns the coordinates of the motif specified with
+// the given position identifier.
+// ---
+
+  // Try to get the motif position from the motif map first
+  AliMpMotifPosition* motifPosition
+    = GetRow()->GetMotifMap()->FindMotifPosition(motifPositionId);
+  if (motifPosition) return motifPosition->Position();
+
+  // Use slow method otherwise
+  return MotifCenterSlow(motifPositionId);
+}
+
+//______________________________________________________________________________
+TVector2 AliMpVRowSegmentSpecial::Dimensions() const
+{
+// Returns the halflengths in x, y of the row segment rectangular envelope.
+// ---
+
+  Double_t x = 0.;                 
+  Double_t y = 0.;  
+  for (Int_t i=0; i<GetNofPadRows(); i++) {    
+    AliMpPadRow* padRow = GetPadRow(i); 
+    
+    // Add all pad rows y halfsizes   
+    y += padRow->HalfSizeY();
+
+    // Find the biggest pad rows x halfsize
+    Double_t xx 
+      = (padRow->GetPadRowSegment(0)->RightBorderX() -
+         padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX())/2.;
+    if (xx > x) x = xx;                   
+  }                  
+    
+  return TVector2(x, y);   
+}
+
+//______________________________________________________________________________
+void AliMpVRowSegmentSpecial::SetGlobalIndices()
+{
+// Sets indices limits.
+// ---
+
+  AliMpMotifPosition* firstPos = 0;
+  AliMpMotifPosition* lastPos = 0;
+       
+  for (Int_t i=0;i<GetNofMotifs();i++) {
+    AliMpMotifPosition* mPos
+      = GetRow()->GetMotifMap()
+        ->FindMotifPosition(GetMotifPositionId(i));
+       
+    if (!firstPos || 
+        mPos->GetLowIndicesLimit().GetFirst()
+       < firstPos->GetLowIndicesLimit().GetFirst())
+       firstPos = mPos;
+       
+    if (!lastPos || 
+        mPos->GetHighIndicesLimit().GetFirst()
+       >lastPos->GetHighIndicesLimit().GetFirst())
+       lastPos = mPos;
+  }
+
+  // Check if the motif positions has the limits set
+  if ( !firstPos->HasValidIndices() || !lastPos->HasValidIndices())
+    Fatal("SetGlobalIndices", "Indices of motif positions have to be set first.");
+
+  SetLowIndicesLimit(firstPos->GetLowIndicesLimit());
+  SetHighIndicesLimit(lastPos->GetHighIndicesLimit());
+}  
+
+//______________________________________________________________________________
+AliMpRow*  AliMpVRowSegmentSpecial::GetRow() const
+{
+// Returns the row.which this row segment belongs to.
+// ---
+
+  return fRow;
+}  
+
+//______________________________________________________________________________
+Int_t  AliMpVRowSegmentSpecial::GetNofMotifs() const 
+{ 
+// Returns the number of different motifs present in this row segment.
+// ---
+
+  return fMotifs.size();
+}  
+
+//______________________________________________________________________________
+AliMpVMotif* AliMpVRowSegmentSpecial::GetMotif(Int_t i) const  
+{
+// Returns the i-th motif present in this row segment.
+// ---
+
+   return fMotifs[i]; 
+}
+
+//______________________________________________________________________________
+Int_t  AliMpVRowSegmentSpecial::GetMotifPositionId(Int_t i) const 
+{ 
+// Returns the i-th motif position Id present in this row segment.
+// ---
+
+   return fMotifPositionIds[i]; 
+} 
+
diff --git a/MUON/mapping/AliMpVRowSegmentSpecial.h b/MUON/mapping/AliMpVRowSegmentSpecial.h
new file mode 100644 (file)
index 0000000..e13d696
--- /dev/null
@@ -0,0 +1,93 @@
+// $Id$
+// Category: sector
+//
+// Class AliMpVRowSegmentSpecial
+// -----------------------------
+// Abstract base class for a special row segment composed of the 
+// pad rows.
+//
+// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+
+#ifndef ALI_MP_V_ROW_SEGMENT_SPECIAL_H
+#define ALI_MP_V_ROW_SEGMENT_SPECIAL_H
+
+#include <TVector2.h>
+
+#include "AliMpSectorTypes.h"
+#include "AliMpVRowSegment.h"
+#include "AliMpVMotif.h"
+
+class AliMpRow;
+class AliMpPadRow;
+class AliMpVPadRowSegment;
+class AliMpIntPair;
+
+class AliMpVRowSegmentSpecial : public AliMpVRowSegment
+{
+  public:
+    AliMpVRowSegmentSpecial(AliMpRow* row, Double_t offsetX);
+    AliMpVRowSegmentSpecial();
+    virtual ~AliMpVRowSegmentSpecial();
+    
+    // methods
+    void  AddPadRow(AliMpPadRow* padRow);
+    void  UpdateMotifVector();
+    virtual void  UpdatePadsOffset() = 0;
+    virtual Double_t  LeftBorderX() const = 0;
+    virtual Double_t  RightBorderX() const= 0;
+    virtual Double_t  HalfSizeY() const;
+
+    // find methods
+    virtual AliMpVMotif*  FindMotif(const TVector2& position) const;    
+    virtual Int_t     FindMotifPositionId(const TVector2& position) const;
+    virtual Bool_t    HasMotifPosition(Int_t motifPositionId) const;
+    virtual TVector2  MotifCenter(Int_t motifPositionId) const;
+
+    // geometry
+    virtual TVector2  Position() const = 0;
+    virtual TVector2  Dimensions() const;
+
+    // set methods
+    virtual void   SetOffset(const TVector2& /*offset*/) {}
+    virtual void   SetGlobalIndices();
+    virtual Int_t  SetIndicesToMotifPosition(Int_t i, 
+                             const AliMpIntPair& indices) = 0;
+
+    // get methods
+    virtual AliMpRow*     GetRow() const;
+    virtual Int_t         GetNofMotifs() const;
+    virtual AliMpVMotif*  GetMotif(Int_t i) const;
+    virtual Int_t         GetMotifPositionId(Int_t i) const;
+
+  protected:
+    // methods
+    virtual TVector2  MotifCenterSlow(Int_t motifPositionId) const = 0;
+    AliMpPadRow*         FindPadRow(Double_t y) const;
+    AliMpVPadRowSegment* FindPadRowSegment(Int_t motifPositionId) const;
+    AliMpIntPair         FindRelativeLowIndicesOf(Int_t motifPositionId) const;
+    Int_t   MaxNofPadsInRow() const;
+    Bool_t  HasMotif(const AliMpVMotif* motif) const;    
+
+    // get methods
+    Int_t         GetNofPadRows() const;
+    AliMpPadRow*  GetPadRow(Int_t i) const;
+    Double_t      GetOffsetX() const;
+
+  private:
+    // data members
+    AliMpRow*     fRow;     //the row containing this segment 
+    Double_t      fOffsetX; //the x position of the border that touches a standard
+                            //row segment
+    PadRowVector  fPadRows; //pad rows vector
+    MotifVector   fMotifs;  //motifs vector
+    MotifPositionIdVector  fMotifPositionIds; //motifs position Ids vector
+    
+  ClassDef(AliMpVRowSegmentSpecial,1)  //Row segment
+};
+
+// inline functions
+
+inline Double_t AliMpVRowSegmentSpecial::GetOffsetX() const
+{ return fOffsetX; }    
+
+#endif //ALI_MP_V_ROW_SEGMENT_SPECIAL_H
diff --git a/MUON/mapping/AliMpXDirection.h b/MUON/mapping/AliMpXDirection.h
new file mode 100644 (file)
index 0000000..32f0810
--- /dev/null
@@ -0,0 +1,19 @@
+// $Id$
+// Category: basic
+//
+// Enum AliMpDirection
+// -------------------
+// Enumeration for the directions in a plane.
+//
+// Authors: David Guez, IPN Orsay
+
+#ifndef ALI_MP_X_DIRECTION_H
+#define ALI_MP_X_DIRECTION_H
+
+enum AliMpXDirection
+{
+  kLeft,  // special row segments built from right to left
+  kRight  // special row segments built from left to right
+};
+
+#endif //ALI_MP_X_DIRECTION_H