1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 // $MpId: AliMpMotifPositionPadIterator.cxx,v 1.6 2006/05/24 13:58:41 ivana Exp $
20 //-----------------------------------------------------------------------------
21 // Class AliMpMotifPositionPadIterator
22 // -----------------------------------
23 // Class, which defines an iterator over the pads of a given motif type
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 //-----------------------------------------------------------------------------
28 #include "AliMpMotifPositionPadIterator.h"
29 #include "AliMpMotifPosition.h"
30 #include "AliMpMotifType.h"
31 #include "AliMpConnection.h"
34 ClassImp(AliMpMotifPositionPadIterator)
37 //______________________________________________________________________________
38 AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator():
43 /// Default constructor, set the current position to "invalid"
46 //______________________________________________________________________________
48 AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator(
49 const AliMpMotifPosition* motifPos)
50 : AliMpVPadIterator(),
52 fIterator(motifPos->GetMotif()->GetMotifType())
54 /// Standard constructor, let *this to invalid position
57 //______________________________________________________________________________
58 AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator(
59 const AliMpMotifPositionPadIterator& right)
60 : AliMpVPadIterator(right),
61 fMotifPos(right.fMotifPos),
62 fIterator(right.fIterator)
68 //______________________________________________________________________________
69 AliMpMotifPositionPadIterator::~AliMpMotifPositionPadIterator()
76 //______________________________________________________________________________
77 AliMpMotifPositionPadIterator&
78 AliMpMotifPositionPadIterator::operator = (const AliMpMotifPositionPadIterator& right)
80 /// Assignment operator
82 // if the right hand iterator isn't of good type
83 // the current operator is invalidated
85 // check assignment to self
86 if (this == &right) return *this;
88 // base class assignment
89 AliMpVPadIterator::operator=(right);
91 fMotifPos = right.fMotifPos;
92 fIterator = right.fIterator;
100 //______________________________________________________________________________
101 Bool_t AliMpMotifPositionPadIterator::IsValid() const
103 /// Is the iterator in a valid position?
105 return (fMotifPos!=0) && (!fIterator.IsDone());
112 //______________________________________________________________________________
113 void AliMpMotifPositionPadIterator::First()
115 /// Reset the iterator, so that it points to the first available
116 /// pad in the motif type
127 //______________________________________________________________________________
128 void AliMpMotifPositionPadIterator::Next()
130 /// Move the iterator to the next valid pad.
135 //______________________________________________________________________________
136 Bool_t AliMpMotifPositionPadIterator::IsDone() const
138 /// Is the iterator in the end?
143 //______________________________________________________________________________
144 AliMpPad AliMpMotifPositionPadIterator::CurrentItem() const
146 /// Return current pad.
149 return AliMpPad::Invalid();
151 AliMpIntPair ind = fIterator.CurrentItem().GetIndices();
152 AliMpMotifType* mt = fMotifPos->GetMotif()->GetMotifType();
153 AliMpConnection* connect =
154 mt->FindConnectionByLocalIndices(ind);
155 return AliMpPad(AliMpIntPair(fMotifPos->GetID(),connect->GetGassiNum()),
156 fMotifPos->GlobalIndices(ind),
157 fMotifPos->Position()+fMotifPos->GetMotif()->PadPositionLocal(ind),
158 fMotifPos->GetMotif()->GetPadDimensions(ind));
162 //______________________________________________________________________________
163 void AliMpMotifPositionPadIterator::Invalidate()
165 /// Let the iterator point to the invalid position
167 fIterator.Invalidate();