- Disentangle masks effect from trigger chamber efficiency estimation.
[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
79dbdbc3 28#include "AliLog.h"
55ab3bd1 29#include <TClonesArray.h>
30#include <TObjArray.h>
31
32/// \cond CLASSIMP
33ClassImp(AliMUONTOTCAStoreIterator)
34/// \endcond
35
36//_____________________________________________________________________________
37AliMUONTOTCAStoreIterator::AliMUONTOTCAStoreIterator(const TObjArray* data,
38 Int_t firstChamberId,
39 Int_t lastChamberId)
40:
41TIterator(),
72dae9ff 42fkData(data),
55ab3bd1 43fFirstChamberId(firstChamberId),
44fLastChamberId(lastChamberId),
45fCurrentTCA(0x0),
46fCurrentTCAIndex(-1),
47fCurrentChamberId(-1)
48{
49 /// Standard constructor
50 Reset();
51}
52
53//_____________________________________________________________________________
6805f5be 54AliMUONTOTCAStoreIterator&
55ab3bd1 55AliMUONTOTCAStoreIterator::operator=(const TIterator& rhs)
56{
57 /// Overriden operator= (imposed by Root's declaration of TIterator ?)
79dbdbc3 58 if ( this != &rhs )
55ab3bd1 59 {
79dbdbc3 60 if ( rhs.IsA() != AliMUONTOTCAStoreIterator::Class() )
61 {
62 AliErrorGeneral("AliMUONTOTCAStoreIterator::operator=","Wrong type");
63 }
64 else
65 {
66 const AliMUONTOTCAStoreIterator& rhs1 =
67 static_cast<const AliMUONTOTCAStoreIterator&>(rhs);
68 rhs1.CopyTo(*this);
69 }
55ab3bd1 70 }
71 return *this;
72}
73
74//_____________________________________________________________________________
75AliMUONTOTCAStoreIterator::AliMUONTOTCAStoreIterator(const AliMUONTOTCAStoreIterator& rhs)
76:
77TIterator(rhs),
72dae9ff 78fkData(0x0),
55ab3bd1 79fFirstChamberId(-1),
80fLastChamberId(-1),
81fCurrentTCA(0x0),
82fCurrentTCAIndex(-1),
83fCurrentChamberId(-1)
84{
85 /// Copy constructor
86
87 rhs.CopyTo(*this);
88}
89
90//_____________________________________________________________________________
91AliMUONTOTCAStoreIterator::~AliMUONTOTCAStoreIterator()
92{
93 /// Destructor
94}
95
96//_____________________________________________________________________________
97AliMUONTOTCAStoreIterator&
98AliMUONTOTCAStoreIterator::operator=(const AliMUONTOTCAStoreIterator& rhs)
99{
100 /// Assignment operator
101
102 rhs.CopyTo(*this);
103 return *this;
104}
105
106//_____________________________________________________________________________
107void
108AliMUONTOTCAStoreIterator::CopyTo(AliMUONTOTCAStoreIterator& destination) const
109{
110 /// Copy *this to destination
72dae9ff 111 destination.fkData=fkData;
55ab3bd1 112 destination.fFirstChamberId=fFirstChamberId;
113 destination.fLastChamberId=fLastChamberId;
114 destination.fCurrentTCAIndex=fCurrentTCAIndex;
115 destination.fCurrentChamberId=fCurrentChamberId;
116 destination.fCurrentTCA=fCurrentTCA;
117}
118
119//_____________________________________________________________________________
120const TCollection*
121AliMUONTOTCAStoreIterator::GetCollection() const
122{
123 /// The top level collection we're iterating upon, i.e. a TObjArray
72dae9ff 124 return fkData;
55ab3bd1 125}
126
127//_____________________________________________________________________________
128TObject*
129AliMUONTOTCAStoreIterator::Next()
130{
131 /// Find and return next element in the store
132
133 if ( fCurrentTCA && fCurrentTCAIndex < fCurrentTCA->GetLast() )
134 {
135 ++fCurrentTCAIndex;
136 }
137 else
138 {
139 fCurrentTCAIndex = 0;
140 fCurrentTCA = 0;
141
142 while ( ( !fCurrentTCA || fCurrentTCA->GetLast()==-1 ) &&
143 fCurrentChamberId < fLastChamberId )
144 {
145 ++fCurrentChamberId;
72dae9ff 146 fCurrentTCA = static_cast<TClonesArray*>(fkData->At(fCurrentChamberId));
55ab3bd1 147 }
148 }
149
150 if ( fCurrentTCA )
151 {
152 // get the pointer to be returned
153 return fCurrentTCA->At(fCurrentTCAIndex);
154 }
155
156 return 0x0;
157}
158
159//_____________________________________________________________________________
160void
161AliMUONTOTCAStoreIterator::Reset()
162{
163 /// Reset the iterator
164 fCurrentTCAIndex = -1;
165 fCurrentChamberId = fFirstChamberId-1;
166 fCurrentTCA = 0x0;
167}