]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterStoreV2Iterator.cxx
AliMUONDigitCalibrator
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterStoreV2Iterator.cxx
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 //-----------------------------------------------------------------------------
19 /// \class AliMUONClusterStoreV2Iterator
20 ///
21 /// Implementation of TIterator for AliMUONClusterStoreV2
22 ///
23 /// \author Philippe Pillot, Subatech
24 ///
25 //-----------------------------------------------------------------------------
26
27 #include "AliMUONClusterStoreV2Iterator.h"
28 #include "AliMUONClusterStoreV2.h"
29
30 #include "AliMpExMapIterator.h"
31 #include "AliMpExMap.h"
32
33 #include "AliLog.h"
34
35 /// \cond CLASSIMP
36 ClassImp(AliMUONClusterStoreV2Iterator)
37 /// \endcond
38
39 //_____________________________________________________________________________
40 AliMUONClusterStoreV2Iterator::AliMUONClusterStoreV2Iterator(const AliMUONClusterStoreV2* store,
41                                                              Int_t firstChamberId, Int_t lastChamberId)
42 : TIterator(),
43   fStore(store),
44   fFirstChamberId(firstChamberId),
45   fLastChamberId(lastChamberId),
46   fCurrentChamberId(-1),
47   fChamberIterator(0x0)
48 {
49   /// Constructor for partial iteration
50   if (fFirstChamberId > fLastChamberId) {
51     fLastChamberId = fFirstChamberId;
52     fFirstChamberId = lastChamberId;
53   }
54   Reset();
55 }
56
57 //_____________________________________________________________________________
58 TIterator& AliMUONClusterStoreV2Iterator::operator=(const TIterator& /*iter*/)
59 {
60   /// Overriden operator= (imposed by Root's definition of TIterator::operator= ?)
61 /*
62   if ( this != &iter && iter.IsA() == AliMUONClusterStoreV2Iterator::Class() ) {
63     (*this) = static_cast<const AliMUONClusterStoreV2Iterator&>(iter);
64   }
65 */
66   AliFatalGeneral("AliMUONClusterStoreV2Iterator::operator=","reimplement me");
67   return *this;
68 }
69
70 //_____________________________________________________________________________
71 AliMUONClusterStoreV2Iterator::~AliMUONClusterStoreV2Iterator()
72 {
73   /// Destructor
74   delete fChamberIterator;
75 }
76
77 //_____________________________________________________________________________
78 TObject* AliMUONClusterStoreV2Iterator::NextInCurrentChamber() const
79 {
80   /// Return the value corresponding to theKey in iterator iter
81   
82   return fChamberIterator->Next();
83 }
84
85 //_____________________________________________________________________________
86 TObject* AliMUONClusterStoreV2Iterator::Next()
87 {
88   /// Return next cluster in store
89   TObject* o = NextInCurrentChamber();
90   
91   while (!o) {
92     // fChamberIterator exhausted, try to get the next ones
93     if (fCurrentChamberId == fLastChamberId) return 0x0; // we reached the end
94     
95     fCurrentChamberId++;
96     delete fChamberIterator;
97     fChamberIterator = static_cast<AliMpExMap*>(fStore->fMap->UncheckedAt(fCurrentChamberId))->CreateIterator();
98     
99     o = NextInCurrentChamber();
100   }
101   
102   return o;
103 }
104
105 //_____________________________________________________________________________
106 void AliMUONClusterStoreV2Iterator::Reset()
107 {
108   /// Reset the iterator
109   fCurrentChamberId = fFirstChamberId;
110   delete fChamberIterator;
111   fChamberIterator = static_cast<AliMpExMap*>(fStore->fMap->UncheckedAt(fCurrentChamberId))->CreateIterator();
112 }