UInt_t currentFilePos = fFile->Tellp();
UInt_t size = currentFilePos-fDataHeaderPos;
- size -= sizeof(AliRawDataHeader);
+ size -= sizeof(AliRawDataHeaderV3);
if ((size % 5) != 0) {
AliFatal(Form("The current raw data payload is not a mutiple of 5 (%d) ! Can not write the RCU trailer !",size));
UInt_t currentFilePos = fFile->Tellp();
UInt_t size = currentFilePos-fDataHeaderPos;
- size -= sizeof(AliRawDataHeader);
+ size -= sizeof(AliRawDataHeaderV3);
size /= 4;
if (size > 0x3FFFFFF) {
--- /dev/null
+#ifndef ALIRAWDATAHEADERV3_H
+#define ALIRAWDATAHEADERV3_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+struct AliRawDataHeaderV3 {
+ AliRawDataHeaderV3() :
+ fSize(0xFFFFFFFF),
+ fWord2(3<<24),
+ fEventID2(0),
+ fAttributesSubDetectors(0),
+ fStatusMiniEventID(0x10000), // status bit 4: no L1/L2 trigger information
+ fTriggerClassLow(0),
+ fTriggerClassesMiddleLow(0),
+ fTriggerClassesMiddleHigh(0),
+ fROILowTriggerClassHigh(0),
+ fROIHigh(0)
+ {}
+
+ // Adding virtual destructor breaks
+ // C++ struct backward compatibility
+ // Do not uncomment the line below!!!
+ // virtual ~AliRawDataHeaderV3() {}
+
+ UShort_t GetEventID1() const
+ {
+ return (UShort_t)( fWord2 & 0xFFF );
+ };
+
+ UInt_t GetEventID2() const
+ {
+ return fEventID2;
+ };
+
+ UChar_t GetL1TriggerMessage() const
+ {
+ return (UChar_t)( (fWord2 >> 14) & 0xFF );
+ };
+
+ UChar_t GetVersion() const
+ {
+ return (UChar_t)( (fWord2 >> 24) & 0xFF );
+ };
+
+ UChar_t GetAttributes() const
+ {return (fAttributesSubDetectors >> 24) & 0xFF;};
+ Bool_t TestAttribute(Int_t index) const
+ {return (fAttributesSubDetectors >> (24 + index)) & 1;};
+ void SetAttribute(Int_t index)
+ {fAttributesSubDetectors |= (1 << (24 + index));};
+ void ResetAttribute(Int_t index)
+ {fAttributesSubDetectors &= (0xFFFFFFFF ^ (1 << (24 + index)));};
+ UInt_t GetSubDetectors() const
+ {return fAttributesSubDetectors & 0xFFFFFF;};
+
+ UInt_t GetStatus() const
+ {return (fStatusMiniEventID >> 12) & 0xFFFF;};
+ UInt_t GetMiniEventID() const
+ {return fStatusMiniEventID & 0xFFF;};
+
+ ULong64_t GetTriggerClasses() const
+ {return (((ULong64_t) (fTriggerClassesMiddleLow & 0x3FFFF)) << 32) | fTriggerClassLow;}
+ ULong64_t GetTriggerClassesNext50() const
+ {return (((ULong64_t) (fROILowTriggerClassHigh & 0x3FFFF)) << 32) | fTriggerClassesMiddleHigh;}
+ ULong64_t GetROI() const
+ {return (((ULong64_t) fROIHigh) << 4) | ((fROILowTriggerClassHigh >> 28) & 0xF);}
+
+ void SetTriggerClass(ULong64_t mask)
+ {fTriggerClassLow = (UInt_t)(mask & 0xFFFFFFFF); // low bits of trigger class
+ fTriggerClassesMiddleLow = (UInt_t)((mask >> 32) & 0x3FFFF); // low bits of ROI data (bits 28-31) and high bits of trigger class (bits 0-17)
+ };
+ void SetTriggerClassNext50(ULong64_t mask)
+ {fTriggerClassesMiddleHigh = (UInt_t)(mask & 0xFFFFFFFF); // low bits of trigger class
+ fROILowTriggerClassHigh = (UInt_t)((mask >> 32) & 0x3FFFF); // low bits of ROI data (bits 28-31) and high bits of trigger class (bits 0-17)
+ };
+
+ UInt_t fSize; // size of the raw data in bytes
+ UInt_t fWord2; // bunch crossing, L1 trigger message and fomrat version
+ UInt_t fEventID2; // orbit number
+ UInt_t fAttributesSubDetectors; // block attributes (bits 24-31) and participating sub detectors
+ UInt_t fStatusMiniEventID; // status & error bits (bits 12-27) and mini event ID (bits 0-11)
+ UInt_t fTriggerClassLow; // low bits of trigger class
+ UInt_t fTriggerClassesMiddleLow; // 18 bits go into eventTriggerPattern[1] (low), 14 bits are zeroes (cdhMBZ2)
+ UInt_t fTriggerClassesMiddleHigh; // Goes into eventTriggerPattern[1] (high) and [2] (low)
+ UInt_t fROILowTriggerClassHigh; // low bits of ROI data (bits 28-31) and high bits of trigger class (bits 0-17)
+ UInt_t fROIHigh; // high bits of ROI data
+};
+
+#endif
END_EVENT_HEADER(3,13)
+START_EVENT_HEADER(3,14)
+
+ UInt_t fType; // event type
+ UInt_t fRunNb; // run number
+ UInt_t fId[2]; // id field
+ UInt_t fTriggerPattern[4]; // trigger pattern
+ UInt_t fDetectorPattern; // detector pattern
+ UInt_t fTypeAttribute[3]; // system (0,1) and user (2) attributes
+ UInt_t fLdcId; // LDC id
+ UInt_t fGdcId; // GDC id
+ UInt_t fTimestamp; // event timestamp
+ UInt_t fTimestampUsec; // event timestamp (microseconds)
+
+END_EVENT_HEADER(3,14)
+
#endif
fEquipmentIdsOut(NULL),
fRequireHeader(kTRUE),
fHeader(NULL),
+ fHeaderV3(NULL),
fCount(0),
fSelectEquipmentType(-1),
fSelectMinEquipmentId(-1),
fEventNumber(-1),
fErrorLogs("AliRawDataErrorLog",100),
fHeaderSwapped(NULL),
+ fHeaderSwappedV3(NULL),
fIsValid(kTRUE),
fIsTriggerClassLoaded(kFALSE)
{
// Allocate the swapped header in case of Mac
#ifndef R__BYTESWAP
fHeaderSwapped=new AliRawDataHeader();
+ fHeaderSwappedV3=new AliRawDataHeaderV3();
#endif
}
fEquipmentIdsOut(rawReader.fEquipmentIdsOut),
fRequireHeader(rawReader.fRequireHeader),
fHeader(rawReader.fHeader),
+ fHeaderV3(rawReader.fHeaderV3),
fCount(rawReader.fCount),
fSelectEquipmentType(rawReader.fSelectEquipmentType),
fSelectMinEquipmentId(rawReader.fSelectMinEquipmentId),
fEventNumber(-1),
fErrorLogs("AliRawDataErrorLog",100),
fHeaderSwapped(NULL),
+ fHeaderSwappedV3(NULL),
fIsValid(rawReader.fIsValid),
fIsTriggerClassLoaded(rawReader.fIsTriggerClassLoaded)
{
// Allocate the swapped header in case of Mac
#ifndef R__BYTESWAP
fHeaderSwapped=new AliRawDataHeader(*rawReader.fHeaderSwapped);
+ fHeaderSwappedV3=new AliRawDataHeader(*rawReader.fHeaderSwappedV3);
#endif
}
fEquipmentIdsOut = rawReader.fEquipmentIdsOut;
fHeader = rawReader.fHeader;
+ fHeaderV3 = rawReader.fHeaderV3;
fCount = rawReader.fCount;
fSelectEquipmentType = rawReader.fSelectEquipmentType;
if (fEquipmentIdsOut) delete fEquipmentIdsOut;
fErrorLogs.Delete();
if (fHeaderSwapped) delete fHeaderSwapped;
+ if (fHeaderSwappedV3) delete fHeaderSwappedV3;
}
AliRawReader* AliRawReader::Create(const char *uri)
#include "AliRawDataErrorLog.h"
#include "AliRawDataHeader.h"
+#include "AliRawDataHeaderV3.h"
class THashList;
class TChain;
Int_t GetDataSize() const
{if (fHeader) {
- if (fHeader->fSize != 0xFFFFFFFF) return fHeader->fSize - sizeof(AliRawDataHeader);
- else return GetEquipmentSize() - GetEquipmentHeaderSize() - sizeof(AliRawDataHeader);
- } else return GetEquipmentSize() - GetEquipmentHeaderSize();};
+ if (fHeader->fSize != 0xFFFFFFFF) return fHeader->fSize - sizeof(AliRawDataHeader);
+ else return GetEquipmentSize() - GetEquipmentHeaderSize() - sizeof(AliRawDataHeader);
+ } else if(fHeaderV3){
+ if (fHeaderV3->fSize != 0xFFFFFFFF) return fHeaderV3->fSize - sizeof(AliRawDataHeaderV3);
+ else return GetEquipmentSize() - GetEquipmentHeaderSize() - sizeof(AliRawDataHeaderV3);
+ }
+ else return GetEquipmentSize() - GetEquipmentHeaderSize();};
Int_t GetVersion() const
- {if (fHeader) return fHeader->GetVersion(); else return -1;};
+ {if (fHeader) return fHeader->GetVersion();
+ else if (fHeaderV3) return fHeaderV3->GetVersion();
+ else return -1;};
Bool_t IsValid() const
- {if (fHeader) return fHeader->TestAttribute(0);
- else return kFALSE;};
+ {if (fHeader) return fHeader->TestAttribute(0);
+ else if (fHeaderV3) return fHeaderV3->TestAttribute(0);
+ else return kFALSE;};
Bool_t IsCompressed() const
{if (fHeader) return fHeader->TestAttribute(1);
+ else if (fHeaderV3) return fHeaderV3->TestAttribute(1);
else return kFALSE;};
Bool_t TestBlockAttribute(Int_t index) const
- {if (fHeader) return fHeader->TestAttribute(index);
+ {if (fHeader) return fHeader->TestAttribute(index);
+ else if (fHeaderV3) return fHeaderV3->TestAttribute(index);
else return kFALSE;};
UChar_t GetBlockAttributes() const
{if (fHeader) return fHeader->GetAttributes();
+ else if (fHeaderV3) return fHeaderV3->GetAttributes();
else return 0;};
UInt_t GetStatusBits() const
{if (fHeader) return fHeader->GetStatus();
+ else if (fHeaderV3) return fHeaderV3->GetStatus();
else return 0;};
const AliRawDataHeader* GetDataHeader() const
{return fHeader;}
+ const AliRawDataHeaderV3* GetDataHeaderV3() const
+ {return fHeaderV3;}
virtual Bool_t ReadHeader() = 0;
virtual Bool_t ReadNextData(UChar_t*& data) = 0;
Bool_t fRequireHeader; // if false, data without header is accepted
AliRawDataHeader* fHeader; // current data header
+ AliRawDataHeaderV3* fHeaderV3; // current data header
Int_t fCount; // counter of bytes to be read for current DDL
Int_t fSelectEquipmentType; // type of selected equipment (<0 = no selection)
TClonesArray fErrorLogs; // raw data decoding errors
AliRawDataHeader* fHeaderSwapped; // temporary buffer for swapping header on PowerPC
+ AliRawDataHeaderV3* fHeaderSwappedV3; // temporary buffer for swapping header on PowerPC
UInt_t SwapWord(UInt_t x) const;
UShort_t SwapShort(UShort_t x) const;
fSubEvent = fEvent->GetSubEvent(fSubEventIndex-1);
fEquipment = fSubEvent->GetEquipment(fEquipmentIndex);
fRawData = fEquipment->GetRawData();
- fCount = 0;
+ fCount = 0;
fHeader = (AliRawDataHeader*) ((UChar_t*) fRawData->GetBuffer() +
((UChar_t*) rawReader.fHeader -
(UChar_t*) rawReader.fRawData->GetBuffer()));
+ // Now check the version of the header
+ UChar_t version = 2;
+ if (fHeader) version = fHeader->GetVersion();
+ if (version==3) {
+ fHeader = NULL;
+ fHeaderV3 = (AliRawDataHeaderV3*) ((UChar_t*) fRawData->GetBuffer() +
+ ((UChar_t*) rawReader.fHeaderV3 -
+ (UChar_t*) rawReader.fRawData->GetBuffer()));
+ }
fPosition = (UChar_t*) fRawData->GetBuffer() +
(rawReader.fPosition - (UChar_t*) rawReader.fRawData->GetBuffer());
fEnd = ((UChar_t*) fRawData->GetBuffer()) + fRawData->GetSize();
// "read" the data header
fHeader = (AliRawDataHeader*) fPosition;
+ // Now check the version of the header
+ UChar_t version = 2;
+ if (fHeader) version=fHeader->GetVersion();
+ if (version==2) {
+ #ifndef R__BYTESWAP
+ SwapData((void*) fHeader, (void*) fHeaderSwapped, sizeof(AliRawDataHeader));
+ fHeader=fHeaderSwapped;
+#endif
+ if ((fPosition + fHeader->fSize) != fEnd) {
+ if (fHeader->fSize != 0xFFFFFFFF)
+ Warning("ReadHeader",
+ "Equipment %d : raw data size found in the header is wrong (%d != %ld)! Using the equipment size instead !",
+ fEquipment->GetEquipmentHeader()->GetId(),fHeader->fSize, fEnd - fPosition);
+ fHeader->fSize = fEnd - fPosition;
+ }
+ fPosition += sizeof(AliRawDataHeader);
+ fHeaderV3 = 0;
+ } else if (version==3) {
+ fHeaderV3 = (AliRawDataHeaderV3*) fPosition;
#ifndef R__BYTESWAP
- SwapData((void*) fHeader, (void*) fHeaderSwapped, sizeof(AliRawDataHeader));
- fHeader=fHeaderSwapped;
+ SwapData((void*) fHeaderV3, (void*) fHeaderSwapped, sizeof(AliRawDataHeaderV3));
+ fHeaderV3=fHeaderSwappedV3;
#endif
- if ((fPosition + fHeader->fSize) != fEnd) {
- if (fHeader->fSize != 0xFFFFFFFF)
- Warning("ReadHeader",
- "Equipment %d : raw data size found in the header is wrong (%d != %ld)! Using the equipment size instead !",
- fEquipment->GetEquipmentHeader()->GetId(),fHeader->fSize, fEnd - fPosition);
- fHeader->fSize = fEnd - fPosition;
+ if ((fPosition + fHeaderV3->fSize) != fEnd) {
+ if (fHeaderV3->fSize != 0xFFFFFFFF)
+ Warning("ReadHeader",
+ "Equipment %d : raw data size found in the header is wrong (%d != %ld)! Using the equipment size instead !",
+ fEquipment->GetEquipmentHeader()->GetId(),fHeader->fSize, fEnd - fPosition);
+ fHeaderV3->fSize = fEnd - fPosition;
+ }
+ fPosition += sizeof(AliRawDataHeaderV3);
+ fHeader = 0;
}
- fPosition += sizeof(AliRawDataHeader);
}
if (fHeader && (fHeader->fSize != 0xFFFFFFFF)) {
fCount = fHeader->fSize - sizeof(AliRawDataHeader);
+ // check consistency of data size in the header and in the sub event
+ if (fPosition + fCount > fEnd) {
+ Error("ReadHeader", "size in data header exceeds event size!");
+ Warning("ReadHeader", "skipping %ld bytes", fEnd - fPosition);
+ fEquipment->GetEquipmentHeader()->Dump();
+ fCount = 0;
+ fPosition = fEnd;
+ fErrorCode = kErrSize;
+ continue;
+ }
+ } else if (fHeaderV3 && (fHeaderV3->fSize != 0xFFFFFFFF)) {
+ fCount = fHeaderV3->fSize - sizeof(AliRawDataHeaderV3);
+
// check consistency of data size in the header and in the sub event
if (fPosition + fCount > fEnd) {
Error("ReadHeader", "size in data header exceeds event size!");
fEquipment = NULL;
fRawData = NULL;
fHeader = NULL;
+ fHeaderV3 = NULL;
fCount = 0;
fPosition = fEnd = NULL;
endif(DATE_ROOT)
-set ( EXPORT AliRawDataHeader.h AliAltroMapping.h)
+set ( EXPORT AliRawDataHeader.h AliRawDataHeaderV3.h AliAltroMapping.h)
set ( EINCLUDE STEER/ESD STEER/STEERBase )
struct eventHeaderStruct header;
int loaded;
unsigned long32 detPattern;
- eventTimestampType timestamp;
+ eventTimestampSecType timestamp;
} *currGdc;
struct ldcEventDescriptorStruct {
struct equipmentEventDescriptorStruct *head;
struct eventHeaderStruct header;
int loaded;
unsigned long32 detPattern;
- eventTimestampType timestamp;
+ eventTimestampSecType timestamp;
} *currLdc;
struct equipmentEventDescriptorStruct {
struct equipmentEventDescriptorStruct *next;
int lineNmb;
eventGdcIdType currGdcId;
unsigned long32 currDetPattern;
-eventTimestampType currTimestamp;
+eventTimestampSecType currTimestamp;
eventLdcIdType currLdcId;
equipmentIdType currEquipmentId;
int currRunNb;
printf( "\n" );
printf( " " );
- if ( cdh->cdhMBZ3 != 0 ) {
- printf( "MBZ3:0x%x ",
- cdh->cdhMBZ3 );
- }
printf( "ROI:0x(%08x-%01x)", cdh->cdhRoiHigh, cdh->cdhRoiLow );
if ( cdh->cdhRoiHigh != 0
|| cdh->cdhRoiLow != 0 ) {
if ( cdh->cdhMBZ0 != 0
|| cdh->cdhMBZ1 != 0
|| cdh->cdhMBZ2 != 0
- || cdh->cdhMBZ3 != 0 ) {
+ ) {
fprintf( stderr,
- "%s: CDH check failed. MBZ0:0x%x MBZ1:0x%x MBZ2:0x%x MBZ3:0x%x\n",
+ "%s: CDH check failed. MBZ0:0x%x MBZ1:0x%x MBZ2:0x%x\n",
myName,
- cdh->cdhMBZ0, cdh->cdhMBZ1, cdh->cdhMBZ2, cdh->cdhMBZ3 );
+ cdh->cdhMBZ0, cdh->cdhMBZ1, cdh->cdhMBZ2 );
exit( 1 );
}
}
* L1 trigger message [14-21]
* V03.08 RD 17-Jan-07 Added "BY DETECTOR" event system attribute
* V03.09 RD 08-Feb-07 Moved trigger and detector masks down 1 bit
+ * KS 14-May-08 Define trigger error bits 13+14 for the CDH
+ * V03.10 RD 10-Nov-09 Define ATTR_EMPTY_EVENT attribute (removed)
+ * V03.11 RD 01-Dec-10 Timestamp sec + usec
+ * V03.12 RD 13-Sep-11 Added ATTR_ORIGINAL_EVENT and CDH_ORIGINAL_EVENT
+ * V03.13 RD 15-Feb-12 Added SYNC event
+ * RD 15-Jan-14 Added FLUSHED_EVENT and INCOMPLETE_EVENT
+ * V03.14 RD 12-Feb-14 Changes for increased number of trigger classes
+ * (old:50, new:100) and for CDH V3
*
* Preprocessor definitions:
* NDEBUG Define BEFORE including this file to disable run-time checks on
- * various parameters
+ * various parameters made via assert()
*
* Related facilities:
* validateEvent.c Validation program, should be run after EACH change to
#ifndef __event_h__
#define __event_h__
-#define EVENT_MAJOR_VERSION_NUMBER 0x0003
-#define EVENT_MINOR_VERSION_NUMBER 0x0009
+#define EVENT_MAJOR_VERSION_NUMBER 3
+#define EVENT_MINOR_VERSION_NUMBER 14
/* ========== System includes ========= */
#include <string.h> /* Needed by: memset, memcpy */
/* ========== Definitions for the event header ========== */
-/* ---------- Header base size ---------- */
-/* This value must be updated for each change in the eventHeaderStruct */
-#define EVENT_HEAD_BASE_SIZE 68
+/* ------------------------- Header base size ------------------------- */
+/* This value must be updated for each change in the eventHeaderStruct */
+/* This has not been made automatic as we want to keep this value under */
+/* strict control... */
+#define EVENT_HEAD_BASE_SIZE 80
/* ---------- Event size ---------- */
typedef unsigned long32 eventSizeType;
-/* ---------- Magic signature and its byte-swapped version ---------- */
+/* ----------- Magic signature and its byte-swapped version ----------- */
typedef unsigned long32 eventMagicType;
#define EVENT_MAGIC_NUMBER ((eventMagicType)0xDA1E5AFE)
#define EVENT_MAGIC_NUMBER_SWAPPED ((eventMagicType)0xFE5A1EDA)
#define END_OF_DATA ((eventTypeType)11)
#define SYSTEM_SOFTWARE_TRIGGER_EVENT ((eventTypeType)12)
#define DETECTOR_SOFTWARE_TRIGGER_EVENT ((eventTypeType)13)
+#define SYNC_EVENT ((eventTypeType)14)
#define EVENT_TYPE_MIN 1
-#define EVENT_TYPE_MAX 13
+#define EVENT_TYPE_MAX 14
enum eventTypeEnum {
startOfRun = START_OF_RUN,
endOfRun = END_OF_RUN,
startOfData = START_OF_DATA,
endOfData = END_OF_DATA,
systemSoftwareTriggerEvent = SYSTEM_SOFTWARE_TRIGGER_EVENT,
- detectorSoftwareTriggerEvent = DETECTOR_SOFTWARE_TRIGGER_EVENT
+ detectorSoftwareTriggerEvent = DETECTOR_SOFTWARE_TRIGGER_EVENT,
+ syncEvent = SYNC_EVENT
};
#define EVENT_TYPE_OK(t) (((t) >= EVENT_TYPE_MIN) && (((t) <= EVENT_TYPE_MAX)))
memcpy((void*)to,(const void*)from,EVENT_ID_BYTES)
#define ADD_EVENT_ID(a,b) ((a)[1]+=(b)[1],(a)[0]+=(b)[0])
#define SUB_EVENT_ID(a,b) ((a)[1]-=(b)[1],(a)[0]-=(b)[0])
-#define ZERO_EVENT_ID(id) memset(id,0,EVENT_ID_BYTES)
+#define ZERO_EVENT_ID(id) memset((void *)(id),0,EVENT_ID_BYTES)
/* ---------- Trigger pattern (and relative masks) ---------- */
-#define EVENT_TRIGGER_PATTERN_BYTES 8
+// The top bit of the trigger pattern is reserved for the validity flag
+#define EVENT_TRIGGER_PATTERN_BYTES 16
#define EVENT_TRIGGER_PATTERN_WORDS ((EVENT_TRIGGER_PATTERN_BYTES)>>2)
typedef unsigned long32 eventTriggerPatternType[EVENT_TRIGGER_PATTERN_WORDS];
#define EVENT_TRIGGER_ID_MIN 0
-#define EVENT_TRIGGER_ID_MAX 49
+#define EVENT_TRIGGER_ID_MAX 99
#define CHECK_TRIGGER(t) (assert(((t)>=EVENT_TRIGGER_ID_MIN) && \
((t)<=EVENT_TRIGGER_ID_MAX)))
#define TRIGGER_TO_BIT(t) (1<<((t)&0x1f))
#define TRIGGER_TO_WORD(t) (CHECK_TRIGGER(t), (t)>>5)
-#define ZERO_TRIGGER_PATTERN(p) ((p)[0]=0, (p)[1]=0)
+#define ZERO_TRIGGER_PATTERN(p) memset( (void *)(p), 0, EVENT_TRIGGER_PATTERN_BYTES )
#define SET_TRIGGER_IN_PATTERN(p,id) (p)[TRIGGER_TO_WORD(id)] |= \
TRIGGER_TO_BIT(id)
#define CLEAR_TRIGGER_IN_PATTERN(p,id) (p)[TRIGGER_TO_WORD(id)] &= \
TRIGGER_TO_BIT(id)
#define TEST_TRIGGER_IN_PATTERN(p,id) (((p)[TRIGGER_TO_WORD(id)] & \
TRIGGER_TO_BIT(id)) != 0)
-#define TRIGGER_PATTERN_INVALID(p) (((p)[1] & 0x80000000) == 0)
-#define TRIGGER_PATTERN_VALID(p) (((p)[1] & 0x80000000) != 0)
-#define VALIDATE_TRIGGER_PATTERN(p) ((p)[1] |= 0x80000000)
-#define INVALIDATE_TRIGGER_PATTERN(p) ((p)[1] &= 0x7fffffff)
-#define COPY_TRIGGER_PATTERN(f,t) ((t)[0] = (f)[0], (t)[1]=(f)[1])
-#define TRIGGER_PATTERN_OK(p) (((p)[1] & 0x7fe00000) == 0)
+#define TRIGGER_PATTERN_INVALID(p) (((p)[EVENT_TRIGGER_PATTERN_WORDS-1] & 0x80000000) == 0)
+#define TRIGGER_PATTERN_VALID(p) (((p)[EVENT_TRIGGER_PATTERN_WORDS-1] & 0x80000000) != 0)
+#define VALIDATE_TRIGGER_PATTERN(p) ((p)[EVENT_TRIGGER_PATTERN_WORDS-1] |= 0x80000000)
+#define INVALIDATE_TRIGGER_PATTERN(p) ((p)[EVENT_TRIGGER_PATTERN_WORDS-1] &= 0x7fffffff)
+#define COPY_TRIGGER_PATTERN(f,t) memcpy( (void *)(t), (void *)(f), EVENT_TRIGGER_PATTERN_BYTES )
+#define TRIGGER_PATTERN_OK(p) (((p)[EVENT_TRIGGER_PATTERN_WORDS-1] & 0x7ffffff0) == 0)
/* ---------- Detectors cluster (and relative masks) ---------- */
#define EVENT_DETECTOR_PATTERN_BYTES 4
#define EVENT_DETECTOR_PATTERN_WORDS (EVENT_DETECTOR_PATTERN_BYTES>>2)
typedef unsigned long32 eventDetectorPatternType[EVENT_DETECTOR_PATTERN_WORDS];
#define EVENT_DETECTOR_ID_MIN 0
-#define EVENT_DETECTOR_HW_ID_MAX 23
#define EVENT_DETECTOR_ID_MAX 30
#define CHECK_DETECTOR(d) (assert(((d) >= EVENT_DETECTOR_ID_MIN) &&\
((d) <= EVENT_DETECTOR_ID_MAX)))
#define VALIDATE_DETECTOR_PATTERN(p) ((p)[0] |= 0x80000000)
#define INVALIDATE_DETECTOR_PATTERN(p) ((p)[0] &= 0x7fffffff)
#define COPY_DETECTOR_PATTERN(f,t) ((t)[0] = (f)[0])
-#define DETECTOR_PATTERN_OK(p) (((p)[0] & 0x3f000000) == 0)
-#define EVENT_DETECTOR_ITS_SPD 0
-#define EVENT_DETECTOR_ITS_SDD 1
-#define EVENT_DETECTOR_ITS_SSD 2
-#define EVENT_DETECTOR_TPC 3
-#define EVENT_DETECTOR_TRD 4
-#define EVENT_DETECTOR_TOF 5
-#define EVENT_DETECTOR_HMPID 6
-#define EVENT_DETECTOR_PHOS 7
-#define EVENT_DETECTOR_CPV 8
-#define EVENT_DETECTOR_PMD 9
-#define EVENT_DETECTOR_MUON_TRK 10
-#define EVENT_DETECTOR_MOUN_TRG 11
-#define EVENT_DETECTOR_FMD 12
-#define EVENT_DETECTOR_T0 13
-#define EVENT_DETECTOR_V0 14
-#define EVENT_DETECTOR_ZDC 15
-#define EVENT_DETECTOR_ACORDE 16
-#define EVENT_DETECTOR_TRG 17
-#define EVENT_DETECTOR_EMCAL 18
-#define EVENT_DETECTOR_HLT 19
-#define EVENT_DETECTOR_DAQ_TEST 30
+#define DETECTOR_PATTERN_OK(p) (((p)[0] & 0x1f000000) == 0)
+
/* ---------- The sizes and positions of the typeAttribute field ---------- */
#define ALL_ATTRIBUTE_WORDS 3
#define ATTR_KEEP_PAGES 70 /* Do not deallocate pages */
#define ATTR_HLT_DECISION 71 /* Event contains HLT decis. */
#define ATTR_BY_DETECTOR_EVENT 72 /* Event created by "by det."*/
+#define ATTR_ORIGINAL_EVENT 73 /* All original payloads */
+#define ATTR_FLUSHED_EVENT 92 /* Flushed event */
+#define ATTR_INCOMPLETE_EVENT 93 /* Incomplete event */
#define ATTR_EVENT_DATA_TRUNCATED 94 /* Truncated payload */
#define ATTR_EVENT_ERROR 95 /* Invalid event content */
ATTR_2_B(ATTR_KEEP_PAGES) | \
ATTR_2_B(ATTR_HLT_DECISION) | \
ATTR_2_B(ATTR_BY_DETECTOR_EVENT) | \
+ ATTR_2_B(ATTR_ORIGINAL_EVENT) | \
+ ATTR_2_B(ATTR_INCOMPLETE_EVENT) | \
+ ATTR_2_B(ATTR_FLUSHED_EVENT) | \
ATTR_2_B(ATTR_EVENT_DATA_TRUNCATED) | \
ATTR_2_B(ATTR_EVENT_ERROR))) == 0)
#define HOST_ID_MAX ((eventHostIdType)511) /* The maximum allowed ID */
#define VOID_ID ((eventHostIdType)-1) /* Unloaded ID */
-/* ---------- timestamp ---------- */
-/* The following definition is in common for 32 and 64 bit machines.
+/* ---------- Timestamps ----------
+
+ The timestamp of the event is associated to:
+
+ - Trigger arrived on the LDC
+ - First sub-event arrived on the GDC
+ - Event ready when monitoring by detector
+
+ The timestamp is split into seconds and microseconds.
+
+ Please note that the typical accuracy of the Unix clock is on
+ the order of the millisecond.
+
+ For more details on the subject, see the man page for gettimeofday
+ and the description of the Unix standard type struct timeval
+*/
+
+/* ---------- Seconds timestamp ----------
+
+ The following definition is in common for 32 and 64 bit machines.
In both architectures, the field must be loaded into a time_t
variable before being used. Failure to do so may cause undefined
results up to the early termination of the process.
time_t t;
- t = eventHeaderStruct.eventTimestamp;
+ t = eventHeaderStruct.eventTimestampSec;
cTime( &t ); (or whatever else can be done with a time_t)
Please note that the available timestamp will wrap sometime
around Jan 18, 19:14:07, 2038...
*/
-typedef unsigned long32 eventTimestampType;
+typedef unsigned long32 eventTimestampSecType;
+
+/* Microseconds: range [0..999999]
+ */
+typedef unsigned long32 eventTimestampUsecType;
/* ---------- The event header structure (with + without data) ---------- */
struct eventHeaderStruct {
eventTypeAttributeType eventTypeAttribute;
eventLdcIdType eventLdcId;
eventGdcIdType eventGdcId;
- eventTimestampType eventTimestamp;
+ union {
+ eventTimestampSecType eventTimestampSec;
+ /* This definition is only for backward compatibility with event.h < 3.11 */
+ eventTimestampSecType eventTimestamp;
+ };
+ eventTimestampUsecType eventTimestampUsec;
};
struct eventStruct {
};
/* ========== Definitions for the Vector ========== */
-typedef short eventVectorBankIdType;
-typedef unsigned int eventVectorSizeType;
-typedef unsigned int eventVectorOffsetType;
+typedef short eventVectorBankIdType;
+typedef datePointer eventVectorSizeType;
+typedef datePointer eventVectorOffsetType;
struct eventVectorStruct {
eventVectorBankIdType eventVectorBankId;
struct equipmentDescriptorStruct {
struct equipmentHeaderStruct equipmentHeader;
struct eventVectorStruct equipmentVector;
-};
+}
+#ifdef __GNUC__
+ __attribute__((__packed__));
+#else
+ // Find whatever method for your compiler to pack the above structure without paddings
+ ;
+#endif
struct equipmentStruct {
struct equipmentHeaderStruct equipmentHeader;
(sizeof( struct equipmentDescriptorStruct ))))
/* ========== Common data header ========== */
-#define CDH_SIZE (8 * 4)
-#define CDH_VERSION 2
-
-#define CDH_TRIGGER_OVERLAP_ERROR_BIT 0
-#define CDH_TRIGGER_MISSING_ERROR_BIT 1
-#define CDH_DATA_PARITY_ERROR_BIT 2
-#define CDH_CONTROL_PARITY_ERROR_BIT 3
-#define CDH_TRIGGER_INFORMATION_UNAVAILABLE_BIT 4
-#define CDH_FEE_ERROR_BIT 5
-#define CDH_HLT_DECISION_BIT 6
-#define CDH_HLT_PAYLOAD_BIT 7
-#define CDH_DDG_PAYLOAD_BIT 8
-#define CDH_TRIGGER_L1_TIME_VIOLATION_ERROR_BIT 9
-#define CDH_TRIGGER_L2_TIME_VIOLATION_ERROR_BIT 10
-#define CDH_TRIGGER_PREPULSE_ERROR_BIT 11
-#define CDH_TRIGGER_ERROR_BIT 12
+#define CDH_SIZE (4* 10)
+#define CDH_VERSION 3
+
+#define CDH_TRIGGER_OVERLAP_ERROR_BIT 0
+#define CDH_TRIGGER_MISSING_ERROR_BIT 1
+#define CDH_DATA_PARITY_ERROR_BIT 2
+#define CDH_CONTROL_PARITY_ERROR_BIT 3
+#define CDH_TRIGGER_INFORMATION_UNAVAILABLE_BIT 4
+#define CDH_FEE_ERROR_BIT 5
+#define CDH_HLT_DECISION_BIT 6
+#define CDH_HLT_PAYLOAD_BIT 7
+#define CDH_DDG_PAYLOAD_BIT 8
+#define CDH_TRIGGER_L1_TIME_VIOLATION_ERROR_BIT 9
+#define CDH_TRIGGER_L2_TIME_VIOLATION_ERROR_BIT 10
+#define CDH_TRIGGER_PREPULSE_ERROR_BIT 11
+#define CDH_TRIGGER_ERROR_BIT 12
+#define CDH_TRIGGER_L1_MISSING_L2_RECEIVED_BIT 13
+#define CDH_TRIGGER_MULTI_EVENT_BUFFER_ERROR_BIT 14
+#define CDH_ORIGINAL_EVENT_BIT 15
+
+/* Macro to load the trigger classes of an event header
+ using the cdhTriggerClasses* fields */
+#define CDH_LOAD_EVENT_TRIGGER_PATTERN( etp, l, ml, mh, h ) \
+ ( etp[0] = ((unsigned long32)(l)), \
+ etp[1] = ((unsigned long32)(ml) & 0x0003ffff) | ((unsigned long32)(mh) << 18), \
+ etp[2] = ((unsigned long32)(mh) >> 14) | ((unsigned long32)(h) << 18), \
+ etp[3] = ((unsigned long32)(h) >> 14) & 0xf)
/* Please note how the above data structure has been
defined for LE systems. Code running on BE systems
must have all fields reverted to work correctly! */
struct commonDataHeaderStruct {
+ unsigned cdhBlockLength : 32;
+ /* ------------------------------------- */
+ unsigned cdhEventId1 : 12;
+ unsigned cdhMBZ1 : 2;
+ unsigned cdhL1TriggerMessage : 8;
+ unsigned cdhMBZ0 : 2;
+ unsigned cdhVersion : 8;
+ /* ------------------------------------- */
+ unsigned cdhEventId2 : 24;
+ unsigned cdhParRequests : 8;
+ /* ------------------------------------- */
+ unsigned cdhParticipatingSubDetectors : 24;
+ unsigned cdhBlockAttributes : 8;
+ /* ------------------------------------- */
+ unsigned cdhMiniEventId : 12;
+ unsigned cdhStatusErrorBits : 20;
+ /* ------------------------------------- */
+ unsigned cdhTriggerClassesLow : 32; // Goes into eventTriggerPattern[0]
+ /* ------------------------------------- */
+ unsigned cdhTriggerClassesMiddleLow : 18; // Goes into eventTriggerPattern[1] (low)
+ unsigned cdhMBZ2 : 14;
+ /* ------------------------------------- */
+ unsigned cdhTriggerClassesMiddleHigh : 32; // Goes into eventTriggerPattern[1] (high) and [2] (low)
+ /* ------------------------------------- */
+ unsigned cdhTriggerClassesHigh : 18; // Goes into eventTriggerPattern[2] (high) and [3]
+ unsigned cdhMBZ4 : 10;
+ unsigned cdhRoiLow : 4;
+ /* ------------------------------------- */
+ unsigned cdhRoiHigh : 32;
+};
+
+/* Old (V2) structure, defined for backward
+ compatibility.
+
+ MAY DISAPPEAR IN FUTURE VERSIONS OF DATE!
+*/
+struct commonDataHeaderV2Struct {
unsigned cdhBlockLength : 32;
/* ------------------------------------- */
unsigned cdhEventId1 : 12;
#include <TError.h>
-#include "AliRawDataHeader.h"
+#include "AliRawDataHeaderV3.h"
#include "AliRunLoader.h"
#include "AliCentralTrigger.h"
-class AliRawDataHeaderSim : public AliRawDataHeader {
+class AliRawDataHeaderSim : public AliRawDataHeaderV3 {
public:
- AliRawDataHeaderSim() : AliRawDataHeader() {
+ AliRawDataHeaderSim() : AliRawDataHeaderV3() {
// Takes the trigger mask and
// stores it in the data header
AliRunLoader *runloader = AliRunLoader::Instance();
#include "AliTOFDecoder.h"
#include "AliTOFGeometry.h"
#include "AliRawDataHeader.h"
+#include "AliRawDataHeaderV3.h"
#include "AliTOFRawDataFormat.h"
ClassImp(AliTOFDecoder)
//_________________________________________________________________
Bool_t
-AliTOFDecoder::Decode(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh)
+AliTOFDecoder::Decode(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh, const AliRawDataHeaderV3 *cdhV3)
{
/* main decoding routine.
* it loops over nWords 32-bit words
Short_t currentBunchID = -1;
Short_t currentL0BCID = -1;
Short_t currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)(-1);
+ currentMiniEventID = cdhV3 ? cdhV3->GetMiniEventID() : (Short_t)(-1);
Short_t currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)(-1);
+ currentEventID1 = cdhV3 ? cdhV3->GetEventID1() : (Short_t)(-1);
AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh->GetEventID2(), currentMiniEventID));
- if (!cdh)
+ if (!cdh && !cdhV3)
AliWarning("CDH not valid: deltaBunchID not reliable ");
/*** V2718 patch ***/
}
//------------------------------------------------------------
-void AliTOFDecoder::PrintStack(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh)
+void AliTOFDecoder::PrintStack(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh, const AliRawDataHeaderV3 *cdhV3)
{
/* It loops over nWords 32-bit words
* starting at *rawData and prints them in 0x format.
*/
Short_t currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)(-1);
+ currentMiniEventID = cdhV3 ? cdhV3->GetMiniEventID() : (Short_t)(-1);
Short_t currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)(-1);
+ currentEventID1 = cdhV3 ? cdhV3->GetEventID1() : (Short_t)(-1);
AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh->GetEventID2(), currentMiniEventID));
- if (!cdh)
+ if (!cdh && !cdhV3)
AliWarning("CDH not valid: deltaBunchID not reliable ");
AliInfo("Printing raw data stack for current equipment\n");
class AliTOFHitDataBuffer;
struct AliRawDataHeader;
+struct AliRawDataHeaderV3;
class AliTOFDecoder : public TObject
{
AliTOFDecoder &operator = (const AliTOFDecoder &source); //operator =
~AliTOFDecoder(); //distructor
- Bool_t Decode(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh); //main decode function
+ Bool_t Decode(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh, const AliRawDataHeaderV3 *cdhV3=0); //main decode function
void SetVerbose(Int_t Verbose = 1) {fVerbose = Verbose;}; //set verbose level
void SetV2718Patch(Bool_t V2718Patch = kTRUE) {fV2718Patch = V2718Patch;}; //set V2718 patch (no DRM)
void SetDataBuffer(AliTOFHitDataBuffer *DB) {fDataBuffer = DB;}; //set up data buffer
void SetPackedDataBuffer(AliTOFHitDataBuffer *PDB) {fPackedDataBuffer = PDB;}; //set up packed data buffer
void GetArrayDDL(Int_t* array, Int_t iDDL); // method to return array of TOFchannels corresponding to a given DDL id
- void PrintStack(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh);
+ void PrintStack(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh, const AliRawDataHeaderV3 *cdhV3=0);
enum {
kMinPlate0=0,kMaxPlate0=2,
#include "AliRawEventHeaderBase.h"
#include "AliRawDataHeader.h"
+#include "AliRawDataHeaderV3.h"
#include "AliTOFDecoderV2.h"
#include "AliTOFTDCHit.h"
Int_t currentEquipment;
Int_t currentDDL;
- const AliRawDataHeader *currentCDH;
+ const AliRawDataHeader *currentCDH = 0x0;
+ const AliRawDataHeaderV3 *currentCDHV3 = 0x0;
//pointers
UChar_t *data = 0x0;
}
currentCDH = fRawReader->GetDataHeader();
+ if (!currentCDH) currentCDHV3 = fRawReader->GetDataHeaderV3();
const Int_t kDataSize = fRawReader->GetDataSize();
const Int_t kDataWords = kDataSize / 4;
data = new UChar_t[kDataSize];
fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
//start decoding
- if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
+ if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH, currentCDHV3) == kTRUE) {
fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
if (verbose) AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
ResetDataBuffer(currentDDL);
/* read and check CDH info */
const AliRawDataHeader *currentCDH = fRawReader->GetDataHeader();
- Int_t currentMiniEventID = currentCDH->GetMiniEventID();
- Int_t currentEventID1 = currentCDH->GetEventID1();
+ const AliRawDataHeaderV3 *currentCDHV3 = fRawReader->GetDataHeaderV3();
+ Int_t currentMiniEventID = currentCDH ? currentCDH->GetMiniEventID(): -1;
+ currentMiniEventID = currentCDHV3 ? currentCDHV3->GetMiniEventID(): -1;
+ Int_t currentEventID1 = currentCDH? currentCDH->GetEventID1() : -1;
+ currentEventID1 = currentCDHV3? currentCDHV3->GetEventID1() : -1;
/* read decoder summary data */
AliTOFDecoderSummaryData *decodersd;