]>
Commit | Line | Data |
---|---|---|
97d7844b | 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 | //----------------------------------------------------------------------------- |
97d7844b | 19 | /// \class AliMUONDigitStoreVImplIterator |
20 | /// | |
21 | /// Implementation of AliMUONVDataIterator for AliMUONDigitStoreVImpl | |
22 | /// | |
23 | /// \author Laurent Aphecetche, Subatech | |
24 | /// | |
3d1463c8 | 25 | //----------------------------------------------------------------------------- |
97d7844b | 26 | |
27 | #include "AliMUONDigitStoreVImplIterator.h" | |
28 | ||
29 | #include "AliMUONVDigit.h" | |
30 | #include "AliMUONDigitStoreVImpl.h" | |
31 | #include "AliMUON2DMap.h" | |
32 | #include "AliMUONVCalibParam.h" | |
33 | #include <TClonesArray.h> | |
34 | #include <TError.h> | |
35 | ||
36 | /// \cond CLASSIMP | |
37 | ClassImp(AliMUONDigitStoreVImplIterator) | |
38 | /// \endcond | |
39 | ||
40 | //_____________________________________________________________________________ | |
41 | AliMUONDigitStoreVImplIterator::AliMUONDigitStoreVImplIterator(const AliMUONDigitStoreVImpl* store) | |
42 | : TIterator(), | |
43 | fStore(store), | |
44 | fFirstDetElemId(100), | |
45 | fLastDetElemId(1417), | |
46 | fCathode(2), | |
47 | fStoreIterator(store->fMap->CreateIterator()), | |
48 | fCurrentCalibParam(0x0), | |
49 | fCurrentCalibParamIndex(-1) | |
50 | { | |
51 | /// ctor for full iteration | |
52 | } | |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | AliMUONDigitStoreVImplIterator::AliMUONDigitStoreVImplIterator(const AliMUONDigitStoreVImpl* store, | |
caa04e49 | 56 | Int_t firstDE, |
57 | Int_t lastDE, | |
58 | Int_t cathode) | |
97d7844b | 59 | : TIterator(), |
60 | fStore(store), | |
61 | fFirstDetElemId(firstDE), | |
62 | fLastDetElemId(lastDE), | |
63 | fCathode(cathode), | |
64 | fStoreIterator(store->fMap->CreateIterator(firstDE,lastDE)), | |
65 | fCurrentCalibParam(0x0), | |
66 | fCurrentCalibParamIndex(-1) | |
67 | { | |
68 | /// ctor for partial iteration | |
69 | } | |
70 | ||
71 | //_____________________________________________________________________________ | |
72 | AliMUONDigitStoreVImplIterator::AliMUONDigitStoreVImplIterator(const AliMUONDigitStoreVImplIterator& rhs) | |
73 | : TIterator(rhs), | |
74 | fStore(rhs.fStore), | |
75 | fFirstDetElemId(rhs.fFirstDetElemId), | |
76 | fLastDetElemId(rhs.fLastDetElemId), | |
77 | fCathode(rhs.fCathode), | |
78 | fStoreIterator(0x0), | |
79 | fCurrentCalibParam(0x0), | |
80 | fCurrentCalibParamIndex(-1) | |
81 | { | |
82 | /// copy ctor | |
83 | Fatal("AliMUONDigitStoreVImplIterator::copy tor","Not implementeable"); // because there's no clone in TIterator :-( | |
84 | } | |
85 | ||
86 | //_____________________________________________________________________________ | |
87 | AliMUONDigitStoreVImplIterator& | |
88 | AliMUONDigitStoreVImplIterator::operator=(const AliMUONDigitStoreVImplIterator&) | |
89 | { | |
90 | /// assignment operator | |
91 | Fatal("AliMUONDigitStoreVImplIterator::operator=","Not implementeable"); // because there's no clone in TIterator :-( | |
92 | return *this; | |
93 | } | |
94 | ||
95 | //_____________________________________________________________________________ | |
96 | TIterator& | |
97 | AliMUONDigitStoreVImplIterator::operator=(const TIterator&) | |
98 | { | |
99 | /// overriden assignment operator (imposed by Root's declaration of Titerator ?) | |
100 | Fatal("TIterator::operator=","Not implementeable"); // because there's no clone in TIterator :-( | |
101 | return *this; | |
102 | } | |
103 | ||
104 | //_____________________________________________________________________________ | |
105 | AliMUONDigitStoreVImplIterator::~AliMUONDigitStoreVImplIterator() | |
106 | { | |
107 | /// dtor | |
108 | delete fStoreIterator; | |
109 | } | |
110 | ||
111 | //_____________________________________________________________________________ | |
112 | TObject* | |
113 | AliMUONDigitStoreVImplIterator::Next() | |
114 | { | |
115 | /// Return next digit in store | |
116 | if ( !fCurrentCalibParam ) | |
117 | { | |
118 | fCurrentCalibParam = static_cast<AliMUONVCalibParam*>(fStoreIterator->Next()); | |
119 | fCurrentCalibParamIndex = 0; | |
120 | if ( !fCurrentCalibParam ) return 0x0; | |
121 | } | |
caa04e49 | 122 | |
97d7844b | 123 | Int_t ix(-1); |
124 | AliMUONVDigit* d(0x0); | |
125 | ||
126 | if ( fCathode == 2 ) | |
127 | { | |
128 | while ( fCurrentCalibParamIndex < 64 && ix < 0 ) | |
129 | { | |
130 | ix = fCurrentCalibParam->ValueAsInt(fCurrentCalibParamIndex++); | |
131 | }; | |
132 | ||
133 | if (ix>=0) | |
134 | { | |
135 | d = static_cast<AliMUONVDigit*>(fStore->fDigits->UncheckedAt(ix)); | |
136 | } | |
137 | } | |
138 | else | |
139 | { | |
caa04e49 | 140 | while ( d == 0x0 ) |
97d7844b | 141 | { |
caa04e49 | 142 | while ( fCurrentCalibParamIndex < 64 && ix < 0 ) |
143 | { | |
144 | ix = fCurrentCalibParam->ValueAsInt(fCurrentCalibParamIndex++); | |
145 | }; | |
97d7844b | 146 | |
caa04e49 | 147 | if (ix>=0) |
148 | { | |
149 | d = static_cast<AliMUONVDigit*>(fStore->fDigits->UncheckedAt(ix)); | |
150 | ||
151 | if ( fCathode == 2 || d->Cathode() == fCathode ) | |
152 | { | |
153 | break; | |
154 | } | |
155 | d = 0x0; | |
156 | ix = -1; | |
157 | } | |
158 | else | |
97d7844b | 159 | { |
160 | break; | |
161 | } | |
97d7844b | 162 | } |
163 | } | |
97d7844b | 164 | |
165 | if (ix<0) | |
166 | { | |
167 | fCurrentCalibParam = 0x0; | |
168 | return Next(); | |
169 | } | |
170 | ||
171 | return d; | |
172 | } | |
173 | ||
174 | //_____________________________________________________________________________ | |
175 | void | |
176 | AliMUONDigitStoreVImplIterator::Reset() | |
177 | { | |
178 | /// Reset the iterator | |
179 | fCurrentCalibParam = 0x0; | |
180 | fCurrentCalibParamIndex = 0; | |
181 | fStoreIterator->Reset(); | |
182 | } |