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