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