]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpRowSegment.cxx
Fixing a backward compatibility issue
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegment.cxx
index 6ec8f24988b3feb3605aa33bf0eafb53f605efb5..09db8d89241281a05ec7ee0c1f22d922c23eab91 100755 (executable)
 // $Id$
 // $MpId: AliMpRowSegment.cxx,v 1.10 2006/05/24 13:58:46 ivana Exp $
 // Category: sector
-//
+
+//-----------------------------------------------------------------------------
 // Class AliMpRowSegment
 // ---------------------
 // Class describing a row segment composed of the 
 // the identic motifs.
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+//-----------------------------------------------------------------------------
 
 #include "AliMpRowSegment.h"
 #include "AliMpRow.h"
@@ -32,6 +34,9 @@
 #include "AliMpMotifMap.h"
 #include "AliMpMotifPosition.h"
 #include "AliMpConstants.h"
+#include "AliMpEncodePair.h"
+
+#include "AliLog.h"
 
 #include <TMath.h>
 #include <Riostream.h>
@@ -42,13 +47,14 @@ ClassImp(AliMpRowSegment)
 
 //_____________________________________________________________________________
 AliMpRowSegment::AliMpRowSegment(AliMpRow* row, AliMpVMotif* motif, 
-                                 AliMpIntPair padOffset, 
+                                 Int_t padOffsetX, Int_t padOffsetY,
                                  Int_t nofMotifs,
                                  Int_t motifPositionId, Int_t motifPositionDId)
   : AliMpVRowSegment(),
     fNofMotifs(nofMotifs),
-    fPadOffset(padOffset),
-    fOffset(TVector2()),
+    fLPadOffset(AliMp::Pair(padOffsetX,padOffsetY)),
+    fOffsetX(0.),
+    fOffsetY(0.),
     fRow(row),
     fMotif(motif),
     fMotifPositionId(motifPositionId),
@@ -57,15 +63,16 @@ AliMpRowSegment::AliMpRowSegment(AliMpRow* row, AliMpVMotif* motif,
 /// Standard constructor
  
   // Keep pad offset in the low indices limits
-  SetLowIndicesLimit(padOffset);
+  SetLowIndicesLimit(fLPadOffset);
 }
 
 //_____________________________________________________________________________
 AliMpRowSegment::AliMpRowSegment() 
   : AliMpVRowSegment(),
     fNofMotifs(0),
-    fPadOffset(AliMpIntPair()),
-    fOffset(TVector2()),
+    fLPadOffset(0),
+    fOffsetX(0.),
+    fOffsetY(0.),
     fRow(0),
     fMotif(0),
     fMotifPositionId(0),
@@ -80,7 +87,7 @@ AliMpRowSegment::~AliMpRowSegment()
 /// Destructor  
 }
 
-//
+//\13
 // private methods  
 //
 
@@ -90,7 +97,7 @@ Double_t AliMpRowSegment::FirstMotifCenterX() const
 /// Return the x coordinate of the first motif center
 /// in the global coordinate system.
 
-  return fOffset.X();
+  return fOffsetX;
 }  
 
 //_____________________________________________________________________________
@@ -99,7 +106,7 @@ Double_t AliMpRowSegment::LastMotifCenterX() const
 /// Return the x coordinate of the last motif center
 /// in the global coordinate system.
 
-  return fOffset.X() + 2.*(fNofMotifs-1)*fMotif->Dimensions().X();
+  return fOffsetX + 2.*(fNofMotifs-1)*fMotif->DimensionX();
 }
 
 //_____________________________________________________________________________
@@ -117,7 +124,7 @@ Double_t AliMpRowSegment::MotifCenterX(Int_t motifPositionId) const
   // Find the position number in the segment  
   Int_t num = (motifPositionId - fMotifPositionId) *  fMotifPositionDId;
 
-  return fOffset.X() + num*(fMotif->Dimensions().X() * 2.0);
+  return fOffsetX + num*(fMotif->DimensionX() * 2.0);
 }
 
 //_____________________________________________________________________________
@@ -132,19 +139,19 @@ Double_t AliMpRowSegment::MotifCenterY(Int_t motifPositionId) const
     return 0;
   }
   
-  return GetRow()->Position().Y() + fOffset.Y();
+  return GetRow()->GetPositionY() + fOffsetY;
 }
 
 //_____________________________________________________________________________
-Bool_t AliMpRowSegment::IsInside(const TVector2& position, Bool_t warn) const
+Bool_t AliMpRowSegment::IsInside(Double_t x, Double_t y, Bool_t warn) const
 {
 /// Check if the position is inside some motif of this row segment.
 
-  Double_t minY = GetRow()->Position().Y() + fOffset.Y() - fMotif->Dimensions().Y();
-  Double_t maxY = GetRow()->Position().Y() + fOffset.Y() + fMotif->Dimensions().Y();
+  Double_t minY = GetRow()->GetPositionY() + fOffsetY - fMotif->DimensionY();
+  Double_t maxY = GetRow()->GetPositionY() + fOffsetY + fMotif->DimensionY();
 
-  if ( position.X() < LeftBorderX() || position.X() > RightBorderX() ||
-       position.Y() < minY || position.Y() > maxY ) {
+  if ( x < LeftBorderX() || x > RightBorderX() ||
+       y < minY || y > maxY ) {
 
     if (warn)
       AliWarningStream() << "Outside row segment region" << endl;
@@ -164,7 +171,7 @@ Double_t  AliMpRowSegment::LeftBorderX() const
 /// Return the x coordinate of the left row segment border
 /// in the global coordinate system.
 
-  return FirstMotifCenterX() - fMotif->Dimensions().X();
+  return FirstMotifCenterX() - fMotif->DimensionX();
 }
 
 //_____________________________________________________________________________
@@ -173,7 +180,7 @@ Double_t  AliMpRowSegment::RightBorderX() const
 /// Return the x coordinate of the right row segment border
 /// in the global coordinate system.
 
-  return LastMotifCenterX() + fMotif->Dimensions().X();
+  return LastMotifCenterX() + fMotif->DimensionX();
 }
 
 //_____________________________________________________________________________
@@ -181,31 +188,31 @@ Double_t  AliMpRowSegment::HalfSizeY() const
 {
 /// Return the size in y of this row segment.
 
-  return fMotif->Dimensions().Y() + fOffset.Y();
+  return fMotif->DimensionY() + fOffsetY;
 }
 
 //_____________________________________________________________________________
-AliMpVMotif*  AliMpRowSegment::FindMotif(const TVector2& position) const
+AliMpVMotif*  AliMpRowSegment::FindMotif(Double_t x, Double_t y) const
 {
 /// Return the motif of this row; 
 
-  if (IsInside(position, false))
+  if ( IsInside(x, y, false) )
     return fMotif;
   else  
     return 0;
 }  
 
 //_____________________________________________________________________________
-Int_t AliMpRowSegment::FindMotifPositionId(const TVector2& position) const
+Int_t AliMpRowSegment::FindMotifPositionId(Double_t x, Double_t y) const
 {
 /// Return the motif position identified for the given
 /// geometric position.
 
-  if (!IsInside(position, false)) return 0;
+  if ( ! IsInside(x, y, false) ) return 0;
 
   // Find the position number in the segment  
   Int_t num 
-    = Int_t((position.X() - LeftBorderX()) / (fMotif->Dimensions().X() * 2.0));
+    = Int_t((x - LeftBorderX()) / (fMotif->DimensionX() * 2.0));
 
   // Calculate the position Id
   return fMotifPositionId + num*fMotifPositionDId;  
@@ -230,61 +237,72 @@ Bool_t AliMpRowSegment::HasMotifPosition(Int_t motifPositionId) const
 }
 
 //_____________________________________________________________________________
-TVector2 AliMpRowSegment::MotifCenter(Int_t motifPositionId) const
+void AliMpRowSegment::MotifCenter(Int_t motifPositionId,
+                                  Double_t& x, Double_t& y) const
 {
 /// Return the coordinates of the motif specified with
 /// the given position identifier.
 
-  return TVector2(MotifCenterX(motifPositionId), MotifCenterY(motifPositionId));
+  x = MotifCenterX(motifPositionId);
+  y = MotifCenterY(motifPositionId);
 }
 
 //_____________________________________________________________________________
-TVector2 AliMpRowSegment::Position() const
+Double_t AliMpRowSegment::GetPositionX() const
 {
-/// Return the position of the row segment centre.
+/// Return the position of the row segment centre.
 
-  Double_t x = (LeftBorderX() + RightBorderX())/2.;                
-  Double_t y = GetRow()->Position().Y();  
-    
-  return TVector2(x, y);   
+  return (LeftBorderX() + RightBorderX())/2.;              
 }
 
+//_____________________________________________________________________________
+Double_t AliMpRowSegment::GetPositionY() const
+{
+/// Return the y position of the row segment centre.
+
+  return GetRow()->GetPositionY();  
+}
 
 //_____________________________________________________________________________
-TVector2 AliMpRowSegment::Dimensions() const
+Double_t AliMpRowSegment::GetDimensionX() const
 {
 /// Return the halflengths of the row segment in x, y.
 // ---
 
-  Double_t x = (RightBorderX() - LeftBorderX())/2.;                
-  Double_t y = GetRow()->Dimensions().Y();  
-    
-  return TVector2(x, y);   
+  return (RightBorderX() - LeftBorderX())/2.;              
 }
 
 //_____________________________________________________________________________
-void   AliMpRowSegment::SetOffset(const TVector2& offset)
+Double_t AliMpRowSegment::GetDimensionY() const
+{
+/// Return the halflengths of the row segment in x, y.
+// ---
+
+  return GetRow()->GetDimensionY();  
+}
+
+//_____________________________________________________________________________
+void   AliMpRowSegment::SetOffset(Double_t x, Double_t y)
 {
 /// Calculate offset from given offset and 
 /// stored offset in pads.
 
   AliMpMotifTypePadIterator iter(fMotif->GetMotifType());
   iter.First();
-  AliMpIntPair localPos = iter.CurrentItem().GetIndices();
-     
-  Double_t offsetX 
-     = offset.X() 
-       + 2.*fPadOffset.GetFirst() * fMotif->GetPadDimensions(localPos).X() 
-       + fMotif->Dimensions().X(); 
 
-  Double_t offsetY 
-    = offset.Y()
-      + fPadOffset.GetSecond() * fMotif->GetPadDimensions(localPos).Y(); 
+  Int_t ix = iter.CurrentItem().GetIx();
+  Int_t iy = iter.CurrentItem().GetIy();
+  
+  Double_t dx, dy;
+  fMotif->GetPadDimensionsByIndices(ix, iy, dx, dy);  
+
+  fOffsetX 
+     = x + 2.*AliMp::PairFirst(fLPadOffset) * dx + fMotif->DimensionX(); 
 
-  fOffset = TVector2(offsetX, offsetY);
+  fOffsetY
+    = y + AliMp::PairSecond(fLPadOffset) * dy; 
 }
 
-#include <Riostream.h>
 //_____________________________________________________________________________
 void AliMpRowSegment::SetGlobalIndices(AliMpRow* /*rowBefore*/)
 {
@@ -307,26 +325,25 @@ void AliMpRowSegment::SetGlobalIndices(AliMpRow* /*rowBefore*/)
        Fatal("SetGlobalIndices", 
              "Indices of motif positions have to be set first.");
             
-     if ( mPos->GetLowIndicesLimit().GetFirst() < ixl ) 
-       ixl = mPos->GetLowIndicesLimit().GetFirst();
+     if ( mPos->GetLowLimitIx() < ixl ) 
+       ixl = mPos->GetLowLimitIx();
        
-     if ( mPos->GetLowIndicesLimit().GetSecond() < iyl ) 
-       iyl = mPos->GetLowIndicesLimit().GetSecond();
+     if ( mPos->GetLowLimitIy() < iyl ) 
+       iyl = mPos->GetLowLimitIy();
 
-     if ( mPos->GetHighIndicesLimit().GetFirst() > ixh ) 
-       ixh = mPos->GetHighIndicesLimit().GetFirst();
+     if ( mPos->GetHighLimitIx() > ixh ) 
+       ixh = mPos->GetHighLimitIx();
        
-     if ( mPos->GetHighIndicesLimit().GetSecond() > iyh ) 
-       iyh = mPos->GetHighIndicesLimit().GetSecond();
+     if ( mPos->GetHighLimitIy() > iyh ) 
+       iyh = mPos->GetHighLimitIy();
   }     
 
-  SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
-  SetHighIndicesLimit(AliMpIntPair(ixh, iyh));
+  SetLowIndicesLimit(ixl, iyl);
+  SetHighIndicesLimit(ixh, iyh);
 }  
 
 //_____________________________________________________________________________
-Int_t AliMpRowSegment::SetIndicesToMotifPosition(Int_t i, 
-                                 const AliMpIntPair& indices)
+Int_t AliMpRowSegment::SetIndicesToMotifPosition(Int_t i, MpPair_t indices)
 {
 /// Set global indices to i-th motif position and returns next index
 /// in x.
@@ -336,18 +353,18 @@ Int_t AliMpRowSegment::SetIndicesToMotifPosition(Int_t i,
     = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
 
   // Low limit
-  AliMpIntPair low = indices + AliMpIntPair(0, GetLowIndicesLimit().GetSecond());
+  MpPair_t low = indices + AliMp::Pair(0, GetLowLimitIy());
   motifPosition->SetLowIndicesLimit(low);
          
   // High limit
   AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();    
-  AliMpIntPair high
-    = motifPosition->GetLowIndicesLimit() 
-      + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
+  MpPair_t high
+    = motifPosition->GetLowIndicesLimit()
+      + AliMp::Pair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
   motifPosition->SetHighIndicesLimit(high);
 
   // Return next index in x
-  return high.GetFirst()+1;
+  return AliMp::PairFirst(high)+1;
   // return motifType->GetNofPadsX();
 }