]>
Commit | Line | Data |
---|---|---|
a6e7b125 | 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 | ||
a6e7b125 | 18 | /////////////////////////////////////////////////////////////////////////////// |
bea6b2a4 | 19 | /// |
20 | /// This is the base class for reading raw data. | |
21 | /// | |
22 | /// The derived classes, which operate on concrete raw data formats, | |
23 | /// should implement | |
24 | /// - ReadHeader to read the next (data/equipment) header | |
25 | /// - ReadNextData to read the next raw data block (=1 DDL) | |
26 | /// - ReadNext to read a given number of bytes | |
27 | /// - several getters like GetType | |
28 | /// | |
29 | /// Sequential access to the raw data is provided by the methods | |
30 | /// ReadHeader, ReadNextData, ReadNextInt, ReadNextShort, ReadNextChar | |
31 | /// | |
32 | /// If only data from a specific detector (and a given range of DDL numbers) | |
33 | /// should be read, this can be achieved by the Select method. | |
34 | /// Several getters provide information about the current event and the | |
35 | /// current type of raw data. | |
36 | /// | |
a6e7b125 | 37 | /////////////////////////////////////////////////////////////////////////////// |
38 | ||
43787b8e | 39 | #include <TClass.h> |
40 | #include <TPluginManager.h> | |
41 | #include <TROOT.h> | |
42 | ||
0cfe2438 | 43 | #include <Riostream.h> |
a6e7b125 | 44 | #include "AliRawReader.h" |
43787b8e | 45 | #include "AliRawReaderFile.h" |
46 | #include "AliRawReaderDate.h" | |
47 | #include "AliRawReaderRoot.h" | |
362c9d61 | 48 | #include "AliDAQ.h" |
38cf12f3 | 49 | #include "AliLog.h" |
8de97894 | 50 | |
a6e7b125 | 51 | ClassImp(AliRawReader) |
52 | ||
53 | ||
c946ab02 | 54 | AliRawReader::AliRawReader() : |
0cfe2438 | 55 | fEquipmentIdsIn(NULL), |
56 | fEquipmentIdsOut(NULL), | |
18882b3b | 57 | fRequireHeader(kTRUE), |
39f9963f | 58 | fHeader(NULL), |
c946ab02 | 59 | fCount(0), |
f224de6c | 60 | fSelectEquipmentType(-1), |
61 | fSelectMinEquipmentId(-1), | |
62 | fSelectMaxEquipmentId(-1), | |
39f9963f | 63 | fSkipInvalid(kFALSE), |
dd9a70fe | 64 | fSelectEventType(-1), |
00665a00 | 65 | fSelectTriggerMask(0), |
38cf12f3 | 66 | fErrorCode(0), |
67 | fEventNumber(-1), | |
edd06192 | 68 | fErrorLogs("AliRawDataErrorLog",100), |
69 | fHeaderSwapped(NULL) | |
a6e7b125 | 70 | { |
42d20574 | 71 | // default constructor: initialize data members |
edd06192 | 72 | // Allocate the swapped header in case of Mac |
73 | #ifndef R__BYTESWAP | |
74 | fHeaderSwapped=new AliRawDataHeader(); | |
75 | #endif | |
0cfe2438 | 76 | } |
42d20574 | 77 | |
0cfe2438 | 78 | Bool_t AliRawReader::LoadEquipmentIdsMap(const char *fileName) |
79 | { | |
80 | // Open the mapping file | |
81 | // and load the mapping data | |
82 | ifstream input(fileName); | |
83 | if (input.is_open()) { | |
84 | Warning("AliRawReader","Equipment ID mapping file is found !"); | |
85 | const Int_t kMaxDDL = 256; | |
86 | fEquipmentIdsIn = new TArrayI(kMaxDDL); | |
87 | fEquipmentIdsOut = new TArrayI(kMaxDDL); | |
88 | Int_t equipIn, equipOut; | |
89 | Int_t nIds = 0; | |
90 | while (input >> equipIn >> equipOut) { | |
91 | if (nIds >= kMaxDDL) { | |
92 | Error("AliRawReader","Too many equipment Id mappings found ! Truncating the list !"); | |
93 | break; | |
94 | } | |
95 | fEquipmentIdsIn->AddAt(equipIn,nIds); | |
96 | fEquipmentIdsOut->AddAt(equipOut,nIds); | |
97 | nIds++; | |
98 | } | |
99 | fEquipmentIdsIn->Set(nIds); | |
100 | fEquipmentIdsOut->Set(nIds); | |
101 | input.close(); | |
102 | return kTRUE; | |
103 | } | |
104 | else { | |
105 | Error("AliRawReader","equipment id map file is not found ! Skipping the mapping !"); | |
106 | return kFALSE; | |
107 | } | |
a6e7b125 | 108 | } |
109 | ||
42d20574 | 110 | AliRawReader::AliRawReader(const AliRawReader& rawReader) : |
c946ab02 | 111 | TObject(rawReader), |
0cfe2438 | 112 | fEquipmentIdsIn(rawReader.fEquipmentIdsIn), |
113 | fEquipmentIdsOut(rawReader.fEquipmentIdsOut), | |
18882b3b | 114 | fRequireHeader(rawReader.fRequireHeader), |
39f9963f | 115 | fHeader(rawReader.fHeader), |
c946ab02 | 116 | fCount(rawReader.fCount), |
f224de6c | 117 | fSelectEquipmentType(rawReader.fSelectEquipmentType), |
118 | fSelectMinEquipmentId(rawReader.fSelectMinEquipmentId), | |
119 | fSelectMaxEquipmentId(rawReader.fSelectMaxEquipmentId), | |
39f9963f | 120 | fSkipInvalid(rawReader.fSkipInvalid), |
dd9a70fe | 121 | fSelectEventType(rawReader.fSelectEventType), |
00665a00 | 122 | fSelectTriggerMask(rawReader.fSelectTriggerMask), |
38cf12f3 | 123 | fErrorCode(0), |
124 | fEventNumber(-1), | |
edd06192 | 125 | fErrorLogs("AliRawDataErrorLog",100), |
126 | fHeaderSwapped(NULL) | |
42d20574 | 127 | { |
128 | // copy constructor | |
edd06192 | 129 | // Allocate the swapped header in case of Mac |
130 | #ifndef R__BYTESWAP | |
131 | fHeaderSwapped=new AliRawDataHeader(*rawReader.fHeaderSwapped); | |
132 | #endif | |
42d20574 | 133 | } |
134 | ||
135 | AliRawReader& AliRawReader::operator = (const AliRawReader& rawReader) | |
136 | { | |
137 | // assignment operator | |
0cfe2438 | 138 | fEquipmentIdsIn = rawReader.fEquipmentIdsIn; |
139 | fEquipmentIdsOut = rawReader.fEquipmentIdsOut; | |
42d20574 | 140 | |
39f9963f | 141 | fHeader = rawReader.fHeader; |
42d20574 | 142 | fCount = rawReader.fCount; |
143 | ||
39f9963f | 144 | fSelectEquipmentType = rawReader.fSelectEquipmentType; |
145 | fSelectMinEquipmentId = rawReader.fSelectMinEquipmentId; | |
146 | fSelectMaxEquipmentId = rawReader.fSelectMaxEquipmentId; | |
147 | fSkipInvalid = rawReader.fSkipInvalid; | |
dd9a70fe | 148 | fSelectEventType = rawReader.fSelectEventType; |
00665a00 | 149 | fSelectTriggerMask = rawReader.fSelectTriggerMask; |
42d20574 | 150 | |
b4857df7 | 151 | fErrorCode = rawReader.fErrorCode; |
152 | ||
38cf12f3 | 153 | fEventNumber = rawReader.fEventNumber; |
154 | fErrorLogs = *((TClonesArray*)rawReader.fErrorLogs.Clone()); | |
155 | ||
42d20574 | 156 | return *this; |
157 | } | |
158 | ||
0cfe2438 | 159 | AliRawReader::~AliRawReader() |
160 | { | |
161 | // destructor | |
162 | // delete the mapping arrays if | |
163 | // initialized | |
164 | if (fEquipmentIdsIn) delete fEquipmentIdsIn; | |
165 | if (fEquipmentIdsOut) delete fEquipmentIdsOut; | |
79dac785 | 166 | fErrorLogs.Delete(); |
edd06192 | 167 | if (fHeaderSwapped) delete fHeaderSwapped; |
0cfe2438 | 168 | } |
169 | ||
43787b8e | 170 | AliRawReader* AliRawReader::Create(const char *uri) |
171 | { | |
172 | // RawReader's factory | |
173 | // It instantiate corresponding raw-reader implementation class object | |
174 | // depending on the URI provided | |
175 | // Normal URIs point to files, while the URI starting with | |
176 | // 'mem://:' or 'mem://<filename>' will create | |
177 | // AliRawReaderDateOnline object which is supposed to be used | |
178 | // in the online reconstruction | |
179 | ||
180 | TString strURI = uri; | |
181 | ||
182 | if (strURI.IsNull()) { | |
183 | AliWarningClass("No raw-reader created"); | |
184 | return NULL; | |
185 | } | |
186 | ||
3f7450e0 | 187 | TObjArray *fields = strURI.Tokenize("?"); |
188 | TString &fileURI = ((TObjString*)fields->At(0))->String(); | |
189 | ||
43787b8e | 190 | AliRawReader *rawReader = NULL; |
3f7450e0 | 191 | if (!fileURI.BeginsWith("mem://")) { |
192 | AliInfoClass(Form("Creating raw-reader in order to read raw-data file: %s",fileURI.Data())); | |
193 | if (fileURI.EndsWith("/")) { | |
194 | rawReader = new AliRawReaderFile(fileURI); | |
195 | } else if (fileURI.EndsWith(".root")) { | |
196 | rawReader = new AliRawReaderRoot(fileURI); | |
43787b8e | 197 | } else { |
3f7450e0 | 198 | rawReader = new AliRawReaderDate(fileURI); |
43787b8e | 199 | } |
200 | } | |
201 | else { | |
3f7450e0 | 202 | fileURI.ReplaceAll("mem://",""); |
203 | AliInfoClass(Form("Creating raw-reader in order to read events in shared memory (option=%s)",fileURI.Data())); | |
43787b8e | 204 | |
205 | TPluginManager* pluginManager = gROOT->GetPluginManager(); | |
206 | TString rawReaderName = "AliRawReaderDateOnline"; | |
207 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliRawReader", "online"); | |
208 | // if not, add a plugin for it | |
209 | if (!pluginHandler) { | |
210 | pluginManager->AddHandler("AliRawReader", "online", | |
211 | "AliRawReaderDateOnline", "RAWDatarecOnline", "AliRawReaderDateOnline(const char*)"); | |
212 | pluginHandler = pluginManager->FindHandler("AliRawReader", "online"); | |
213 | } | |
214 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
3f7450e0 | 215 | rawReader = (AliRawReader*)pluginHandler->ExecPlugin(1,fileURI.Data()); |
43787b8e | 216 | } |
217 | else { | |
218 | return NULL; | |
219 | } | |
220 | } | |
221 | ||
3f7450e0 | 222 | // Now apply event selection criteria (if specified) |
223 | if (fields->GetEntries() > 1) { | |
224 | Int_t eventType = -1; | |
225 | ULong64_t triggerMask = 0; | |
226 | for(Int_t i = 1; i < fields->GetEntries(); i++) { | |
227 | if (!fields->At(i)) continue; | |
228 | TString &option = ((TObjString*)fields->At(i))->String(); | |
229 | if (option.BeginsWith("EventType=",TString::kIgnoreCase)) { | |
230 | option.ReplaceAll("EventType=",""); | |
231 | eventType = option.Atoi(); | |
232 | continue; | |
233 | } | |
234 | if (option.BeginsWith("Trigger=",TString::kIgnoreCase)) { | |
235 | option.ReplaceAll("Trigger=",""); | |
236 | triggerMask = option.Atoll(); | |
237 | continue; | |
238 | } | |
239 | AliWarningClass(Form("Ignoring invalid event selection option: %s",option.Data())); | |
240 | } | |
241 | AliInfoClass(Form("Event selection criteria specified: eventype=%d trigger mask=%llx", | |
242 | eventType,triggerMask)); | |
243 | rawReader->SelectEvents(eventType,triggerMask); | |
244 | } | |
245 | ||
246 | fields->Delete(); | |
247 | delete fields; | |
248 | ||
43787b8e | 249 | return rawReader; |
250 | } | |
251 | ||
0cfe2438 | 252 | Int_t AliRawReader::GetMappedEquipmentId() const |
253 | { | |
254 | if (!fEquipmentIdsIn || !fEquipmentIdsOut) { | |
255 | Error("AliRawReader","equipment Ids mapping is not initialized !"); | |
256 | return GetEquipmentId(); | |
257 | } | |
258 | Int_t equipmentId = GetEquipmentId(); | |
259 | for(Int_t iId = 0; iId < fEquipmentIdsIn->GetSize(); iId++) { | |
260 | if (equipmentId == fEquipmentIdsIn->At(iId)) { | |
261 | equipmentId = fEquipmentIdsOut->At(iId); | |
262 | break; | |
263 | } | |
264 | } | |
265 | return equipmentId; | |
266 | } | |
267 | ||
268 | Int_t AliRawReader::GetDetectorID() const | |
269 | { | |
270 | // Get the detector ID | |
271 | // The list of detector IDs | |
362c9d61 | 272 | // can be found in AliDAQ.h |
0cfe2438 | 273 | Int_t equipmentId; |
274 | if (fEquipmentIdsIn && fEquipmentIdsIn) | |
275 | equipmentId = GetMappedEquipmentId(); | |
276 | else | |
277 | equipmentId = GetEquipmentId(); | |
278 | ||
362c9d61 | 279 | if (equipmentId >= 0) { |
280 | Int_t ddlIndex; | |
281 | return AliDAQ::DetectorIDFromDdlID(equipmentId,ddlIndex); | |
282 | } | |
0cfe2438 | 283 | else |
284 | return -1; | |
285 | } | |
286 | ||
287 | Int_t AliRawReader::GetDDLID() const | |
288 | { | |
289 | // Get the DDL ID (within one sub-detector) | |
290 | // The list of detector IDs | |
362c9d61 | 291 | // can be found in AliDAQ.h |
0cfe2438 | 292 | Int_t equipmentId; |
293 | if (fEquipmentIdsIn && fEquipmentIdsIn) | |
294 | equipmentId = GetMappedEquipmentId(); | |
295 | else | |
296 | equipmentId = GetEquipmentId(); | |
297 | ||
362c9d61 | 298 | if (equipmentId >= 0) { |
299 | Int_t ddlIndex; | |
300 | AliDAQ::DetectorIDFromDdlID(equipmentId,ddlIndex); | |
301 | return ddlIndex; | |
302 | } | |
0cfe2438 | 303 | else |
304 | return -1; | |
305 | } | |
8de97894 | 306 | |
362c9d61 | 307 | void AliRawReader::Select(const char *detectorName, Int_t minDDLID, Int_t maxDDLID) |
308 | { | |
309 | // read only data of the detector with the given name and in the given | |
310 | // range of DDLs (minDDLID <= DDLID <= maxDDLID). | |
311 | // no selection is applied if a value < 0 is used. | |
312 | Int_t detectorID = AliDAQ::DetectorID(detectorName); | |
313 | if(detectorID >= 0) | |
314 | Select(detectorID,minDDLID,maxDDLID); | |
315 | } | |
316 | ||
8de97894 | 317 | void AliRawReader::Select(Int_t detectorID, Int_t minDDLID, Int_t maxDDLID) |
a6e7b125 | 318 | { |
8de97894 | 319 | // read only data of the detector with the given ID and in the given |
f224de6c | 320 | // range of DDLs (minDDLID <= DDLID <= maxDDLID). |
8de97894 | 321 | // no selection is applied if a value < 0 is used. |
a6e7b125 | 322 | |
0cfe2438 | 323 | fSelectEquipmentType = -1; |
362c9d61 | 324 | |
325 | if (minDDLID < 0) | |
326 | fSelectMinEquipmentId = AliDAQ::DdlIDOffset(detectorID); | |
327 | else | |
328 | fSelectMinEquipmentId = AliDAQ::DdlID(detectorID,minDDLID); | |
329 | ||
330 | if (maxDDLID < 0) | |
331 | fSelectMaxEquipmentId = AliDAQ::DdlID(detectorID,AliDAQ::NumberOfDdls(detectorID)-1); | |
332 | else | |
333 | fSelectMaxEquipmentId = AliDAQ::DdlID(detectorID,maxDDLID); | |
8de97894 | 334 | } |
a6e7b125 | 335 | |
f224de6c | 336 | void AliRawReader::SelectEquipment(Int_t equipmentType, |
337 | Int_t minEquipmentId, Int_t maxEquipmentId) | |
338 | { | |
339 | // read only data of the equipment with the given type and in the given | |
340 | // range of IDs (minEquipmentId <= EquipmentId <= maxEquipmentId). | |
341 | // no selection is applied if a value < 0 is used. | |
342 | ||
343 | fSelectEquipmentType = equipmentType; | |
344 | fSelectMinEquipmentId = minEquipmentId; | |
345 | fSelectMaxEquipmentId = maxEquipmentId; | |
346 | } | |
347 | ||
00665a00 | 348 | void AliRawReader::SelectEvents(Int_t type, ULong64_t triggerMask) |
dd9a70fe | 349 | { |
00665a00 | 350 | // read only events with the given type and optionally |
351 | // trigger mask. | |
dd9a70fe | 352 | // no selection is applied if a value < 0 is used. |
353 | ||
354 | fSelectEventType = type; | |
00665a00 | 355 | fSelectTriggerMask = triggerMask; |
dd9a70fe | 356 | } |
357 | ||
42d20574 | 358 | Bool_t AliRawReader::IsSelected() const |
a6e7b125 | 359 | { |
8de97894 | 360 | // apply the selection (if any) |
361 | ||
39f9963f | 362 | if (fSkipInvalid && !IsValid()) return kFALSE; |
f224de6c | 363 | |
0cfe2438 | 364 | if (fSelectEquipmentType >= 0) |
f224de6c | 365 | if (GetEquipmentType() != fSelectEquipmentType) return kFALSE; |
0cfe2438 | 366 | |
367 | Int_t equipmentId; | |
368 | if (fEquipmentIdsIn && fEquipmentIdsIn) | |
369 | equipmentId = GetMappedEquipmentId(); | |
370 | else | |
371 | equipmentId = GetEquipmentId(); | |
372 | ||
373 | if ((fSelectMinEquipmentId >= 0) && | |
374 | (equipmentId < fSelectMinEquipmentId)) | |
375 | return kFALSE; | |
376 | if ((fSelectMaxEquipmentId >= 0) && | |
377 | (equipmentId > fSelectMaxEquipmentId)) | |
378 | return kFALSE; | |
f224de6c | 379 | |
8de97894 | 380 | return kTRUE; |
a6e7b125 | 381 | } |
382 | ||
dd9a70fe | 383 | Bool_t AliRawReader::IsEventSelected() const |
384 | { | |
00665a00 | 385 | // apply the event selection (if any) |
dd9a70fe | 386 | |
00665a00 | 387 | // First check the event type |
dd9a70fe | 388 | if (fSelectEventType >= 0) { |
389 | if (GetType() != (UInt_t) fSelectEventType) return kFALSE; | |
390 | } | |
391 | ||
00665a00 | 392 | // Then check the trigger pattern and compared it |
393 | // to the required trigger mask | |
394 | if (fSelectTriggerMask != 0) { | |
395 | if ((GetClassMask() & fSelectTriggerMask) != fSelectTriggerMask) return kFALSE; | |
396 | } | |
397 | ||
dd9a70fe | 398 | return kTRUE; |
399 | } | |
400 | ||
91f76e9b | 401 | UInt_t AliRawReader::SwapWord(UInt_t x) const |
402 | { | |
403 | // Swap the endianess of the integer value 'x' | |
404 | ||
405 | return (((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) << 8) | | |
406 | ((x & 0x00ff0000U) >> 8) | ((x & 0xff000000U) >> 24)); | |
407 | } | |
408 | ||
409 | UShort_t AliRawReader::SwapShort(UShort_t x) const | |
410 | { | |
411 | // Swap the endianess of the short value 'x' | |
412 | ||
413 | return (((x & 0x00ffU) << 8) | ((x & 0xff00U) >> 8)) ; | |
414 | } | |
a6e7b125 | 415 | |
a6e7b125 | 416 | Bool_t AliRawReader::ReadNextInt(UInt_t& data) |
417 | { | |
8de97894 | 418 | // reads the next 4 bytes at the current position |
419 | // returns kFALSE if the data could not be read | |
a6e7b125 | 420 | |
421 | while (fCount == 0) { | |
c946ab02 | 422 | if (!ReadHeader()) return kFALSE; |
a6e7b125 | 423 | } |
8de97894 | 424 | if (fCount < (Int_t) sizeof(data)) { |
425 | Error("ReadNextInt", | |
426 | "too few data left (%d bytes) to read an UInt_t!", fCount); | |
427 | return kFALSE; | |
428 | } | |
429 | if (!ReadNext((UChar_t*) &data, sizeof(data))) { | |
a6e7b125 | 430 | Error("ReadNextInt", "could not read data!"); |
431 | return kFALSE; | |
432 | } | |
91f76e9b | 433 | #ifndef R__BYTESWAP |
434 | data=SwapWord(data); | |
435 | #endif | |
a6e7b125 | 436 | return kTRUE; |
437 | } | |
438 | ||
439 | Bool_t AliRawReader::ReadNextShort(UShort_t& data) | |
440 | { | |
8de97894 | 441 | // reads the next 2 bytes at the current position |
442 | // returns kFALSE if the data could not be read | |
a6e7b125 | 443 | |
444 | while (fCount == 0) { | |
c946ab02 | 445 | if (!ReadHeader()) return kFALSE; |
a6e7b125 | 446 | } |
8de97894 | 447 | if (fCount < (Int_t) sizeof(data)) { |
448 | Error("ReadNextShort", | |
449 | "too few data left (%d bytes) to read an UShort_t!", fCount); | |
450 | return kFALSE; | |
451 | } | |
452 | if (!ReadNext((UChar_t*) &data, sizeof(data))) { | |
a6e7b125 | 453 | Error("ReadNextShort", "could not read data!"); |
454 | return kFALSE; | |
455 | } | |
91f76e9b | 456 | #ifndef R__BYTESWAP |
457 | data=SwapShort(data); | |
458 | #endif | |
a6e7b125 | 459 | return kTRUE; |
460 | } | |
461 | ||
462 | Bool_t AliRawReader::ReadNextChar(UChar_t& data) | |
463 | { | |
464 | // reads the next 1 byte at the current stream position | |
8de97894 | 465 | // returns kFALSE if the data could not be read |
a6e7b125 | 466 | |
467 | while (fCount == 0) { | |
c946ab02 | 468 | if (!ReadHeader()) return kFALSE; |
a6e7b125 | 469 | } |
8de97894 | 470 | if (!ReadNext((UChar_t*) &data, sizeof(data))) { |
a6e7b125 | 471 | Error("ReadNextChar", "could not read data!"); |
472 | return kFALSE; | |
473 | } | |
a6e7b125 | 474 | return kTRUE; |
475 | } | |
476 | ||
b4857df7 | 477 | |
478 | Int_t AliRawReader::CheckData() const | |
479 | { | |
480 | // check the consistency of the data | |
481 | // derived classes should overwrite the default method which returns 0 (no err) | |
482 | ||
483 | return 0; | |
484 | } | |
485 | ||
509a7696 | 486 | |
487 | void AliRawReader::DumpData(Int_t limit) | |
488 | { | |
489 | // print the raw data | |
490 | // if limit is not negative, only the first and last "limit" lines of raw data | |
491 | // are printed | |
492 | ||
493 | Reset(); | |
494 | if (!ReadHeader()) { | |
495 | Error("DumpData", "no header"); | |
496 | return; | |
497 | } | |
498 | printf("header:\n" | |
499 | " type = %d run = %d ", GetType(), GetRunNumber()); | |
500 | if (GetEventId()) { | |
501 | printf("event = %8.8x %8.8x\n", GetEventId()[1], GetEventId()[0]); | |
502 | } else { | |
503 | printf("event = -------- --------\n"); | |
504 | } | |
505 | if (GetTriggerPattern()) { | |
506 | printf(" trigger = %8.8x %8.8x ", | |
507 | GetTriggerPattern()[1], GetTriggerPattern()[0]); | |
508 | } else { | |
509 | printf(" trigger = -------- -------- "); | |
510 | } | |
511 | if (GetDetectorPattern()) { | |
512 | printf("detector = %8.8x\n", GetDetectorPattern()[0]); | |
513 | } else { | |
514 | printf("detector = --------\n"); | |
515 | } | |
516 | if (GetAttributes()) { | |
517 | printf(" attributes = %8.8x %8.8x %8.8x ", | |
518 | GetAttributes()[2], GetAttributes()[1], GetAttributes()[0]); | |
519 | } else { | |
520 | printf(" attributes = -------- -------- -------- "); | |
521 | } | |
522 | printf("GDC = %d\n", GetGDCId()); | |
523 | printf("\n"); | |
524 | ||
525 | do { | |
526 | printf("-------------------------------------------------------------------------------\n"); | |
527 | printf("LDC = %d\n", GetLDCId()); | |
528 | ||
529 | printf("equipment:\n" | |
530 | " size = %d type = %d id = %d\n", | |
531 | GetEquipmentSize(), GetEquipmentType(), GetEquipmentId()); | |
532 | if (GetEquipmentAttributes()) { | |
533 | printf(" attributes = %8.8x %8.8x %8.8x ", GetEquipmentAttributes()[2], | |
534 | GetEquipmentAttributes()[1], GetEquipmentAttributes()[0]); | |
535 | } else { | |
536 | printf(" attributes = -------- -------- -------- "); | |
537 | } | |
538 | printf("element size = %d\n", GetEquipmentElementSize()); | |
539 | ||
39f9963f | 540 | printf("data header:\n" |
541 | " size = %d version = %d valid = %d compression = %d\n", | |
542 | GetDataSize(), GetVersion(), IsValid(), IsCompressed()); | |
509a7696 | 543 | |
544 | printf("\n"); | |
545 | if (limit == 0) continue; | |
546 | ||
547 | Int_t size = GetDataSize(); | |
548 | char line[70]; | |
549 | for (Int_t i = 0; i < 70; i++) line[i] = ' '; | |
550 | line[69] = '\0'; | |
551 | Int_t pos = 0; | |
552 | Int_t max = 16; | |
553 | UChar_t byte; | |
554 | ||
555 | for (Int_t n = 0; n < size; n++) { | |
556 | if (!ReadNextChar(byte)) { | |
557 | Error("DumpData", "couldn't read byte number %d\n", n); | |
558 | break; | |
559 | } | |
560 | if (pos >= max) { | |
561 | printf("%8.8x %s\n", n-pos, line); | |
562 | for (Int_t i = 0; i < 70; i++) line[i] = ' '; | |
563 | line[69] = '\0'; | |
564 | pos = 0; | |
565 | if ((limit > 0) && (n/max == limit)) { | |
566 | Int_t nContinue = ((size-1)/max+1-limit) * max; | |
567 | if (nContinue > n) { | |
568 | printf(" [skipping %d bytes]\n", nContinue-n); | |
569 | n = nContinue-1; | |
570 | continue; | |
571 | } | |
572 | } | |
573 | } | |
574 | Int_t offset = pos/4; | |
575 | if ((byte > 0x20) && (byte < 0x7f)) { | |
576 | line[pos+offset] = byte; | |
577 | } else { | |
578 | line[pos+offset] = '.'; | |
579 | } | |
580 | char hex[3]; | |
581 | sprintf(hex, "%2.2x", byte); | |
582 | line[max+max/4+3+2*pos+offset] = hex[0]; | |
583 | line[max+max/4+4+2*pos+offset] = hex[1]; | |
584 | pos++; | |
585 | } | |
586 | ||
587 | if (pos > 0) printf("%8.8x %s\n", size-pos, line); | |
588 | printf("\n"); | |
589 | ||
590 | } while (ReadHeader()); | |
591 | } | |
38cf12f3 | 592 | |
9fc249d9 | 593 | void AliRawReader::AddErrorLog(AliRawDataErrorLog::ERawDataErrorLevel level, |
594 | Int_t code, | |
38cf12f3 | 595 | const char *message) |
596 | { | |
597 | // Add a raw data error message to the list | |
598 | // of raw-data decoding errors | |
599 | if (fEventNumber < 0) { | |
38cf12f3 | 600 | return; |
601 | } | |
3aea4e5e | 602 | Int_t ddlId = GetEquipmentId(); |
38cf12f3 | 603 | if (ddlId < 0) { |
604 | AliError("No ddl raw data have been read so far! Impossible to add a raw data error log!"); | |
605 | return; | |
606 | } | |
607 | ||
79dac785 | 608 | Int_t prevEventNumber = -1; |
609 | Int_t prevDdlId = -1; | |
610 | Int_t prevErrorCode = -1; | |
611 | AliRawDataErrorLog *prevLog = (AliRawDataErrorLog *)fErrorLogs.Last(); | |
612 | if (prevLog) { | |
613 | prevEventNumber = prevLog->GetEventNumber(); | |
614 | prevDdlId = prevLog->GetDdlID(); | |
615 | prevErrorCode = prevLog->GetErrorCode(); | |
616 | } | |
617 | ||
618 | if ((prevEventNumber != fEventNumber) || | |
619 | (prevDdlId != ddlId) || | |
620 | (prevErrorCode != code)) { | |
621 | new (fErrorLogs[fErrorLogs.GetEntriesFast()]) | |
622 | AliRawDataErrorLog(fEventNumber, | |
623 | ddlId, | |
624 | level, | |
625 | code, | |
626 | message); | |
627 | } | |
628 | else | |
629 | if (prevLog) prevLog->AddCount(); | |
630 | ||
38cf12f3 | 631 | } |