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