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