]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDataDigitIterator.cxx
Initial version
[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"
21#include "AliMUONDigit.h"
22#include "TClonesArray.h"
23
24///
25/// An iterator to access digits (stored into AliMUONData).
26///
27/// Iteration can occur on tracking chambers only, trigger chambers only,
28/// or both.
29///
30
31//_____________________________________________________________________________
32AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONData* data,
33 Int_t firstChamber,
34 Int_t lastChamber)
35:
36AliMUONVDataIterator(),
37fData(data),
38fFirstChamber(firstChamber),
39fLastChamber(lastChamber)
40{
41 //
42 // Ctor
43 //
44 Reset();
45}
46
47//_____________________________________________________________________________
48AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONDataDigitIterator& rhs)
49:
50AliMUONVDataIterator()
51{
52 rhs.CopyTo(*this);
53}
54
55//_____________________________________________________________________________
56AliMUONDataDigitIterator&
57AliMUONDataDigitIterator::operator=(const AliMUONDataDigitIterator& rhs)
58{
59 rhs.CopyTo(*this);
60 return *this;
61}
62
63//_____________________________________________________________________________
64void
65AliMUONDataDigitIterator::CopyTo(AliMUONDataDigitIterator& destination) const
66{
67 destination.fData=fData;
68 destination.fFirstChamber=fFirstChamber;
69 destination.fLastChamber=fLastChamber;
70 destination.fCurrentDigit=fCurrentDigit;
71 destination.fCurrentChamber=fCurrentChamber;
72 destination.fDigits=fDigits;
73}
74
75//_____________________________________________________________________________
76TObject*
77AliMUONDataDigitIterator::Next()
78{
79 // Return current element and self-position to the next one.
80
81 TObject* rv(0x0);
82
83 if ( fDigits )
84 {
85 // get the pointer to be returned
86 rv = fDigits->At(fCurrentDigit);
87 // prepare for the next position, if it exists
88 if ( fCurrentDigit < fDigits->GetLast() )
89 {
90 ++fCurrentDigit;
91 }
92 else
93 {
94 fCurrentDigit = 0;
95 ++fCurrentChamber;
96 if ( fCurrentChamber <= fLastChamber )
97 {
98 fDigits = fData->Digits(fCurrentChamber);
99 }
100 else
101 {
102 fDigits = 0x0;
103 }
104 }
105 }
106
107 return rv;
108}
109
110//_____________________________________________________________________________
111Bool_t
112AliMUONDataDigitIterator::Remove()
113{
114 // Remove current element.
115
116 if ( fDigits )
117 {
118 fDigits->RemoveAt(fCurrentDigit);
119 fDigits->Compress();
120 return kTRUE;
121 }
122
123 return kFALSE;
124}
125
126//_____________________________________________________________________________
127void
128AliMUONDataDigitIterator::Reset()
129{
130 fData->GetDigits();
131 fCurrentDigit = 0;
132 fCurrentChamber = fFirstChamber;
133 fDigits = fData->Digits(fCurrentChamber);
134}