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