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