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
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'}
122 * an AliESD object of varying origin
124 # define kAliHLTESDTreeDataTypeID {'E','S','D','_','T','R','E','E'}
129 //////////////////////////////////////////////////////////////////////////
131 // Basic HLT data types
133 //////////////////////////////////////////////////////////////////////////
135 typedef unsigned char AliHLTUInt8_t;
137 typedef signed char AliHLTInt8_t;
139 typedef unsigned short AliHLTUInt16_t;
141 typedef signed short AliHLTInt16_t;
143 typedef unsigned int AliHLTUInt32_t;
145 typedef signed int AliHLTInt32_t;
147 typedef unsigned long long AliHLTUInt64_t;
149 typedef signed long long AliHLTInt64_t;
151 typedef float AliHLTFloat32_t;
153 typedef double AliHLTFloat64_t;
155 typedef AliHLTUInt64_t AliHLTEventID_t;
157 //////////////////////////////////////////////////////////////////////////
159 // HLT logging levels
161 //////////////////////////////////////////////////////////////////////////
163 enum AliHLTComponentLogSeverity {
165 kHLTLogBenchmark = 0x1,
168 kHLTLogWarning = 0x8,
172 kHLTLogDefault = 0x3d
175 //////////////////////////////////////////////////////////////////////////
177 // HLT data structures for data exchange and external interface
179 //////////////////////////////////////////////////////////////////////////
182 * @struct AliHLTComponentEventData
185 struct AliHLTComponentEventData
187 AliHLTUInt32_t fStructSize;
188 AliHLTEventID_t fEventID;
189 AliHLTUInt32_t fEventCreation_s;
190 AliHLTUInt32_t fEventCreation_us;
191 AliHLTUInt32_t fBlockCnt;
195 * @struct AliHLTComponentShmData
196 * Shared memory descriptor.
197 * Irrelevant for analysis components.
199 struct AliHLTComponentShmData
201 AliHLTUInt32_t fStructSize;
202 AliHLTUInt32_t fShmType;
203 AliHLTUInt64_t fShmID;
207 * @struct AliHLTComponentDataType
208 * Data type descriptor for data blocks transferred through the processing
211 struct AliHLTComponentDataType
213 AliHLTUInt32_t fStructSize;
214 char fID[kAliHLTComponentDataTypefIDsize]; //!
215 char fOrigin[kAliHLTComponentDataTypefOriginSize]; //!
219 * @struct AliHLTComponentBlockData
220 * This is the decription of data blocks exchanged between components.
221 * \b IMPORTANT: The validity of fPtr and fOffset is different for input and
223 * - input blocks: The \em fPtr member always points to the beginning of the data
224 * of size \em fSize. fOffset is ignored and should be in most
226 * - output blocks: The \em fPtr member is ignored by the framework. \em fOffset
227 * must specify the start of the data relative to the output
228 * buffer. The data block has size \em fSize.
230 struct AliHLTComponentBlockData
232 /* size and version of the struct */
233 AliHLTUInt32_t fStructSize;
234 /* shared memory key, ignored by processing components */
235 AliHLTComponentShmData fShmKey;
236 /* offset of output data relative to the output buffer */
237 AliHLTUInt32_t fOffset;
238 /* start of the data for input data blocks, fOffset to be ignored*/
240 /* size of the data block */
241 AliHLTUInt32_t fSize;
242 /* data type of the data block */
243 AliHLTComponentDataType fDataType;
244 /* data specification of the data block */
245 AliHLTUInt32_t fSpecification;
249 * @struct AliHLTComponentEventDoneData
252 struct AliHLTComponentEventDoneData
254 AliHLTUInt32_t fStructSize;
255 AliHLTUInt32_t fDataSize;
260 * @struct AliHLTRunDesc
262 * The struct is send with the SOR and EOR events.
266 AliHLTUInt32_t fStructSize;
267 AliHLTUInt32_t fRunNo;
268 AliHLTUInt32_t fRunType;
271 //////////////////////////////////////////////////////////////////////////
273 // Trigger meta information
275 //////////////////////////////////////////////////////////////////////////
277 /** field size of fAttribute */
278 static const int gkAliHLTBlockDAttributeCount = 8;
280 /** field size of fCommonHeader */
281 static const int gkAliHLTCommonHeaderCount = 8;
283 /** size of the DDL list */
284 static const int gkAliHLTDDLListSize = 29;
287 * @struct AliHLTEventDDL
289 * The struct is send with the DDLLIST event.
290 * Used in the trigger structure for internal apperance of
291 * the DLLs as well as for the HLT readout list send to DAQ
292 * ( as DataType : kAliHLTDataTypeDDL )
294 struct AliHLTEventDDL
296 AliHLTUInt32_t fCount;
297 AliHLTUInt32_t fList[gkAliHLTDDLListSize];
301 * @struct AliHLTEventTriggerData
303 struct AliHLTEventTriggerData
305 AliHLTUInt8_t fAttributes[gkAliHLTBlockDAttributeCount];
306 AliHLTUInt64_t fHLTStatus; // Bit field
307 AliHLTUInt32_t fCommonHeaderWordCnt;
308 AliHLTUInt32_t fCommonHeader[gkAliHLTCommonHeaderCount];
309 AliHLTEventDDL fReadoutList;
313 * @struct AliHLTComponentTriggerData
316 struct AliHLTComponentTriggerData
318 AliHLTUInt32_t fStructSize;
319 AliHLTUInt32_t fDataSize;
323 //////////////////////////////////////////////////////////////////////////
325 // HLT Event Type Specification
327 //////////////////////////////////////////////////////////////////////////
329 /** Unknown eventType specification */
330 static const AliHLTUInt32_t gkAliEventTypeUnknown = ~(AliHLTUInt32_t)0;
331 /** SOR eventType specification */
332 static const AliHLTUInt32_t gkAliEventTypeStartOfRun=1;
333 /** Data eventType specification */
334 static const AliHLTUInt32_t gkAliEventTypeData=2;
335 /** EOR eventType specification */
336 static const AliHLTUInt32_t gkAliEventTypeEndOfRun=4;
337 /** Corrupt eventType specification */
338 static const AliHLTUInt32_t gkAliEventTypeCorruptID=8;
339 /** Calibration eventType specification */
340 static const AliHLTUInt32_t gkAliEventTypeCalibration=16;
341 /** DataReplay eventType specification */
342 static const AliHLTUInt32_t gkAliEventTypeDataReplay=32;
343 /** Tick eventType specification */
344 static const AliHLTUInt32_t gkAliEventTypeTick=64;
345 /** Max eventType specification */
346 static const AliHLTUInt32_t gkAliEventTypeMax=64;
348 //////////////////////////////////////////////////////////////////////////
350 // HLT defines and defaults
352 //////////////////////////////////////////////////////////////////////////
354 /** invalid event id */
355 const AliHLTEventID_t kAliHLTVoidEventID=~(AliHLTEventID_t)0;
357 /** invalid data specification */
358 const AliHLTUInt32_t kAliHLTVoidDataSpec = ~(AliHLTUInt32_t)0;
360 /** invalid shared memory type */
361 const AliHLTUInt32_t gkAliHLTComponentInvalidShmType = 0;
363 /** invalid shared memory id */
364 const AliHLTUInt64_t gkAliHLTComponentInvalidShmID = ~(AliHLTUInt64_t)0;
366 /** invalid data type */
367 const AliHLTComponentDataType kAliHLTVoidDataType = {
368 sizeof(AliHLTComponentDataType),
369 kAliHLTVoidDataTypeID,
370 kAliHLTDataOriginVoid
373 // there is currently a problem with rootcint if the predefined ids
374 // (commented below) are used. rootcint does not find the id if they
375 // are char arrays defined with {} and individual chars. If strings
376 // are used it works fine
378 const AliHLTComponentDataType kAliHLTAnyDataType = {
379 sizeof(AliHLTComponentDataType),
380 kAliHLTAnyDataTypeID,
384 /** multiple output data types */
385 extern const AliHLTComponentDataType kAliHLTMultipleDataType;
387 /** data to file exchange subscriber */
388 extern const AliHLTComponentDataType kAliHLTDataTypeFXSCalib;
390 /** DDL list data type */
391 extern const AliHLTComponentDataType kAliHLTDataTypeDDL;
394 extern const AliHLTComponentDataType kAliHLTDataTypeSOR;
397 extern const AliHLTComponentDataType kAliHLTDataTypeEOR;
399 /** Event type specification */
400 extern const AliHLTComponentDataType kAliHLTDataTypeEvent;
402 /** RAW DDL data specification, origin is 'any', data publisher origin correctly */
403 extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw;
405 /** ESD Tree data specification, origin is 'any' */
406 extern const AliHLTComponentDataType kAliHLTDataTypeESDTree;
408 //////////////////////////////////////////////////////////////////////////
410 // FXS subscriber meta information
412 //////////////////////////////////////////////////////////////////////////
414 static const int gkAliHLTFXSHeaderfOriginSize = 4;
415 static const int gkAliHLTFXSHeaderfFileIDSize = 128;
416 static const int gkAliHLTFXSHeaderfDDLNumberSize = 64;
418 /** Header in front of the data payload, in order to sent data to the FXS. */
419 struct AliHLTFXSHeader
421 AliHLTUInt32_t fHeaderVersion;
422 AliHLTUInt32_t fRunNumber;
423 char fOrigin[gkAliHLTFXSHeaderfOriginSize];
424 char fFileID[gkAliHLTFXSHeaderfFileIDSize];
425 char fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize];
428 //////////////////////////////////////////////////////////////////////////
430 // Component running environment
432 //////////////////////////////////////////////////////////////////////////
434 /** logging function */
435 typedef int (*AliHLTfctLogging)( void* param,
436 AliHLTComponentLogSeverity severity,
439 const char* message);
442 * @struct AliHLTComponentEnvironment
443 * Running environment for analysis components.
444 * The struct describes function callbacks for
446 struct AliHLTComponentEnvironment
448 AliHLTUInt32_t fStructSize;
450 void* (*fAllocMemoryFunc)( void* param, unsigned long size );
452 // future addition already foreseen/envisioned
453 // IMPORTANT: don not just remove the defines as this breaks the binary
455 int (*fAllocShmMemoryFunc)( void* param, unsigned long size, AliHLTComponentBlockData* blockLocation );
457 int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd );
458 AliHLTfctLogging fLoggingFunc;
462 //////////////////////////////////////////////////////////////////////////
464 // Data type helper functions
466 //////////////////////////////////////////////////////////////////////////
468 inline bool operator==( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
470 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
471 if ( dt1.fID[i] != dt2.fID[i] )
473 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
474 if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
479 inline bool operator!=( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
481 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
482 if ( dt1.fID[i] != dt2.fID[i] )
484 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
485 if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
490 inline AliHLTComponentDataType operator|(const AliHLTComponentDataType srcdt, const char origin[kAliHLTComponentDataTypefOriginSize])
492 AliHLTComponentDataType dt=srcdt;
493 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
494 dt.fOrigin[i]=origin[i];