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"
29 #include "AliMpExMapIterator.h"
30 #include "AliMpDEStore.h"
31 #include "AliMpDetElement.h"
32 #include "AliMpDEManager.h"
33 #include "AliMpFiles.h"
37 #include <Riostream.h>
42 ClassImp(AliMpDEIterator)
45 //______________________________________________________________________________
46 AliMpDEIterator::AliMpDEIterator()
49 fIterator(AliMpDEStore::Instance()->fDetElements.CreateIterator()),
52 /// Standard and default constructor
55 //______________________________________________________________________________
57 AliMpDEIterator::~AliMpDEIterator()
68 //______________________________________________________________________________
69 void AliMpDEIterator::First()
71 /// Set iterator to the first DE Id defined
74 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
78 //______________________________________________________________________________
79 void AliMpDEIterator::First(Int_t chamberId)
81 /// Reset the iterator, so that it points to the first DE
83 if ( ! AliMpDEManager::IsValidChamberId(chamberId) ) {
84 AliErrorStream() << "Invalid chamber Id " << chamberId << endl;
93 while ( fChamberId != chamberId )
95 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
96 if (!fCurrentDE) return;
97 fChamberId = AliMpDEManager::GetChamberId(CurrentDEId());
101 //______________________________________________________________________________
102 void AliMpDEIterator::Next()
104 /// Increment iterator to next DE
106 if ( fChamberId < 0 )
108 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
112 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
114 while ( fCurrentDE && (AliMpDEManager::GetChamberId(fCurrentDE->GetId()) != fChamberId) )
116 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
117 if (!fCurrentDE) return;
122 //______________________________________________________________________________
123 Bool_t AliMpDEIterator::IsDone() const
125 /// Is the iterator in the end?
127 return ( fCurrentDE == 0x0 );
130 //______________________________________________________________________________
131 AliMpDetElement* AliMpDEIterator::CurrentDE() const
138 //______________________________________________________________________________
140 AliMpDEIterator::CurrentDEId() const
146 return fCurrentDE->GetId();
150 << "Not in valid position - returning invalid DE." << endl;