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