]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDataDigitIterator.cxx
Not needed.
[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 {
48   /// Standard constructor
49   Reset();
50 }
51
52 //_____________________________________________________________________________
53 AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONDataDigitIterator& rhs)
54
55 AliMUONVDataIterator()
56 {
57   /// Copy constructor
58
59   rhs.CopyTo(*this);
60 }
61
62 //_____________________________________________________________________________
63 AliMUONDataDigitIterator::~AliMUONDataDigitIterator()
64 {
65   /// Destructor
66 }
67
68 //_____________________________________________________________________________
69 AliMUONDataDigitIterator&
70 AliMUONDataDigitIterator::operator=(const AliMUONDataDigitIterator& rhs)
71 {
72   /// Assignment operator
73
74   rhs.CopyTo(*this);
75   return *this;
76 }
77
78 //_____________________________________________________________________________
79 void
80 AliMUONDataDigitIterator::CopyTo(AliMUONDataDigitIterator& destination) const
81 {
82   /// Copy *this to destination
83   destination.fData=fData;
84   destination.fFirstChamber=fFirstChamber;
85   destination.fLastChamber=fLastChamber;
86   destination.fCurrentDigit=fCurrentDigit;
87   destination.fCurrentChamber=fCurrentChamber;
88   destination.fDigits=fDigits;
89 }
90
91 //_____________________________________________________________________________
92 TObject*
93 AliMUONDataDigitIterator::Next()
94 {
95   /// Return current element and self-position to the next one.
96   
97   TObject* rv(0x0);
98   
99   if ( fDigits ) 
100   {
101     // get the pointer to be returned
102     rv = fDigits->At(fCurrentDigit);
103     // prepare for the next position, if it exists
104     if ( fCurrentDigit < fDigits->GetLast() ) 
105     {
106       ++fCurrentDigit;
107     }
108     else
109     {
110       fCurrentDigit = 0;
111       ++fCurrentChamber;
112       if ( fCurrentChamber <= fLastChamber )
113       {
114         fDigits = fData->Digits(fCurrentChamber);
115       }
116       else
117       {
118         fDigits = 0x0;
119       }
120     }
121   }
122   
123   return rv;
124 }
125
126 //_____________________________________________________________________________
127 Bool_t
128 AliMUONDataDigitIterator::Remove()
129 {
130   /// Remove current element.
131   
132   if ( fDigits ) 
133   {
134     fDigits->RemoveAt(fCurrentDigit);
135     fDigits->Compress();
136     return kTRUE;
137   }
138   
139   return kFALSE;
140 }
141
142 //_____________________________________________________________________________
143 void
144 AliMUONDataDigitIterator::Reset()
145 {
146   /// Reset the iterator
147   fData->GetDigits();
148   fCurrentDigit = 0;
149   fCurrentChamber = fFirstChamber;
150   fDigits = fData->Digits(fCurrentChamber);
151 }