]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpNeighboursPadIterator.cxx
- Reordering includes and/or
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpNeighboursPadIterator.cxx
index 2dc978a5b6a494219173fc3ec8d48af4a55abbf9..9547b6456c8ac7a5e7a7c33d17ac83c65e6a5982 100755 (executable)
@@ -1,4 +1,20 @@
+/**************************************************************************
+ * 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: AliMpNeighboursPadIterator.cxx,v 1.11 2006/03/02 16:37:30 ivana Exp $
 // Category: sector
 //
 // Class AliMpNeighboursPadIterator
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
 
-#include <TVector2.h>
-
 #include "AliMpNeighboursPadIterator.h"
 #include "AliMpIntPair.h"
 #include "AliMpSectorSegmentation.h"
 #include "AliMpRow.h"
 #include "AliMpConstants.h"
 
-ClassImp(AliMpNeighboursPadIterator)
+#include <TVector2.h>
 
 const UInt_t AliMpNeighboursPadIterator::fgkInvalidIndex = 9999; 
                                                    //never so much neighbours...
 
+ClassImp(AliMpNeighboursPadIterator)
+
 //______________________________________________________________________________
 AliMpNeighboursPadIterator::AliMpNeighboursPadIterator()
   : AliMpVPadIterator(),
@@ -28,7 +44,7 @@ AliMpNeighboursPadIterator::AliMpNeighboursPadIterator()
     fPads(),
     fIndex(fgkInvalidIndex)
 {
-// default constructor, set the current position to "invalid"
+/// Default constructor, set the current position to "invalid"
 }
 
 //______________________________________________________________________________
@@ -41,7 +57,7 @@ AliMpNeighboursPadIterator::AliMpNeighboursPadIterator(
     fCenterPad(centerPad),
     fIndex(fgkInvalidIndex)
 {
-// normal constructor, set *this to invalid position
+/// Standard constructor, set *this to invalid position
 
     FillPadsVector(includeCenter);
 }
@@ -51,7 +67,7 @@ AliMpNeighboursPadIterator::AliMpNeighboursPadIterator(
                                  const AliMpNeighboursPadIterator& right)
   : AliMpVPadIterator(right)
 {
-// copy constructor
+/// Copy constructor
 
   *this = right;
 }
@@ -59,7 +75,7 @@ AliMpNeighboursPadIterator::AliMpNeighboursPadIterator(
 //______________________________________________________________________________
 AliMpNeighboursPadIterator::~AliMpNeighboursPadIterator()
 {
-// destructor
+/// Destructor
 
 #ifdef WITH_ROOT
   fPads.Delete();
@@ -72,14 +88,15 @@ AliMpNeighboursPadIterator::~AliMpNeighboursPadIterator()
 AliMpNeighboursPadIterator& 
 AliMpNeighboursPadIterator::operator = (const AliMpNeighboursPadIterator& right)
 {
-// assignement operator
-// if the right hand iterator isn't of good type
-// the current operator is invalidated
+/// Assignment operator.                                                     \n
+/// If the right hand iterator isn't of a good type
+/// the current operator is invalidated                                      \n
+/// Not provided for WITH_ROOT option.
 
-  // check assignement to self
+  // check assignment to self
   if (this == &right) return *this;
 
-  // base class assignement
+  // base class assignment
   AliMpVPadIterator::operator=(right);
 
 #ifdef WITH_STL
@@ -95,15 +112,18 @@ AliMpNeighboursPadIterator::operator = (const AliMpNeighboursPadIterator& right)
   return *this;
 } 
 
-//private methods
+//
+// private methods
+//
 
 //______________________________________________________________________________
-Bool_t AliMpNeighboursPadIterator::IsNeighbours(const AliMpPad& pad) const
+Bool_t AliMpNeighboursPadIterator::IsNeighbour(const AliMpPad& pad) const
 {
-// true if the pad located by <padIndice> is a neighbours of those
-// located at <fCenterPad>
+/// Return true if the pad located by <padIndice> is a neighbour of those
+/// located at <fCenterPad>
+
+    if ( !pad.IsValid() ) return kFALSE;    
 
-    
     TVector2 relPos  = pad.Position()   - fCenterPad.Position();
     TVector2 bounds  = pad.Dimensions() + fCenterPad.Dimensions();
     return (TMath::Abs(relPos.X())- bounds.X()<AliMpConstants::LengthTolerance()) && 
@@ -113,25 +133,26 @@ Bool_t AliMpNeighboursPadIterator::IsNeighbours(const AliMpPad& pad) const
 
 #ifdef WITH_STL
 //______________________________________________________________________________
-PadVector AliMpNeighboursPadIterator::PadVectorLine(const AliMpPad& from,
-                                           const AliMpIntPair& direction) const
+AliMpNeighboursPadIterator::PadVector 
+AliMpNeighboursPadIterator::PadVectorLine(const AliMpPad& from,
+                                          const AliMpIntPair& direction) const
 {
-// Fill  a new vector with all pads which have common
-// parts with the pad located at <fCenterPad>, in a given line
-// starting from <from> and moving by <direction>
+/// Fill  a new vector with all pads which have common
+/// parts with the pad located at <fCenterPad>, in a given line
+/// starting from <from> and moving by <direction>
 
     AliMpPad current = from;
     PadVector ans;
     Bool_t cont=kTRUE;
     do {
-        if (IsNeighbours(current))
+        if (IsNeighbour(current))
             ans.push_back(current);
         else
             cont=kFALSE;
         TVector2 nextPos = current.Position() + TVector2(
           current.Dimensions().X()*(AliMpConstants::LengthStep()+1.)*direction.GetFirst(),
           current.Dimensions().Y()*(AliMpConstants::LengthStep()+1.)*direction.GetSecond());
-        current = fkSegmentation->PadByPosition(nextPos);
+        current = fkSegmentation->PadByPosition(nextPos, false);
     } while (cont);
     return ans;
 }
@@ -140,8 +161,8 @@ PadVector AliMpNeighboursPadIterator::PadVectorLine(const AliMpPad& from,
 void  AliMpNeighboursPadIterator::UpdateTotalSet(PadSet& setTotal, 
                                                  const PadVector& from) const
 {
-// Add pads from pad vector to the total set 
-// only if they are not yet included
+/// Add pads from pad vector to the total set 
+/// only if they are not yet included
 
     setTotal.insert(from.begin(),from.end());
 }    
@@ -149,25 +170,26 @@ void  AliMpNeighboursPadIterator::UpdateTotalSet(PadSet& setTotal,
 #endif
 #ifdef WITH_ROOT
 //______________________________________________________________________________
-PadVector* AliMpNeighboursPadIterator::PadVectorLine(const AliMpPad& from,
-                                           const AliMpIntPair& direction) const
+AliMpNeighboursPadIterator::PadVector* 
+AliMpNeighboursPadIterator::PadVectorLine(const AliMpPad& from,
+                                          const AliMpIntPair& direction) const
 {
-// Fill  a new vector with all pads which have common
-// parts with the pad located at <fCenterPad>, in a given line
-// starting from <from> and moving by <direction>
+/// Fill  a new vector with all pads which have common
+/// parts with the pad located at <fCenterPad>, in a given line
+/// starting from <from> and moving by <direction>
 
     AliMpPad current = from;
     PadVector* ans = new PadVector();
     Bool_t cont=kTRUE;
     do {
-        if (IsNeighbours(current))
+        if (IsNeighbour(current))
             ans->Add(new AliMpPad(current));
         else
             cont=kFALSE;
         TVector2 nextPos = current.Position() + TVector2(
           current.Dimensions().X()*(AliMpConstants::LengthStep()+1.)*direction.GetFirst(),
           current.Dimensions().Y()*(AliMpConstants::LengthStep()+1.)*direction.GetSecond());
-        current = fkSegmentation->PadByPosition(nextPos);
+        current = fkSegmentation->PadByPosition(nextPos, false);
     } while (cont);
     return ans;
 }
@@ -176,8 +198,8 @@ PadVector* AliMpNeighboursPadIterator::PadVectorLine(const AliMpPad& from,
 void  AliMpNeighboursPadIterator::UpdateTotalSet(PadSet& setTotal, 
                                                  PadVector* from) const
 {
-// Add pads from pad vector to the total set 
-// only if they are not yet included and deletes the pad vector
+/// Add pads from pad vector to the total set 
+/// only if they are not yet included and deletes the pad vector
 
     for (Int_t i=0; i<from->GetEntriesFast(); i++) {
       AliMpPad* candidate = (AliMpPad*)from->At(i);
@@ -204,8 +226,8 @@ void  AliMpNeighboursPadIterator::UpdateTotalSet(PadSet& setTotal,
 //______________________________________________________________________________
 void AliMpNeighboursPadIterator::FillPadsVector(Bool_t includeCenter)
 {
-// Fill the indices vector with all indices of pads which have common
-// parts with the pad located at <fCenterPad>
+/// Fill the indices vector with all indices of pads which have common
+/// parts with the pad located at <fCenterPad>
 
     if (!fkSegmentation || !fCenterPad.IsValid()) return;
     
@@ -296,7 +318,7 @@ void AliMpNeighboursPadIterator::FillPadsVector(Bool_t includeCenter)
     if (includeCenter) fPads.push_back(fCenterPad);
     //fPads.insert(fPads.end(),setTotal.begin(),setTotal.end());
     
-    PadSetIterator it;
+    PadSetCIterator it;
     for (it = setTotal.begin(); it != setTotal.end(); it++)
       fPads.push_back((*it));
 #endif
@@ -314,7 +336,8 @@ void AliMpNeighboursPadIterator::FillPadsVector(Bool_t includeCenter)
 //______________________________________________________________________________
 Bool_t AliMpNeighboursPadIterator::IsValid() const
 {
-// Is the iterator in a valid position?
+/// Is the iterator in a valid position?
+
     return (fkSegmentation!=0 && fIndex!=fgkInvalidIndex);
 } 
 
@@ -323,8 +346,8 @@ Bool_t AliMpNeighboursPadIterator::IsValid() const
 //______________________________________________________________________________
 void AliMpNeighboursPadIterator::First()
 {
-// Reset the iterator, so that it points to the first available
-// pad in the sector
+/// Reset the iterator, so that it points to the first available
+/// pad in the sector
 
 #ifdef WITH_STL
     if ((fkSegmentation != 0) && (fPads.size() != 0)) 
@@ -341,8 +364,8 @@ void AliMpNeighboursPadIterator::First()
 //______________________________________________________________________________
 void AliMpNeighboursPadIterator::Next()
 {
-// pre-increment operator. Should be used by default for iterating over
-// pads
+/// Pre-increment operator. Should be used by default for iterating over
+/// pads
 
 
   if (!IsValid()) return;
@@ -361,14 +384,16 @@ void AliMpNeighboursPadIterator::Next()
 //______________________________________________________________________________
 Bool_t AliMpNeighboursPadIterator::IsDone() const
 {
-// 
+/// Is the iterator in the end?
   return !IsValid();
 }
 
 //______________________________________________________________________________
 AliMpPad AliMpNeighboursPadIterator::CurrentItem() const 
 {
-// dereferencement operator
+/// Dereferencement function
+
   if (!IsValid())
     return AliMpPad::Invalid();
   else
@@ -383,7 +408,8 @@ AliMpPad AliMpNeighboursPadIterator::CurrentItem() const
 //______________________________________________________________________________
 void AliMpNeighboursPadIterator::Invalidate()
 {
-// Let the iterator points to the invalid position
+/// Let the iterator point to the invalid position
+
     fIndex=fgkInvalidIndex;
 }