]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpRow.cxx
updates in Kaon Train
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRow.cxx
index 80ff5d6800becae87e5f0bc9c96cdacfc71256ad..f010c5a5bd20fd1bb5a59de3ed88edb4d8659635 100755 (executable)
@@ -1,15 +1,29 @@
+/**************************************************************************
+ * 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: AliMpRow.cxx,v 1.9 2006/05/24 13:58:46 ivana Exp $
 // Category: sector
-//
+
+//-----------------------------------------------------------------------------
 // Class AliMpRow
 // --------------
 // Class describing a row composed of the row segments.
-//
+// Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
-
-#include <Riostream.h>
-#include <TError.h>
-#include <TMath.h>
+//-----------------------------------------------------------------------------
 
 #include "AliMpRow.h"
 #include "AliMpVRowSegment.h"
 #include "AliMpMotifMap.h"
 #include "AliMpConstants.h"
 
+#include "AliLog.h"
+
+#include <TMath.h>
+#include <Riostream.h>
+
+using std::endl;
+/// \cond CLASSIMP
 ClassImp(AliMpRow)
+/// \endcond
 
 //_____________________________________________________________________________
 AliMpRow::AliMpRow(Int_t id, AliMpMotifMap* motifMap) 
@@ -31,7 +53,7 @@ AliMpRow::AliMpRow(Int_t id, AliMpMotifMap* motifMap)
     fSegments(),
     fMotifMap(motifMap)
 {
-//
+/// Standard constructor
 }
 
 //_____________________________________________________________________________
@@ -42,45 +64,17 @@ AliMpRow::AliMpRow()
     fSegments(),
     fMotifMap(0)
 {
-//
+/// Default constructor
 }
 
 //_____________________________________________________________________________
-AliMpRow::AliMpRow(const AliMpRow& right) 
-  : AliMpVIndexed(right) {
-// 
-  Fatal("AliMpRow", "Copy constructor not provided.");
-}
-
-//_____________________________________________________________________________
-AliMpRow::~AliMpRow() {
-// 
-
-#ifdef WITH_STL
-  for (Int_t i=0; i<GetNofRowSegments(); i++)
-    delete fSegments[i]; 
-#endif
+AliMpRow::~AliMpRow() 
+{
+/// Destructor 
 
-#ifdef WITH_ROOT
   fSegments.Delete();
-#endif
 }
 
-//
-// operators
-//
-
-//_____________________________________________________________________________
-AliMpRow&  AliMpRow::operator=(const AliMpRow& right)
-{
-  // check assignement to self
-  if (this == &right) return *this;
-
-  Fatal("operator =", "Assignement operator not provided.");
-    
-  return *this;  
-}    
-
 //
 // private methods
 //
@@ -88,14 +82,13 @@ AliMpRow&  AliMpRow::operator=(const AliMpRow& right)
 //_____________________________________________________________________________
 AliMpVRowSegment*  AliMpRow::FindRowSegment(Int_t ix) const
 {    
-// Finds first normal row segment with low indices limit >= ix.
-// --- 
+/// Find first normal row segment with low indices limit >= ix.
 
   for (Int_t i=0; i<GetNofRowSegments(); i++) {
     AliMpVRowSegment* segment = GetRowSegment(i);
 
     if (!dynamic_cast<AliMpVRowSegmentSpecial*>(segment) &&
-         segment->GetHighIndicesLimit().GetFirst() >= ix)
+         segment->GetHighLimitIx() >= ix)
         
      return segment;    
   }   
@@ -107,9 +100,8 @@ AliMpVRowSegment*  AliMpRow::FindRowSegment(Int_t ix) const
 AliMpMotifPosition*  
 AliMpRow::FindMotifPosition(AliMpVRowSegment* segment, Int_t ix) const
 {
-// Finds first motif position in the specified row segment 
-// with high indices limit >= ix.
-// --- 
+/// Find first motif position in the specified row segment 
+/// with high indices limit >= ix.
 
   if (!segment) return 0;
 
@@ -122,7 +114,7 @@ AliMpRow::FindMotifPosition(AliMpVRowSegment* segment, Int_t ix) const
        return 0;
      }  
      
-     if (motifPosition->GetHighIndicesLimit().GetFirst()>=ix) 
+     if (motifPosition->GetHighLimitIx()>=ix) 
        return motifPosition;
   }
   
@@ -133,16 +125,14 @@ AliMpRow::FindMotifPosition(AliMpVRowSegment* segment, Int_t ix) const
 //_____________________________________________________________________________
 void AliMpRow::SetHighIndicesLimits(Int_t iy)
 {
-// Sets the global indices high limit to its row segments,
-// motif positions with a given value.
-// Keeps ix unmodified.
-// --- 
+/// Set the global indices high limit to its row segments,
+/// motif positions with a given value.
+/// Keep ix unmodified.
 
   for (Int_t j=0; j<GetNofRowSegments(); j++) {
      AliMpVRowSegment* rowSegment = GetRowSegment(j);       
      rowSegment
-       ->SetHighIndicesLimit(
-           AliMpIntPair(rowSegment->GetHighIndicesLimit().GetFirst(),iy));
+       ->SetHighIndicesLimit(rowSegment->GetHighLimitIx(),iy);
 
     for (Int_t k=0; k<rowSegment->GetNofMotifs(); k++) {
 
@@ -151,8 +141,7 @@ void AliMpRow::SetHighIndicesLimits(Int_t iy)
        = GetMotifMap()->FindMotifPosition(motifPositionId);
 
       motifPosition
-       ->SetHighIndicesLimit(
-            AliMpIntPair(motifPosition->GetHighIndicesLimit().GetFirst(), iy));
+       ->SetHighIndicesLimit(motifPosition->GetHighLimitIx(), iy);
      
     }
   }  
@@ -161,8 +150,7 @@ void AliMpRow::SetHighIndicesLimits(Int_t iy)
 //_____________________________________________________________________________
 void  AliMpRow::CheckEmpty() const
 {
-// Give a fatal if row is empty.
-// ---
+/// Give a fatal if the row is empty.
 
   if (GetNofRowSegments() == 0) 
     Fatal("CheckEmpty", "Empty row");
@@ -175,48 +163,28 @@ void  AliMpRow::CheckEmpty() const
 //_____________________________________________________________________________
 void AliMpRow::AddRowSegment(AliMpVRowSegment* rowSegment)
 {
-// Adds row segment at the end.
-// ---
-
-#ifdef WITH_STL
-  fSegments.push_back(rowSegment);
-#endif
+/// Add row segment at the end.
 
-#ifdef WITH_ROOT
   fSegments.Add(rowSegment);
-#endif
 }  
   
 //_____________________________________________________________________________
 void AliMpRow::AddRowSegmentInFront(AliMpVRowSegment* rowSegment)
 {
-// Inserts row segment in the first vector position.
-// ---
+/// Insert row segment in the first vector position.
 
-#ifdef WITH_STL
-  fSegments.insert(fSegments.begin(), rowSegment);
-#endif
-
-#ifdef WITH_ROOT
   fSegments.AddFirst(rowSegment);
-#endif
 }  
   
 //_____________________________________________________________________________
 AliMpVRowSegment* AliMpRow::FindRowSegment(Double_t x) const
 {
-// Finds the row segment for the specified x position;
-// returns 0 if no row segment is found.
-// ---
+/// Find the row segment for the specified x position;
+/// return 0 if no row segment is found.
 
   for (Int_t i=0; i<GetNofRowSegments(); i++) {
 
-#ifdef WITH_STL
-    AliMpVRowSegment* rs = fSegments[i];
-#endif
-#ifdef WITH_ROOT
     AliMpVRowSegment* rs = (AliMpVRowSegment*)fSegments.At(i);
-#endif
 
     if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
       return rs;
@@ -228,9 +196,8 @@ AliMpVRowSegment* AliMpRow::FindRowSegment(Double_t x) const
 //_____________________________________________________________________________
 Double_t AliMpRow::LowBorderY() const
 {
-// Returns the lowest row offset (the Y coordinate of the position of the
-// low border of motif).
-// ---
+/// Return the lowest row offset (the Y coordinate of the position of the
+/// low border of motif).
 
   CheckEmpty();
 
@@ -240,10 +207,9 @@ Double_t AliMpRow::LowBorderY() const
 //_____________________________________________________________________________
 Double_t AliMpRow::UpperBorderY() const
 {
-// Returns the uppermost row offset (the Y coordinate of the position of the
-// upper border of motif).
-// ---
-
+/// Return the uppermost row offset (the Y coordinate of the position of the
+/// upper border of motif).
+\
   CheckEmpty();
 
   return fOffsetY + GetRowSegment(0)->HalfSizeY();
@@ -252,10 +218,9 @@ Double_t AliMpRow::UpperBorderY() const
 //_____________________________________________________________________________
 AliMpVPadIterator* AliMpRow::CreateIterator() const
 {
-// Iterator is not yet implemented.
-// ---
+/// Iterator is not implemented.
 
-  Fatal("CreateIterator", "Iterator is not yet implemented.");
+  Fatal("CreateIterator", "Iterator is not implemented.");
   
   return 0;
 }  
@@ -263,8 +228,7 @@ AliMpVPadIterator* AliMpRow::CreateIterator() const
 //_____________________________________________________________________________
 void AliMpRow::SetMotifPositions()
 {
-// Creates motif positions objects and fills them in the motif map.
-// ---
+/// Create motif positions objects and fills them in the motif map.
 
   CheckEmpty();
 
@@ -275,14 +239,17 @@ void AliMpRow::SetMotifPositions()
         // Get values 
        Int_t motifPositionId = rowSegment->GetMotifPositionId(k);
        AliMpVMotif* motif = rowSegment->GetMotif(k);
-       TVector2 position = rowSegment->MotifCenter(motifPositionId);
+        
+        Double_t posx, posy;
+       rowSegment->MotifCenter(motifPositionId, posx, posy);
        
         AliMpMotifPosition* motifPosition 
-         = new AliMpMotifPosition(motifPositionId, motif, position);
+         = new AliMpMotifPosition(motifPositionId, motif, posx, posy);
+
         // set the initial value to of HighIndicesLimit() Invalid()
         // (this is used for calculation of indices in case of
         // special row segments)
-        motifPosition->SetHighIndicesLimit(AliMpIntPair::Invalid());
+        motifPosition->SetHighIndicesLimit(0, 0, false);
 
         //Bool_t warn = (rowSegment->GetNofMotifs()==1); 
         Bool_t warn = true;
@@ -298,12 +265,11 @@ void AliMpRow::SetMotifPositions()
 }    
 
 //_____________________________________________________________________________
-void AliMpRow::SetGlobalIndices(AliMpDirection constPadSizeDirection, 
+void AliMpRow::SetGlobalIndices(AliMp::Direction constPadSizeDirection, 
                                 AliMpRow* rowBefore)
 {
-// Sets the global indices limits to its row segments,
-// motif positions.
-// ---
+/// Set the global indices limits to its row segments, motif positions
+/// and itself.
 
   Int_t ix = AliMpConstants::StartPadIndex();
   Int_t iy = AliMpConstants::StartPadIndex();
@@ -311,72 +277,101 @@ void AliMpRow::SetGlobalIndices(AliMpDirection constPadSizeDirection,
   for (Int_t j=0; j<GetNofRowSegments(); j++) {
      AliMpVRowSegment* rowSegment = GetRowSegment(j);
      
-     ix += rowSegment->GetLowIndicesLimit().GetFirst();
+     ix += rowSegment->GetLowLimitIx();
 
      for (Int_t k=0; k<rowSegment->GetNofMotifs(); k++) {
      
        // Find the y index value of the low edge
        if (rowBefore) {
-         if (constPadSizeDirection == kY) {
-           iy = rowBefore->GetHighIndicesLimit().GetSecond()+1;
+         if (constPadSizeDirection == AliMp::kY) {
+           iy = rowBefore->GetHighLimitIy()+1;
          } 
         else {
            AliMpVRowSegment* seg = rowBefore->FindRowSegment(ix);      
           AliMpMotifPosition* motPos =  FindMotifPosition(seg, ix);
           if (!dynamic_cast<AliMpRowSegmentRSpecial*>(rowSegment)) {
-             if (!motPos) 
+             if (!motPos) {
               Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
+               return;
+             }  
           
-             iy = motPos->GetHighIndicesLimit().GetSecond()+1;
+             iy = motPos->GetHighLimitIy()+1;
           }  
          }
        } 
 
        // Set (ix, iy) to k-th motif position and update ix
-       ix = rowSegment->SetIndicesToMotifPosition(k, AliMpIntPair(ix, iy));               
+       ix = rowSegment->SetIndicesToMotifPosition(k, AliMp::Pair(ix, iy));
     }
-    rowSegment->SetGlobalIndices();    
+    rowSegment->SetGlobalIndices(rowBefore);    
   }
 
-  SetLowIndicesLimit(GetRowSegment(0)->GetLowIndicesLimit());
-  SetHighIndicesLimit(GetRowSegment(GetNofRowSegments()-1)->GetHighIndicesLimit());
+  // The low/high indices limits has to be taken as the highest/lowest from all 
+  // row segments
+  Int_t ixl = 9999;
+  Int_t iyl = 9999;
+  Int_t ixh = AliMpConstants::StartPadIndex();
+  Int_t iyh = AliMpConstants::StartPadIndex();
 
-  return ;
+  for (Int_t i=0; i<GetNofRowSegments(); i++) {
+    
+    AliMpVRowSegment* rowSegment = GetRowSegment(i);
+    
+    if ( rowSegment->GetLowLimitIx() < ixl ) 
+       ixl = rowSegment->GetLowLimitIx();
+       
+    if ( rowSegment->GetLowLimitIy() < iyl ) 
+       iyl = rowSegment->GetLowLimitIy();
+
+    if ( rowSegment->GetHighLimitIx() > ixh ) 
+       ixh = rowSegment->GetHighLimitIx();
+       
+    if ( rowSegment->GetHighLimitIy() > iyh ) 
+       iyh = rowSegment->GetHighLimitIy();
+  }     
+
+  SetLowIndicesLimit(ixl, iyl);
+  SetHighIndicesLimit(ixh, iyh);
 }
 
 //_____________________________________________________________________________
-TVector2  AliMpRow::Position() const
+Double_t  AliMpRow::GetPositionX() const
 {
-// Returns the position of the row centre.
-// ---
+/// Return the position of the row centre.
 
-  Double_t x = (GetRowSegment(0)->LeftBorderX() +
-                GetRowSegment(GetNofRowSegments()-1)->RightBorderX())/2.;
-                   
-  Double_t y = fOffsetY;  
-    
-  return TVector2(x, y);   
+  return ( GetRowSegment(0)->LeftBorderX() +
+           GetRowSegment(GetNofRowSegments()-1)->RightBorderX() )/2.;
 }
 
 //_____________________________________________________________________________
-TVector2  AliMpRow::Dimensions() const
+Double_t  AliMpRow::GetPositionY() const
 {
-// Returns the maximum halflengths of the row in x, y.
-// ---
+/// Return the position of the row centre.
 
-  Double_t x = (GetRowSegment(GetNofRowSegments()-1)->RightBorderX() -
-                GetRowSegment(0)->LeftBorderX())/2.;
-                  
-  Double_t y = GetRowSegment(0)->HalfSizeY();  
-    
-  return TVector2(x, y);   
+  return fOffsetY;  
 }
 
 //_____________________________________________________________________________
-void AliMpRow::SetRowSegmentOffsets(const TVector2& offset)
+Double_t  AliMpRow::GetDimensionX() const
 {
-// Sets the row segments offsets in X .
-// ---
+/// Return the maximum halflengths of the row in x, y.
+
+  return ( GetRowSegment(GetNofRowSegments()-1)->RightBorderX() -
+           GetRowSegment(0)->LeftBorderX() )/2.;
+}
+
+//_____________________________________________________________________________
+Double_t  AliMpRow::GetDimensionY() const
+{
+/// Return the maximum halflengths of the row in x, y.
+
+  return GetRowSegment(0)->HalfSizeY();  
+}
+
+//_____________________________________________________________________________
+void AliMpRow::SetRowSegmentOffsets(Double_t offsetx)
+{
+/// Set the row segments offsets in X .
 
   CheckEmpty();
   
@@ -389,9 +384,9 @@ void AliMpRow::SetRowSegmentOffsets(const TVector2& offset)
      if (previous) 
       offsetX = previous->RightBorderX();
     else
-      offsetX = offset.X();  
+      offsetX = offsetx;  
   
-    rowSegment->SetOffset(TVector2(offsetX, 0.));
+    rowSegment->SetOffset(offsetX, 0.);
     previous = rowSegment;  
   }
 }
@@ -400,9 +395,8 @@ void AliMpRow::SetRowSegmentOffsets(const TVector2& offset)
 //_____________________________________________________________________________
 Double_t AliMpRow::SetOffsetY(Double_t offsetY)
 {
-// Sets the row offset (the Y coordinate of the position of the
-// center of motif) and returns the offset of the top border.
-// ---
+/// Set the row offset (the Y coordinate of the position of the
+/// center of motif) and returns the offset of the top border.
 
   CheckEmpty();
 
@@ -415,8 +409,6 @@ Double_t AliMpRow::SetOffsetY(Double_t offsetY)
      Double_t sizeY = GetRowSegment(i)->HalfSizeY();
      
      if (TMath::Abs(sizeY - rowSizeY) >= AliMpConstants::LengthTolerance()) {
-       //cout << GetID() << "th row " << i << "th segment " 
-       //     << sizeY << "  " << rowSizeY  << endl;
        Fatal("SetOffsetY", "Motif with different Y size in one row");
        return 0.;
      }  
@@ -432,35 +424,21 @@ Double_t AliMpRow::SetOffsetY(Double_t offsetY)
 //_____________________________________________________________________________
 Int_t AliMpRow::GetNofRowSegments() const 
 {
-// Returns number of row segments.
-// ---
-
-#ifdef WITH_STL
-  return fSegments.size();
-#endif
+/// Return number of row segments.
 
-#ifdef WITH_ROOT
   return fSegments.GetSize();
-#endif
 }  
 
 //_____________________________________________________________________________
 AliMpVRowSegment* AliMpRow::GetRowSegment(Int_t i) const 
 {
-// Returns i-th row segment.
-// ---
+/// Return i-th row segment.
 
   if (i<0 || i>=GetNofRowSegments()) {
-    Warning("GetRowSegment", "Index outside range");
+    AliWarningStream() << "Index outside range" << endl;
     return 0;
   }
   
-#ifdef WITH_STL
-  return fSegments[i];  
-#endif
-
-#ifdef WITH_ROOT
   return (AliMpVRowSegment*)fSegments.At(i);  
-#endif
 }