]>
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 "AliMUONDataIterator.h" | |
19 | ||
20 | #include "AliMUONConstants.h" | |
21 | #include "AliMUONData.h" | |
22 | #include "AliMUONDataDigitIterator.h" | |
23 | #include "TString.h" | |
24 | ||
4b6ea57b | 25 | /// \class AliMUONDataIterator |
26 | /// A wrapper to various iterators used to loop over | |
27 | /// objects handled by AliMUONData, like sdigits, digits, rawclusters, | |
28 | /// and so on. | |
29 | /// Currently only implemented for digits, as a proof-of-principle. | |
30 | /// | |
31 | /// \author Laurent Aphecetche | |
70b4a8d6 | 32 | |
5398f946 | 33 | /// \cond CLASSIMP |
34 | ClassImp(AliMUONDataIterator) | |
35 | /// \endcond | |
36 | ||
70b4a8d6 | 37 | namespace |
38 | { | |
39 | void GetChamberNumbers(AliMUONDataIterator::EIterationStyle type, | |
40 | Int_t& firstChamber, Int_t& lastChamber) | |
41 | { | |
42 | switch ( type ) | |
43 | { | |
44 | case AliMUONDataIterator::kAllChambers: | |
45 | firstChamber=0; | |
46 | lastChamber=AliMUONConstants::NCh()-1; | |
47 | break; | |
48 | case AliMUONDataIterator::kTrackingChambers: | |
49 | firstChamber=0; | |
50 | lastChamber=AliMUONConstants::NCh()-1; | |
51 | break; | |
52 | case AliMUONDataIterator::kTriggerChambers: | |
53 | firstChamber=AliMUONConstants::NTrackingCh(); | |
54 | lastChamber=AliMUONConstants::NCh()-1; | |
55 | break; | |
56 | default: | |
57 | firstChamber=lastChamber=-1; | |
58 | break; | |
59 | } | |
60 | } | |
61 | } | |
62 | ||
70b4a8d6 | 63 | //_____________________________________________________________________________ |
64 | AliMUONDataIterator::AliMUONDataIterator() | |
65 | : | |
66 | TObject(), | |
67 | fIterator(0x0) | |
68 | { | |
71a2d3aa | 69 | /// Default constructor |
70b4a8d6 | 70 | } |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | AliMUONDataIterator::AliMUONDataIterator(AliMUONData* data, | |
74 | const char* onWhatToIterate, | |
75 | EIterationStyle howToIterate) | |
76 | : | |
77 | TObject(), | |
78 | fIterator(0x0) | |
79 | { | |
71a2d3aa | 80 | /// Standard constructor |
81 | ||
70b4a8d6 | 82 | TString opt(onWhatToIterate); |
83 | opt.ToLower(); | |
84 | if ( opt.Contains("digit") || opt.Contains("d") ) | |
85 | { | |
86 | Int_t firstChamber; | |
87 | Int_t lastChamber; | |
88 | GetChamberNumbers(howToIterate,firstChamber,lastChamber); | |
89 | if ( firstChamber >= 0 && lastChamber >= 0 ) | |
90 | { | |
91 | data->GetLoader()->LoadDigits("READ"); | |
92 | data->SetTreeAddress("D,GLT"); | |
93 | fIterator = new AliMUONDataDigitIterator(data,firstChamber,lastChamber); | |
94 | } | |
95 | } | |
96 | } | |
97 | ||
98 | //_____________________________________________________________________________ | |
99 | AliMUONDataIterator::~AliMUONDataIterator() | |
100 | { | |
71a2d3aa | 101 | /// Destructor |
102 | ||
70b4a8d6 | 103 | delete fIterator; |
104 | } | |
105 | ||
106 | //_____________________________________________________________________________ | |
107 | TObject* | |
108 | AliMUONDataIterator::Next() | |
109 | { | |
71a2d3aa | 110 | /// Set iterator to the next element |
111 | ||
a0dc51a6 | 112 | if (fIterator) return fIterator->Next(); |
70b4a8d6 | 113 | return 0x0; |
114 | } | |
115 | ||
116 | //_____________________________________________________________________________ | |
117 | Bool_t | |
118 | AliMUONDataIterator::Remove() | |
71a2d3aa | 119 | { |
120 | /// Remove current element | |
121 | ||
a0dc51a6 | 122 | if (fIterator) return fIterator->Remove(); |
70b4a8d6 | 123 | return kFALSE; |
124 | } | |
125 | ||
126 | //_____________________________________________________________________________ | |
127 | void | |
128 | AliMUONDataIterator::Reset() | |
129 | { | |
71a2d3aa | 130 | /// Reset |
131 | ||
a0dc51a6 | 132 | if (fIterator) fIterator->Reset(); |
70b4a8d6 | 133 | } |