Line data Source code
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 18 : ClassImp(AliMUONClusterStoreV2Iterator)
37 : /// \endcond
38 :
39 : //_____________________________________________________________________________
40 : AliMUONClusterStoreV2Iterator::AliMUONClusterStoreV2Iterator(const AliMUONClusterStoreV2* store,
41 : Int_t firstChamberId, Int_t lastChamberId)
42 494 : : TIterator(),
43 494 : fkStore(store),
44 494 : fFirstChamberId(firstChamberId),
45 494 : fLastChamberId(lastChamberId),
46 494 : fCurrentChamberId(-1),
47 494 : fChamberIterator(0x0)
48 2470 : {
49 : /// Constructor for partial iteration
50 494 : if (fFirstChamberId > fLastChamberId) {
51 0 : fLastChamberId = fFirstChamberId;
52 0 : fFirstChamberId = lastChamberId;
53 0 : }
54 494 : Reset();
55 988 : }
56 :
57 : //_____________________________________________________________________________
58 : AliMUONClusterStoreV2Iterator&
59 : AliMUONClusterStoreV2Iterator::operator=(const TIterator& /*iter*/)
60 : {
61 : // Overriden operator= (imposed by Root's definition of TIterator::operator= ?)
62 :
63 0 : AliFatalGeneral("AliMUONClusterStoreV2Iterator::operator=","reimplement me");
64 0 : return *this;
65 : }
66 :
67 : //_____________________________________________________________________________
68 : AliMUONClusterStoreV2Iterator::~AliMUONClusterStoreV2Iterator()
69 2964 : {
70 : /// Destructor
71 988 : delete fChamberIterator;
72 1482 : }
73 :
74 : //_____________________________________________________________________________
75 : TObject* AliMUONClusterStoreV2Iterator::NextInCurrentChamber() const
76 : {
77 : /// Return the value corresponding to theKey in iterator iter
78 :
79 3696 : return fChamberIterator->Next();
80 : }
81 :
82 : //_____________________________________________________________________________
83 : TObject* AliMUONClusterStoreV2Iterator::Next()
84 : {
85 : /// Return next cluster in store
86 3696 : TObject* o = NextInCurrentChamber();
87 :
88 3696 : while (!o) {
89 : // fChamberIterator exhausted, try to get the next ones
90 1212 : if (fCurrentChamberId == fLastChamberId) return 0x0; // we reached the end
91 :
92 0 : fCurrentChamberId++;
93 0 : delete fChamberIterator;
94 0 : fChamberIterator = static_cast<AliMpExMap*>(fkStore->fMap->UncheckedAt(fCurrentChamberId))->CreateIterator();
95 :
96 0 : o = NextInCurrentChamber();
97 : }
98 :
99 1242 : return o;
100 1848 : }
101 :
102 : //_____________________________________________________________________________
103 : void AliMUONClusterStoreV2Iterator::Reset()
104 : {
105 : /// Reset the iterator
106 1428 : fCurrentChamberId = fFirstChamberId;
107 934 : delete fChamberIterator;
108 714 : fChamberIterator = static_cast<AliMpExMap*>(fkStore->fMap->UncheckedAt(fCurrentChamberId))->CreateIterator();
109 714 : }
|