]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpDEIterator.cxx
Flexible pt range for the efficiency histogramming
[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
b80faac0 40using std::endl;
13985652 41/// \cond CLASSIMP
42ClassImp(AliMpDEIterator)
43/// \endcond
44
73250182 45//______________________________________________________________________________
46AliMpDEIterator::AliMpDEIterator()
630711ed 47: TObject(),
48 fCurrentDE(0x0),
49 fIterator(AliMpDEStore::Instance()->fDetElements.CreateIterator()),
50 fChamberId(-1)
73250182 51{
52/// Standard and default constructor
73250182 53}
54
73250182 55//______________________________________________________________________________
56
57AliMpDEIterator::~AliMpDEIterator()
58{
59/// Destructor
73250182 60
630711ed 61 delete fIterator;
38956661 62}
63
73250182 64//
65// public methods
66//
67
68//______________________________________________________________________________
69void AliMpDEIterator::First()
70{
71/// Set iterator to the first DE Id defined
72
630711ed 73 fIterator->Reset();
74 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
0a478fb1 75 fChamberId = -1;
73250182 76}
77
78//______________________________________________________________________________
0a478fb1 79void AliMpDEIterator::First(Int_t chamberId)
73250182 80{
490da820 81/// Reset the iterator, so that it points to the first DE
73250182 82
0a478fb1 83 if ( ! AliMpDEManager::IsValidChamberId(chamberId) ) {
84 AliErrorStream() << "Invalid chamber Id " << chamberId << endl;
630711ed 85 fIterator->Reset();
86 fChamberId = -1;
87 fCurrentDE = 0x0;
73250182 88 return;
89 }
90
630711ed 91 fIterator->Reset();
92 fChamberId = -1;
93 while ( fChamberId != chamberId )
94 {
95 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
96 if (!fCurrentDE) return;
97 fChamberId = AliMpDEManager::GetChamberId(CurrentDEId());
73250182 98 }
73250182 99}
100
101//______________________________________________________________________________
102void AliMpDEIterator::Next()
103{
490da820 104/// Increment iterator to next DE
105
630711ed 106 if ( fChamberId < 0 )
107 {
108 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
109 }
110 else
111 {
112 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
113
114 while ( fCurrentDE && (AliMpDEManager::GetChamberId(fCurrentDE->GetId()) != fChamberId) )
115 {
116 fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
117 if (!fCurrentDE) return;
118 }
119 }
73250182 120}
121
122//______________________________________________________________________________
123Bool_t AliMpDEIterator::IsDone() const
124{
490da820 125/// Is the iterator in the end?
126
630711ed 127 return ( fCurrentDE == 0x0 );
73250182 128}
129
130//______________________________________________________________________________
38956661 131AliMpDetElement* AliMpDEIterator::CurrentDE() const
132{
133/// Current DE Id
134
630711ed 135 return fCurrentDE;
38956661 136}
137
138//______________________________________________________________________________
630711ed 139Int_t
140AliMpDEIterator::CurrentDEId() const
73250182 141{
490da820 142/// Current DE Id
143
630711ed 144 if ( fCurrentDE )
145 {
146 return fCurrentDE->GetId();
147 }
73250182 148 else {
149 AliErrorStream()
150 << "Not in valid position - returning invalid DE." << endl;
151 return 0;
152 }
153}
154