]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpDEIterator.cxx
Fixing a backward compatibility issue
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpDEIterator.cxx
CommitLineData
73250182 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
490da820 16// $Id$
13985652 17// $MpId: AliMpDEIterator.cxx,v 1.6 2006/05/24 13:58:34 ivana Exp $
700013f0 18// Category: management
490da820 19
3d1463c8 20//-----------------------------------------------------------------------------
490da820 21// Class AliMpDEIterator
22// ------------------------
38956661 23// The iterator over valid detection elements
490da820 24// Author: Ivana Hrivnacova, IPN Orsay
3d1463c8 25//-----------------------------------------------------------------------------
73250182 26
27#include "AliMpDEIterator.h"
630711ed 28
29#include "AliMpExMapIterator.h"
38956661 30#include "AliMpDEStore.h"
31#include "AliMpDetElement.h"
73250182 32#include "AliMpDEManager.h"
33#include "AliMpFiles.h"
34
35#include "AliLog.h"
36
37#include <Riostream.h>
38#include <TSystem.h>
39
13985652 40/// \cond CLASSIMP
41ClassImp(AliMpDEIterator)
42/// \endcond
43
73250182 44//______________________________________________________________________________
45AliMpDEIterator::AliMpDEIterator()
630711ed 46: TObject(),
47 fCurrentDE(0x0),
48 fIterator(AliMpDEStore::Instance()->fDetElements.CreateIterator()),
49 fChamberId(-1)
73250182 50{
51/// Standard and default constructor
73250182 52}
53
73250182 54//______________________________________________________________________________
55
56AliMpDEIterator::~AliMpDEIterator()
57{
58/// Destructor
73250182 59
630711ed 60 delete fIterator;
38956661 61}
62
73250182 63//
64// public methods
65//
66
67//______________________________________________________________________________
68void AliMpDEIterator::First()
69{
70/// Set iterator to the first DE Id defined
71
630711ed 72 fIterator->Reset();
73 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
0a478fb1 74 fChamberId = -1;
73250182 75}
76
77//______________________________________________________________________________
0a478fb1 78void AliMpDEIterator::First(Int_t chamberId)
73250182 79{
490da820 80/// Reset the iterator, so that it points to the first DE
73250182 81
0a478fb1 82 if ( ! AliMpDEManager::IsValidChamberId(chamberId) ) {
83 AliErrorStream() << "Invalid chamber Id " << chamberId << endl;
630711ed 84 fIterator->Reset();
85 fChamberId = -1;
86 fCurrentDE = 0x0;
73250182 87 return;
88 }
89
630711ed 90 fIterator->Reset();
91 fChamberId = -1;
92 while ( fChamberId != chamberId )
93 {
94 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
95 if (!fCurrentDE) return;
96 fChamberId = AliMpDEManager::GetChamberId(CurrentDEId());
73250182 97 }
73250182 98}
99
100//______________________________________________________________________________
101void AliMpDEIterator::Next()
102{
490da820 103/// Increment iterator to next DE
104
630711ed 105 if ( fChamberId < 0 )
106 {
107 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
108 }
109 else
110 {
111 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
112
113 while ( fCurrentDE && (AliMpDEManager::GetChamberId(fCurrentDE->GetId()) != fChamberId) )
114 {
115 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
116 if (!fCurrentDE) return;
117 }
118 }
73250182 119}
120
121//______________________________________________________________________________
122Bool_t AliMpDEIterator::IsDone() const
123{
490da820 124/// Is the iterator in the end?
125
630711ed 126 return ( fCurrentDE == 0x0 );
73250182 127}
128
129//______________________________________________________________________________
38956661 130AliMpDetElement* AliMpDEIterator::CurrentDE() const
131{
132/// Current DE Id
133
630711ed 134 return fCurrentDE;
38956661 135}
136
137//______________________________________________________________________________
630711ed 138Int_t
139AliMpDEIterator::CurrentDEId() const
73250182 140{
490da820 141/// Current DE Id
142
630711ed 143 if ( fCurrentDE )
144 {
145 return fCurrentDE->GetId();
146 }
73250182 147 else {
148 AliErrorStream()
149 << "Not in valid position - returning invalid DE." << endl;
150 return 0;
151 }
152}
153