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