]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpMotifPositionPadIterator.cxx
In SetNofManusPerModule(): return false if no action
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifPositionPadIterator.cxx
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 // Class AliMpMotifPositionPadIterator
21 // -----------------------------------
22 // Class, which defines an iterator over the pads of a given motif type
23 // Included in AliRoot: 2003/05/02
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 /// \cond CLASSIMP
32 ClassImp(AliMpMotifPositionPadIterator)
33 /// \endcond
34
35 //______________________________________________________________________________
36 AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator():
37     AliMpVPadIterator(),
38     fMotifPos(0),
39     fIterator()
40 {
41 /// Default constructor, set the current position to "invalid"
42 }
43
44 //______________________________________________________________________________
45
46 AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator(
47                                     const AliMpMotifPosition* motifPos)
48   : AliMpVPadIterator(),
49     fMotifPos(motifPos),
50     fIterator(motifPos->GetMotif()->GetMotifType())
51 {
52 /// Standard constructor, let *this to invalid position
53 }
54
55 //______________________________________________________________________________
56 AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator(
57                                     const AliMpMotifPositionPadIterator& right)
58   : AliMpVPadIterator(right),
59     fMotifPos(right.fMotifPos),
60     fIterator(right.fIterator)
61     
62 {
63 /// Copy constructor
64 }
65
66 //______________________________________________________________________________
67 AliMpMotifPositionPadIterator::~AliMpMotifPositionPadIterator()
68 {
69 /// Destructor
70 }
71
72 // operators
73
74 //______________________________________________________________________________
75 AliMpMotifPositionPadIterator& 
76 AliMpMotifPositionPadIterator::operator = (const AliMpMotifPositionPadIterator& right)
77 {
78 /// Assignment operator
79
80 // if the right hand iterator isn't of good type
81 // the current operator is invalidated
82
83   // check assignment to self
84   if (this == &right) return *this;
85
86   // base class assignment
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 {
101 /// Is the iterator in a valid position?
102
103     return (fMotifPos!=0) && (!fIterator.IsDone());
104
105
106 //
107 // public methods
108 //
109
110 //______________________________________________________________________________
111 void AliMpMotifPositionPadIterator::First()
112 {
113 /// Reset the iterator, so that it points to the first available
114 /// pad in the motif type
115
116     if (!fMotifPos) {
117         Invalidate();
118         return ;
119     }
120
121     fIterator.First();
122     return;
123 }
124
125 //______________________________________________________________________________
126 void AliMpMotifPositionPadIterator::Next()
127 {
128 /// Move the iterator to the next valid pad.
129
130   fIterator.Next();
131 }
132
133 //______________________________________________________________________________
134 Bool_t AliMpMotifPositionPadIterator::IsDone() const
135 {
136 /// Is the iterator in the end? 
137
138   return !IsValid();
139 }
140
141 //______________________________________________________________________________
142 AliMpPad AliMpMotifPositionPadIterator::CurrentItem() const 
143 {
144 /// Return current pad.
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 {
163 /// Let the iterator point to the invalid position
164
165   fIterator.Invalidate();
166
167