]>
Commit | Line | Data |
---|---|---|
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: AliMpMotifPositionPadIterator.cxx,v 1.6 2006/05/24 13:58:41 ivana Exp $ |
5f91c9e8 | 18 | // Category: motif |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
5f91c9e8 | 21 | // Class AliMpMotifPositionPadIterator |
22 | // ----------------------------------- | |
23 | // Class, which defines an iterator over the pads of a given motif type | |
dbe945cc | 24 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 25 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
3d1463c8 | 26 | //----------------------------------------------------------------------------- |
5f91c9e8 | 27 | |
28 | #include "AliMpMotifPositionPadIterator.h" | |
29 | #include "AliMpMotifPosition.h" | |
30 | #include "AliMpMotifType.h" | |
31 | #include "AliMpConnection.h" | |
32 | ||
13985652 | 33 | /// \cond CLASSIMP |
5f91c9e8 | 34 | ClassImp(AliMpMotifPositionPadIterator) |
13985652 | 35 | /// \endcond |
5f91c9e8 | 36 | |
37 | //______________________________________________________________________________ | |
38 | AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator(): | |
39 | AliMpVPadIterator(), | |
7d5d0cc5 | 40 | fkMotifPos(0), |
5f91c9e8 | 41 | fIterator() |
42 | { | |
dee1d5f1 | 43 | /// Default constructor, set the current position to "invalid" |
5f91c9e8 | 44 | } |
45 | ||
46 | //______________________________________________________________________________ | |
47 | ||
48 | AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator( | |
49 | const AliMpMotifPosition* motifPos) | |
50 | : AliMpVPadIterator(), | |
7d5d0cc5 | 51 | fkMotifPos(motifPos), |
5f91c9e8 | 52 | fIterator(motifPos->GetMotif()->GetMotifType()) |
53 | { | |
dee1d5f1 | 54 | /// Standard constructor, let *this to invalid position |
5f91c9e8 | 55 | } |
56 | ||
57 | //______________________________________________________________________________ | |
58 | AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator( | |
59 | const AliMpMotifPositionPadIterator& right) | |
60 | : AliMpVPadIterator(right), | |
7d5d0cc5 | 61 | fkMotifPos(right.fkMotifPos), |
5f91c9e8 | 62 | fIterator(right.fIterator) |
63 | ||
64 | { | |
dee1d5f1 | 65 | /// Copy constructor |
5f91c9e8 | 66 | } |
67 | ||
68 | //______________________________________________________________________________ | |
69 | AliMpMotifPositionPadIterator::~AliMpMotifPositionPadIterator() | |
70 | { | |
dee1d5f1 | 71 | /// Destructor |
5f91c9e8 | 72 | } |
73 | ||
74 | // operators | |
75 | ||
76 | //______________________________________________________________________________ | |
77 | AliMpMotifPositionPadIterator& | |
78 | AliMpMotifPositionPadIterator::operator = (const AliMpMotifPositionPadIterator& right) | |
79 | { | |
dee1d5f1 | 80 | /// Assignment operator |
81 | ||
5f91c9e8 | 82 | // if the right hand iterator isn't of good type |
83 | // the current operator is invalidated | |
84 | ||
dee1d5f1 | 85 | // check assignment to self |
5f91c9e8 | 86 | if (this == &right) return *this; |
87 | ||
dee1d5f1 | 88 | // base class assignment |
5f91c9e8 | 89 | AliMpVPadIterator::operator=(right); |
90 | ||
7d5d0cc5 | 91 | fkMotifPos = right.fkMotifPos; |
5f91c9e8 | 92 | fIterator = right.fIterator; |
93 | ||
94 | return *this; | |
95 | } | |
96 | ||
97 | //private methods | |
98 | ||
99 | ||
100 | //______________________________________________________________________________ | |
101 | Bool_t AliMpMotifPositionPadIterator::IsValid() const | |
102 | { | |
dee1d5f1 | 103 | /// Is the iterator in a valid position? |
5f91c9e8 | 104 | |
7d5d0cc5 | 105 | return (fkMotifPos!=0) && (!fIterator.IsDone()); |
5f91c9e8 | 106 | } |
107 | ||
dee1d5f1 | 108 | // |
109 | // public methods | |
110 | // | |
5f91c9e8 | 111 | |
112 | //______________________________________________________________________________ | |
113 | void AliMpMotifPositionPadIterator::First() | |
114 | { | |
dee1d5f1 | 115 | /// Reset the iterator, so that it points to the first available |
116 | /// pad in the motif type | |
5f91c9e8 | 117 | |
7d5d0cc5 | 118 | if (!fkMotifPos) { |
5f91c9e8 | 119 | Invalidate(); |
120 | return ; | |
121 | } | |
122 | ||
123 | fIterator.First(); | |
124 | return; | |
125 | } | |
126 | ||
127 | //______________________________________________________________________________ | |
128 | void AliMpMotifPositionPadIterator::Next() | |
129 | { | |
dee1d5f1 | 130 | /// Move the iterator to the next valid pad. |
131 | ||
5f91c9e8 | 132 | fIterator.Next(); |
133 | } | |
134 | ||
135 | //______________________________________________________________________________ | |
136 | Bool_t AliMpMotifPositionPadIterator::IsDone() const | |
137 | { | |
dee1d5f1 | 138 | /// Is the iterator in the end? |
139 | ||
5f91c9e8 | 140 | return !IsValid(); |
141 | } | |
142 | ||
143 | //______________________________________________________________________________ | |
144 | AliMpPad AliMpMotifPositionPadIterator::CurrentItem() const | |
145 | { | |
dee1d5f1 | 146 | /// Return current pad. |
5f91c9e8 | 147 | |
7d5d0cc5 | 148 | if (!fkMotifPos) |
5f91c9e8 | 149 | return AliMpPad::Invalid(); |
150 | else { | |
151 | AliMpIntPair ind = fIterator.CurrentItem().GetIndices(); | |
7d5d0cc5 | 152 | AliMpMotifType* mt = fkMotifPos->GetMotif()->GetMotifType(); |
5f91c9e8 | 153 | AliMpConnection* connect = |
154 | mt->FindConnectionByLocalIndices(ind); | |
34ee05d7 | 155 | return AliMpPad(AliMpIntPair(fkMotifPos->GetID(),connect->GetManuChannel()), |
7d5d0cc5 | 156 | fkMotifPos->GlobalIndices(ind), |
157 | fkMotifPos->Position()+fkMotifPos->GetMotif()->PadPositionLocal(ind), | |
158 | fkMotifPos->GetMotif()->GetPadDimensions(ind)); | |
5f91c9e8 | 159 | } |
160 | } | |
161 | ||
162 | //______________________________________________________________________________ | |
163 | void AliMpMotifPositionPadIterator::Invalidate() | |
164 | { | |
dee1d5f1 | 165 | /// Let the iterator point to the invalid position |
166 | ||
5f91c9e8 | 167 | fIterator.Invalidate(); |
168 | } | |
169 |