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