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