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
25 //-----------------------------------------------------------------------------
27 #include "AliMpDEIterator.h"
28 #include "AliMpDEStore.h"
29 #include "AliMpDetElement.h"
30 #include "AliMpDEManager.h"
31 #include "AliMpFiles.h"
35 #include <Riostream.h>
39 ClassImp(AliMpDEIterator)
42 //______________________________________________________________________________
43 AliMpDEIterator::AliMpDEIterator()
45 fDEStore(AliMpDEStore::Instance()),
49 /// Standard and default constructor
52 //______________________________________________________________________________
53 AliMpDEIterator::AliMpDEIterator(const AliMpDEIterator& rhs)
55 fDEStore(rhs.fDEStore),
57 fChamberId(rhs.fChamberId)
62 //______________________________________________________________________________
64 AliMpDEIterator::~AliMpDEIterator()
69 //______________________________________________________________________________
70 AliMpDEIterator& AliMpDEIterator::operator=(const AliMpDEIterator& rhs)
72 /// Assignement operator
74 // check assignment to self
75 if (this == &rhs) return *this;
77 // base class assignment
78 TObject::operator=(rhs);
80 fDEStore = rhs.fDEStore;
82 fChamberId = rhs.fChamberId;
91 //______________________________________________________________________________
92 AliMpDetElement* AliMpDEIterator::GetDetElement(Int_t index) const
94 /// Return the detection element from the map via index
96 return static_cast<AliMpDetElement*>(fDEStore->fDetElements.GetObject(index));
103 //______________________________________________________________________________
104 void AliMpDEIterator::First()
106 /// Set iterator to the first DE Id defined
112 //______________________________________________________________________________
113 void AliMpDEIterator::First(Int_t chamberId)
115 /// Reset the iterator, so that it points to the first DE
119 if ( ! AliMpDEManager::IsValidChamberId(chamberId) ) {
120 AliErrorStream() << "Invalid chamber Id " << chamberId << endl;
125 while ( i < fDEStore->fDetElements.GetSize() && fChamberId < 0 ) {
126 Int_t detElemId = GetDetElement(i)->GetId();
127 if ( AliMpDEManager::GetChamberId(detElemId) == chamberId ) {
128 fChamberId = chamberId;
134 if ( fChamberId < 0 ) {
136 << "No DEs of Chamber Id " << chamberId << " found" << endl;
142 //______________________________________________________________________________
143 void AliMpDEIterator::Next()
145 /// Increment iterator to next DE
149 // Invalidate if at the end
150 if ( ( fIndex == fDEStore->fDetElements.GetSize() ) ||
152 AliMpDEManager::GetChamberId(CurrentDEId()) != fChamberId ) ) {
157 //______________________________________________________________________________
158 Bool_t AliMpDEIterator::IsDone() const
160 /// Is the iterator in the end?
162 return ( fIndex < 0 );
165 //______________________________________________________________________________
166 AliMpDetElement* AliMpDEIterator::CurrentDE() const
171 return GetDetElement(fIndex);
174 << "Not in valid position - returning invalid DE." << endl;
179 //______________________________________________________________________________
180 Int_t AliMpDEIterator::CurrentDEId() const
185 return GetDetElement(fIndex)->GetId();
188 << "Not in valid position - returning invalid DE." << endl;