]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTDataTypes.h
Fixing coding violations (Livio, Pietro)
[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
c704e290 27 * to be used with the operator| (AliHLTComponentDataType)
28 * 2007-11-24 added trigger structs and ESD tree data type
b543e186 29 * 4 Component configuration and DCS update events added
2efb85be 30 * gkAliHLTDDLListSize set from 29 to 30 according to new PubSub
31 * specs
2cbdb37e 32 */
853121af 33#define ALIHLT_DATA_TYPES_VERSION 4
2cbdb37e 34
32db4144 35//////////////////////////////////////////////////////////////////////////
36//
69347e0d 37// HLT data origin variables.
38//
39// By converting from defines to variables, the origins can be used with
40// the operator|
41//
42// AliHLTComponentDataType dt;
43// dt = kAliHLTDataTypeDDLRaw | gkAliHLTDataOriginTPC;
32db4144 44//
45//////////////////////////////////////////////////////////////////////////
46
47/** field size of datat type origin */
48const int kAliHLTComponentDataTypefOriginSize=4;
49
50
51/** invalid data origin */
3f850585 52# define kAliHLTDataOriginVoid "\0\0\0"
53/** old invalid data origin, kept for backward compatibility */
32db4144 54# define kAliHLTVoidDataOrigin "\0\0\0"
55
3f850585 56/** wildcard data type origin */
57# define kAliHLTDataOriginAny "***"
58/** old wildcard data type origin, kept for backward compatibility */
32db4144 59# define kAliHLTAnyDataOrigin "***"
60
61/** HLT out */
69347e0d 62extern const char kAliHLTDataOriginOut[kAliHLTComponentDataTypefOriginSize];
32db4144 63
64/** HLT/PubSub private internal */
69347e0d 65extern const char kAliHLTDataOriginPrivate[kAliHLTComponentDataTypefOriginSize];
32db4144 66
67/** TPC */
69347e0d 68extern const char kAliHLTDataOriginTPC[kAliHLTComponentDataTypefOriginSize];
32db4144 69
70/** PHOS */
69347e0d 71extern const char kAliHLTDataOriginPHOS[kAliHLTComponentDataTypefOriginSize];
32db4144 72
73/** MUON */
69347e0d 74extern const char kAliHLTDataOriginMUON[kAliHLTComponentDataTypefOriginSize];
32db4144 75
76/** TRD */
69347e0d 77extern const char kAliHLTDataOriginTRD[kAliHLTComponentDataTypefOriginSize];
32db4144 78
79/** ITS */
69347e0d 80extern const char kAliHLTDataOriginITS[kAliHLTComponentDataTypefOriginSize];
32db4144 81
82//////////////////////////////////////////////////////////////////////////
83//
84// HLT common data type defines
85//
86//////////////////////////////////////////////////////////////////////////
87
88/** field size of data type id */
89const int kAliHLTComponentDataTypefIDsize=8;
90
91
92/** invalid data type id */
93# define kAliHLTVoidDataTypeID "\0\0\0\0\0\0\0"
94
95/** special id for any data type id */
96# define kAliHLTAnyDataTypeID "*******"
97
3f850585 98/** DDL RAW data */
99# define kAliHLTDDLRawDataTypeID {'D','D','L','_','R','A','W',' '}
100
32db4144 101/** calibration data for file exchange subscriber */
102# define kAliHLTFXSCalibDataTypeID {'F','X','S','_','C','A','L',' '}
103
104/** start of run (SOR) event
2cbdb37e 105 * @ref AliHLTRunDesc
32db4144 106 */
107# define kAliHLTSORDataTypeID {'S','T','A','R','T','O','F','R'}
108
109/** end of run (EOR) event
2cbdb37e 110 * @ref AliHLTRunDesc
32db4144 111 */
112# define kAliHLTEORDataTypeID {'E','N','D','O','F','R','U','N'}
113
114/** DDL list event
115 * @ref AliHLTEventDDL
116 */
117# define kAliHLTDDLDataTypeID {'D','D','L','L','I','S','T',' '}
118
9d9ffd37 119/** EventType event
120 * - empty payload, specification gives eventType
121 */
122# define kAliHLTEventDataTypeID {'E','V','E','N','T','T','Y','P'}
123
853121af 124/** ComponentConfiguration event
b543e186 125 * - payload contains the CDB path as string
853121af 126 */
127# define kAliHLTComConfDataTypeID {'C','O','M','_','C','O','N','F'}
128
b543e186 129/** DCS value update event
130 * - payload contains string of relevant detectors
131 */
132# define kAliHLTUpdtDCSDataTypeID {'U','P','D','T','_','D','C','S'}
133
c704e290 134/** ESD data block
135 * an AliESD object of varying origin
853121af 136 * The 'V0' at the end allows a versioning
c704e290 137 */
a978c0d5 138# define kAliHLTESDObjectDataTypeID {'A','L','I','E','S','D','V','0'}
c704e290 139
a978c0d5 140/** ESD tree data block
141 * TTree with an AliESD object of varying origin
142 */
143# define kAliHLTESDTreeDataTypeID {'E','S','D','_','T','R','E','E'}
64defa03 144
145/** HW Address selection data block
146 * - a selection list for 16 bit HW addresses
147 * - varying origin
148 */
149# define kAliHLTHwAddr16DataTypeID {'H','W','A','D','D','R','1','6'}
150
1843b457 151using namespace std;
f23a6e1a 152
153extern "C" {
32db4144 154 //////////////////////////////////////////////////////////////////////////
155 //
156 // Basic HLT data types
157 //
158 //////////////////////////////////////////////////////////////////////////
f23a6e1a 159
160 typedef unsigned char AliHLTUInt8_t;
161
eda89fe6 162 typedef signed char AliHLTInt8_t;
163
71d7c760 164 typedef unsigned short AliHLTUInt16_t;
165
eda89fe6 166 typedef signed short AliHLTInt16_t;
167
f23a6e1a 168 typedef unsigned int AliHLTUInt32_t;
169
eda89fe6 170 typedef signed int AliHLTInt32_t;
171
f23a6e1a 172 typedef unsigned long long AliHLTUInt64_t;
173
eda89fe6 174 typedef signed long long AliHLTInt64_t;
175
176 typedef float AliHLTFloat32_t;
177
178 typedef double AliHLTFloat64_t;
179
f23a6e1a 180 typedef AliHLTUInt64_t AliHLTEventID_t;
181
32db4144 182 //////////////////////////////////////////////////////////////////////////
183 //
184 // HLT logging levels
185 //
186 //////////////////////////////////////////////////////////////////////////
f23a6e1a 187
2efb85be 188 /**
189 * Logging severities of the HLT
190 */
191 enum AliHLTComponentLogSeverity {
192 /** no logging */
32db4144 193 kHLTLogNone = 0,
2efb85be 194 /** benchmark messages */
32db4144 195 kHLTLogBenchmark = 0x1,
2efb85be 196 /** debug messages */
32db4144 197 kHLTLogDebug = 0x2,
2efb85be 198 /** info messages */
32db4144 199 kHLTLogInfo = 0x4,
2efb85be 200 /** warning messages */
32db4144 201 kHLTLogWarning = 0x8,
2efb85be 202 /** error messages */
32db4144 203 kHLTLogError = 0x10,
b2065764 204 /** fatal error messages */
32db4144 205 kHLTLogFatal = 0x20,
b2065764 206 /** few important messages not to be filtered out.
207 * redirected to kHLTLogInfo in AliRoot
208 */
209 kHLTLogImportant = 0x40,
2efb85be 210 /** special value to enable all messages */
b2065764 211 kHLTLogAll = 0x7f,
2efb85be 212 /** the default logging filter */
b2065764 213 kHLTLogDefault = 0x7d
32db4144 214};
215
216 //////////////////////////////////////////////////////////////////////////
217 //
218 // HLT data structures for data exchange and external interface
219 //
220 //////////////////////////////////////////////////////////////////////////
221
222 /**
223 * @struct AliHLTComponentEventData
224 * Event descriptor
225 */
8ede8717 226 struct AliHLTComponentEventData
f23a6e1a 227 {
228 AliHLTUInt32_t fStructSize;
229 AliHLTEventID_t fEventID;
230 AliHLTUInt32_t fEventCreation_s;
231 AliHLTUInt32_t fEventCreation_us;
232 AliHLTUInt32_t fBlockCnt;
233 };
234
32db4144 235 /**
236 * @struct AliHLTComponentShmData
237 * Shared memory descriptor.
238 * Irrelevant for analysis components.
239 */
8ede8717 240 struct AliHLTComponentShmData
f23a6e1a 241 {
242 AliHLTUInt32_t fStructSize;
243 AliHLTUInt32_t fShmType;
244 AliHLTUInt64_t fShmID;
245 };
71d7c760 246
32db4144 247 /**
248 * @struct AliHLTComponentDataType
559631d5 249 * Data type descriptor for data blocks transferred through the processing
32db4144 250 * chain.
251 */
8ede8717 252 struct AliHLTComponentDataType
f23a6e1a 253 {
254 AliHLTUInt32_t fStructSize;
32db4144 255 char fID[kAliHLTComponentDataTypefIDsize]; //!
256 char fOrigin[kAliHLTComponentDataTypefOriginSize]; //!
f23a6e1a 257 };
2d7ff710 258
32db4144 259 /**
260 * @struct AliHLTComponentBlockData
3294f81a 261 * This is the decription of data blocks exchanged between components.
262 * \b IMPORTANT: The validity of fPtr and fOffset is different for input and
263 * output blocks:
264 * - input blocks: The \em fPtr member always points to the beginning of the data
265 * of size \em fSize. fOffset is ignored and should be in most
266 * case 0.
267 * - output blocks: The \em fPtr member is ignored by the framework. \em fOffset
268 * must specify the start of the data relative to the output
269 * buffer. The data block has size \em fSize.
32db4144 270 */
8ede8717 271 struct AliHLTComponentBlockData
f23a6e1a 272 {
3294f81a 273 /* size and version of the struct */
f23a6e1a 274 AliHLTUInt32_t fStructSize;
3294f81a 275 /* shared memory key, ignored by processing components */
8ede8717 276 AliHLTComponentShmData fShmKey;
3294f81a 277 /* offset of output data relative to the output buffer */
f23a6e1a 278 AliHLTUInt32_t fOffset;
3294f81a 279 /* start of the data for input data blocks, fOffset to be ignored*/
f23a6e1a 280 void* fPtr;
3294f81a 281 /* size of the data block */
f23a6e1a 282 AliHLTUInt32_t fSize;
3294f81a 283 /* data type of the data block */
8ede8717 284 AliHLTComponentDataType fDataType;
3294f81a 285 /* data specification of the data block */
f23a6e1a 286 AliHLTUInt32_t fSpecification;
287 };
288
32db4144 289 /**
290 * @struct AliHLTComponentEventDoneData
291 *
292 */
8ede8717 293 struct AliHLTComponentEventDoneData
f23a6e1a 294 {
295 AliHLTUInt32_t fStructSize;
296 AliHLTUInt32_t fDataSize;
297 void* fData;
298 };
299
32db4144 300 /**
2cbdb37e 301 * @struct AliHLTRunDesc
32db4144 302 * Event descriptor.
303 * The struct is send with the SOR and EOR events.
304 */
2cbdb37e 305 struct AliHLTRunDesc
32db4144 306 {
307 AliHLTUInt32_t fStructSize;
308 AliHLTUInt32_t fRunNo;
309 AliHLTUInt32_t fRunType;
310 };
311
8f81abf4 312 //////////////////////////////////////////////////////////////////////////
313 //
314 // Trigger meta information
315 //
316 //////////////////////////////////////////////////////////////////////////
317
318 /** field size of fAttribute */
319 static const int gkAliHLTBlockDAttributeCount = 8;
320
321 /** field size of fCommonHeader */
322 static const int gkAliHLTCommonHeaderCount = 8;
323
32db4144 324 /** size of the DDL list */
e7f921b5 325 static const int gkAliHLTDDLListSize = 30;
32db4144 326
327 /**
328 * @struct AliHLTEventDDL
329 * DDL list event.
330 * The struct is send with the DDLLIST event.
8f81abf4 331 * Used in the trigger structure for internal apperance of
332 * the DLLs as well as for the HLT readout list send to DAQ
511b2509 333 * ( as DataType : kAliHLTDataTypeDDL )
32db4144 334 */
335 struct AliHLTEventDDL
336 {
337 AliHLTUInt32_t fCount;
338 AliHLTUInt32_t fList[gkAliHLTDDLListSize];
339 };
340
8f81abf4 341 /**
342 * @struct AliHLTEventTriggerData
8f81abf4 343 */
344 struct AliHLTEventTriggerData
345 {
8f81abf4 346 AliHLTUInt8_t fAttributes[gkAliHLTBlockDAttributeCount];
511b2509 347 AliHLTUInt64_t fHLTStatus; // Bit field
8f81abf4 348 AliHLTUInt32_t fCommonHeaderWordCnt;
349 AliHLTUInt32_t fCommonHeader[gkAliHLTCommonHeaderCount];
8f81abf4 350 AliHLTEventDDL fReadoutList;
351 };
352
353 /**
354 * @struct AliHLTComponentTriggerData
355 * Trigger data
356 */
357 struct AliHLTComponentTriggerData
358 {
359 AliHLTUInt32_t fStructSize;
360 AliHLTUInt32_t fDataSize;
361 void* fData;
362 };
363
9d9ffd37 364 //////////////////////////////////////////////////////////////////////////
365 //
366 // HLT Event Type Specification
367 //
368 //////////////////////////////////////////////////////////////////////////
369
370 /** Unknown eventType specification */
371 static const AliHLTUInt32_t gkAliEventTypeUnknown = ~(AliHLTUInt32_t)0;
372 /** SOR eventType specification */
373 static const AliHLTUInt32_t gkAliEventTypeStartOfRun=1;
374 /** Data eventType specification */
375 static const AliHLTUInt32_t gkAliEventTypeData=2;
376 /** EOR eventType specification */
377 static const AliHLTUInt32_t gkAliEventTypeEndOfRun=4;
378 /** Corrupt eventType specification */
379 static const AliHLTUInt32_t gkAliEventTypeCorruptID=8;
380 /** Calibration eventType specification */
381 static const AliHLTUInt32_t gkAliEventTypeCalibration=16;
382 /** DataReplay eventType specification */
383 static const AliHLTUInt32_t gkAliEventTypeDataReplay=32;
b543e186 384 /** Configuration eventType specification */
385 static const AliHLTUInt32_t gkAliEventTypeConfiguration=34;
d6b69874 386 /** Update DCS eventType specification */
387 static const AliHLTUInt32_t gkAliEventTypeReadPreprocessor=35;
9d9ffd37 388 /** Tick eventType specification */
389 static const AliHLTUInt32_t gkAliEventTypeTick=64;
390 /** Max eventType specification */
391 static const AliHLTUInt32_t gkAliEventTypeMax=64;
392
32db4144 393 //////////////////////////////////////////////////////////////////////////
394 //
395 // HLT defines and defaults
396 //
397 //////////////////////////////////////////////////////////////////////////
398
399 /** invalid event id */
400 const AliHLTEventID_t kAliHLTVoidEventID=~(AliHLTEventID_t)0;
401
402 /** invalid data specification */
403 const AliHLTUInt32_t kAliHLTVoidDataSpec = ~(AliHLTUInt32_t)0;
404
405 /** invalid shared memory type */
406 const AliHLTUInt32_t gkAliHLTComponentInvalidShmType = 0;
407
408 /** invalid shared memory id */
409 const AliHLTUInt64_t gkAliHLTComponentInvalidShmID = ~(AliHLTUInt64_t)0;
410
411 /** invalid data type */
412 const AliHLTComponentDataType kAliHLTVoidDataType = {
413 sizeof(AliHLTComponentDataType),
414 kAliHLTVoidDataTypeID,
3f850585 415 kAliHLTDataOriginVoid
32db4144 416 };
417
418 // there is currently a problem with rootcint if the predefined ids
419 // (commented below) are used. rootcint does not find the id if they
420 // are char arrays defined with {} and individual chars. If strings
421 // are used it works fine
422 /** any data type */
423 const AliHLTComponentDataType kAliHLTAnyDataType = {
424 sizeof(AliHLTComponentDataType),
425 kAliHLTAnyDataTypeID,
3f850585 426 kAliHLTDataOriginAny
32db4144 427 };
428
de6593d0 429 /** multiple output data types */
430 extern const AliHLTComponentDataType kAliHLTMultipleDataType;
431
32db4144 432 /** data to file exchange subscriber */
433 extern const AliHLTComponentDataType kAliHLTDataTypeFXSCalib;
434
435 /** DDL list data type */
436 extern const AliHLTComponentDataType kAliHLTDataTypeDDL;
437
438 /** SOR data type */
439 extern const AliHLTComponentDataType kAliHLTDataTypeSOR;
440
441 /** EOR data type */
442 extern const AliHLTComponentDataType kAliHLTDataTypeEOR;
5ec8e281 443
77405890 444 /** Event type specification */
445 extern const AliHLTComponentDataType kAliHLTDataTypeEvent;
446
853121af 447 /** Configuration event data type */
448 extern const AliHLTComponentDataType kAliHLTDataTypeComConf;
449
b543e186 450 /** DCS value update event */
451 extern const AliHLTComponentDataType kAliHLTDataTypeUpdtDCS;
452
c704e290 453 /** RAW DDL data specification, origin is 'any', data publisher origin correctly */
3f850585 454 extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw;
455
a978c0d5 456 /** ESD object data specification, origin is 'any' */
457 extern const AliHLTComponentDataType kAliHLTDataTypeESDObject;
458
c704e290 459 /** ESD Tree data specification, origin is 'any' */
460 extern const AliHLTComponentDataType kAliHLTDataTypeESDTree;
461
64defa03 462 /** 16 bit Hardware address selection data specification, origin is 'any' */
463 extern const AliHLTComponentDataType kAliHLTDataTypeHwAddr16;
464
32db4144 465 //////////////////////////////////////////////////////////////////////////
466 //
467 // FXS subscriber meta information
468 //
469 //////////////////////////////////////////////////////////////////////////
470
471 static const int gkAliHLTFXSHeaderfOriginSize = 4;
472 static const int gkAliHLTFXSHeaderfFileIDSize = 128;
473 static const int gkAliHLTFXSHeaderfDDLNumberSize = 64;
474
475 /** Header in front of the data payload, in order to sent data to the FXS. */
476 struct AliHLTFXSHeader
477 {
478 AliHLTUInt32_t fHeaderVersion;
479 AliHLTUInt32_t fRunNumber;
480 char fOrigin[gkAliHLTFXSHeaderfOriginSize];
481 char fFileID[gkAliHLTFXSHeaderfFileIDSize];
482 char fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize];
483 };
484
485 //////////////////////////////////////////////////////////////////////////
486 //
487 // Component running environment
488 //
489 //////////////////////////////////////////////////////////////////////////
490
491 /** logging function */
492 typedef int (*AliHLTfctLogging)( void* param,
493 AliHLTComponentLogSeverity severity,
494 const char* origin,
495 const char* keyword,
496 const char* message);
497
498 /**
499 * @struct AliHLTComponentEnvironment
500 * Running environment for analysis components.
501 * The struct describes function callbacks for
502 */
f23a6e1a 503 struct AliHLTComponentEnvironment
504 {
505 AliHLTUInt32_t fStructSize;
506 void* fParam;
507 void* (*fAllocMemoryFunc)( void* param, unsigned long size );
508#if 0
32db4144 509 // future addition already foreseen/envisioned
510 // IMPORTANT: don not just remove the defines as this breaks the binary
511 // compatibility
512 int (*fAllocShmMemoryFunc)( void* param, unsigned long size, AliHLTComponentBlockData* blockLocation );
f23a6e1a 513#endif
8ede8717 514 int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd );
5ec8e281 515 AliHLTfctLogging fLoggingFunc;
f23a6e1a 516 };
517}
518
32db4144 519//////////////////////////////////////////////////////////////////////////
520//
521// Data type helper functions
522//
523//////////////////////////////////////////////////////////////////////////
524
8ede8717 525inline bool operator==( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
853121af 526{
527 bool any1=true, any2=true, void1=true, void2=true, match=true;
528 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) {
529 any1&=(dt1.fOrigin[i]==kAliHLTDataOriginAny[i]);
530 any2&=(dt2.fOrigin[i]==kAliHLTDataOriginAny[i]);
531 void1&=(dt1.fOrigin[i]==kAliHLTDataOriginVoid[i]);
532 void2&=(dt2.fOrigin[i]==kAliHLTDataOriginVoid[i]);
533 match&=dt1.fOrigin[i]==dt2.fOrigin[i];
534 if (!(match || (any2 && !void1) || (any1 && !void2)))
535 return false;
536 }
537
538 any1=true, any2=true, match=true;
539 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) {
540 any1&=(dt1.fID[i]==kAliHLTAnyDataTypeID[i]);
541 any2&=(dt2.fID[i]==kAliHLTAnyDataTypeID[i]);
542 void1&=(dt1.fID[i]==kAliHLTVoidDataTypeID[i]);
543 void2&=(dt2.fID[i]==kAliHLTVoidDataTypeID[i]);
544 match&=dt1.fID[i]==dt2.fID[i];
545 if (!(match || (any2 && !void1) || (any1 && !void2)))
546 return false;
547 }
548 return true;
549}
71d7c760 550
8ede8717 551inline bool operator!=( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
853121af 552{
553 return !(dt1==dt2);
554}
71d7c760 555
732e8f50 556inline bool MatchExactly( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
557{
558 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
559 if ( dt1.fID[i] != dt2.fID[i] )
560 return false;
561 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
562 if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
563 return false;
564 return true;
565}
566
69347e0d 567inline AliHLTComponentDataType operator|(const AliHLTComponentDataType srcdt, const char origin[kAliHLTComponentDataTypefOriginSize])
853121af 568{
569 AliHLTComponentDataType dt=srcdt;
570 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
571 dt.fOrigin[i]=origin[i];
572 return dt;
573}
32db4144 574
f23a6e1a 575#endif