]>
Commit | Line | Data |
---|---|---|
b864d801 | 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 | /////////////////////////////////////////////////////////////////////////////// | |
19 | /// | |
20 | /// This class provides access to TRD digits in raw data. | |
21 | /// | |
22 | /// It loops over all TRD digits in the raw data given by the AliRawReader. | |
23 | /// The Next method goes to the next digit. If there are no digits left | |
24 | /// it returns kFALSE. | |
25 | /// Several getters provide information about the current digit. | |
26 | /// | |
27 | /////////////////////////////////////////////////////////////////////////////// | |
28 | ||
29 | #include "AliTRDRawStream.h" | |
30 | #include "AliRawReader.h" | |
928e9fae | 31 | #include "AliTRDparameter.h" |
b864d801 | 32 | |
33 | ClassImp(AliTRDRawStream) | |
34 | ||
35 | ||
928e9fae | 36 | AliTRDRawStream::AliTRDRawStream(AliRawReader* rawReader, AliTRDparameter* parameter) : |
b864d801 | 37 | fRawReader(rawReader), |
928e9fae | 38 | fTimeTotal(parameter->GetTimeTotal()), |
b864d801 | 39 | fCount(0), |
40 | fDetector(-1), | |
41 | fPrevDetector(-1), | |
42 | fNPads(-1), | |
43 | fRow(-1), | |
44 | fPrevRow(-1), | |
45 | fColumn(-1), | |
46 | fPrevColumn(-1), | |
47 | fTime(-1), | |
48 | fSignal(-1) | |
49 | { | |
50 | // create an object to read TRD raw digits | |
51 | ||
52 | fRawReader->Select(4); | |
53 | } | |
54 | ||
55 | AliTRDRawStream::AliTRDRawStream(const AliTRDRawStream& stream) : | |
56 | TObject(stream), | |
57 | fRawReader(NULL), | |
928e9fae | 58 | fTimeTotal(0), |
b864d801 | 59 | fCount(0), |
60 | fDetector(-1), | |
61 | fPrevDetector(-1), | |
62 | fNPads(-1), | |
63 | fRow(-1), | |
64 | fPrevRow(-1), | |
65 | fColumn(-1), | |
66 | fPrevColumn(-1), | |
67 | fTime(-1), | |
68 | fSignal(-1) | |
69 | { | |
70 | Fatal("AliTRDRawStream", "copy constructor not implemented"); | |
71 | } | |
72 | ||
73 | AliTRDRawStream& AliTRDRawStream::operator = (const AliTRDRawStream& | |
74 | /* stream */) | |
75 | { | |
76 | Fatal("operator =", "assignment operator not implemented"); | |
77 | return *this; | |
78 | } | |
79 | ||
80 | AliTRDRawStream::~AliTRDRawStream() | |
81 | { | |
82 | // clean up | |
83 | ||
84 | } | |
85 | ||
86 | ||
87 | Bool_t AliTRDRawStream::Next() | |
88 | { | |
89 | // read the next raw digit | |
90 | // returns kFALSE if there is no digit left | |
91 | ||
92 | fPrevDetector = fDetector; | |
93 | fPrevRow = fRow; | |
94 | fPrevColumn = fColumn; | |
95 | UChar_t data; | |
96 | ||
97 | while (fCount >= 0) { | |
98 | ||
99 | while (fCount == 0) { // next detector | |
100 | // read the flag | |
101 | if (!fRawReader->ReadNextChar(data)) return kFALSE; | |
102 | if (data != 0xBB) { | |
103 | Error("Next", "wrong flag: %x", data); | |
104 | fCount = -1; | |
105 | return kFALSE; | |
106 | } | |
107 | ||
108 | // read the detector number | |
109 | if (!fRawReader->ReadNextChar(data)) { | |
110 | Error("Next", "could not read detector number"); | |
111 | fCount = -1; | |
112 | return kFALSE; | |
113 | } | |
114 | fDetector = data; | |
115 | if (!fRawReader->ReadNextChar(data)) { | |
116 | Error("Next", "could not read detector number"); | |
117 | fCount = -1; | |
118 | return kFALSE; | |
119 | } | |
120 | fDetector += (UInt_t(data) << 8); | |
121 | ||
122 | // read the number of byts | |
123 | if (!fRawReader->ReadNextChar(data)) { | |
124 | Error("Next", "could not read number of bytes"); | |
125 | fCount = -1; | |
126 | return kFALSE; | |
127 | } | |
128 | fCount = data; | |
129 | if (!fRawReader->ReadNextChar(data)) { | |
130 | Error("Next", "could not read number of bytes"); | |
131 | fCount = -1; | |
132 | return kFALSE; | |
133 | } | |
134 | fCount += (UInt_t(data) << 8); | |
928e9fae | 135 | if (!fRawReader->ReadNextChar(data)) { |
136 | Error("Next", "could not read number of bytes"); | |
137 | fCount = -1; | |
138 | return kFALSE; | |
139 | } | |
140 | fCount += (UInt_t(data) << 16); | |
b864d801 | 141 | |
142 | // read the number of active pads | |
143 | if (!fRawReader->ReadNextChar(data)) { | |
144 | Error("Next", "could not read number of active pads"); | |
145 | fCount = -1; | |
146 | return kFALSE; | |
147 | } | |
148 | fNPads = data; | |
149 | if (!fRawReader->ReadNextChar(data)) { | |
150 | Error("Next", "could not read number of active pads"); | |
151 | fCount = -1; | |
152 | return kFALSE; | |
153 | } | |
154 | fNPads += (UInt_t(data) << 8); | |
155 | ||
928e9fae | 156 | fTime = fTimeTotal; |
b864d801 | 157 | |
b864d801 | 158 | } |
159 | ||
160 | // read the pad row and column number | |
928e9fae | 161 | if ((fTime >= fTimeTotal) && (fCount > 2)) { |
b864d801 | 162 | if (!fRawReader->ReadNextChar(data)) { |
163 | Error("Next", "could not read row number"); | |
164 | fCount = -1; | |
165 | return kFALSE; | |
166 | } | |
167 | fCount--; | |
168 | fRow = data - 1; | |
169 | if (!fRawReader->ReadNextChar(data)) { | |
170 | Error("Next", "could not read column number"); | |
171 | fCount = -1; | |
172 | return kFALSE; | |
173 | } | |
174 | fCount--; | |
175 | fColumn = data - 1; | |
176 | fTime = 0; | |
177 | } | |
178 | ||
179 | // read the next data byte | |
180 | if (!fRawReader->ReadNextChar(data)) { | |
181 | Error("Next", "could not read data"); | |
182 | fCount = -1; | |
183 | return kFALSE; | |
184 | } | |
185 | fCount--; | |
186 | ||
187 | if (data == 0) { // zeros | |
188 | if (!fRawReader->ReadNextChar(data)) { | |
189 | Error("Next", "could not read time value"); | |
190 | fCount = -1; | |
191 | return kFALSE; | |
192 | } | |
193 | fCount--; | |
194 | fTime += data + 1; | |
195 | ||
196 | } else { // signal | |
197 | fSignal = (UInt_t(data & 0x7F) << 8); | |
198 | if (!fRawReader->ReadNextChar(data)) { | |
199 | Error("Next", "could not read ADC value"); | |
200 | fCount = -1; | |
201 | return kFALSE; | |
202 | } | |
203 | fCount--; | |
204 | fSignal += data; | |
205 | fTime++; | |
206 | return kTRUE; | |
207 | } | |
208 | } | |
209 | ||
210 | return kFALSE; | |
211 | } |