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