]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTOTCAStoreIterator.cxx
New raw-reader class which deals with events taken from shared memory via the DATE...
[u/mrichter/AliRoot.git] / MUON / AliMUONTOTCAStoreIterator.cxx
CommitLineData
55ab3bd1 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//-----------------------------------------------------------------------------
55ab3bd1 19/// \class AliMUONTOTCAStoreIterator
20///
21/// An iterator to access TObject stored in a TObjArray of TClonesArray
22///
55ab3bd1 23/// \author Laurent Aphecetche, Subatech
3d1463c8 24//-----------------------------------------------------------------------------
55ab3bd1 25
26#include "AliMUONTOTCAStoreIterator.h"
27
28#include <TClonesArray.h>
29#include <TObjArray.h>
30
31/// \cond CLASSIMP
32ClassImp(AliMUONTOTCAStoreIterator)
33/// \endcond
34
35//_____________________________________________________________________________
36AliMUONTOTCAStoreIterator::AliMUONTOTCAStoreIterator(const TObjArray* data,
37 Int_t firstChamberId,
38 Int_t lastChamberId)
39:
40TIterator(),
41fData(data),
42fFirstChamberId(firstChamberId),
43fLastChamberId(lastChamberId),
44fCurrentTCA(0x0),
45fCurrentTCAIndex(-1),
46fCurrentChamberId(-1)
47{
48 /// Standard constructor
49 Reset();
50}
51
52//_____________________________________________________________________________
53TIterator&
54AliMUONTOTCAStoreIterator::operator=(const TIterator& rhs)
55{
56 /// Overriden operator= (imposed by Root's declaration of TIterator ?)
57 if ( this != &rhs && rhs.IsA() == AliMUONTOTCAStoreIterator::Class() )
58 {
59 const AliMUONTOTCAStoreIterator& rhs1 =
60 static_cast<const AliMUONTOTCAStoreIterator&>(rhs);
61
62 rhs1.CopyTo(*this);
63 }
64 return *this;
65}
66
67//_____________________________________________________________________________
68AliMUONTOTCAStoreIterator::AliMUONTOTCAStoreIterator(const AliMUONTOTCAStoreIterator& rhs)
69:
70TIterator(rhs),
71fData(0x0),
72fFirstChamberId(-1),
73fLastChamberId(-1),
74fCurrentTCA(0x0),
75fCurrentTCAIndex(-1),
76fCurrentChamberId(-1)
77{
78 /// Copy constructor
79
80 rhs.CopyTo(*this);
81}
82
83//_____________________________________________________________________________
84AliMUONTOTCAStoreIterator::~AliMUONTOTCAStoreIterator()
85{
86 /// Destructor
87}
88
89//_____________________________________________________________________________
90AliMUONTOTCAStoreIterator&
91AliMUONTOTCAStoreIterator::operator=(const AliMUONTOTCAStoreIterator& rhs)
92{
93 /// Assignment operator
94
95 rhs.CopyTo(*this);
96 return *this;
97}
98
99//_____________________________________________________________________________
100void
101AliMUONTOTCAStoreIterator::CopyTo(AliMUONTOTCAStoreIterator& destination) const
102{
103 /// Copy *this to destination
104 destination.fData=fData;
105 destination.fFirstChamberId=fFirstChamberId;
106 destination.fLastChamberId=fLastChamberId;
107 destination.fCurrentTCAIndex=fCurrentTCAIndex;
108 destination.fCurrentChamberId=fCurrentChamberId;
109 destination.fCurrentTCA=fCurrentTCA;
110}
111
112//_____________________________________________________________________________
113const TCollection*
114AliMUONTOTCAStoreIterator::GetCollection() const
115{
116 /// The top level collection we're iterating upon, i.e. a TObjArray
117 return fData;
118}
119
120//_____________________________________________________________________________
121TObject*
122AliMUONTOTCAStoreIterator::Next()
123{
124 /// Find and return next element in the store
125
126 if ( fCurrentTCA && fCurrentTCAIndex < fCurrentTCA->GetLast() )
127 {
128 ++fCurrentTCAIndex;
129 }
130 else
131 {
132 fCurrentTCAIndex = 0;
133 fCurrentTCA = 0;
134
135 while ( ( !fCurrentTCA || fCurrentTCA->GetLast()==-1 ) &&
136 fCurrentChamberId < fLastChamberId )
137 {
138 ++fCurrentChamberId;
139 fCurrentTCA = static_cast<TClonesArray*>(fData->At(fCurrentChamberId));
140 }
141 }
142
143 if ( fCurrentTCA )
144 {
145 // get the pointer to be returned
146 return fCurrentTCA->At(fCurrentTCAIndex);
147 }
148
149 return 0x0;
150}
151
152//_____________________________________________________________________________
153void
154AliMUONTOTCAStoreIterator::Reset()
155{
156 /// Reset the iterator
157 fCurrentTCAIndex = -1;
158 fCurrentChamberId = fFirstChamberId-1;
159 fCurrentTCA = 0x0;
160}