1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpDEIterator.cxx,v 1.6 2006/05/24 13:58:34 ivana Exp $
18 // Category: management
20 // ------------------------
21 // Class AliMpDEIterator
22 // ------------------------
23 // The iterator over valid detection elements
24 // Author: Ivana Hrivnacova, IPN Orsay
26 #include "AliMpDEIterator.h"
27 #include "AliMpDEStore.h"
28 #include "AliMpDetElement.h"
29 #include "AliMpDEManager.h"
30 #include "AliMpFiles.h"
34 #include <Riostream.h>
38 ClassImp(AliMpDEIterator)
41 //______________________________________________________________________________
42 AliMpDEIterator::AliMpDEIterator()
44 fDEStore(AliMpDEStore::Instance()),
48 /// Standard and default constructor
51 //______________________________________________________________________________
52 AliMpDEIterator::AliMpDEIterator(const AliMpDEIterator& rhs)
54 fDEStore(rhs.fDEStore),
56 fChamberId(rhs.fChamberId)
61 //______________________________________________________________________________
63 AliMpDEIterator::~AliMpDEIterator()
68 //______________________________________________________________________________
69 AliMpDEIterator& AliMpDEIterator::operator=(const AliMpDEIterator& rhs)
71 /// Assignement operator
73 // check assignment to self
74 if (this == &rhs) return *this;
76 // base class assignment
77 TObject::operator=(rhs);
79 fDEStore = rhs.fDEStore;
81 fChamberId = rhs.fChamberId;
90 //______________________________________________________________________________
91 AliMpDetElement* AliMpDEIterator::GetDetElement(Int_t index) const
93 /// Return the detection element from the map via index
95 return static_cast<AliMpDetElement*>(fDEStore->fDetElements.GetObject(index));
102 //______________________________________________________________________________
103 void AliMpDEIterator::First()
105 /// Set iterator to the first DE Id defined
111 //______________________________________________________________________________
112 void AliMpDEIterator::First(Int_t chamberId)
114 /// Reset the iterator, so that it points to the first DE
118 if ( ! AliMpDEManager::IsValidChamberId(chamberId) ) {
119 AliErrorStream() << "Invalid chamber Id " << chamberId << endl;
124 while ( i < fDEStore->fDetElements.GetSize() && fChamberId < 0 ) {
125 Int_t detElemId = GetDetElement(i)->GetId();
126 if ( AliMpDEManager::GetChamberId(detElemId) == chamberId ) {
127 fChamberId = chamberId;
133 if ( fChamberId < 0 ) {
135 << "No DEs of Chamber Id " << chamberId << " found" << endl;
141 //______________________________________________________________________________
142 void AliMpDEIterator::Next()
144 /// Increment iterator to next DE
148 // Invalidate if at the end
149 if ( ( fIndex == fDEStore->fDetElements.GetSize() ) ||
151 AliMpDEManager::GetChamberId(CurrentDEId()) != fChamberId ) ) {
156 //______________________________________________________________________________
157 Bool_t AliMpDEIterator::IsDone() const
159 /// Is the iterator in the end?
161 return ( fIndex < 0 );
164 //______________________________________________________________________________
165 AliMpDetElement* AliMpDEIterator::CurrentDE() const
170 return GetDetElement(fIndex);
173 << "Not in valid position - returning invalid DE." << endl;
178 //______________________________________________________________________________
179 Int_t AliMpDEIterator::CurrentDEId() const
184 return GetDetElement(fIndex)->GetId();
187 << "Not in valid position - returning invalid DE." << endl;