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| (AliHLTComponentDataType)
28 * 2007-11-24 added trigger structs and ESD tree data type
29 * 4 Component configuration event added
31 #define ALIHLT_DATA_TYPES_VERSION 4
33 //////////////////////////////////////////////////////////////////////////
35 // HLT data origin variables.
37 // By converting from defines to variables, the origins can be used with
40 // AliHLTComponentDataType dt;
41 // dt = kAliHLTDataTypeDDLRaw | gkAliHLTDataOriginTPC;
43 //////////////////////////////////////////////////////////////////////////
45 /** field size of datat type origin */
46 const int kAliHLTComponentDataTypefOriginSize=4;
49 /** invalid data origin */
50 # define kAliHLTDataOriginVoid "\0\0\0"
51 /** old invalid data origin, kept for backward compatibility */
52 # define kAliHLTVoidDataOrigin "\0\0\0"
54 /** wildcard data type origin */
55 # define kAliHLTDataOriginAny "***"
56 /** old wildcard data type origin, kept for backward compatibility */
57 # define kAliHLTAnyDataOrigin "***"
60 extern const char kAliHLTDataOriginOut[kAliHLTComponentDataTypefOriginSize];
62 /** HLT/PubSub private internal */
63 extern const char kAliHLTDataOriginPrivate[kAliHLTComponentDataTypefOriginSize];
66 extern const char kAliHLTDataOriginTPC[kAliHLTComponentDataTypefOriginSize];
69 extern const char kAliHLTDataOriginPHOS[kAliHLTComponentDataTypefOriginSize];
72 extern const char kAliHLTDataOriginMUON[kAliHLTComponentDataTypefOriginSize];
75 extern const char kAliHLTDataOriginTRD[kAliHLTComponentDataTypefOriginSize];
78 extern const char kAliHLTDataOriginITS[kAliHLTComponentDataTypefOriginSize];
80 //////////////////////////////////////////////////////////////////////////
82 // HLT common data type defines
84 //////////////////////////////////////////////////////////////////////////
86 /** field size of data type id */
87 const int kAliHLTComponentDataTypefIDsize=8;
90 /** invalid data type id */
91 # define kAliHLTVoidDataTypeID "\0\0\0\0\0\0\0"
93 /** special id for any data type id */
94 # define kAliHLTAnyDataTypeID "*******"
97 # define kAliHLTDDLRawDataTypeID {'D','D','L','_','R','A','W',' '}
99 /** calibration data for file exchange subscriber */
100 # define kAliHLTFXSCalibDataTypeID {'F','X','S','_','C','A','L',' '}
102 /** start of run (SOR) event
105 # define kAliHLTSORDataTypeID {'S','T','A','R','T','O','F','R'}
107 /** end of run (EOR) event
110 # define kAliHLTEORDataTypeID {'E','N','D','O','F','R','U','N'}
113 * @ref AliHLTEventDDL
115 # define kAliHLTDDLDataTypeID {'D','D','L','L','I','S','T',' '}
118 * - empty payload, specification gives eventType
120 # define kAliHLTEventDataTypeID {'E','V','E','N','T','T','Y','P'}
122 /** ComponentConfiguration event
123 * - payload contains the ID of the component in the analysis chain
125 # define kAliHLTComConfDataTypeID {'C','O','M','_','C','O','N','F'}
128 * an AliESD object of varying origin
129 * The 'V0' at the end allows a versioning
131 # define kAliHLTESDObjectDataTypeID {'A','L','I','E','S','D','V','0'}
133 /** ESD tree data block
134 * TTree with an AliESD object of varying origin
136 # define kAliHLTESDTreeDataTypeID {'E','S','D','_','T','R','E','E'}
138 /** HW Address selection data block
139 * - a selection list for 16 bit HW addresses
142 # define kAliHLTHwAddr16DataTypeID {'H','W','A','D','D','R','1','6'}
147 //////////////////////////////////////////////////////////////////////////
149 // Basic HLT data types
151 //////////////////////////////////////////////////////////////////////////
153 typedef unsigned char AliHLTUInt8_t;
155 typedef signed char AliHLTInt8_t;
157 typedef unsigned short AliHLTUInt16_t;
159 typedef signed short AliHLTInt16_t;
161 typedef unsigned int AliHLTUInt32_t;
163 typedef signed int AliHLTInt32_t;
165 typedef unsigned long long AliHLTUInt64_t;
167 typedef signed long long AliHLTInt64_t;
169 typedef float AliHLTFloat32_t;
171 typedef double AliHLTFloat64_t;
173 typedef AliHLTUInt64_t AliHLTEventID_t;
175 //////////////////////////////////////////////////////////////////////////
177 // HLT logging levels
179 //////////////////////////////////////////////////////////////////////////
181 enum AliHLTComponentLogSeverity {
183 kHLTLogBenchmark = 0x1,
186 kHLTLogWarning = 0x8,
190 kHLTLogDefault = 0x3d
193 //////////////////////////////////////////////////////////////////////////
195 // HLT data structures for data exchange and external interface
197 //////////////////////////////////////////////////////////////////////////
200 * @struct AliHLTComponentEventData
203 struct AliHLTComponentEventData
205 AliHLTUInt32_t fStructSize;
206 AliHLTEventID_t fEventID;
207 AliHLTUInt32_t fEventCreation_s;
208 AliHLTUInt32_t fEventCreation_us;
209 AliHLTUInt32_t fBlockCnt;
213 * @struct AliHLTComponentShmData
214 * Shared memory descriptor.
215 * Irrelevant for analysis components.
217 struct AliHLTComponentShmData
219 AliHLTUInt32_t fStructSize;
220 AliHLTUInt32_t fShmType;
221 AliHLTUInt64_t fShmID;
225 * @struct AliHLTComponentDataType
226 * Data type descriptor for data blocks transferred through the processing
229 struct AliHLTComponentDataType
231 AliHLTUInt32_t fStructSize;
232 char fID[kAliHLTComponentDataTypefIDsize]; //!
233 char fOrigin[kAliHLTComponentDataTypefOriginSize]; //!
237 * @struct AliHLTComponentBlockData
238 * This is the decription of data blocks exchanged between components.
239 * \b IMPORTANT: The validity of fPtr and fOffset is different for input and
241 * - input blocks: The \em fPtr member always points to the beginning of the data
242 * of size \em fSize. fOffset is ignored and should be in most
244 * - output blocks: The \em fPtr member is ignored by the framework. \em fOffset
245 * must specify the start of the data relative to the output
246 * buffer. The data block has size \em fSize.
248 struct AliHLTComponentBlockData
250 /* size and version of the struct */
251 AliHLTUInt32_t fStructSize;
252 /* shared memory key, ignored by processing components */
253 AliHLTComponentShmData fShmKey;
254 /* offset of output data relative to the output buffer */
255 AliHLTUInt32_t fOffset;
256 /* start of the data for input data blocks, fOffset to be ignored*/
258 /* size of the data block */
259 AliHLTUInt32_t fSize;
260 /* data type of the data block */
261 AliHLTComponentDataType fDataType;
262 /* data specification of the data block */
263 AliHLTUInt32_t fSpecification;
267 * @struct AliHLTComponentEventDoneData
270 struct AliHLTComponentEventDoneData
272 AliHLTUInt32_t fStructSize;
273 AliHLTUInt32_t fDataSize;
278 * @struct AliHLTRunDesc
280 * The struct is send with the SOR and EOR events.
284 AliHLTUInt32_t fStructSize;
285 AliHLTUInt32_t fRunNo;
286 AliHLTUInt32_t fRunType;
289 //////////////////////////////////////////////////////////////////////////
291 // Trigger meta information
293 //////////////////////////////////////////////////////////////////////////
295 /** field size of fAttribute */
296 static const int gkAliHLTBlockDAttributeCount = 8;
298 /** field size of fCommonHeader */
299 static const int gkAliHLTCommonHeaderCount = 8;
301 /** size of the DDL list */
302 static const int gkAliHLTDDLListSize = 29;
305 * @struct AliHLTEventDDL
307 * The struct is send with the DDLLIST event.
308 * Used in the trigger structure for internal apperance of
309 * the DLLs as well as for the HLT readout list send to DAQ
310 * ( as DataType : kAliHLTDataTypeDDL )
312 struct AliHLTEventDDL
314 AliHLTUInt32_t fCount;
315 AliHLTUInt32_t fList[gkAliHLTDDLListSize];
319 * @struct AliHLTEventTriggerData
321 struct AliHLTEventTriggerData
323 AliHLTUInt8_t fAttributes[gkAliHLTBlockDAttributeCount];
324 AliHLTUInt64_t fHLTStatus; // Bit field
325 AliHLTUInt32_t fCommonHeaderWordCnt;
326 AliHLTUInt32_t fCommonHeader[gkAliHLTCommonHeaderCount];
327 AliHLTEventDDL fReadoutList;
331 * @struct AliHLTComponentTriggerData
334 struct AliHLTComponentTriggerData
336 AliHLTUInt32_t fStructSize;
337 AliHLTUInt32_t fDataSize;
341 //////////////////////////////////////////////////////////////////////////
343 // HLT Event Type Specification
345 //////////////////////////////////////////////////////////////////////////
347 /** Unknown eventType specification */
348 static const AliHLTUInt32_t gkAliEventTypeUnknown = ~(AliHLTUInt32_t)0;
349 /** SOR eventType specification */
350 static const AliHLTUInt32_t gkAliEventTypeStartOfRun=1;
351 /** Data eventType specification */
352 static const AliHLTUInt32_t gkAliEventTypeData=2;
353 /** EOR eventType specification */
354 static const AliHLTUInt32_t gkAliEventTypeEndOfRun=4;
355 /** Corrupt eventType specification */
356 static const AliHLTUInt32_t gkAliEventTypeCorruptID=8;
357 /** Calibration eventType specification */
358 static const AliHLTUInt32_t gkAliEventTypeCalibration=16;
359 /** DataReplay eventType specification */
360 static const AliHLTUInt32_t gkAliEventTypeDataReplay=32;
361 /** Tick eventType specification */
362 static const AliHLTUInt32_t gkAliEventTypeTick=64;
363 /** Max eventType specification */
364 static const AliHLTUInt32_t gkAliEventTypeMax=64;
366 //////////////////////////////////////////////////////////////////////////
368 // HLT defines and defaults
370 //////////////////////////////////////////////////////////////////////////
372 /** invalid event id */
373 const AliHLTEventID_t kAliHLTVoidEventID=~(AliHLTEventID_t)0;
375 /** invalid data specification */
376 const AliHLTUInt32_t kAliHLTVoidDataSpec = ~(AliHLTUInt32_t)0;
378 /** invalid shared memory type */
379 const AliHLTUInt32_t gkAliHLTComponentInvalidShmType = 0;
381 /** invalid shared memory id */
382 const AliHLTUInt64_t gkAliHLTComponentInvalidShmID = ~(AliHLTUInt64_t)0;
384 /** invalid data type */
385 const AliHLTComponentDataType kAliHLTVoidDataType = {
386 sizeof(AliHLTComponentDataType),
387 kAliHLTVoidDataTypeID,
388 kAliHLTDataOriginVoid
391 // there is currently a problem with rootcint if the predefined ids
392 // (commented below) are used. rootcint does not find the id if they
393 // are char arrays defined with {} and individual chars. If strings
394 // are used it works fine
396 const AliHLTComponentDataType kAliHLTAnyDataType = {
397 sizeof(AliHLTComponentDataType),
398 kAliHLTAnyDataTypeID,
402 /** multiple output data types */
403 extern const AliHLTComponentDataType kAliHLTMultipleDataType;
405 /** data to file exchange subscriber */
406 extern const AliHLTComponentDataType kAliHLTDataTypeFXSCalib;
408 /** DDL list data type */
409 extern const AliHLTComponentDataType kAliHLTDataTypeDDL;
412 extern const AliHLTComponentDataType kAliHLTDataTypeSOR;
415 extern const AliHLTComponentDataType kAliHLTDataTypeEOR;
417 /** Event type specification */
418 extern const AliHLTComponentDataType kAliHLTDataTypeEvent;
420 /** Configuration event data type */
421 extern const AliHLTComponentDataType kAliHLTDataTypeComConf;
423 /** RAW DDL data specification, origin is 'any', data publisher origin correctly */
424 extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw;
426 /** ESD object data specification, origin is 'any' */
427 extern const AliHLTComponentDataType kAliHLTDataTypeESDObject;
429 /** ESD Tree data specification, origin is 'any' */
430 extern const AliHLTComponentDataType kAliHLTDataTypeESDTree;
432 /** 16 bit Hardware address selection data specification, origin is 'any' */
433 extern const AliHLTComponentDataType kAliHLTDataTypeHwAddr16;
435 //////////////////////////////////////////////////////////////////////////
437 // FXS subscriber meta information
439 //////////////////////////////////////////////////////////////////////////
441 static const int gkAliHLTFXSHeaderfOriginSize = 4;
442 static const int gkAliHLTFXSHeaderfFileIDSize = 128;
443 static const int gkAliHLTFXSHeaderfDDLNumberSize = 64;
445 /** Header in front of the data payload, in order to sent data to the FXS. */
446 struct AliHLTFXSHeader
448 AliHLTUInt32_t fHeaderVersion;
449 AliHLTUInt32_t fRunNumber;
450 char fOrigin[gkAliHLTFXSHeaderfOriginSize];
451 char fFileID[gkAliHLTFXSHeaderfFileIDSize];
452 char fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize];
455 //////////////////////////////////////////////////////////////////////////
457 // Component running environment
459 //////////////////////////////////////////////////////////////////////////
461 /** logging function */
462 typedef int (*AliHLTfctLogging)( void* param,
463 AliHLTComponentLogSeverity severity,
466 const char* message);
469 * @struct AliHLTComponentEnvironment
470 * Running environment for analysis components.
471 * The struct describes function callbacks for
473 struct AliHLTComponentEnvironment
475 AliHLTUInt32_t fStructSize;
477 void* (*fAllocMemoryFunc)( void* param, unsigned long size );
479 // future addition already foreseen/envisioned
480 // IMPORTANT: don not just remove the defines as this breaks the binary
482 int (*fAllocShmMemoryFunc)( void* param, unsigned long size, AliHLTComponentBlockData* blockLocation );
484 int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd );
485 AliHLTfctLogging fLoggingFunc;
489 //////////////////////////////////////////////////////////////////////////
491 // Data type helper functions
493 //////////////////////////////////////////////////////////////////////////
495 inline bool operator==( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
497 bool any1=true, any2=true, void1=true, void2=true, match=true;
498 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) {
499 any1&=(dt1.fOrigin[i]==kAliHLTDataOriginAny[i]);
500 any2&=(dt2.fOrigin[i]==kAliHLTDataOriginAny[i]);
501 void1&=(dt1.fOrigin[i]==kAliHLTDataOriginVoid[i]);
502 void2&=(dt2.fOrigin[i]==kAliHLTDataOriginVoid[i]);
503 match&=dt1.fOrigin[i]==dt2.fOrigin[i];
504 if (!(match || (any2 && !void1) || (any1 && !void2)))
508 any1=true, any2=true, match=true;
509 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) {
510 any1&=(dt1.fID[i]==kAliHLTAnyDataTypeID[i]);
511 any2&=(dt2.fID[i]==kAliHLTAnyDataTypeID[i]);
512 void1&=(dt1.fID[i]==kAliHLTVoidDataTypeID[i]);
513 void2&=(dt2.fID[i]==kAliHLTVoidDataTypeID[i]);
514 match&=dt1.fID[i]==dt2.fID[i];
515 if (!(match || (any2 && !void1) || (any1 && !void2)))
521 inline bool operator!=( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
526 inline AliHLTComponentDataType operator|(const AliHLTComponentDataType srcdt, const char origin[kAliHLTComponentDataTypefOriginSize])
528 AliHLTComponentDataType dt=srcdt;
529 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
530 dt.fOrigin[i]=origin[i];