]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpSectorPadIterator.cxx
Compilation on Windows/Cygwin. Corrected dependences
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSectorPadIterator.cxx
index 618e4d93eecb67eb414ae7c3aff2d4f6ed504d90..4d3dc4734615b6fc3ae01ba7cc3ab92f8b500bb1 100755 (executable)
 // $Id$
 // $MpId: AliMpSectorPadIterator.cxx,v 1.6 2006/05/24 13:58:46 ivana Exp $
 // Category: sector
-//
+
+//-----------------------------------------------------------------------------
 // Class AliMpSectorPadIterator
 // ----------------------------
 // Class, which defines an iterator over the pads of a sector
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+//-----------------------------------------------------------------------------
+
 
 #include "AliMpSectorPadIterator.h"
 #include "AliMpIntPair.h"
@@ -41,9 +44,7 @@ ClassImp(AliMpSectorPadIterator)
 AliMpSectorPadIterator::AliMpSectorPadIterator()
   : AliMpVPadIterator(),
     fkSector(0),
-    fCurrentRow(0),
-    fCurrentSeg(0),
-    fCurrentMotif(0),
+    fCurrentIndex(0),
     fMotifPos(0),
     fIterator()
 {
@@ -54,9 +55,7 @@ AliMpSectorPadIterator::AliMpSectorPadIterator()
 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* const sector)
   : AliMpVPadIterator(),
     fkSector(sector),
-    fCurrentRow(0),
-    fCurrentSeg(0),
-    fCurrentMotif(0),
+    fCurrentIndex(0),
     fMotifPos(0),
     fIterator()
 {
@@ -65,7 +64,11 @@ AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* const sector)
 
 //______________________________________________________________________________
 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
-  : AliMpVPadIterator(right)
+  : AliMpVPadIterator(right),
+    fkSector(0),
+    fCurrentIndex(0),
+    fMotifPos(0),
+    fIterator()
 {
 /// Copy constructor
  
@@ -95,9 +98,8 @@ AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
   AliMpVPadIterator::operator=(right);
 
   fkSector      = right.fkSector;
-  fCurrentRow   = right.fCurrentRow;
-  fCurrentSeg   = right.fCurrentSeg;
-  fCurrentMotif = right.fCurrentMotif;
+  fCurrentIndex = right.fCurrentIndex,
+  fMotifPos     = right.fMotifPos;
   fIterator     = right.fIterator;
 
   return *this;
@@ -111,33 +113,15 @@ AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
 /// Find the AliMpMotifType object associated with the triplet
 /// (fCurrentRow, fCurrentSeg, fCurrentMotif),
 /// place it in the private fMotifType member and return it.
-  
-  fMotifPos =0;
-  
-  if (fkSector){
-    AliMpRow* row;
-    if ((fCurrentRow >= 0) && (fCurrentRow < fkSector->GetNofRows())){
-      row= fkSector->GetRow(fCurrentRow);
-
-      AliMpVRowSegment* seg;
-      if (fCurrentSeg<row->GetNofRowSegments()){
-        seg = row->GetRowSegment(fCurrentSeg);
-
-        if (fCurrentMotif<seg->GetNofMotifs()){
-          fMotifPos = 
-           fkSector->GetMotifMap()->FindMotifPosition(
-                seg->GetMotifPositionId(fCurrentMotif));
-        }
-      }
-    }
-  }
-  
-  if (fMotifPos) {
-    fIterator = AliMpMotifPositionPadIterator(fMotifPos);
-    fIterator.First();
-  }
-  else
+
+  if ( fCurrentIndex == fkSector->GetMotifMap()->GetNofMotifPositions() ) {
     Invalidate();
+    return 0;
+  }  
+    
+  fMotifPos = fkSector->GetMotifMap()->GetMotifPosition(fCurrentIndex);
+  fIterator = AliMpMotifPositionPadIterator(fMotifPos);
+  fIterator.First();
 
   return fMotifPos;
 }
@@ -164,10 +148,7 @@ void AliMpSectorPadIterator::First()
         Invalidate();
         return;
     }
-    fCurrentRow =0;
-    fCurrentSeg=0;
-    fCurrentMotif=0;
-    
+    fCurrentIndex =0;
     ResetToCurrentMotifPosition();
 
     return;
@@ -178,7 +159,6 @@ void AliMpSectorPadIterator::Next()
 {
 /// Move the iterator to the next valid pad.
 
-  //if (!IsValid()) return *this;
   if (!IsValid()) return;
 
   fIterator.Next();
@@ -186,23 +166,10 @@ void AliMpSectorPadIterator::Next()
   if (!fIterator.IsDone()) return;
   
 
-  // Go to ne next motif, in the current segment
-  ++fCurrentMotif;
-  if (ResetToCurrentMotifPosition()) return;
-
-
-  // if motif number is too big, set it to 0 and pass to the next row segment
-  fCurrentMotif=0;
-  ++fCurrentSeg;
+  // Go to the next motif, in the current segment
+  ++fCurrentIndex;
   if (ResetToCurrentMotifPosition()) return;
 
-
-  // if row segment number is too big, pass to the next row
-  fCurrentSeg=0;
-  ++fCurrentRow;
-  if (ResetToCurrentMotifPosition()) return;
-  
-  // if row number is too big, the invalidate the iterator (==End())
   Invalidate();
   return;
 
@@ -213,7 +180,7 @@ Bool_t AliMpSectorPadIterator::IsDone() const
 {
 /// Is the iterator in the end? 
 
-  return !IsValid();
+  return ! IsValid();
 }
 
 //______________________________________________________________________________
@@ -226,7 +193,6 @@ AliMpPad AliMpSectorPadIterator::CurrentItem () const
       
 
   // no more verification, since IsValid() is TRUE here.
-
   return fIterator.CurrentItem();
 }