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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONClusterStoreV2Iterator
21 /// Implementation of TIterator for AliMUONClusterStoreV2
23 /// \author Philippe Pillot, Subatech
25 //-----------------------------------------------------------------------------
27 #include "AliMUONClusterStoreV2Iterator.h"
29 #include "AliMUONClusterStoreV2.h"
31 #include "AliMpExMap.h"
36 ClassImp(AliMUONClusterStoreV2Iterator)
39 //_____________________________________________________________________________
40 AliMUONClusterStoreV2Iterator::AliMUONClusterStoreV2Iterator(const AliMUONClusterStoreV2* store,
41 Int_t firstChamberId, Int_t lastChamberId)
44 fFirstChamberId(firstChamberId),
45 fLastChamberId(lastChamberId),
46 fCurrentChamberId(-1),
49 /// Constructor for partial iteration
50 if (fFirstChamberId > fLastChamberId) {
51 fLastChamberId = fFirstChamberId;
52 fFirstChamberId = lastChamberId;
57 //_____________________________________________________________________________
58 AliMUONClusterStoreV2Iterator::AliMUONClusterStoreV2Iterator(const AliMUONClusterStoreV2Iterator& iter)
61 fFirstChamberId(iter.fFirstChamberId),
62 fLastChamberId(iter.fLastChamberId),
63 fCurrentChamberId(iter.fCurrentChamberId),
67 if (iter.fChamberIterator) fChamberIterator = new TExMapIter(*(iter.fChamberIterator));
70 //_____________________________________________________________________________
71 AliMUONClusterStoreV2Iterator& AliMUONClusterStoreV2Iterator::operator=(const AliMUONClusterStoreV2Iterator& iter)
73 /// Assignment operator
74 if ( this != &iter ) {
75 fFirstChamberId = iter.fFirstChamberId;
76 fLastChamberId = iter.fLastChamberId;
77 fCurrentChamberId = iter.fCurrentChamberId;
78 delete fChamberIterator;
79 fChamberIterator = 0x0;
80 if (iter.fChamberIterator) fChamberIterator = new TExMapIter(*(iter.fChamberIterator));
85 //_____________________________________________________________________________
86 TIterator& AliMUONClusterStoreV2Iterator::operator=(const TIterator& iter)
88 /// Overriden operator= (imposed by Root's definition of TIterator::operator= ?)
89 if ( this != &iter && iter.IsA() == AliMUONClusterStoreV2Iterator::Class() ) {
90 (*this) = static_cast<const AliMUONClusterStoreV2Iterator&>(iter);
95 //_____________________________________________________________________________
96 AliMUONClusterStoreV2Iterator::~AliMUONClusterStoreV2Iterator()
99 delete fChamberIterator;
102 //_____________________________________________________________________________
103 TObject* AliMUONClusterStoreV2Iterator::NextInCurrentChamber() const
105 /// Return the value corresponding to theKey in iterator iter
107 if (fChamberIterator->Next(key,value)) return reinterpret_cast<TObject*>(value);
111 //_____________________________________________________________________________
112 TObject* AliMUONClusterStoreV2Iterator::Next()
114 /// Return next cluster in store
115 TObject* o = NextInCurrentChamber();
118 // fChamberIterator exhausted, try to get the next ones
119 if (fCurrentChamberId == fLastChamberId) return 0x0; // we reached the end
122 delete fChamberIterator;
123 fChamberIterator = new TExMapIter(static_cast<AliMpExMap*>(fStore->fMap->UncheckedAt(fCurrentChamberId))->GetIterator());
125 o = NextInCurrentChamber();
131 //_____________________________________________________________________________
132 void AliMUONClusterStoreV2Iterator::Reset()
134 /// Reset the iterator
135 fCurrentChamberId = fFirstChamberId;
136 delete fChamberIterator;
137 fChamberIterator = new TExMapIter(static_cast<AliMpExMap*>(fStore->fMap->UncheckedAt(fCurrentChamberId))->GetIterator());