]>
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" | |
168e9c4d | 32 | #include "AliMpEncodePair.h" |
5f91c9e8 | 33 | |
13985652 | 34 | /// \cond CLASSIMP |
5f91c9e8 | 35 | ClassImp(AliMpMotifPositionPadIterator) |
13985652 | 36 | /// \endcond |
5f91c9e8 | 37 | |
38 | //______________________________________________________________________________ | |
39 | AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator(): | |
40 | AliMpVPadIterator(), | |
7d5d0cc5 | 41 | fkMotifPos(0), |
5f91c9e8 | 42 | fIterator() |
43 | { | |
dee1d5f1 | 44 | /// Default constructor, set the current position to "invalid" |
5f91c9e8 | 45 | } |
46 | ||
47 | //______________________________________________________________________________ | |
48 | ||
49 | AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator( | |
50 | const AliMpMotifPosition* motifPos) | |
51 | : AliMpVPadIterator(), | |
7d5d0cc5 | 52 | fkMotifPos(motifPos), |
5f91c9e8 | 53 | fIterator(motifPos->GetMotif()->GetMotifType()) |
54 | { | |
dee1d5f1 | 55 | /// Standard constructor, let *this to invalid position |
5f91c9e8 | 56 | } |
57 | ||
58 | //______________________________________________________________________________ | |
59 | AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator( | |
60 | const AliMpMotifPositionPadIterator& right) | |
61 | : AliMpVPadIterator(right), | |
7d5d0cc5 | 62 | fkMotifPos(right.fkMotifPos), |
5f91c9e8 | 63 | fIterator(right.fIterator) |
64 | ||
65 | { | |
dee1d5f1 | 66 | /// Copy constructor |
5f91c9e8 | 67 | } |
68 | ||
69 | //______________________________________________________________________________ | |
70 | AliMpMotifPositionPadIterator::~AliMpMotifPositionPadIterator() | |
71 | { | |
dee1d5f1 | 72 | /// Destructor |
5f91c9e8 | 73 | } |
74 | ||
75 | // operators | |
76 | ||
77 | //______________________________________________________________________________ | |
78 | AliMpMotifPositionPadIterator& | |
79 | AliMpMotifPositionPadIterator::operator = (const AliMpMotifPositionPadIterator& right) | |
80 | { | |
dee1d5f1 | 81 | /// Assignment operator |
82 | ||
5f91c9e8 | 83 | // if the right hand iterator isn't of good type |
84 | // the current operator is invalidated | |
85 | ||
dee1d5f1 | 86 | // check assignment to self |
5f91c9e8 | 87 | if (this == &right) return *this; |
88 | ||
dee1d5f1 | 89 | // base class assignment |
5f91c9e8 | 90 | AliMpVPadIterator::operator=(right); |
91 | ||
7d5d0cc5 | 92 | fkMotifPos = right.fkMotifPos; |
5f91c9e8 | 93 | fIterator = right.fIterator; |
94 | ||
95 | return *this; | |
96 | } | |
97 | ||
98 | //private methods | |
99 | ||
100 | ||
101 | //______________________________________________________________________________ | |
102 | Bool_t AliMpMotifPositionPadIterator::IsValid() const | |
103 | { | |
dee1d5f1 | 104 | /// Is the iterator in a valid position? |
5f91c9e8 | 105 | |
7d5d0cc5 | 106 | return (fkMotifPos!=0) && (!fIterator.IsDone()); |
5f91c9e8 | 107 | } |
108 | ||
dee1d5f1 | 109 | // |
110 | // public methods | |
111 | // | |
5f91c9e8 | 112 | |
113 | //______________________________________________________________________________ | |
114 | void AliMpMotifPositionPadIterator::First() | |
115 | { | |
dee1d5f1 | 116 | /// Reset the iterator, so that it points to the first available |
117 | /// pad in the motif type | |
5f91c9e8 | 118 | |
7d5d0cc5 | 119 | if (!fkMotifPos) { |
5f91c9e8 | 120 | Invalidate(); |
121 | return ; | |
122 | } | |
123 | ||
124 | fIterator.First(); | |
125 | return; | |
126 | } | |
127 | ||
128 | //______________________________________________________________________________ | |
129 | void AliMpMotifPositionPadIterator::Next() | |
130 | { | |
dee1d5f1 | 131 | /// Move the iterator to the next valid pad. |
132 | ||
5f91c9e8 | 133 | fIterator.Next(); |
134 | } | |
135 | ||
136 | //______________________________________________________________________________ | |
137 | Bool_t AliMpMotifPositionPadIterator::IsDone() const | |
138 | { | |
dee1d5f1 | 139 | /// Is the iterator in the end? |
140 | ||
5f91c9e8 | 141 | return !IsValid(); |
142 | } | |
143 | ||
144 | //______________________________________________________________________________ | |
145 | AliMpPad AliMpMotifPositionPadIterator::CurrentItem() const | |
146 | { | |
dee1d5f1 | 147 | /// Return current pad. |
5f91c9e8 | 148 | |
7d5d0cc5 | 149 | if (!fkMotifPos) |
5f91c9e8 | 150 | return AliMpPad::Invalid(); |
151 | else { | |
168e9c4d | 152 | MpPair_t ind = fIterator.CurrentItem().GetIndices(); |
7d5d0cc5 | 153 | AliMpMotifType* mt = fkMotifPos->GetMotif()->GetMotifType(); |
5f91c9e8 | 154 | AliMpConnection* connect = |
155 | mt->FindConnectionByLocalIndices(ind); | |
6e97fbb8 | 156 | |
157 | Double_t posx, posy; | |
158 | fkMotifPos->GetMotif()->PadPositionLocal(ind, posx, posy); | |
159 | posx += fkMotifPos->GetPositionX(); | |
160 | posy += fkMotifPos->GetPositionY(); | |
161 | ||
162 | Double_t dx, dy; | |
163 | fkMotifPos->GetMotif()->GetPadDimensionsByIndices(ind, dx, dy); | |
164 | ||
168e9c4d | 165 | return AliMpPad( |
166 | fkMotifPos->GetID(),connect->GetManuChannel(), | |
7d5d0cc5 | 167 | fkMotifPos->GlobalIndices(ind), |
6e97fbb8 | 168 | posx, posy, dx, dy); |
5f91c9e8 | 169 | } |
170 | } | |
171 | ||
172 | //______________________________________________________________________________ | |
173 | void AliMpMotifPositionPadIterator::Invalidate() | |
174 | { | |
dee1d5f1 | 175 | /// Let the iterator point to the invalid position |
176 | ||
5f91c9e8 | 177 | fIterator.Invalidate(); |
178 | } | |
179 |