Line data Source code
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 18 : ClassImp(AliMpSectorPadIterator)
40 : /// \endcond
41 :
42 : //______________________________________________________________________________
43 : AliMpSectorPadIterator::AliMpSectorPadIterator()
44 0 : : AliMpVPadIterator(),
45 0 : fkSector(0),
46 0 : fCurrentIndex(0),
47 0 : fMotifPos(0),
48 0 : fIterator()
49 0 : {
50 : /// Default constructor, set the current position to "invalid"
51 0 : }
52 :
53 : //______________________________________________________________________________
54 : AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* sector)
55 64 : : AliMpVPadIterator(),
56 64 : fkSector(sector),
57 64 : fCurrentIndex(0),
58 64 : fMotifPos(0),
59 64 : fIterator()
60 320 : {
61 : /// Standard constructor, set *this to invalid position
62 128 : }
63 :
64 : //______________________________________________________________________________
65 : AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
66 0 : : AliMpVPadIterator(right),
67 0 : fkSector(0),
68 0 : fCurrentIndex(0),
69 0 : fMotifPos(0),
70 0 : fIterator()
71 0 : {
72 : /// Copy constructor
73 :
74 0 : *this = right;
75 0 : }
76 :
77 : //______________________________________________________________________________
78 : AliMpSectorPadIterator::~AliMpSectorPadIterator()
79 384 : {
80 : /// Destructor
81 192 : }
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 0 : if (this == &right) return *this;
95 :
96 : // base class assignment
97 0 : AliMpVPadIterator::operator=(right);
98 :
99 0 : fkSector = right.fkSector;
100 0 : fCurrentIndex = right.fCurrentIndex,
101 0 : fMotifPos = right.fMotifPos;
102 0 : fIterator = right.fIterator;
103 :
104 0 : return *this;
105 0 : }
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 28736 : if ( fCurrentIndex == fkSector->GetMotifMap()->GetNofMotifPositions() ) {
117 64 : Invalidate();
118 64 : return 0;
119 : }
120 :
121 14304 : fMotifPos = fkSector->GetMotifMap()->GetMotifPosition(fCurrentIndex);
122 28608 : fIterator = AliMpMotifPositionPadIterator(fMotifPos);
123 14304 : fIterator.First();
124 :
125 14304 : return fMotifPos;
126 14368 : }
127 :
128 : //______________________________________________________________________________
129 : Bool_t AliMpSectorPadIterator::IsValid() const
130 : {
131 : /// Is the iterator in a valid position?
132 :
133 10868416 : 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 128 : if (!fkSector) {
147 0 : Invalidate();
148 0 : return;
149 : }
150 64 : fCurrentIndex =0;
151 64 : ResetToCurrentMotifPosition();
152 :
153 64 : return;
154 64 : }
155 :
156 : //______________________________________________________________________________
157 : void AliMpSectorPadIterator::Next()
158 : {
159 : /// Move the iterator to the next valid pad.
160 :
161 1811360 : if (!IsValid()) return;
162 :
163 905680 : fIterator.Next();
164 :
165 905680 : if (!fIterator.IsDone()) return;
166 :
167 :
168 : // Go to the next motif, in the current segment
169 14304 : ++fCurrentIndex;
170 14304 : if (ResetToCurrentMotifPosition()) return;
171 :
172 64 : Invalidate();
173 64 : return;
174 :
175 905680 : }
176 :
177 : //______________________________________________________________________________
178 : Bool_t AliMpSectorPadIterator::IsDone() const
179 : {
180 : /// Is the iterator in the end?
181 :
182 1811488 : return ! IsValid();
183 : }
184 :
185 : //______________________________________________________________________________
186 : AliMpPad AliMpSectorPadIterator::CurrentItem () const
187 : {
188 : /// Return current pad.
189 :
190 1811360 : if (!IsValid())
191 0 : return AliMpPad::Invalid();
192 :
193 :
194 : // no more verification, since IsValid() is TRUE here.
195 905680 : return fIterator.CurrentItem();
196 905680 : }
197 :
198 : //______________________________________________________________________________
199 : void AliMpSectorPadIterator::Invalidate()
200 : {
201 : /// Let the iterator point to the invalid position
202 256 : fMotifPos = 0;
203 128 : fIterator.Invalidate();
204 128 : }
205 :
|