3 #ifndef ALIHLTDATATYPES_H
4 #define ALIHLTDATATYPES_H
5 /* This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
9 /** @file AliHLTDataTypes.h
10 @author Matthias Richter, Timm Steinbeck, Jochen Thaeder
12 @brief Data type declaration for the HLT module.
15 //////////////////////////////////////////////////////////////////////////
17 // version no of HLT data types
19 //////////////////////////////////////////////////////////////////////////
21 /* Version Description
22 * 1 first version until June 07; implicite, not tagged
23 * 2 introduced June 07, enhanced/cleaned/arranged structure
24 * 3 2007-11-15 RAW DDL data type added; some inconsistencies fixed
25 * ('void' and 'any' origins); added signed HLT basic data types
26 * 2007-11-23 origin defines have become variables in conjunction
27 * to be used with the operator| (AliHLTComponentDatatType
28 * 2007-11-24 added trigger structs
30 #define ALIHLT_DATA_TYPES_VERSION 3
32 //////////////////////////////////////////////////////////////////////////
34 // HLT data origin variables.
36 // By converting from defines to variables, the origins can be used with
39 // AliHLTComponentDataType dt;
40 // dt = kAliHLTDataTypeDDLRaw | gkAliHLTDataOriginTPC;
42 //////////////////////////////////////////////////////////////////////////
44 /** field size of datat type origin */
45 const int kAliHLTComponentDataTypefOriginSize=4;
48 /** invalid data origin */
49 # define kAliHLTDataOriginVoid "\0\0\0"
50 /** old invalid data origin, kept for backward compatibility */
51 # define kAliHLTVoidDataOrigin "\0\0\0"
53 /** wildcard data type origin */
54 # define kAliHLTDataOriginAny "***"
55 /** old wildcard data type origin, kept for backward compatibility */
56 # define kAliHLTAnyDataOrigin "***"
59 extern const char kAliHLTDataOriginOut[kAliHLTComponentDataTypefOriginSize];
61 /** HLT/PubSub private internal */
62 extern const char kAliHLTDataOriginPrivate[kAliHLTComponentDataTypefOriginSize];
65 extern const char kAliHLTDataOriginTPC[kAliHLTComponentDataTypefOriginSize];
68 extern const char kAliHLTDataOriginPHOS[kAliHLTComponentDataTypefOriginSize];
71 extern const char kAliHLTDataOriginMUON[kAliHLTComponentDataTypefOriginSize];
74 extern const char kAliHLTDataOriginTRD[kAliHLTComponentDataTypefOriginSize];
77 extern const char kAliHLTDataOriginITS[kAliHLTComponentDataTypefOriginSize];
79 //////////////////////////////////////////////////////////////////////////
81 // HLT common data type defines
83 //////////////////////////////////////////////////////////////////////////
85 /** field size of data type id */
86 const int kAliHLTComponentDataTypefIDsize=8;
89 /** invalid data type id */
90 # define kAliHLTVoidDataTypeID "\0\0\0\0\0\0\0"
92 /** special id for any data type id */
93 # define kAliHLTAnyDataTypeID "*******"
96 # define kAliHLTDDLRawDataTypeID {'D','D','L','_','R','A','W',' '}
98 /** calibration data for file exchange subscriber */
99 # define kAliHLTFXSCalibDataTypeID {'F','X','S','_','C','A','L',' '}
101 /** start of run (SOR) event
104 # define kAliHLTSORDataTypeID {'S','T','A','R','T','O','F','R'}
106 /** end of run (EOR) event
109 # define kAliHLTEORDataTypeID {'E','N','D','O','F','R','U','N'}
112 * @ref AliHLTEventDDL
114 # define kAliHLTDDLDataTypeID {'D','D','L','L','I','S','T',' '}
117 * - empty payload, specification gives eventType
119 # define kAliHLTEventDataTypeID {'E','V','E','N','T','T','Y','P'}
124 //////////////////////////////////////////////////////////////////////////
126 // Basic HLT data types
128 //////////////////////////////////////////////////////////////////////////
130 typedef unsigned char AliHLTUInt8_t;
132 typedef signed char AliHLTInt8_t;
134 typedef unsigned short AliHLTUInt16_t;
136 typedef signed short AliHLTInt16_t;
138 typedef unsigned int AliHLTUInt32_t;
140 typedef signed int AliHLTInt32_t;
142 typedef unsigned long long AliHLTUInt64_t;
144 typedef signed long long AliHLTInt64_t;
146 typedef float AliHLTFloat32_t;
148 typedef double AliHLTFloat64_t;
150 typedef AliHLTUInt64_t AliHLTEventID_t;
152 //////////////////////////////////////////////////////////////////////////
154 // HLT logging levels
156 //////////////////////////////////////////////////////////////////////////
158 enum AliHLTComponentLogSeverity {
160 kHLTLogBenchmark = 0x1,
163 kHLTLogWarning = 0x8,
167 kHLTLogDefault = 0x3d
170 //////////////////////////////////////////////////////////////////////////
172 // HLT data structures for data exchange and external interface
174 //////////////////////////////////////////////////////////////////////////
177 * @struct AliHLTComponentEventData
180 struct AliHLTComponentEventData
182 AliHLTUInt32_t fStructSize;
183 AliHLTEventID_t fEventID;
184 AliHLTUInt32_t fEventCreation_s;
185 AliHLTUInt32_t fEventCreation_us;
186 AliHLTUInt32_t fBlockCnt;
190 * @struct AliHLTComponentShmData
191 * Shared memory descriptor.
192 * Irrelevant for analysis components.
194 struct AliHLTComponentShmData
196 AliHLTUInt32_t fStructSize;
197 AliHLTUInt32_t fShmType;
198 AliHLTUInt64_t fShmID;
202 * @struct AliHLTComponentDataType
203 * Data type descriptor for data blocks transferred through the processing
206 struct AliHLTComponentDataType
208 AliHLTUInt32_t fStructSize;
209 char fID[kAliHLTComponentDataTypefIDsize]; //!
210 char fOrigin[kAliHLTComponentDataTypefOriginSize]; //!
214 * @struct AliHLTComponentBlockData
215 * This is the decription of data blocks exchanged between components.
216 * \b IMPORTANT: The validity of fPtr and fOffset is different for input and
218 * - input blocks: The \em fPtr member always points to the beginning of the data
219 * of size \em fSize. fOffset is ignored and should be in most
221 * - output blocks: The \em fPtr member is ignored by the framework. \em fOffset
222 * must specify the start of the data relative to the output
223 * buffer. The data block has size \em fSize.
225 struct AliHLTComponentBlockData
227 /* size and version of the struct */
228 AliHLTUInt32_t fStructSize;
229 /* shared memory key, ignored by processing components */
230 AliHLTComponentShmData fShmKey;
231 /* offset of output data relative to the output buffer */
232 AliHLTUInt32_t fOffset;
233 /* start of the data for input data blocks, fOffset to be ignored*/
235 /* size of the data block */
236 AliHLTUInt32_t fSize;
237 /* data type of the data block */
238 AliHLTComponentDataType fDataType;
239 /* data specification of the data block */
240 AliHLTUInt32_t fSpecification;
244 * @struct AliHLTComponentEventDoneData
247 struct AliHLTComponentEventDoneData
249 AliHLTUInt32_t fStructSize;
250 AliHLTUInt32_t fDataSize;
255 * @struct AliHLTRunDesc
257 * The struct is send with the SOR and EOR events.
261 AliHLTUInt32_t fStructSize;
262 AliHLTUInt32_t fRunNo;
263 AliHLTUInt32_t fRunType;
266 //////////////////////////////////////////////////////////////////////////
268 // Trigger meta information
270 //////////////////////////////////////////////////////////////////////////
272 /** field size of fAttribute */
273 static const int gkAliHLTBlockDAttributeCount = 8;
275 /** field size of fCommonHeader */
276 static const int gkAliHLTCommonHeaderCount = 8;
278 /** size of the DDL list */
279 static const int gkAliHLTDDLListSize = 29;
282 * @struct AliHLTEventDDL
284 * The struct is send with the DDLLIST event.
285 * Used in the trigger structure for internal apperance of
286 * the DLLs as well as for the HLT readout list send to DAQ
287 * ( as DataType :kAliHLTDataTypeDDL )
289 struct AliHLTEventDDL
291 AliHLTUInt32_t fCount;
292 AliHLTUInt32_t fList[gkAliHLTDDLListSize];
296 * @struct AliHLTBlockHeader
297 * 1 to 1 copy from HLT framework, remember before changeing
299 struct AliHLTBlockHeader
301 AliHLTUInt32_t fLength;
305 AliHLTUInt8_t fDescr[4];
309 AliHLTUInt32_t fID:24;
310 AliHLTUInt8_t fDescr[3];
312 AliHLTUInt8_t fVersion;
316 * @struct AliHLTEventTriggerStruct
317 * 1 to 1 copy from HLT framework, remember before changeing
319 struct AliHLTEventTriggerStruct
321 AliHLTBlockHeader fHeader;
322 AliHLTUInt32_t fDataWordCount;
323 AliHLTUInt32_t fDataWords[0];
327 * @struct AliHLTEventTriggerData
328 * 1 to 1 copy from HLT framework, remember before changeing
330 struct AliHLTEventTriggerData
332 AliHLTEventTriggerStruct fETS;
333 AliHLTUInt8_t fAttributes[gkAliHLTBlockDAttributeCount];
335 AliHLTUInt64_t fHLTStatus;
336 AliHLTUInt32_t fCommonHeaderWordCnt;
337 AliHLTUInt32_t fCommonHeader[gkAliHLTCommonHeaderCount];
338 /** First word holds number of words (excluding first word) */
339 //AliHLTUInt32_t fReadoutList[gkAliHLTDDLListSize+1];
340 AliHLTEventDDL fReadoutList;
344 * @struct AliHLTComponentTriggerData
347 struct AliHLTComponentTriggerData
349 AliHLTUInt32_t fStructSize;
350 AliHLTUInt32_t fDataSize;
354 //////////////////////////////////////////////////////////////////////////
356 // HLT Event Type Specification
358 //////////////////////////////////////////////////////////////////////////
360 /** Unknown eventType specification */
361 static const AliHLTUInt32_t gkAliEventTypeUnknown = ~(AliHLTUInt32_t)0;
362 /** SOR eventType specification */
363 static const AliHLTUInt32_t gkAliEventTypeStartOfRun=1;
364 /** Data eventType specification */
365 static const AliHLTUInt32_t gkAliEventTypeData=2;
366 /** EOR eventType specification */
367 static const AliHLTUInt32_t gkAliEventTypeEndOfRun=4;
368 /** Corrupt eventType specification */
369 static const AliHLTUInt32_t gkAliEventTypeCorruptID=8;
370 /** Calibration eventType specification */
371 static const AliHLTUInt32_t gkAliEventTypeCalibration=16;
372 /** DataReplay eventType specification */
373 static const AliHLTUInt32_t gkAliEventTypeDataReplay=32;
374 /** Tick eventType specification */
375 static const AliHLTUInt32_t gkAliEventTypeTick=64;
376 /** Max eventType specification */
377 static const AliHLTUInt32_t gkAliEventTypeMax=64;
379 //////////////////////////////////////////////////////////////////////////
381 // HLT defines and defaults
383 //////////////////////////////////////////////////////////////////////////
385 /** invalid event id */
386 const AliHLTEventID_t kAliHLTVoidEventID=~(AliHLTEventID_t)0;
388 /** invalid data specification */
389 const AliHLTUInt32_t kAliHLTVoidDataSpec = ~(AliHLTUInt32_t)0;
391 /** invalid shared memory type */
392 const AliHLTUInt32_t gkAliHLTComponentInvalidShmType = 0;
394 /** invalid shared memory id */
395 const AliHLTUInt64_t gkAliHLTComponentInvalidShmID = ~(AliHLTUInt64_t)0;
397 /** invalid data type */
398 const AliHLTComponentDataType kAliHLTVoidDataType = {
399 sizeof(AliHLTComponentDataType),
400 kAliHLTVoidDataTypeID,
401 kAliHLTDataOriginVoid
404 // there is currently a problem with rootcint if the predefined ids
405 // (commented below) are used. rootcint does not find the id if they
406 // are char arrays defined with {} and individual chars. If strings
407 // are used it works fine
409 const AliHLTComponentDataType kAliHLTAnyDataType = {
410 sizeof(AliHLTComponentDataType),
411 kAliHLTAnyDataTypeID,
415 /** multiple output data types */
416 extern const AliHLTComponentDataType kAliHLTMultipleDataType;
418 /** data to file exchange subscriber */
419 extern const AliHLTComponentDataType kAliHLTDataTypeFXSCalib;
421 /** DDL list data type */
422 extern const AliHLTComponentDataType kAliHLTDataTypeDDL;
425 extern const AliHLTComponentDataType kAliHLTDataTypeSOR;
428 extern const AliHLTComponentDataType kAliHLTDataTypeEOR;
430 /** Event type specification */
431 extern const AliHLTComponentDataType kAliHLTDataTypeEvent;
433 /** RAW DDL data specification, data publisher will set type id and origin correctly */
434 extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw;
436 //////////////////////////////////////////////////////////////////////////
438 // FXS subscriber meta information
440 //////////////////////////////////////////////////////////////////////////
442 static const int gkAliHLTFXSHeaderfOriginSize = 4;
443 static const int gkAliHLTFXSHeaderfFileIDSize = 128;
444 static const int gkAliHLTFXSHeaderfDDLNumberSize = 64;
446 /** Header in front of the data payload, in order to sent data to the FXS. */
447 struct AliHLTFXSHeader
449 AliHLTUInt32_t fHeaderVersion;
450 AliHLTUInt32_t fRunNumber;
451 char fOrigin[gkAliHLTFXSHeaderfOriginSize];
452 char fFileID[gkAliHLTFXSHeaderfFileIDSize];
453 char fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize];
456 //////////////////////////////////////////////////////////////////////////
458 // Component running environment
460 //////////////////////////////////////////////////////////////////////////
462 /** logging function */
463 typedef int (*AliHLTfctLogging)( void* param,
464 AliHLTComponentLogSeverity severity,
467 const char* message);
470 * @struct AliHLTComponentEnvironment
471 * Running environment for analysis components.
472 * The struct describes function callbacks for
474 struct AliHLTComponentEnvironment
476 AliHLTUInt32_t fStructSize;
478 void* (*fAllocMemoryFunc)( void* param, unsigned long size );
480 // future addition already foreseen/envisioned
481 // IMPORTANT: don not just remove the defines as this breaks the binary
483 int (*fAllocShmMemoryFunc)( void* param, unsigned long size, AliHLTComponentBlockData* blockLocation );
485 int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd );
486 AliHLTfctLogging fLoggingFunc;
490 //////////////////////////////////////////////////////////////////////////
492 // Data type helper functions
494 //////////////////////////////////////////////////////////////////////////
496 inline bool operator==( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
498 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
499 if ( dt1.fID[i] != dt2.fID[i] )
501 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
502 if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
507 inline bool operator!=( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
509 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
510 if ( dt1.fID[i] != dt2.fID[i] )
512 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
513 if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
518 inline AliHLTComponentDataType operator|(const AliHLTComponentDataType srcdt, const char origin[kAliHLTComponentDataTypefOriginSize])
520 AliHLTComponentDataType dt=srcdt;
521 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
522 dt.fOrigin[i]=origin[i];