data origin defines converted to constants, operator| for merging of DataType struct...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDataTypes.h
CommitLineData
f23a6e1a 1// @(#) $Id$
2
3#ifndef ALIHLTDATATYPES_H
4#define ALIHLTDATATYPES_H
32db4144 5/* This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
f23a6e1a 7 * See cxx source for full Copyright notice */
8
b22e91eb 9/** @file AliHLTDataTypes.h
32db4144 10 @author Matthias Richter, Timm Steinbeck, Jochen Thaeder
b22e91eb 11 @date
12 @brief Data type declaration for the HLT module.
13*/
14
2cbdb37e 15//////////////////////////////////////////////////////////////////////////
16//
17// version no of HLT data types
18//
19//////////////////////////////////////////////////////////////////////////
20
21/* Version Description
22 * 1 first version until June 07; implicite, not tagged
23 * 2 introduced June 07, enhanced/cleaned/arranged structure
eda89fe6 24 * 3 2007-11-15 RAW DDL data type added; some inconsistencies fixed
25 * ('void' and 'any' origins); added signed HLT basic data types
69347e0d 26 * 2007-11-23 origin defines have become variables in conjunction
27 * to be used with the operator| (AliHLTComponentDatatType
2cbdb37e 28 */
d934f004 29#define ALIHLT_DATA_TYPES_VERSION 3
2cbdb37e 30
32db4144 31//////////////////////////////////////////////////////////////////////////
32//
69347e0d 33// HLT data origin variables.
34//
35// By converting from defines to variables, the origins can be used with
36// the operator|
37//
38// AliHLTComponentDataType dt;
39// dt = kAliHLTDataTypeDDLRaw | gkAliHLTDataOriginTPC;
32db4144 40//
41//////////////////////////////////////////////////////////////////////////
42
43/** field size of datat type origin */
44const int kAliHLTComponentDataTypefOriginSize=4;
45
46
47/** invalid data origin */
3f850585 48# define kAliHLTDataOriginVoid "\0\0\0"
49/** old invalid data origin, kept for backward compatibility */
32db4144 50# define kAliHLTVoidDataOrigin "\0\0\0"
51
3f850585 52/** wildcard data type origin */
53# define kAliHLTDataOriginAny "***"
54/** old wildcard data type origin, kept for backward compatibility */
32db4144 55# define kAliHLTAnyDataOrigin "***"
56
57/** HLT out */
69347e0d 58extern const char kAliHLTDataOriginOut[kAliHLTComponentDataTypefOriginSize];
32db4144 59
60/** HLT/PubSub private internal */
69347e0d 61extern const char kAliHLTDataOriginPrivate[kAliHLTComponentDataTypefOriginSize];
32db4144 62
63/** TPC */
69347e0d 64extern const char kAliHLTDataOriginTPC[kAliHLTComponentDataTypefOriginSize];
32db4144 65
66/** PHOS */
69347e0d 67extern const char kAliHLTDataOriginPHOS[kAliHLTComponentDataTypefOriginSize];
32db4144 68
69/** MUON */
69347e0d 70extern const char kAliHLTDataOriginMUON[kAliHLTComponentDataTypefOriginSize];
32db4144 71
72/** TRD */
69347e0d 73extern const char kAliHLTDataOriginTRD[kAliHLTComponentDataTypefOriginSize];
32db4144 74
75/** ITS */
69347e0d 76extern const char kAliHLTDataOriginITS[kAliHLTComponentDataTypefOriginSize];
32db4144 77
78//////////////////////////////////////////////////////////////////////////
79//
80// HLT common data type defines
81//
82//////////////////////////////////////////////////////////////////////////
83
84/** field size of data type id */
85const int kAliHLTComponentDataTypefIDsize=8;
86
87
88/** invalid data type id */
89# define kAliHLTVoidDataTypeID "\0\0\0\0\0\0\0"
90
91/** special id for any data type id */
92# define kAliHLTAnyDataTypeID "*******"
93
3f850585 94/** DDL RAW data */
95# define kAliHLTDDLRawDataTypeID {'D','D','L','_','R','A','W',' '}
96
32db4144 97/** calibration data for file exchange subscriber */
98# define kAliHLTFXSCalibDataTypeID {'F','X','S','_','C','A','L',' '}
99
100/** start of run (SOR) event
2cbdb37e 101 * @ref AliHLTRunDesc
32db4144 102 */
103# define kAliHLTSORDataTypeID {'S','T','A','R','T','O','F','R'}
104
105/** end of run (EOR) event
2cbdb37e 106 * @ref AliHLTRunDesc
32db4144 107 */
108# define kAliHLTEORDataTypeID {'E','N','D','O','F','R','U','N'}
109
110/** DDL list event
111 * @ref AliHLTEventDDL
112 */
113# define kAliHLTDDLDataTypeID {'D','D','L','L','I','S','T',' '}
114
9d9ffd37 115/** EventType event
116 * - empty payload, specification gives eventType
117 */
118# define kAliHLTEventDataTypeID {'E','V','E','N','T','T','Y','P'}
119
1843b457 120using namespace std;
f23a6e1a 121
122extern "C" {
32db4144 123 //////////////////////////////////////////////////////////////////////////
124 //
125 // Basic HLT data types
126 //
127 //////////////////////////////////////////////////////////////////////////
f23a6e1a 128
129 typedef unsigned char AliHLTUInt8_t;
130
eda89fe6 131 typedef signed char AliHLTInt8_t;
132
71d7c760 133 typedef unsigned short AliHLTUInt16_t;
134
eda89fe6 135 typedef signed short AliHLTInt16_t;
136
f23a6e1a 137 typedef unsigned int AliHLTUInt32_t;
138
eda89fe6 139 typedef signed int AliHLTInt32_t;
140
f23a6e1a 141 typedef unsigned long long AliHLTUInt64_t;
142
eda89fe6 143 typedef signed long long AliHLTInt64_t;
144
145 typedef float AliHLTFloat32_t;
146
147 typedef double AliHLTFloat64_t;
148
f23a6e1a 149 typedef AliHLTUInt64_t AliHLTEventID_t;
150
32db4144 151 //////////////////////////////////////////////////////////////////////////
152 //
153 // HLT logging levels
154 //
155 //////////////////////////////////////////////////////////////////////////
f23a6e1a 156
32db4144 157 enum AliHLTComponentLogSeverity {
158 kHLTLogNone = 0,
159 kHLTLogBenchmark = 0x1,
160 kHLTLogDebug = 0x2,
161 kHLTLogInfo = 0x4,
162 kHLTLogWarning = 0x8,
163 kHLTLogError = 0x10,
164 kHLTLogFatal = 0x20,
165 kHLTLogAll = 0x3f,
166 kHLTLogDefault = 0x3d
167};
168
169 //////////////////////////////////////////////////////////////////////////
170 //
171 // HLT data structures for data exchange and external interface
172 //
173 //////////////////////////////////////////////////////////////////////////
174
175 /**
176 * @struct AliHLTComponentEventData
177 * Event descriptor
178 */
8ede8717 179 struct AliHLTComponentEventData
f23a6e1a 180 {
181 AliHLTUInt32_t fStructSize;
182 AliHLTEventID_t fEventID;
183 AliHLTUInt32_t fEventCreation_s;
184 AliHLTUInt32_t fEventCreation_us;
185 AliHLTUInt32_t fBlockCnt;
186 };
187
32db4144 188 /**
189 * @struct AliHLTComponentShmData
190 * Shared memory descriptor.
191 * Irrelevant for analysis components.
192 */
8ede8717 193 struct AliHLTComponentShmData
f23a6e1a 194 {
195 AliHLTUInt32_t fStructSize;
196 AliHLTUInt32_t fShmType;
197 AliHLTUInt64_t fShmID;
198 };
71d7c760 199
32db4144 200 /**
201 * @struct AliHLTComponentDataType
559631d5 202 * Data type descriptor for data blocks transferred through the processing
32db4144 203 * chain.
204 */
8ede8717 205 struct AliHLTComponentDataType
f23a6e1a 206 {
207 AliHLTUInt32_t fStructSize;
32db4144 208 char fID[kAliHLTComponentDataTypefIDsize]; //!
209 char fOrigin[kAliHLTComponentDataTypefOriginSize]; //!
f23a6e1a 210 };
2d7ff710 211
32db4144 212 /**
213 * @struct AliHLTComponentBlockData
3294f81a 214 * This is the decription of data blocks exchanged between components.
215 * \b IMPORTANT: The validity of fPtr and fOffset is different for input and
216 * output blocks:
217 * - input blocks: The \em fPtr member always points to the beginning of the data
218 * of size \em fSize. fOffset is ignored and should be in most
219 * case 0.
220 * - output blocks: The \em fPtr member is ignored by the framework. \em fOffset
221 * must specify the start of the data relative to the output
222 * buffer. The data block has size \em fSize.
32db4144 223 */
8ede8717 224 struct AliHLTComponentBlockData
f23a6e1a 225 {
3294f81a 226 /* size and version of the struct */
f23a6e1a 227 AliHLTUInt32_t fStructSize;
3294f81a 228 /* shared memory key, ignored by processing components */
8ede8717 229 AliHLTComponentShmData fShmKey;
3294f81a 230 /* offset of output data relative to the output buffer */
f23a6e1a 231 AliHLTUInt32_t fOffset;
3294f81a 232 /* start of the data for input data blocks, fOffset to be ignored*/
f23a6e1a 233 void* fPtr;
3294f81a 234 /* size of the data block */
f23a6e1a 235 AliHLTUInt32_t fSize;
3294f81a 236 /* data type of the data block */
8ede8717 237 AliHLTComponentDataType fDataType;
3294f81a 238 /* data specification of the data block */
f23a6e1a 239 AliHLTUInt32_t fSpecification;
240 };
241
32db4144 242 /**
243 * @struct AliHLTComponentTriggerData
244 * Trigger data, not yet defined
245 */
8ede8717 246 struct AliHLTComponentTriggerData
f23a6e1a 247 {
248 AliHLTUInt32_t fStructSize;
249 AliHLTUInt32_t fDataSize;
250 void* fData;
251 };
32db4144 252
253 /**
254 * @struct AliHLTComponentEventDoneData
255 *
256 */
8ede8717 257 struct AliHLTComponentEventDoneData
f23a6e1a 258 {
259 AliHLTUInt32_t fStructSize;
260 AliHLTUInt32_t fDataSize;
261 void* fData;
262 };
263
32db4144 264 /**
2cbdb37e 265 * @struct AliHLTRunDesc
32db4144 266 * Event descriptor.
267 * The struct is send with the SOR and EOR events.
268 */
2cbdb37e 269 struct AliHLTRunDesc
32db4144 270 {
271 AliHLTUInt32_t fStructSize;
272 AliHLTUInt32_t fRunNo;
273 AliHLTUInt32_t fRunType;
274 };
275
276 /** size of the DDL list */
277 static const int gkAliHLTDDLListSize = 29;
278
279 /**
280 * @struct AliHLTEventDDL
281 * DDL list event.
282 * The struct is send with the DDLLIST event.
283 */
284 struct AliHLTEventDDL
285 {
286 AliHLTUInt32_t fCount;
287 AliHLTUInt32_t fList[gkAliHLTDDLListSize];
288 };
289
9d9ffd37 290 //////////////////////////////////////////////////////////////////////////
291 //
292 // HLT Event Type Specification
293 //
294 //////////////////////////////////////////////////////////////////////////
295
296 /** Unknown eventType specification */
297 static const AliHLTUInt32_t gkAliEventTypeUnknown = ~(AliHLTUInt32_t)0;
298 /** SOR eventType specification */
299 static const AliHLTUInt32_t gkAliEventTypeStartOfRun=1;
300 /** Data eventType specification */
301 static const AliHLTUInt32_t gkAliEventTypeData=2;
302 /** EOR eventType specification */
303 static const AliHLTUInt32_t gkAliEventTypeEndOfRun=4;
304 /** Corrupt eventType specification */
305 static const AliHLTUInt32_t gkAliEventTypeCorruptID=8;
306 /** Calibration eventType specification */
307 static const AliHLTUInt32_t gkAliEventTypeCalibration=16;
308 /** DataReplay eventType specification */
309 static const AliHLTUInt32_t gkAliEventTypeDataReplay=32;
310 /** Tick eventType specification */
311 static const AliHLTUInt32_t gkAliEventTypeTick=64;
312 /** Max eventType specification */
313 static const AliHLTUInt32_t gkAliEventTypeMax=64;
314
32db4144 315 //////////////////////////////////////////////////////////////////////////
316 //
317 // HLT defines and defaults
318 //
319 //////////////////////////////////////////////////////////////////////////
320
321 /** invalid event id */
322 const AliHLTEventID_t kAliHLTVoidEventID=~(AliHLTEventID_t)0;
323
324 /** invalid data specification */
325 const AliHLTUInt32_t kAliHLTVoidDataSpec = ~(AliHLTUInt32_t)0;
326
327 /** invalid shared memory type */
328 const AliHLTUInt32_t gkAliHLTComponentInvalidShmType = 0;
329
330 /** invalid shared memory id */
331 const AliHLTUInt64_t gkAliHLTComponentInvalidShmID = ~(AliHLTUInt64_t)0;
332
333 /** invalid data type */
334 const AliHLTComponentDataType kAliHLTVoidDataType = {
335 sizeof(AliHLTComponentDataType),
336 kAliHLTVoidDataTypeID,
3f850585 337 kAliHLTDataOriginVoid
32db4144 338 };
339
340 // there is currently a problem with rootcint if the predefined ids
341 // (commented below) are used. rootcint does not find the id if they
342 // are char arrays defined with {} and individual chars. If strings
343 // are used it works fine
344 /** any data type */
345 const AliHLTComponentDataType kAliHLTAnyDataType = {
346 sizeof(AliHLTComponentDataType),
347 kAliHLTAnyDataTypeID,
3f850585 348 kAliHLTDataOriginAny
32db4144 349 };
350
de6593d0 351 /** multiple output data types */
352 extern const AliHLTComponentDataType kAliHLTMultipleDataType;
353
32db4144 354 /** data to file exchange subscriber */
355 extern const AliHLTComponentDataType kAliHLTDataTypeFXSCalib;
356
357 /** DDL list data type */
358 extern const AliHLTComponentDataType kAliHLTDataTypeDDL;
359
360 /** SOR data type */
361 extern const AliHLTComponentDataType kAliHLTDataTypeSOR;
362
363 /** EOR data type */
364 extern const AliHLTComponentDataType kAliHLTDataTypeEOR;
5ec8e281 365
77405890 366 /** Event type specification */
367 extern const AliHLTComponentDataType kAliHLTDataTypeEvent;
368
69347e0d 369 /** RAW DDL data specification, data publisher will set type id and origin correctly */
3f850585 370 extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw;
371
32db4144 372 //////////////////////////////////////////////////////////////////////////
373 //
374 // FXS subscriber meta information
375 //
376 //////////////////////////////////////////////////////////////////////////
377
378 static const int gkAliHLTFXSHeaderfOriginSize = 4;
379 static const int gkAliHLTFXSHeaderfFileIDSize = 128;
380 static const int gkAliHLTFXSHeaderfDDLNumberSize = 64;
381
382 /** Header in front of the data payload, in order to sent data to the FXS. */
383 struct AliHLTFXSHeader
384 {
385 AliHLTUInt32_t fHeaderVersion;
386 AliHLTUInt32_t fRunNumber;
387 char fOrigin[gkAliHLTFXSHeaderfOriginSize];
388 char fFileID[gkAliHLTFXSHeaderfFileIDSize];
389 char fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize];
390 };
391
392 //////////////////////////////////////////////////////////////////////////
393 //
394 // Component running environment
395 //
396 //////////////////////////////////////////////////////////////////////////
397
398 /** logging function */
399 typedef int (*AliHLTfctLogging)( void* param,
400 AliHLTComponentLogSeverity severity,
401 const char* origin,
402 const char* keyword,
403 const char* message);
404
405 /**
406 * @struct AliHLTComponentEnvironment
407 * Running environment for analysis components.
408 * The struct describes function callbacks for
409 */
f23a6e1a 410 struct AliHLTComponentEnvironment
411 {
412 AliHLTUInt32_t fStructSize;
413 void* fParam;
414 void* (*fAllocMemoryFunc)( void* param, unsigned long size );
415#if 0
32db4144 416 // future addition already foreseen/envisioned
417 // IMPORTANT: don not just remove the defines as this breaks the binary
418 // compatibility
419 int (*fAllocShmMemoryFunc)( void* param, unsigned long size, AliHLTComponentBlockData* blockLocation );
f23a6e1a 420#endif
8ede8717 421 int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd );
5ec8e281 422 AliHLTfctLogging fLoggingFunc;
f23a6e1a 423 };
424}
425
32db4144 426//////////////////////////////////////////////////////////////////////////
427//
428// Data type helper functions
429//
430//////////////////////////////////////////////////////////////////////////
431
8ede8717 432inline bool operator==( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
71d7c760 433 {
21745ddc 434 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
71d7c760 435 if ( dt1.fID[i] != dt2.fID[i] )
436 return false;
21745ddc 437 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
71d7c760 438 if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
439 return false;
440 return true;
441 }
442
8ede8717 443inline bool operator!=( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
71d7c760 444 {
21745ddc 445 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
71d7c760 446 if ( dt1.fID[i] != dt2.fID[i] )
447 return true;
21745ddc 448 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
71d7c760 449 if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
450 return true;
451 return false;
452 }
453
69347e0d 454inline AliHLTComponentDataType operator|(const AliHLTComponentDataType srcdt, const char origin[kAliHLTComponentDataTypefOriginSize])
455 {
456 AliHLTComponentDataType dt=srcdt;
457 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
458 dt.fOrigin[i]=origin[i];
459 return dt;
460 }
32db4144 461
f23a6e1a 462#endif