Fixing a backward compatibility issue
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSectorPadIterator.cxx
CommitLineData
dee1d5f1 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
5f91c9e8 16// $Id$
13985652 17// $MpId: AliMpSectorPadIterator.cxx,v 1.6 2006/05/24 13:58:46 ivana Exp $
5f91c9e8 18// Category: sector
3d1463c8 19
20//-----------------------------------------------------------------------------
5f91c9e8 21// Class AliMpSectorPadIterator
22// ----------------------------
23// Class, which defines an iterator over the pads of a sector
dbe945cc 24// Included in AliRoot: 2003/05/02
5f91c9e8 25// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
3d1463c8 26//-----------------------------------------------------------------------------
27
5f91c9e8 28
29#include "AliMpSectorPadIterator.h"
5f91c9e8 30#include "AliMpSector.h"
31#include "AliMpMotifType.h"
32
33#include "AliMpRow.h"
34#include "AliMpVRowSegment.h"
35#include "AliMpMotifMap.h"
36#include "AliMpMotifPosition.h"
37
13985652 38/// \cond CLASSIMP
5f91c9e8 39ClassImp(AliMpSectorPadIterator)
13985652 40/// \endcond
5f91c9e8 41
42//______________________________________________________________________________
43AliMpSectorPadIterator::AliMpSectorPadIterator()
44 : AliMpVPadIterator(),
45 fkSector(0),
8c7e6967 46 fCurrentIndex(0),
5f91c9e8 47 fMotifPos(0),
48 fIterator()
49{
dee1d5f1 50/// Default constructor, set the current position to "invalid"
5f91c9e8 51}
52
53//______________________________________________________________________________
8368e0ee 54AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* sector)
5f91c9e8 55 : AliMpVPadIterator(),
56 fkSector(sector),
8c7e6967 57 fCurrentIndex(0),
5f91c9e8 58 fMotifPos(0),
59 fIterator()
60{
dee1d5f1 61/// Standard constructor, set *this to invalid position
5f91c9e8 62}
63
64//______________________________________________________________________________
65AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
0471c97b 66 : AliMpVPadIterator(right),
67 fkSector(0),
8c7e6967 68 fCurrentIndex(0),
0471c97b 69 fMotifPos(0),
70 fIterator()
5f91c9e8 71{
dee1d5f1 72/// Copy constructor
5f91c9e8 73
74 *this = right;
75}
76
77//______________________________________________________________________________
78AliMpSectorPadIterator::~AliMpSectorPadIterator()
79{
dee1d5f1 80/// Destructor
5f91c9e8 81}
82
dee1d5f1 83//
5f91c9e8 84// operators
dee1d5f1 85//
5f91c9e8 86
87//______________________________________________________________________________
88AliMpSectorPadIterator&
89AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
90{
dee1d5f1 91/// Assignment operator
5f91c9e8 92
dee1d5f1 93 // check assignment to self
5f91c9e8 94 if (this == &right) return *this;
95
dee1d5f1 96 // base class assignment
5f91c9e8 97 AliMpVPadIterator::operator=(right);
98
99 fkSector = right.fkSector;
8c7e6967 100 fCurrentIndex = right.fCurrentIndex,
101 fMotifPos = right.fMotifPos;
5f91c9e8 102 fIterator = right.fIterator;
103
104 return *this;
105}
106
107//private methods
108
109//______________________________________________________________________________
110AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
111{
dee1d5f1 112/// Find the AliMpMotifType object associated with the triplet
113/// (fCurrentRow, fCurrentSeg, fCurrentMotif),
114/// place it in the private fMotifType member and return it.
8c7e6967 115
116 if ( fCurrentIndex == fkSector->GetMotifMap()->GetNofMotifPositions() ) {
5f91c9e8 117 Invalidate();
8c7e6967 118 return 0;
119 }
120
121 fMotifPos = fkSector->GetMotifMap()->GetMotifPosition(fCurrentIndex);
122 fIterator = AliMpMotifPositionPadIterator(fMotifPos);
123 fIterator.First();
5f91c9e8 124
125 return fMotifPos;
126}
127
128//______________________________________________________________________________
129Bool_t AliMpSectorPadIterator::IsValid() const
130{
dee1d5f1 131/// Is the iterator in a valid position?
132
5f91c9e8 133 return (fkSector!=0) && (fMotifPos!=0);
134}
135
dee1d5f1 136//
5f91c9e8 137//public methods
dee1d5f1 138//
5f91c9e8 139
140//______________________________________________________________________________
141void AliMpSectorPadIterator::First()
142{
dee1d5f1 143/// Reset the iterator, so that it points to the first available
144/// pad in the sector
5f91c9e8 145
146 if (!fkSector) {
147 Invalidate();
148 return;
149 }
8c7e6967 150 fCurrentIndex =0;
5f91c9e8 151 ResetToCurrentMotifPosition();
152
153 return;
154}
155
156//______________________________________________________________________________
157void AliMpSectorPadIterator::Next()
158{
dee1d5f1 159/// Move the iterator to the next valid pad.
5f91c9e8 160
5f91c9e8 161 if (!IsValid()) return;
162
163 fIterator.Next();
164
165 if (!fIterator.IsDone()) return;
166
167
8c7e6967 168 // Go to the next motif, in the current segment
169 ++fCurrentIndex;
5f91c9e8 170 if (ResetToCurrentMotifPosition()) return;
171
5f91c9e8 172 Invalidate();
173 return;
174
175}
176
177//______________________________________________________________________________
178Bool_t AliMpSectorPadIterator::IsDone() const
179{
dee1d5f1 180/// Is the iterator in the end?
181
8c7e6967 182 return ! IsValid();
5f91c9e8 183}
184
185//______________________________________________________________________________
186AliMpPad AliMpSectorPadIterator::CurrentItem () const
187{
dee1d5f1 188/// Return current pad.
5f91c9e8 189
190 if (!IsValid())
191 return AliMpPad::Invalid();
192
193
194 // no more verification, since IsValid() is TRUE here.
5f91c9e8 195 return fIterator.CurrentItem();
196}
197
198//______________________________________________________________________________
199void AliMpSectorPadIterator::Invalidate()
200{
dee1d5f1 201/// Let the iterator point to the invalid position
5f91c9e8 202 fMotifPos = 0;
203 fIterator.Invalidate();
204}
205