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 |
8f81abf4 |
28 | * 2007-11-24 added trigger structs |
2cbdb37e |
29 | */ |
d934f004 |
30 | #define ALIHLT_DATA_TYPES_VERSION 3 |
2cbdb37e |
31 | |
32db4144 |
32 | ////////////////////////////////////////////////////////////////////////// |
33 | // |
69347e0d |
34 | // HLT data origin variables. |
35 | // |
36 | // By converting from defines to variables, the origins can be used with |
37 | // the operator| |
38 | // |
39 | // AliHLTComponentDataType dt; |
40 | // dt = kAliHLTDataTypeDDLRaw | gkAliHLTDataOriginTPC; |
32db4144 |
41 | // |
42 | ////////////////////////////////////////////////////////////////////////// |
43 | |
44 | /** field size of datat type origin */ |
45 | const int kAliHLTComponentDataTypefOriginSize=4; |
46 | |
47 | |
48 | /** invalid data origin */ |
3f850585 |
49 | # define kAliHLTDataOriginVoid "\0\0\0" |
50 | /** old invalid data origin, kept for backward compatibility */ |
32db4144 |
51 | # define kAliHLTVoidDataOrigin "\0\0\0" |
52 | |
3f850585 |
53 | /** wildcard data type origin */ |
54 | # define kAliHLTDataOriginAny "***" |
55 | /** old wildcard data type origin, kept for backward compatibility */ |
32db4144 |
56 | # define kAliHLTAnyDataOrigin "***" |
57 | |
58 | /** HLT out */ |
69347e0d |
59 | extern const char kAliHLTDataOriginOut[kAliHLTComponentDataTypefOriginSize]; |
32db4144 |
60 | |
61 | /** HLT/PubSub private internal */ |
69347e0d |
62 | extern const char kAliHLTDataOriginPrivate[kAliHLTComponentDataTypefOriginSize]; |
32db4144 |
63 | |
64 | /** TPC */ |
69347e0d |
65 | extern const char kAliHLTDataOriginTPC[kAliHLTComponentDataTypefOriginSize]; |
32db4144 |
66 | |
67 | /** PHOS */ |
69347e0d |
68 | extern const char kAliHLTDataOriginPHOS[kAliHLTComponentDataTypefOriginSize]; |
32db4144 |
69 | |
70 | /** MUON */ |
69347e0d |
71 | extern const char kAliHLTDataOriginMUON[kAliHLTComponentDataTypefOriginSize]; |
32db4144 |
72 | |
73 | /** TRD */ |
69347e0d |
74 | extern const char kAliHLTDataOriginTRD[kAliHLTComponentDataTypefOriginSize]; |
32db4144 |
75 | |
76 | /** ITS */ |
69347e0d |
77 | extern const char kAliHLTDataOriginITS[kAliHLTComponentDataTypefOriginSize]; |
32db4144 |
78 | |
79 | ////////////////////////////////////////////////////////////////////////// |
80 | // |
81 | // HLT common data type defines |
82 | // |
83 | ////////////////////////////////////////////////////////////////////////// |
84 | |
85 | /** field size of data type id */ |
86 | const int kAliHLTComponentDataTypefIDsize=8; |
87 | |
88 | |
89 | /** invalid data type id */ |
90 | # define kAliHLTVoidDataTypeID "\0\0\0\0\0\0\0" |
91 | |
92 | /** special id for any data type id */ |
93 | # define kAliHLTAnyDataTypeID "*******" |
94 | |
3f850585 |
95 | /** DDL RAW data */ |
96 | # define kAliHLTDDLRawDataTypeID {'D','D','L','_','R','A','W',' '} |
97 | |
32db4144 |
98 | /** calibration data for file exchange subscriber */ |
99 | # define kAliHLTFXSCalibDataTypeID {'F','X','S','_','C','A','L',' '} |
100 | |
101 | /** start of run (SOR) event |
2cbdb37e |
102 | * @ref AliHLTRunDesc |
32db4144 |
103 | */ |
104 | # define kAliHLTSORDataTypeID {'S','T','A','R','T','O','F','R'} |
105 | |
106 | /** end of run (EOR) event |
2cbdb37e |
107 | * @ref AliHLTRunDesc |
32db4144 |
108 | */ |
109 | # define kAliHLTEORDataTypeID {'E','N','D','O','F','R','U','N'} |
110 | |
111 | /** DDL list event |
112 | * @ref AliHLTEventDDL |
113 | */ |
114 | # define kAliHLTDDLDataTypeID {'D','D','L','L','I','S','T',' '} |
115 | |
9d9ffd37 |
116 | /** EventType event |
117 | * - empty payload, specification gives eventType |
118 | */ |
119 | # define kAliHLTEventDataTypeID {'E','V','E','N','T','T','Y','P'} |
120 | |
1843b457 |
121 | using namespace std; |
f23a6e1a |
122 | |
123 | extern "C" { |
32db4144 |
124 | ////////////////////////////////////////////////////////////////////////// |
125 | // |
126 | // Basic HLT data types |
127 | // |
128 | ////////////////////////////////////////////////////////////////////////// |
f23a6e1a |
129 | |
130 | typedef unsigned char AliHLTUInt8_t; |
131 | |
eda89fe6 |
132 | typedef signed char AliHLTInt8_t; |
133 | |
71d7c760 |
134 | typedef unsigned short AliHLTUInt16_t; |
135 | |
eda89fe6 |
136 | typedef signed short AliHLTInt16_t; |
137 | |
f23a6e1a |
138 | typedef unsigned int AliHLTUInt32_t; |
139 | |
eda89fe6 |
140 | typedef signed int AliHLTInt32_t; |
141 | |
f23a6e1a |
142 | typedef unsigned long long AliHLTUInt64_t; |
143 | |
eda89fe6 |
144 | typedef signed long long AliHLTInt64_t; |
145 | |
146 | typedef float AliHLTFloat32_t; |
147 | |
148 | typedef double AliHLTFloat64_t; |
149 | |
f23a6e1a |
150 | typedef AliHLTUInt64_t AliHLTEventID_t; |
151 | |
32db4144 |
152 | ////////////////////////////////////////////////////////////////////////// |
153 | // |
154 | // HLT logging levels |
155 | // |
156 | ////////////////////////////////////////////////////////////////////////// |
f23a6e1a |
157 | |
32db4144 |
158 | enum AliHLTComponentLogSeverity { |
159 | kHLTLogNone = 0, |
160 | kHLTLogBenchmark = 0x1, |
161 | kHLTLogDebug = 0x2, |
162 | kHLTLogInfo = 0x4, |
163 | kHLTLogWarning = 0x8, |
164 | kHLTLogError = 0x10, |
165 | kHLTLogFatal = 0x20, |
166 | kHLTLogAll = 0x3f, |
167 | kHLTLogDefault = 0x3d |
168 | }; |
169 | |
170 | ////////////////////////////////////////////////////////////////////////// |
171 | // |
172 | // HLT data structures for data exchange and external interface |
173 | // |
174 | ////////////////////////////////////////////////////////////////////////// |
175 | |
176 | /** |
177 | * @struct AliHLTComponentEventData |
178 | * Event descriptor |
179 | */ |
8ede8717 |
180 | struct AliHLTComponentEventData |
f23a6e1a |
181 | { |
182 | AliHLTUInt32_t fStructSize; |
183 | AliHLTEventID_t fEventID; |
184 | AliHLTUInt32_t fEventCreation_s; |
185 | AliHLTUInt32_t fEventCreation_us; |
186 | AliHLTUInt32_t fBlockCnt; |
187 | }; |
188 | |
32db4144 |
189 | /** |
190 | * @struct AliHLTComponentShmData |
191 | * Shared memory descriptor. |
192 | * Irrelevant for analysis components. |
193 | */ |
8ede8717 |
194 | struct AliHLTComponentShmData |
f23a6e1a |
195 | { |
196 | AliHLTUInt32_t fStructSize; |
197 | AliHLTUInt32_t fShmType; |
198 | AliHLTUInt64_t fShmID; |
199 | }; |
71d7c760 |
200 | |
32db4144 |
201 | /** |
202 | * @struct AliHLTComponentDataType |
559631d5 |
203 | * Data type descriptor for data blocks transferred through the processing |
32db4144 |
204 | * chain. |
205 | */ |
8ede8717 |
206 | struct AliHLTComponentDataType |
f23a6e1a |
207 | { |
208 | AliHLTUInt32_t fStructSize; |
32db4144 |
209 | char fID[kAliHLTComponentDataTypefIDsize]; //! |
210 | char fOrigin[kAliHLTComponentDataTypefOriginSize]; //! |
f23a6e1a |
211 | }; |
2d7ff710 |
212 | |
32db4144 |
213 | /** |
214 | * @struct AliHLTComponentBlockData |
3294f81a |
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 |
217 | * output blocks: |
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 |
220 | * case 0. |
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. |
32db4144 |
224 | */ |
8ede8717 |
225 | struct AliHLTComponentBlockData |
f23a6e1a |
226 | { |
3294f81a |
227 | /* size and version of the struct */ |
f23a6e1a |
228 | AliHLTUInt32_t fStructSize; |
3294f81a |
229 | /* shared memory key, ignored by processing components */ |
8ede8717 |
230 | AliHLTComponentShmData fShmKey; |
3294f81a |
231 | /* offset of output data relative to the output buffer */ |
f23a6e1a |
232 | AliHLTUInt32_t fOffset; |
3294f81a |
233 | /* start of the data for input data blocks, fOffset to be ignored*/ |
f23a6e1a |
234 | void* fPtr; |
3294f81a |
235 | /* size of the data block */ |
f23a6e1a |
236 | AliHLTUInt32_t fSize; |
3294f81a |
237 | /* data type of the data block */ |
8ede8717 |
238 | AliHLTComponentDataType fDataType; |
3294f81a |
239 | /* data specification of the data block */ |
f23a6e1a |
240 | AliHLTUInt32_t fSpecification; |
241 | }; |
242 | |
32db4144 |
243 | /** |
244 | * @struct AliHLTComponentEventDoneData |
245 | * |
246 | */ |
8ede8717 |
247 | struct AliHLTComponentEventDoneData |
f23a6e1a |
248 | { |
249 | AliHLTUInt32_t fStructSize; |
250 | AliHLTUInt32_t fDataSize; |
251 | void* fData; |
252 | }; |
253 | |
32db4144 |
254 | /** |
2cbdb37e |
255 | * @struct AliHLTRunDesc |
32db4144 |
256 | * Event descriptor. |
257 | * The struct is send with the SOR and EOR events. |
258 | */ |
2cbdb37e |
259 | struct AliHLTRunDesc |
32db4144 |
260 | { |
261 | AliHLTUInt32_t fStructSize; |
262 | AliHLTUInt32_t fRunNo; |
263 | AliHLTUInt32_t fRunType; |
264 | }; |
265 | |
8f81abf4 |
266 | ////////////////////////////////////////////////////////////////////////// |
267 | // |
268 | // Trigger meta information |
269 | // |
270 | ////////////////////////////////////////////////////////////////////////// |
271 | |
272 | /** field size of fAttribute */ |
273 | static const int gkAliHLTBlockDAttributeCount = 8; |
274 | |
275 | /** field size of fCommonHeader */ |
276 | static const int gkAliHLTCommonHeaderCount = 8; |
277 | |
32db4144 |
278 | /** size of the DDL list */ |
279 | static const int gkAliHLTDDLListSize = 29; |
280 | |
281 | /** |
282 | * @struct AliHLTEventDDL |
283 | * DDL list event. |
284 | * The struct is send with the DDLLIST event. |
8f81abf4 |
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 ) |
32db4144 |
288 | */ |
289 | struct AliHLTEventDDL |
290 | { |
291 | AliHLTUInt32_t fCount; |
292 | AliHLTUInt32_t fList[gkAliHLTDDLListSize]; |
293 | }; |
294 | |
8f81abf4 |
295 | /** |
296 | * @struct AliHLTBlockHeader |
297 | * 1 to 1 copy from HLT framework, remember before changeing |
298 | */ |
299 | struct AliHLTBlockHeader |
300 | { |
301 | AliHLTUInt32_t fLength; |
302 | union |
303 | { |
304 | AliHLTUInt32_t fID; |
305 | AliHLTUInt8_t fDescr[4]; |
306 | } fType; |
307 | union |
308 | { |
309 | AliHLTUInt32_t fID:24; |
310 | AliHLTUInt8_t fDescr[3]; |
311 | } fSubType; |
312 | AliHLTUInt8_t fVersion; |
313 | }; |
314 | |
315 | /** |
316 | * @struct AliHLTEventTriggerStruct |
317 | * 1 to 1 copy from HLT framework, remember before changeing |
318 | */ |
319 | struct AliHLTEventTriggerStruct |
320 | { |
321 | AliHLTBlockHeader fHeader; |
322 | AliHLTUInt32_t fDataWordCount; |
323 | AliHLTUInt32_t fDataWords[0]; |
324 | }; |
325 | |
326 | /** |
327 | * @struct AliHLTEventTriggerData |
328 | * 1 to 1 copy from HLT framework, remember before changeing |
329 | */ |
330 | struct AliHLTEventTriggerData |
331 | { |
332 | AliHLTEventTriggerStruct fETS; |
333 | AliHLTUInt8_t fAttributes[gkAliHLTBlockDAttributeCount]; |
334 | /** Bit field */ |
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; |
341 | }; |
342 | |
343 | /** |
344 | * @struct AliHLTComponentTriggerData |
345 | * Trigger data |
346 | */ |
347 | struct AliHLTComponentTriggerData |
348 | { |
349 | AliHLTUInt32_t fStructSize; |
350 | AliHLTUInt32_t fDataSize; |
351 | void* fData; |
352 | }; |
353 | |
9d9ffd37 |
354 | ////////////////////////////////////////////////////////////////////////// |
355 | // |
356 | // HLT Event Type Specification |
357 | // |
358 | ////////////////////////////////////////////////////////////////////////// |
359 | |
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; |
378 | |
32db4144 |
379 | ////////////////////////////////////////////////////////////////////////// |
380 | // |
381 | // HLT defines and defaults |
382 | // |
383 | ////////////////////////////////////////////////////////////////////////// |
384 | |
385 | /** invalid event id */ |
386 | const AliHLTEventID_t kAliHLTVoidEventID=~(AliHLTEventID_t)0; |
387 | |
388 | /** invalid data specification */ |
389 | const AliHLTUInt32_t kAliHLTVoidDataSpec = ~(AliHLTUInt32_t)0; |
390 | |
391 | /** invalid shared memory type */ |
392 | const AliHLTUInt32_t gkAliHLTComponentInvalidShmType = 0; |
393 | |
394 | /** invalid shared memory id */ |
395 | const AliHLTUInt64_t gkAliHLTComponentInvalidShmID = ~(AliHLTUInt64_t)0; |
396 | |
397 | /** invalid data type */ |
398 | const AliHLTComponentDataType kAliHLTVoidDataType = { |
399 | sizeof(AliHLTComponentDataType), |
400 | kAliHLTVoidDataTypeID, |
3f850585 |
401 | kAliHLTDataOriginVoid |
32db4144 |
402 | }; |
403 | |
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 |
408 | /** any data type */ |
409 | const AliHLTComponentDataType kAliHLTAnyDataType = { |
410 | sizeof(AliHLTComponentDataType), |
411 | kAliHLTAnyDataTypeID, |
3f850585 |
412 | kAliHLTDataOriginAny |
32db4144 |
413 | }; |
414 | |
de6593d0 |
415 | /** multiple output data types */ |
416 | extern const AliHLTComponentDataType kAliHLTMultipleDataType; |
417 | |
32db4144 |
418 | /** data to file exchange subscriber */ |
419 | extern const AliHLTComponentDataType kAliHLTDataTypeFXSCalib; |
420 | |
421 | /** DDL list data type */ |
422 | extern const AliHLTComponentDataType kAliHLTDataTypeDDL; |
423 | |
424 | /** SOR data type */ |
425 | extern const AliHLTComponentDataType kAliHLTDataTypeSOR; |
426 | |
427 | /** EOR data type */ |
428 | extern const AliHLTComponentDataType kAliHLTDataTypeEOR; |
5ec8e281 |
429 | |
77405890 |
430 | /** Event type specification */ |
431 | extern const AliHLTComponentDataType kAliHLTDataTypeEvent; |
432 | |
69347e0d |
433 | /** RAW DDL data specification, data publisher will set type id and origin correctly */ |
3f850585 |
434 | extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw; |
435 | |
32db4144 |
436 | ////////////////////////////////////////////////////////////////////////// |
437 | // |
438 | // FXS subscriber meta information |
439 | // |
440 | ////////////////////////////////////////////////////////////////////////// |
441 | |
442 | static const int gkAliHLTFXSHeaderfOriginSize = 4; |
443 | static const int gkAliHLTFXSHeaderfFileIDSize = 128; |
444 | static const int gkAliHLTFXSHeaderfDDLNumberSize = 64; |
445 | |
446 | /** Header in front of the data payload, in order to sent data to the FXS. */ |
447 | struct AliHLTFXSHeader |
448 | { |
449 | AliHLTUInt32_t fHeaderVersion; |
450 | AliHLTUInt32_t fRunNumber; |
451 | char fOrigin[gkAliHLTFXSHeaderfOriginSize]; |
452 | char fFileID[gkAliHLTFXSHeaderfFileIDSize]; |
453 | char fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize]; |
454 | }; |
455 | |
456 | ////////////////////////////////////////////////////////////////////////// |
457 | // |
458 | // Component running environment |
459 | // |
460 | ////////////////////////////////////////////////////////////////////////// |
461 | |
462 | /** logging function */ |
463 | typedef int (*AliHLTfctLogging)( void* param, |
464 | AliHLTComponentLogSeverity severity, |
465 | const char* origin, |
466 | const char* keyword, |
467 | const char* message); |
468 | |
469 | /** |
470 | * @struct AliHLTComponentEnvironment |
471 | * Running environment for analysis components. |
472 | * The struct describes function callbacks for |
473 | */ |
f23a6e1a |
474 | struct AliHLTComponentEnvironment |
475 | { |
476 | AliHLTUInt32_t fStructSize; |
477 | void* fParam; |
478 | void* (*fAllocMemoryFunc)( void* param, unsigned long size ); |
479 | #if 0 |
32db4144 |
480 | // future addition already foreseen/envisioned |
481 | // IMPORTANT: don not just remove the defines as this breaks the binary |
482 | // compatibility |
483 | int (*fAllocShmMemoryFunc)( void* param, unsigned long size, AliHLTComponentBlockData* blockLocation ); |
f23a6e1a |
484 | #endif |
8ede8717 |
485 | int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd ); |
5ec8e281 |
486 | AliHLTfctLogging fLoggingFunc; |
f23a6e1a |
487 | }; |
488 | } |
489 | |
32db4144 |
490 | ////////////////////////////////////////////////////////////////////////// |
491 | // |
492 | // Data type helper functions |
493 | // |
494 | ////////////////////////////////////////////////////////////////////////// |
495 | |
8ede8717 |
496 | inline bool operator==( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 ) |
71d7c760 |
497 | { |
21745ddc |
498 | for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) |
71d7c760 |
499 | if ( dt1.fID[i] != dt2.fID[i] ) |
500 | return false; |
21745ddc |
501 | for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) |
71d7c760 |
502 | if ( dt1.fOrigin[i] != dt2.fOrigin[i] ) |
503 | return false; |
504 | return true; |
505 | } |
506 | |
8ede8717 |
507 | inline bool operator!=( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 ) |
71d7c760 |
508 | { |
21745ddc |
509 | for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) |
71d7c760 |
510 | if ( dt1.fID[i] != dt2.fID[i] ) |
511 | return true; |
21745ddc |
512 | for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) |
71d7c760 |
513 | if ( dt1.fOrigin[i] != dt2.fOrigin[i] ) |
514 | return true; |
515 | return false; |
516 | } |
517 | |
69347e0d |
518 | inline AliHLTComponentDataType operator|(const AliHLTComponentDataType srcdt, const char origin[kAliHLTComponentDataTypefOriginSize]) |
519 | { |
520 | AliHLTComponentDataType dt=srcdt; |
521 | for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) |
522 | dt.fOrigin[i]=origin[i]; |
523 | return dt; |
524 | } |
32db4144 |
525 | |
f23a6e1a |
526 | #endif |