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