]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpRowSegmentLSpecial.cxx
Previous commit had the bad side-effect of changing the behaviour of Raw QA to comput...
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegmentLSpecial.cxx
index 30e5b661987eea470b4906a93f4abdce8788640c..84e2f99fe493089299ad3aa49f2d42682bf1b222 100755 (executable)
@@ -1,14 +1,33 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
 // $Id$
+// $MpId: AliMpRowSegmentLSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
 // Category: sector
-//
+
+//-----------------------------------------------------------------------------
 // Class AliMpRowSegmentLSpecial
 // -----------------------------
 // Class describing a special inner row segment composed of the 
 // pad rows.
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+//-----------------------------------------------------------------------------
 
-#include <TError.h>
+#include <Riostream.h>
+#include <TMath.h>
 
 #include "AliMpRowSegmentLSpecial.h"
 #include "AliMpRow.h"
 #include "AliMpMotifMap.h"
 #include "AliMpMotifPosition.h"
 #include "AliMpConstants.h"
+#include "AliMpEncodePair.h"
 
+#include "AliLog.h"
+
+/// \cond CLASSIMP
 ClassImp(AliMpRowSegmentLSpecial)
+/// \endcond
 
 //______________________________________________________________________________
 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
   : AliMpVRowSegmentSpecial(row, offsetX)
 {
-// 
+/// Standard constructor
 }
 
 //______________________________________________________________________________
 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial() 
   : AliMpVRowSegmentSpecial()
 {
-//
+/// Default constructor
 }
 
 //______________________________________________________________________________
 AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial() 
 {
-//  
+/// Destructor  
 }
 
 //
@@ -50,8 +74,7 @@ AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial()
 AliMpVPadRowSegment*  
 AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
 {
-// Find the most right pad row segment with this motifPositionId.
-// ---
+/// Find the most right pad row segment with this motifPositionId.
 
   AliMpVPadRowSegment* found = 0;
 
@@ -76,13 +99,13 @@ AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
 //
 
 //______________________________________________________________________________
-TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
+void AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId,
+                                              Double_t& x, Double_t& y) 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.
-// ---
+/// Fill the coordinates of the motif specified with
+/// the given position identifier.                                           \n
+/// !! 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 
@@ -92,28 +115,26 @@ TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
   
   // Check if the motifPositionId is present 
   if (!downPadRowSegment || !rightPadRowSegment) {
-    Error("MotifCenter", "Outside row segment region");
-    return 0;
+    AliErrorStream() << "Outside row segment region" << endl;
+    return;
   }
 
   // Check if both pad row segments have the same motif 
   if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
-    Fatal("MotifCenter", "Outside row segment region");
-    return 0;
+    AliFatal("Outside row segment region");
+    return;
   }
 
   // Get position of found row segment
-  Double_t x = rightPadRowSegment->RightBorderX();       
-  Double_t y = GetRow()->LowBorderY()  ;   
+  x = rightPadRowSegment->RightBorderX();       
+  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);
+  x -= downPadRowSegment->GetMotif()->DimensionX();
+  y += downPadRowSegment->GetMotif()->DimensionY();
 }
 
 //
@@ -123,9 +144,8 @@ TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
 //______________________________________________________________________________
 void AliMpRowSegmentLSpecial::UpdatePadsOffset()
 {
-// Sets low indices limit to the pad offset calculated
-// from the neighbour normal segment.
-// ---
+/// Set low indices limit to the pad offset calculated
+/// from the neighbour normal segment.
 
   // Get the neighbour row segment
   // (the first normal segment)
@@ -133,26 +153,24 @@ void AliMpRowSegmentLSpecial::UpdatePadsOffset()
 
   // Get the the pads offset of the neighbour row segment
   // (the first normal segment)
-  AliMpIntPair offset = neighbour->GetLowIndicesLimit();
+  MpPair_t offset = neighbour->GetLowIndicesLimit();
   
   // Find max nof pads in a row
   Int_t maxNofPads = MaxNofPadsInRow();
 
   // Set limits
-  SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
+  SetLowIndicesLimit(offset - AliMp::Pair(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()));
+  neighbour->SetLowIndicesLimit(0, neighbour->GetLowLimitIy());
 }
 
 //______________________________________________________________________________
 Double_t  AliMpRowSegmentLSpecial::LeftBorderX() const
 {
-// Returns the x coordinate of the left row segment border
-// in global coordinate system.
-// ---
+/// Return the x coordinate of the left row segment border
+/// in the global coordinate system.
 
   Double_t leftBorder = DBL_MAX;
   for (Int_t i=0; i<GetNofPadRows(); i++) {
@@ -169,9 +187,8 @@ Double_t  AliMpRowSegmentLSpecial::LeftBorderX() const
 //______________________________________________________________________________
 Double_t  AliMpRowSegmentLSpecial::RightBorderX() const
 {
-// Returns the x coordinate of the right row segment border
-// in global coordinate system.
-// ---
+/// Returns the x coordinate of the right row segment border
+/// in the global coordinate system.
 
   Double_t sameBorder = GetOffsetX();
 
@@ -184,7 +201,7 @@ Double_t  AliMpRowSegmentLSpecial::RightBorderX() const
   }  
 
   if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04)  {
-    Error("RightBorderX", "WrongBorder");
+    AliErrorStream() << "WrongBorder" << endl;
     return sameBorder;
   }  
   
@@ -192,66 +209,110 @@ Double_t  AliMpRowSegmentLSpecial::RightBorderX() const
 }
 
 //______________________________________________________________________________
-TVector2 AliMpRowSegmentLSpecial::Position() const
+Double_t AliMpRowSegmentLSpecial::GetPositionX() const
 {
-// Returns the position of the row segment centre.
-// The centre is defined as the centre of the rectangular
-// row segment envelope.
-// ---
+/// Return the x 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);   
+  return GetOffsetX() - GetDimensionX();                   
 }
 
 //______________________________________________________________________________
-Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i, 
-                                         const AliMpIntPair& indices)
+Double_t AliMpRowSegmentLSpecial::GetPositionY() const
 {
-// Sets global indices to i-th motif position and returns next index in x.
-// ---
+/// Return the y position of the row segment centre.
+/// The centre is defined as the centre of the rectangular
+/// row segment envelope.
+
+  return GetRow()->GetPositionY();  
+}
+
+#include <Riostream.h>
+//______________________________________________________________________________
+Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i, MpPair_t indices)
+{
+/// Set 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())
+  MpPair_t low 
+    = AliMp::Pair(GetLowLimitIx() + AliMpConstants::StartPadIndex(), 
+                 AliMp::PairSecond(indices))
       + FindRelativeLowIndicesOf(GetMotifPositionId(i));
             
-  if (! motifPosition->GetHighIndicesLimit().IsValid()) {   
+  if (! motifPosition->IsHighLimitValid()) {   
      motifPosition->SetLowIndicesLimit(low);
   } 
   else {
-    if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
+    if ( motifPosition->GetLowLimitIx() > AliMp::PairFirst(low) )
       motifPosition->SetLowIndicesLimit(
-                        AliMpIntPair(low.GetFirst(),
-                                 motifPosition->GetLowIndicesLimit().GetSecond()));
+                                 AliMp::PairFirst(low),
+                                 motifPosition->GetLowLimitIy());
 
-    if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
+    if ( motifPosition->GetLowLimitIy() > AliMp::PairSecond(low) )
        motifPosition->SetLowIndicesLimit(
-                         AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
-                                  low.GetSecond()));
+                                 motifPosition->GetLowLimitIx(),
+                                 AliMp::PairSecond(low) );
   }
              
   // High limit             
   AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();  
-  AliMpIntPair high 
+  MpPair_t high 
     = motifPosition->GetLowIndicesLimit()
-      + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);            
+      + AliMp::Pair(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();
+  if ( i != GetNofMotifs()-1 
+    return AliMp::PairFirst(indices);
     //return 0;
   else
-    return indices.GetFirst() + MaxNofPadsInRow();  
+    return AliMp::PairFirst(indices) + MaxNofPadsInRow();  
     //return MaxNofPadsInRow();  
 }
+//______________________________________________________________________________
+void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
+{
+/// Set indices limits
+/// The limits are defined as the limits of the smallest rectangle which
+/// includes all pads of this special row segment.
+
+  // Low ix
+  Int_t ixl = GetLowLimitIx() + AliMpConstants::StartPadIndex();
+      // the pads offset was already defined by Reader
+
+  // High ix
+  Int_t ixh = ixl + MaxNofPadsInRow() - 1;
+
+  // Low iy
+  Int_t iyl = AliMpConstants::StartPadIndex();
+  if (rowBefore) {
+    //if (constPadSizeDirection == kY) {
+      iyl = rowBefore->GetHighLimitIy()+1;
+    //} 
+    /*
+    else {
+      AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);  
+      AliMpMotifPosition* motPos =  rowBefore->FindMotifPosition(seg, ixl);
+      if (!motPos) 
+        Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
+      iyl = motPos->GetHighLimitIy()+1;
+    }
+    */
+  }  
+
+  // High iy
+  Int_t iyh = iyl + GetNofPadRows() - 1;
+  
+  SetLowIndicesLimit(ixl, iyl);
+  SetHighIndicesLimit(ixh, iyh);
+}  
+