]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON2DMapIteratorByI.cxx
correct calibration of short runs
[u/mrichter/AliRoot.git] / MUON / AliMUON2DMapIteratorByI.cxx
CommitLineData
5fc43f28 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
16// $Id$
17
3d1463c8 18//-----------------------------------------------------------------------------
5fc43f28 19/// \class AliMUON2DMapIteratorByI
20///
21/// Implementation of TIterator for 2D maps
22///
23/// An implementation of TIterator for 2D maps, which can iterate
24/// on a range of i values (i being the first element of the couple
25/// (i,j) used to index values in the map).
26///
27/// \author Laurent Aphecetche
3d1463c8 28//-----------------------------------------------------------------------------
5fc43f28 29
30#include "AliMUON2DMapIteratorByI.h"
630711ed 31#include "AliMpExMapIterator.h"
5fc43f28 32#include "AliMpExMap.h"
630711ed 33#include "AliLog.h"
5fc43f28 34
35/// \cond CLASSIMP
36ClassImp(AliMUON2DMapIteratorByI)
37/// \endcond
38
39//_____________________________________________________________________________
630711ed 40AliMUON2DMapIteratorByI::AliMUON2DMapIteratorByI(const AliMpExMap& theMap, Int_t firstI, Int_t lastI)
5fc43f28 41: TIterator(),
7332f213 42fkMap(&theMap),
630711ed 43fIter1(theMap.CreateIterator()),
5fc43f28 44fIter2(0x0),
5fc43f28 45fFirstI(firstI),
630711ed 46fLastI(lastI),
47fCurrentI(-1)
5fc43f28 48{
49 /// default ctor
50 Reset();
51}
52
53//_____________________________________________________________________________
6805f5be 54AliMUON2DMapIteratorByI&
55AliMUON2DMapIteratorByI::operator=(const TIterator& /*rhs*/)
5fc43f28 56{
6805f5be 57 // overriden operator= (imposed by Root's definition of TIterator::operator= ?)
630711ed 58
6805f5be 59 AliFatalGeneral("operator=(TIterator&)",""); // as in copy ctor
5fc43f28 60 return *this;
61}
62
63//_____________________________________________________________________________
64AliMUON2DMapIteratorByI::~AliMUON2DMapIteratorByI()
65{
66 /// dtor
be9b25ed 67 delete fIter1;
68 delete fIter2;
5fc43f28 69}
70
71//_____________________________________________________________________________
72const TCollection*
73AliMUON2DMapIteratorByI::GetCollection() const
74{
630711ed 75 /// Return 0 as we're not really dealing with a Root TCollection...
5fc43f28 76 return 0x0;
77}
78
79//_____________________________________________________________________________
630711ed 80AliMpExMapIterator*
81AliMUON2DMapIteratorByI::NextIterator()
5fc43f28 82{
630711ed 83 /// Get next map (from fIter1) and create an iterator to it
84
85 AliMpExMap* m = static_cast<AliMpExMap*>(fIter1->Next(fCurrentI));
86
87 if (!m) return 0x0;
88
89 if ( fCurrentI < fFirstI || fCurrentI > fLastI ) return NextIterator(); // try again
90
91 return m->CreateIterator();
5fc43f28 92}
93
94//_____________________________________________________________________________
95TObject*
96AliMUON2DMapIteratorByI::Next()
97{
630711ed 98 /// return next object
99
5fc43f28 100 if (!fIter2) return 0x0;
101
630711ed 102 TObject* o = fIter2->Next();
103
5fc43f28 104 if (!o)
105 {
be9b25ed 106 delete fIter2;
630711ed 107 fIter2 = NextIterator();
108 return Next();
109 }
5fc43f28 110
111 return o;
112}
113
114//_____________________________________________________________________________
115void
116AliMUON2DMapIteratorByI::Reset()
117{
118 /// rewind the iterator
5fc43f28 119
630711ed 120 delete fIter2;
121 fIter1->Reset();
122 fIter2 = NextIterator();
123 fCurrentI = -1;
5fc43f28 124}
630711ed 125