]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDataDigitIterator.cxx
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / AliMUONDataDigitIterator.cxx
CommitLineData
70b4a8d6 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#include "AliMUONDataDigitIterator.h"
19
20#include "AliMUONData.h"
70b4a8d6 21#include "TClonesArray.h"
22
85fec35d 23///
24/// \class AliMUONDataDigitIterator
70b4a8d6 25///
26/// An iterator to access digits (stored into AliMUONData).
27///
28/// Iteration can occur on tracking chambers only, trigger chambers only,
29/// or both.
30///
85fec35d 31/// \author L. Aphecetche
32///
70b4a8d6 33
5398f946 34/// \cond CLASSIMP
35ClassImp(AliMUONDataDigitIterator)
36/// \endcond
37
70b4a8d6 38//_____________________________________________________________________________
39AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONData* data,
40 Int_t firstChamber,
41 Int_t lastChamber)
42:
43AliMUONVDataIterator(),
44fData(data),
45fFirstChamber(firstChamber),
ccea41d4 46fLastChamber(lastChamber),
47fDigits(0x0),
48fCurrentDigit(-1),
49fCurrentChamber(-1)
70b4a8d6 50{
5398f946 51 /// Standard constructor
70b4a8d6 52 Reset();
53}
54
55//_____________________________________________________________________________
56AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONDataDigitIterator& rhs)
57:
ccea41d4 58AliMUONVDataIterator(),
59fData(0x0),
60fFirstChamber(-1),
61fLastChamber(-1),
62fDigits(0x0),
63fCurrentDigit(-1),
64fCurrentChamber(-1)
70b4a8d6 65{
5398f946 66 /// Copy constructor
67
70b4a8d6 68 rhs.CopyTo(*this);
69}
70
5398f946 71//_____________________________________________________________________________
72AliMUONDataDigitIterator::~AliMUONDataDigitIterator()
73{
74 /// Destructor
75}
76
70b4a8d6 77//_____________________________________________________________________________
78AliMUONDataDigitIterator&
79AliMUONDataDigitIterator::operator=(const AliMUONDataDigitIterator& rhs)
80{
5398f946 81 /// Assignment operator
82
70b4a8d6 83 rhs.CopyTo(*this);
84 return *this;
85}
86
87//_____________________________________________________________________________
88void
89AliMUONDataDigitIterator::CopyTo(AliMUONDataDigitIterator& destination) const
90{
5398f946 91 /// Copy *this to destination
70b4a8d6 92 destination.fData=fData;
93 destination.fFirstChamber=fFirstChamber;
94 destination.fLastChamber=fLastChamber;
95 destination.fCurrentDigit=fCurrentDigit;
96 destination.fCurrentChamber=fCurrentChamber;
97 destination.fDigits=fDigits;
98}
99
100//_____________________________________________________________________________
101TObject*
102AliMUONDataDigitIterator::Next()
103{
5398f946 104 /// Return current element and self-position to the next one.
70b4a8d6 105
106 TObject* rv(0x0);
107
108 if ( fDigits )
109 {
110 // get the pointer to be returned
111 rv = fDigits->At(fCurrentDigit);
112 // prepare for the next position, if it exists
113 if ( fCurrentDigit < fDigits->GetLast() )
114 {
115 ++fCurrentDigit;
116 }
117 else
118 {
119 fCurrentDigit = 0;
120 ++fCurrentChamber;
121 if ( fCurrentChamber <= fLastChamber )
122 {
123 fDigits = fData->Digits(fCurrentChamber);
124 }
125 else
126 {
127 fDigits = 0x0;
128 }
129 }
130 }
131
132 return rv;
133}
134
135//_____________________________________________________________________________
136Bool_t
137AliMUONDataDigitIterator::Remove()
138{
5398f946 139 /// Remove current element.
70b4a8d6 140
141 if ( fDigits )
142 {
143 fDigits->RemoveAt(fCurrentDigit);
144 fDigits->Compress();
145 return kTRUE;
146 }
147
148 return kFALSE;
149}
150
151//_____________________________________________________________________________
152void
153AliMUONDataDigitIterator::Reset()
154{
5398f946 155 /// Reset the iterator
70b4a8d6 156 fData->GetDigits();
157 fCurrentDigit = 0;
158 fCurrentChamber = fFirstChamber;
159 fDigits = fData->Digits(fCurrentChamber);
160}