]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDataDigitIterator.cxx
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / AliMUONDataDigitIterator.cxx
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 "TClonesArray.h"
22
23 ///
24 /// \class AliMUONDataDigitIterator
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 ///
31 /// \author L. Aphecetche
32 ///
33
34 /// \cond CLASSIMP
35 ClassImp(AliMUONDataDigitIterator)
36 /// \endcond
37
38 //_____________________________________________________________________________
39 AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONData* data,
40                                                    Int_t firstChamber, 
41                                                    Int_t lastChamber)
42
43 AliMUONVDataIterator(),
44 fData(data),
45 fFirstChamber(firstChamber),
46 fLastChamber(lastChamber),
47 fDigits(0x0),
48 fCurrentDigit(-1),
49 fCurrentChamber(-1)
50 {
51   /// Standard constructor
52   Reset();
53 }
54
55 //_____________________________________________________________________________
56 AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONDataDigitIterator& rhs)
57
58 AliMUONVDataIterator(),
59 fData(0x0),
60 fFirstChamber(-1),
61 fLastChamber(-1),
62 fDigits(0x0),
63 fCurrentDigit(-1),
64 fCurrentChamber(-1)
65 {
66   /// Copy constructor
67
68   rhs.CopyTo(*this);
69 }
70
71 //_____________________________________________________________________________
72 AliMUONDataDigitIterator::~AliMUONDataDigitIterator()
73 {
74   /// Destructor
75 }
76
77 //_____________________________________________________________________________
78 AliMUONDataDigitIterator&
79 AliMUONDataDigitIterator::operator=(const AliMUONDataDigitIterator& rhs)
80 {
81   /// Assignment operator
82
83   rhs.CopyTo(*this);
84   return *this;
85 }
86
87 //_____________________________________________________________________________
88 void
89 AliMUONDataDigitIterator::CopyTo(AliMUONDataDigitIterator& destination) const
90 {
91   /// Copy *this to destination
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 //_____________________________________________________________________________
101 TObject*
102 AliMUONDataDigitIterator::Next()
103 {
104   /// Return current element and self-position to the next one.
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 //_____________________________________________________________________________
136 Bool_t
137 AliMUONDataDigitIterator::Remove()
138 {
139   /// Remove current element.
140   
141   if ( fDigits ) 
142   {
143     fDigits->RemoveAt(fCurrentDigit);
144     fDigits->Compress();
145     return kTRUE;
146   }
147   
148   return kFALSE;
149 }
150
151 //_____________________________________________________________________________
152 void
153 AliMUONDataDigitIterator::Reset()
154 {
155   /// Reset the iterator
156   fData->GetDigits();
157   fCurrentDigit = 0;
158   fCurrentChamber = fFirstChamber;
159   fDigits = fData->Digits(fCurrentChamber);
160 }