]>
Commit | Line | Data |
---|---|---|
dd1b1dd1 | 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 | ||
bea6b2a4 | 16 | /* $Id$ */ |
17 | ||
dd1b1dd1 | 18 | /////////////////////////////////////////////////////////////////////////////// |
bea6b2a4 | 19 | /// |
20 | /// This class provides access to VME data in test beam raw data. | |
21 | /// | |
dd1b1dd1 | 22 | /////////////////////////////////////////////////////////////////////////////// |
23 | ||
24 | #include "AliVMERawStream.h" | |
25 | #include "AliRawReader.h" | |
26 | ||
27 | ClassImp(AliVMERawStream) | |
28 | ||
29 | ||
30 | ||
31 | AliVMERawStream::AliVMERawStream(AliRawReader* rawReader) : | |
32 | fRawReader(rawReader), | |
33 | fData(0), | |
34 | fNChannels(-1), | |
35 | fBlock(0), | |
36 | fNumber(0), | |
37 | fChannel(0), | |
38 | fValue(0), | |
39 | fTime(0), | |
40 | fTimeMuSec(0) | |
41 | { | |
42 | // create an object to read VME raw digits | |
43 | ||
44 | fRawReader = rawReader; | |
45 | ||
46 | ReadTDC(); | |
47 | ReadTime(); | |
48 | ||
49 | fRawReader->Reset(); | |
50 | fRawReader->SelectEquipment(551, 38, 38); | |
51 | } | |
52 | ||
53 | AliVMERawStream::AliVMERawStream(const AliVMERawStream& stream) : | |
54 | TObject(stream) | |
55 | { | |
56 | Fatal("AliVMERawStream", "copy constructor not implemented"); | |
57 | } | |
58 | ||
59 | AliVMERawStream& AliVMERawStream::operator = (const AliVMERawStream& | |
60 | /* stream */) | |
61 | { | |
62 | Fatal("operator =", "assignment operator not implemented"); | |
63 | return *this; | |
64 | } | |
65 | ||
66 | ||
67 | Bool_t AliVMERawStream::Next() | |
68 | { | |
69 | // read the next raw digit | |
70 | // returns kFALSE if there is no digit left | |
71 | ||
72 | // V551 string | |
73 | if (fNChannels == -1) { | |
74 | if (!fRawReader->ReadNextInt(fData)) return kFALSE; | |
75 | if (!CheckString("V551")) return kFALSE; | |
76 | fNChannels = 0; | |
77 | } | |
78 | ||
79 | while (fNChannels == 0) { | |
80 | // V550 or v551 string | |
81 | if (!fRawReader->ReadNextInt(fData)) { | |
82 | Error("Next", "incomplete equipment"); | |
83 | return kFALSE; | |
84 | } | |
85 | // check for v551 string (end of data) | |
86 | const char* v551 = "v551"; | |
87 | if (fData == *((UInt_t*) v551)) return kFALSE; | |
88 | if (!CheckString("V550")) return kFALSE; | |
89 | ||
90 | // block | |
91 | if (!fRawReader->ReadNextShort(fBlock)) { | |
92 | Error("Next", "incomplete equipment"); | |
93 | return kFALSE; | |
94 | } | |
95 | ||
96 | // serial number | |
97 | if (!fRawReader->ReadNextShort(fNumber)) { | |
98 | Error("Next", "incomplete equipment"); | |
99 | return kFALSE; | |
100 | } | |
101 | ||
102 | // number of channels | |
a6438609 | 103 | if (!fRawReader->ReadNextInt((UInt_t&) fNChannels)) { |
dd1b1dd1 | 104 | Error("Next", "incomplete equipment"); |
105 | return kFALSE; | |
106 | } | |
107 | } | |
108 | ||
109 | if (!fRawReader->ReadNextInt(fData)) { | |
110 | Error("Next", "incomplete equipment"); | |
111 | return kFALSE; | |
112 | } | |
113 | fChannel = (fData >> 12) & 0x03ff; | |
114 | fValue = fData & 0x0fff; | |
115 | fNChannels--; | |
116 | ||
117 | return kTRUE; | |
118 | } | |
119 | ||
120 | ||
121 | ||
122 | Bool_t AliVMERawStream::CheckString(const char* str) const | |
123 | { | |
124 | // check fData to be equal to the given string | |
125 | ||
126 | if (fData != *((UInt_t*) str)) { | |
127 | char strData[5]; | |
128 | memcpy(strData, &fData, 4); | |
129 | strData[4] = 0; | |
130 | Error("CheckString", "invalid %s string (%s)", str, strData); | |
131 | return kFALSE; | |
132 | } | |
133 | return kTRUE; | |
134 | } | |
135 | ||
136 | Bool_t AliVMERawStream::ReadTDC() | |
137 | { | |
138 | // read the TDC information | |
139 | ||
140 | fRawReader->Reset(); | |
141 | fRawReader->SelectEquipment(775, 72, 72); | |
142 | ||
143 | // V775 string | |
144 | if (!fRawReader->ReadNextInt(fData)) return kFALSE; | |
145 | if (!CheckString("V775")) return kFALSE; | |
146 | ||
147 | // header | |
148 | if (!fRawReader->ReadNextInt(fData)) { | |
149 | Error("ReadTDC", "incomplete TDC equipment"); | |
150 | return kFALSE; | |
151 | } | |
152 | if ((fData & 0x02000000) == 0) { | |
153 | Error("ReadTDC", "invalid header: 0x%x", fData); | |
154 | return kFALSE; | |
155 | } | |
156 | ||
157 | // check the array size | |
158 | Int_t nTDC = fRawReader->GetDataSize() / 4 - 4; // - V775,header,counter,v775 | |
159 | if ( nTDC != 3 ) { | |
160 | Error("ReadTDC", "wrong number of TDC channels: %d", nTDC); | |
161 | return kFALSE; | |
162 | } | |
163 | ||
164 | // TDC data | |
165 | for (Int_t i = 0; i < fgkNTDC; i++) { | |
166 | if (!fRawReader->ReadNextInt(fData)) { | |
167 | Error("ReadTDC", "incomplete TDC equipment"); | |
168 | return kFALSE; | |
169 | } | |
170 | if (fData & 0x07000000) { | |
171 | Warning("ReadTDC", "bad TDC data: %x", fData); | |
172 | } | |
173 | if ((fData & 0x00004000) == 0) { | |
174 | Warning("ReadTDC", "TDC data not valid: %x", fData); | |
175 | } | |
176 | if (fData & 0x00002000) { | |
177 | Warning("ReadTDC", "TDC data underflow: %x", fData); | |
178 | } | |
179 | if (fData & 0x00001000) { | |
180 | Warning("ReadTDC", "TDC data overflow: %x", fData); | |
181 | } | |
182 | fTDCChannel[i] = (fData >> 16) & 0x1f; | |
183 | fTDCValue[i] = fData & 0x0fff; | |
184 | } | |
185 | ||
186 | // counter | |
187 | if (!fRawReader->ReadNextInt(fData)) { | |
188 | Error("ReadTDC", "incomplete TDC equipment"); | |
189 | return kFALSE; | |
190 | } | |
191 | if ((fData & 0x04000000) == 0) { | |
192 | Error("ReadTDC", "invalid counter: 0x%x", fData); | |
193 | return kFALSE; | |
194 | } | |
195 | ||
196 | // v775 string | |
197 | if (!fRawReader->ReadNextInt(fData)) { | |
198 | Error("ReadTDC", "incomplete TDC equipment"); | |
199 | return kFALSE; | |
200 | } | |
201 | if (!CheckString("v775")) return kFALSE; | |
202 | ||
203 | return kTRUE; | |
204 | } | |
205 | ||
206 | Bool_t AliVMERawStream::ReadTime() | |
207 | { | |
208 | // read the time information | |
209 | ||
210 | fRawReader->Reset(); | |
211 | fRawReader->SelectEquipment(1970, 0x12345678, 0x12345678); | |
212 | ||
213 | // TIME string | |
214 | if (!fRawReader->ReadNextInt(fData)) return kFALSE; | |
215 | if (!CheckString("TIME")) return kFALSE; | |
216 | ||
217 | // time value | |
218 | if (!fRawReader->ReadNextInt(fTime)) { | |
219 | Error("ReadTime", "incomplete time equipment"); | |
220 | return kFALSE; | |
221 | } | |
222 | ||
223 | // micro seconds value | |
224 | if (!fRawReader->ReadNextInt(fTimeMuSec)) { | |
225 | Error("ReadTime", "incomplete time equipment"); | |
226 | return kFALSE; | |
227 | } | |
228 | ||
229 | // time string | |
230 | if (!fRawReader->ReadNextInt(fData)) { | |
231 | Error("ReadTime", "incomplete time equipment"); | |
232 | return kFALSE; | |
233 | } | |
234 | if (!CheckString("time")) return kFALSE; | |
235 | ||
236 | return kTRUE; | |
237 | } |