]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON2DMapIterator.cxx
hardcoded detector position; bug in alignment pth fixed
[u/mrichter/AliRoot.git] / MUON / AliMUON2DMapIterator.cxx
CommitLineData
f246123b 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
18#include "AliMUON2DMapIterator.h"
19#include "AliMpExMap.h"
20#include "TMap.h"
21#include "AliLog.h"
22#include "AliMpIntPair.h"
23
24/// \class AliMUON2DMapIterator
25/// \brief Implementation of AliMUONVDataIterator for 2Dmaps
26///
27/// A simple implementation of VDataIterator for 2Dmaps.
28///
29/// \author Laurent Aphecetche
30
31/// \cond CLASSIMP
32ClassImp(AliMUON2DMapIterator)
33/// \endcond
34
35//_____________________________________________________________________________
36AliMUON2DMapIterator::AliMUON2DMapIterator(AliMpExMap& theMap)
37: AliMUONVDataIterator(),
38fIter(theMap.GetIterator()),
39fIter2(0x0),
40fCurrentI(-1),
41fCurrentJ(-1)
42{
43 // default ctor
44 Reset();
45}
46
47//_____________________________________________________________________________
48AliMUON2DMapIterator::~AliMUON2DMapIterator()
49{
50 // dtor
51 delete fIter2;
52}
53
54//_____________________________________________________________________________
55TObject*
56AliMUON2DMapIterator::GetValue(TExMapIter& iter, Int_t& theKey) const
57{
58 // return the value corresponding to theKey in iterator iter
59 theKey = -1;
60 Long_t key, value;
61 Bool_t ok = iter.Next(key,value);
62 if (!ok) return 0x0;
63 theKey = (Int_t)(key & 0xFFFF);
64 return reinterpret_cast<TObject*>(value);
65}
66
67//_____________________________________________________________________________
68AliMpExMap*
69AliMUON2DMapIterator::GetMap(TExMapIter& iter, Int_t& key)
70{
71 // get the map corresponding to key
72 AliMpExMap* rv(0x0);
73 TObject* o = GetValue(iter,key);
74 if (o)
75 {
76 rv = dynamic_cast<AliMpExMap*>(o);
77 if (!rv)
78 {
79 AliFatal("boom");
80 }
81 }
82 return rv;
83}
84
85//_____________________________________________________________________________
86TObject*
87AliMUON2DMapIterator::Next()
88{
89 // logic :
90 // get TObject* from fIter2
91 // if null, increment fIter2 by getting next on fIter
92
93 if (!fIter2) return 0x0;
94
95 TObject* o = GetValue(*fIter2,fCurrentJ);
96 if (!o)
97 {
98 // fIter2 exhausted, try to get the next one
99 AliMpExMap* m = GetMap(fIter,fCurrentI);
100 if (!m)
101 {
102 // nothing left, we are done.
103 return 0x0;
104 }
105 delete fIter2;
106 fIter2 = new TExMapIter(m->GetIterator());
107 o = GetValue(*fIter2,fCurrentJ);
108 }
109 return new TPair(new AliMpIntPair(fCurrentI,fCurrentJ),o);
110}
111
112//_____________________________________________________________________________
113void
114AliMUON2DMapIterator::Reset()
115{
116 // rewind the iterator
117 delete fIter2;
118 fIter.Reset();
119 AliMpExMap* m = GetMap(fIter,fCurrentI);
120 if (m)
121 {
122 fIter2 = new TExMapIter(m->GetIterator());
123 }
124}
125
126//_____________________________________________________________________________
127Bool_t
128AliMUON2DMapIterator::Remove()
129{
130 // to be implemented if needed
131 AliInfo("Not supported yet");
132 return kFALSE;
133}