+/**************************************************************************
+ * 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(),
fPads(),
fIndex(fgkInvalidIndex)
{
-// default constructor, set the current position to "invalid"
+/// Default constructor, set the current position to "invalid"
}
//______________________________________________________________________________
fCenterPad(centerPad),
fIndex(fgkInvalidIndex)
{
-// normal constructor, set *this to invalid position
+/// Standard constructor, set *this to invalid position
FillPadsVector(includeCenter);
}
const AliMpNeighboursPadIterator& right)
: AliMpVPadIterator(right)
{
-// copy constructor
+/// Copy constructor
*this = right;
}
//______________________________________________________________________________
AliMpNeighboursPadIterator::~AliMpNeighboursPadIterator()
{
-// destructor
+/// Destructor
#ifdef WITH_ROOT
fPads.Delete();
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
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()) &&
#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;
}
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());
}
#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;
}
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);
//______________________________________________________________________________
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;
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
//______________________________________________________________________________
Bool_t AliMpNeighboursPadIterator::IsValid() const
{
-// Is the iterator in a valid position?
+/// Is the iterator in a valid position?
+
return (fkSegmentation!=0 && fIndex!=fgkInvalidIndex);
}
//______________________________________________________________________________
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))
//______________________________________________________________________________
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;
//______________________________________________________________________________
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
//______________________________________________________________________________
void AliMpNeighboursPadIterator::Invalidate()
{
-// Let the iterator points to the invalid position
+/// Let the iterator point to the invalid position
+
fIndex=fgkInvalidIndex;
}