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