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