]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpSectorPadIterator.cxx
Compilation on Windows/Cygwin. Corrected dependences
[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"
30#include "AliMpIntPair.h"
31#include "AliMpSector.h"
32#include "AliMpMotifType.h"
33
34#include "AliMpRow.h"
35#include "AliMpVRowSegment.h"
36#include "AliMpMotifMap.h"
37#include "AliMpMotifPosition.h"
38
13985652 39/// \cond CLASSIMP
5f91c9e8 40ClassImp(AliMpSectorPadIterator)
13985652 41/// \endcond
5f91c9e8 42
43//______________________________________________________________________________
44AliMpSectorPadIterator::AliMpSectorPadIterator()
45 : AliMpVPadIterator(),
46 fkSector(0),
8c7e6967 47 fCurrentIndex(0),
5f91c9e8 48 fMotifPos(0),
49 fIterator()
50{
dee1d5f1 51/// Default constructor, set the current position to "invalid"
5f91c9e8 52}
53
54//______________________________________________________________________________
dee1d5f1 55AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* const sector)
5f91c9e8 56 : AliMpVPadIterator(),
57 fkSector(sector),
8c7e6967 58 fCurrentIndex(0),
5f91c9e8 59 fMotifPos(0),
60 fIterator()
61{
dee1d5f1 62/// Standard constructor, set *this to invalid position
5f91c9e8 63}
64
65//______________________________________________________________________________
66AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
0471c97b 67 : AliMpVPadIterator(right),
68 fkSector(0),
8c7e6967 69 fCurrentIndex(0),
0471c97b 70 fMotifPos(0),
71 fIterator()
5f91c9e8 72{
dee1d5f1 73/// Copy constructor
5f91c9e8 74
75 *this = right;
76}
77
78//______________________________________________________________________________
79AliMpSectorPadIterator::~AliMpSectorPadIterator()
80{
dee1d5f1 81/// Destructor
5f91c9e8 82}
83
dee1d5f1 84//
5f91c9e8 85// operators
dee1d5f1 86//
5f91c9e8 87
88//______________________________________________________________________________
89AliMpSectorPadIterator&
90AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
91{
dee1d5f1 92/// Assignment operator
5f91c9e8 93
dee1d5f1 94 // check assignment to self
5f91c9e8 95 if (this == &right) return *this;
96
dee1d5f1 97 // base class assignment
5f91c9e8 98 AliMpVPadIterator::operator=(right);
99
100 fkSector = right.fkSector;
8c7e6967 101 fCurrentIndex = right.fCurrentIndex,
102 fMotifPos = right.fMotifPos;
5f91c9e8 103 fIterator = right.fIterator;
104
105 return *this;
106}
107
108//private methods
109
110//______________________________________________________________________________
111AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
112{
dee1d5f1 113/// Find the AliMpMotifType object associated with the triplet
114/// (fCurrentRow, fCurrentSeg, fCurrentMotif),
115/// place it in the private fMotifType member and return it.
8c7e6967 116
117 if ( fCurrentIndex == fkSector->GetMotifMap()->GetNofMotifPositions() ) {
5f91c9e8 118 Invalidate();
8c7e6967 119 return 0;
120 }
121
122 fMotifPos = fkSector->GetMotifMap()->GetMotifPosition(fCurrentIndex);
123 fIterator = AliMpMotifPositionPadIterator(fMotifPos);
124 fIterator.First();
5f91c9e8 125
126 return fMotifPos;
127}
128
129//______________________________________________________________________________
130Bool_t AliMpSectorPadIterator::IsValid() const
131{
dee1d5f1 132/// Is the iterator in a valid position?
133
5f91c9e8 134 return (fkSector!=0) && (fMotifPos!=0);
135}
136
dee1d5f1 137//
5f91c9e8 138//public methods
dee1d5f1 139//
5f91c9e8 140
141//______________________________________________________________________________
142void AliMpSectorPadIterator::First()
143{
dee1d5f1 144/// Reset the iterator, so that it points to the first available
145/// pad in the sector
5f91c9e8 146
147 if (!fkSector) {
148 Invalidate();
149 return;
150 }
8c7e6967 151 fCurrentIndex =0;
5f91c9e8 152 ResetToCurrentMotifPosition();
153
154 return;
155}
156
157//______________________________________________________________________________
158void AliMpSectorPadIterator::Next()
159{
dee1d5f1 160/// Move the iterator to the next valid pad.
5f91c9e8 161
5f91c9e8 162 if (!IsValid()) return;
163
164 fIterator.Next();
165
166 if (!fIterator.IsDone()) return;
167
168
8c7e6967 169 // Go to the next motif, in the current segment
170 ++fCurrentIndex;
5f91c9e8 171 if (ResetToCurrentMotifPosition()) return;
172
5f91c9e8 173 Invalidate();
174 return;
175
176}
177
178//______________________________________________________________________________
179Bool_t AliMpSectorPadIterator::IsDone() const
180{
dee1d5f1 181/// Is the iterator in the end?
182
8c7e6967 183 return ! IsValid();
5f91c9e8 184}
185
186//______________________________________________________________________________
187AliMpPad AliMpSectorPadIterator::CurrentItem () const
188{
dee1d5f1 189/// Return current pad.
5f91c9e8 190
191 if (!IsValid())
192 return AliMpPad::Invalid();
193
194
195 // no more verification, since IsValid() is TRUE here.
5f91c9e8 196 return fIterator.CurrentItem();
197}
198
199//______________________________________________________________________________
200void AliMpSectorPadIterator::Invalidate()
201{
dee1d5f1 202/// Let the iterator point to the invalid position
5f91c9e8 203 fMotifPos = 0;
204 fIterator.Invalidate();
205}
206