Coding conventions (Laurent)
[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
23///
85fec35d 24/// \class AliMUONDataDigitIterator
25///
70b4a8d6 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
34//_____________________________________________________________________________
35AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONData* data,
36 Int_t firstChamber,
37 Int_t lastChamber)
38:
39AliMUONVDataIterator(),
40fData(data),
41fFirstChamber(firstChamber),
42fLastChamber(lastChamber)
43{
44 //
45 // Ctor
46 //
47 Reset();
48}
49
50//_____________________________________________________________________________
51AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONDataDigitIterator& rhs)
52:
53AliMUONVDataIterator()
54{
55 rhs.CopyTo(*this);
56}
57
58//_____________________________________________________________________________
59AliMUONDataDigitIterator&
60AliMUONDataDigitIterator::operator=(const AliMUONDataDigitIterator& rhs)
61{
62 rhs.CopyTo(*this);
63 return *this;
64}
65
66//_____________________________________________________________________________
67void
68AliMUONDataDigitIterator::CopyTo(AliMUONDataDigitIterator& destination) const
69{
85fec35d 70 // Copy *this to destination
70b4a8d6 71 destination.fData=fData;
72 destination.fFirstChamber=fFirstChamber;
73 destination.fLastChamber=fLastChamber;
74 destination.fCurrentDigit=fCurrentDigit;
75 destination.fCurrentChamber=fCurrentChamber;
76 destination.fDigits=fDigits;
77}
78
79//_____________________________________________________________________________
80TObject*
81AliMUONDataDigitIterator::Next()
82{
83 // Return current element and self-position to the next one.
84
85 TObject* rv(0x0);
86
87 if ( fDigits )
88 {
89 // get the pointer to be returned
90 rv = fDigits->At(fCurrentDigit);
91 // prepare for the next position, if it exists
92 if ( fCurrentDigit < fDigits->GetLast() )
93 {
94 ++fCurrentDigit;
95 }
96 else
97 {
98 fCurrentDigit = 0;
99 ++fCurrentChamber;
100 if ( fCurrentChamber <= fLastChamber )
101 {
102 fDigits = fData->Digits(fCurrentChamber);
103 }
104 else
105 {
106 fDigits = 0x0;
107 }
108 }
109 }
110
111 return rv;
112}
113
114//_____________________________________________________________________________
115Bool_t
116AliMUONDataDigitIterator::Remove()
117{
118 // Remove current element.
119
120 if ( fDigits )
121 {
122 fDigits->RemoveAt(fCurrentDigit);
123 fDigits->Compress();
124 return kTRUE;
125 }
126
127 return kFALSE;
128}
129
130//_____________________________________________________________________________
131void
132AliMUONDataDigitIterator::Reset()
133{
85fec35d 134 // Resets the iterator
70b4a8d6 135 fData->GetDigits();
136 fCurrentDigit = 0;
137 fCurrentChamber = fFirstChamber;
138 fDigits = fData->Digits(fCurrentChamber);
139}