]>
Commit | Line | Data |
---|---|---|
70b4a8d6 | 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 "AliMUONDigit.h" | |
22 | #include "TClonesArray.h" | |
23 | ||
24 | /// | |
25 | /// An iterator to access digits (stored into AliMUONData). | |
26 | /// | |
27 | /// Iteration can occur on tracking chambers only, trigger chambers only, | |
28 | /// or both. | |
29 | /// | |
30 | ||
31 | //_____________________________________________________________________________ | |
32 | AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONData* data, | |
33 | Int_t firstChamber, | |
34 | Int_t lastChamber) | |
35 | : | |
36 | AliMUONVDataIterator(), | |
37 | fData(data), | |
38 | fFirstChamber(firstChamber), | |
39 | fLastChamber(lastChamber) | |
40 | { | |
41 | // | |
42 | // Ctor | |
43 | // | |
44 | Reset(); | |
45 | } | |
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONDataDigitIterator& rhs) | |
49 | : | |
50 | AliMUONVDataIterator() | |
51 | { | |
52 | rhs.CopyTo(*this); | |
53 | } | |
54 | ||
55 | //_____________________________________________________________________________ | |
56 | AliMUONDataDigitIterator& | |
57 | AliMUONDataDigitIterator::operator=(const AliMUONDataDigitIterator& rhs) | |
58 | { | |
59 | rhs.CopyTo(*this); | |
60 | return *this; | |
61 | } | |
62 | ||
63 | //_____________________________________________________________________________ | |
64 | void | |
65 | AliMUONDataDigitIterator::CopyTo(AliMUONDataDigitIterator& destination) const | |
66 | { | |
67 | destination.fData=fData; | |
68 | destination.fFirstChamber=fFirstChamber; | |
69 | destination.fLastChamber=fLastChamber; | |
70 | destination.fCurrentDigit=fCurrentDigit; | |
71 | destination.fCurrentChamber=fCurrentChamber; | |
72 | destination.fDigits=fDigits; | |
73 | } | |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | TObject* | |
77 | AliMUONDataDigitIterator::Next() | |
78 | { | |
79 | // Return current element and self-position to the next one. | |
80 | ||
81 | TObject* rv(0x0); | |
82 | ||
83 | if ( fDigits ) | |
84 | { | |
85 | // get the pointer to be returned | |
86 | rv = fDigits->At(fCurrentDigit); | |
87 | // prepare for the next position, if it exists | |
88 | if ( fCurrentDigit < fDigits->GetLast() ) | |
89 | { | |
90 | ++fCurrentDigit; | |
91 | } | |
92 | else | |
93 | { | |
94 | fCurrentDigit = 0; | |
95 | ++fCurrentChamber; | |
96 | if ( fCurrentChamber <= fLastChamber ) | |
97 | { | |
98 | fDigits = fData->Digits(fCurrentChamber); | |
99 | } | |
100 | else | |
101 | { | |
102 | fDigits = 0x0; | |
103 | } | |
104 | } | |
105 | } | |
106 | ||
107 | return rv; | |
108 | } | |
109 | ||
110 | //_____________________________________________________________________________ | |
111 | Bool_t | |
112 | AliMUONDataDigitIterator::Remove() | |
113 | { | |
114 | // Remove current element. | |
115 | ||
116 | if ( fDigits ) | |
117 | { | |
118 | fDigits->RemoveAt(fCurrentDigit); | |
119 | fDigits->Compress(); | |
120 | return kTRUE; | |
121 | } | |
122 | ||
123 | return kFALSE; | |
124 | } | |
125 | ||
126 | //_____________________________________________________________________________ | |
127 | void | |
128 | AliMUONDataDigitIterator::Reset() | |
129 | { | |
130 | fData->GetDigits(); | |
131 | fCurrentDigit = 0; | |
132 | fCurrentChamber = fFirstChamber; | |
133 | fDigits = fData->Digits(fCurrentChamber); | |
134 | } |