]>
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 | /////////////////////////////////////////////////////////////////////////////// | |
2745a409 | 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 | // // | |
b864d801 | 27 | /////////////////////////////////////////////////////////////////////////////// |
28 | ||
2745a409 | 29 | #include "AliLog.h" |
b864d801 | 30 | #include "AliRawReader.h" |
2745a409 | 31 | |
32 | #include "AliTRDRawStream.h" | |
3551db50 | 33 | #include "AliTRDcalibDB.h" |
b864d801 | 34 | |
35 | ClassImp(AliTRDRawStream) | |
36 | ||
2745a409 | 37 | //_____________________________________________________________________________ |
38 | AliTRDRawStream::AliTRDRawStream() | |
39 | :TObject() | |
40 | ,fRawReader(0) | |
41 | ,fCount(0) | |
42 | ,fDetector(-1) | |
43 | ,fPrevDetector(-1) | |
44 | ,fNPads(-1) | |
45 | ,fRow(-1) | |
46 | ,fPrevRow(-1) | |
47 | ,fColumn(-1) | |
48 | ,fPrevColumn(-1) | |
49 | ,fTime(-1) | |
50 | ,fSignal(-1) | |
51 | { | |
52 | // | |
53 | // Default constructor | |
54 | // | |
b864d801 | 55 | |
2745a409 | 56 | } |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliTRDRawStream::AliTRDRawStream(AliRawReader* rawReader) | |
60 | :TObject() | |
61 | ,fRawReader(rawReader) | |
62 | ,fCount(0) | |
63 | ,fDetector(-1) | |
64 | ,fPrevDetector(-1) | |
65 | ,fNPads(-1) | |
66 | ,fRow(-1) | |
67 | ,fPrevRow(-1) | |
68 | ,fColumn(-1) | |
69 | ,fPrevColumn(-1) | |
70 | ,fTime(-1) | |
71 | ,fSignal(-1) | |
b864d801 | 72 | { |
2745a409 | 73 | // |
74 | // Create an object to read TRD raw digits | |
75 | // | |
b864d801 | 76 | |
362c9d61 | 77 | fRawReader->Select("TRD"); |
2745a409 | 78 | |
b864d801 | 79 | } |
80 | ||
2745a409 | 81 | //_____________________________________________________________________________ |
b864d801 | 82 | AliTRDRawStream::AliTRDRawStream(const AliTRDRawStream& stream) : |
83 | TObject(stream), | |
84 | fRawReader(NULL), | |
b864d801 | 85 | fCount(0), |
86 | fDetector(-1), | |
87 | fPrevDetector(-1), | |
88 | fNPads(-1), | |
89 | fRow(-1), | |
90 | fPrevRow(-1), | |
91 | fColumn(-1), | |
92 | fPrevColumn(-1), | |
93 | fTime(-1), | |
94 | fSignal(-1) | |
95 | { | |
2745a409 | 96 | // |
97 | // Copy constructor | |
98 | // | |
99 | ||
100 | AliFatal("Copy constructor not implemented"); | |
101 | ||
b864d801 | 102 | } |
103 | ||
2745a409 | 104 | //_____________________________________________________________________________ |
b864d801 | 105 | AliTRDRawStream& AliTRDRawStream::operator = (const AliTRDRawStream& |
106 | /* stream */) | |
107 | { | |
2745a409 | 108 | // |
109 | // Assigment operator | |
110 | // | |
111 | ||
b864d801 | 112 | Fatal("operator =", "assignment operator not implemented"); |
113 | return *this; | |
2745a409 | 114 | |
b864d801 | 115 | } |
116 | ||
2745a409 | 117 | //_____________________________________________________________________________ |
b864d801 | 118 | AliTRDRawStream::~AliTRDRawStream() |
119 | { | |
2745a409 | 120 | // |
121 | // Destructor | |
122 | // | |
b864d801 | 123 | |
124 | } | |
125 | ||
2745a409 | 126 | //_____________________________________________________________________________ |
b864d801 | 127 | Bool_t AliTRDRawStream::Next() |
128 | { | |
2745a409 | 129 | // |
130 | // Read the next raw digit | |
131 | // Returns kFALSE if there is no digit left | |
132 | // | |
b864d801 | 133 | |
134 | fPrevDetector = fDetector; | |
2745a409 | 135 | fPrevRow = fRow; |
136 | fPrevColumn = fColumn; | |
b864d801 | 137 | UChar_t data; |
138 | ||
3551db50 | 139 | AliTRDcalibDB* calibration = AliTRDcalibDB::Instance(); |
140 | if (!calibration) | |
141 | return kFALSE; | |
142 | ||
143 | Int_t timeBins = calibration->GetNumberOfTimeBins(); | |
144 | ||
b864d801 | 145 | while (fCount >= 0) { |
146 | ||
147 | while (fCount == 0) { // next detector | |
148 | // read the flag | |
149 | if (!fRawReader->ReadNextChar(data)) return kFALSE; | |
150 | if (data != 0xBB) { | |
2745a409 | 151 | AliError(Form("wrong flag: %x", data)); |
b864d801 | 152 | fCount = -1; |
153 | return kFALSE; | |
154 | } | |
155 | ||
156 | // read the detector number | |
157 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 158 | AliError("Could not read detector number"); |
b864d801 | 159 | fCount = -1; |
160 | return kFALSE; | |
161 | } | |
162 | fDetector = data; | |
163 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 164 | AliError("Could not read detector number"); |
b864d801 | 165 | fCount = -1; |
166 | return kFALSE; | |
167 | } | |
168 | fDetector += (UInt_t(data) << 8); | |
169 | ||
170 | // read the number of byts | |
171 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 172 | AliError("Could not read number of bytes"); |
b864d801 | 173 | fCount = -1; |
174 | return kFALSE; | |
175 | } | |
176 | fCount = data; | |
177 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 178 | AliError("Could not read number of bytes"); |
b864d801 | 179 | fCount = -1; |
180 | return kFALSE; | |
181 | } | |
182 | fCount += (UInt_t(data) << 8); | |
928e9fae | 183 | if (!fRawReader->ReadNextChar(data)) { |
2745a409 | 184 | AliError("Could not read number of bytes"); |
928e9fae | 185 | fCount = -1; |
186 | return kFALSE; | |
187 | } | |
188 | fCount += (UInt_t(data) << 16); | |
b864d801 | 189 | |
190 | // read the number of active pads | |
191 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 192 | AliError("Could not read number of active pads"); |
b864d801 | 193 | fCount = -1; |
194 | return kFALSE; | |
195 | } | |
196 | fNPads = data; | |
197 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 198 | AliError("Could not read number of active pads"); |
b864d801 | 199 | fCount = -1; |
200 | return kFALSE; | |
201 | } | |
202 | fNPads += (UInt_t(data) << 8); | |
203 | ||
3551db50 | 204 | fTime = timeBins; |
b864d801 | 205 | |
b864d801 | 206 | } |
207 | ||
208 | // read the pad row and column number | |
3551db50 | 209 | if ((fTime >= timeBins) && (fCount > 2)) { |
b864d801 | 210 | if (!fRawReader->ReadNextChar(data)) { |
2745a409 | 211 | AliError("Could not read row number"); |
b864d801 | 212 | fCount = -1; |
213 | return kFALSE; | |
214 | } | |
215 | fCount--; | |
216 | fRow = data - 1; | |
217 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 218 | AliError("Could not read column number"); |
b864d801 | 219 | fCount = -1; |
220 | return kFALSE; | |
221 | } | |
222 | fCount--; | |
223 | fColumn = data - 1; | |
224 | fTime = 0; | |
225 | } | |
226 | ||
227 | // read the next data byte | |
228 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 229 | AliError("Could not read data"); |
b864d801 | 230 | fCount = -1; |
231 | return kFALSE; | |
232 | } | |
233 | fCount--; | |
234 | ||
235 | if (data == 0) { // zeros | |
236 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 237 | AliError("Could not read time value"); |
b864d801 | 238 | fCount = -1; |
239 | return kFALSE; | |
240 | } | |
241 | fCount--; | |
242 | fTime += data + 1; | |
243 | ||
2745a409 | 244 | } |
245 | else { // signal | |
b864d801 | 246 | fSignal = (UInt_t(data & 0x7F) << 8); |
247 | if (!fRawReader->ReadNextChar(data)) { | |
2745a409 | 248 | AliError("Could not read ADC value"); |
b864d801 | 249 | fCount = -1; |
250 | return kFALSE; | |
251 | } | |
252 | fCount--; | |
253 | fSignal += data; | |
254 | fTime++; | |
255 | return kTRUE; | |
256 | } | |
257 | } | |
258 | ||
259 | return kFALSE; | |
2745a409 | 260 | |
b864d801 | 261 | } |