]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTDataTypes.h
added trigger structs and meta information
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDataTypes.h
1 // @(#) $Id$
2
3 #ifndef ALIHLTDATATYPES_H
4 #define ALIHLTDATATYPES_H
5 /* This file is property of and copyright by the ALICE HLT Project        * 
6  * ALICE Experiment at CERN, All rights reserved.                         *
7  * See cxx source for full Copyright notice                               */
8
9 /** @file   AliHLTDataTypes.h
10     @author Matthias Richter, Timm Steinbeck, Jochen Thaeder
11     @date   
12     @brief  Data type declaration for the HLT module.
13 */
14
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  *   3       2007-11-15 RAW DDL data type added; some inconsistencies fixed
25  *           ('void' and 'any' origins); added signed HLT basic data types
26  *           2007-11-23 origin defines have become variables in conjunction
27  *           to be used with the operator| (AliHLTComponentDatatType
28  *           2007-11-24 added trigger structs
29  */
30 #define ALIHLT_DATA_TYPES_VERSION 3
31
32 //////////////////////////////////////////////////////////////////////////
33 //
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;
41 //
42 //////////////////////////////////////////////////////////////////////////
43
44 /** field size of datat type origin */
45 const int kAliHLTComponentDataTypefOriginSize=4;
46
47
48 /** invalid data origin */
49 # define kAliHLTDataOriginVoid "\0\0\0"
50 /** old invalid data origin, kept for backward compatibility */
51 # define kAliHLTVoidDataOrigin "\0\0\0"
52
53 /** wildcard data type origin */
54 # define kAliHLTDataOriginAny "***"
55 /** old wildcard data type origin, kept for backward compatibility */
56 # define kAliHLTAnyDataOrigin "***"
57
58 /** HLT out */
59 extern const char kAliHLTDataOriginOut[kAliHLTComponentDataTypefOriginSize];
60
61 /** HLT/PubSub private internal */
62 extern const char kAliHLTDataOriginPrivate[kAliHLTComponentDataTypefOriginSize];
63
64 /** TPC */
65 extern const char kAliHLTDataOriginTPC[kAliHLTComponentDataTypefOriginSize];
66
67 /** PHOS */
68 extern const char kAliHLTDataOriginPHOS[kAliHLTComponentDataTypefOriginSize];
69
70 /** MUON */
71 extern const char kAliHLTDataOriginMUON[kAliHLTComponentDataTypefOriginSize];
72
73 /** TRD */
74 extern const char kAliHLTDataOriginTRD[kAliHLTComponentDataTypefOriginSize];
75
76 /** ITS */
77 extern const char kAliHLTDataOriginITS[kAliHLTComponentDataTypefOriginSize];
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
95 /** DDL RAW data */
96 # define kAliHLTDDLRawDataTypeID   {'D','D','L','_','R','A','W',' '}
97
98 /** calibration data for file exchange subscriber */
99 # define kAliHLTFXSCalibDataTypeID {'F','X','S','_','C','A','L',' '}
100
101 /** start of run (SOR) event 
102  * @ref AliHLTRunDesc
103  */
104 # define kAliHLTSORDataTypeID      {'S','T','A','R','T','O','F','R'}
105
106 /** end of run (EOR) event 
107  * @ref AliHLTRunDesc
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
116 /** EventType event 
117  * - empty payload, specification gives eventType
118  */
119 # define kAliHLTEventDataTypeID    {'E','V','E','N','T','T','Y','P'}
120
121 using namespace std;
122
123 extern "C" {
124   //////////////////////////////////////////////////////////////////////////
125   //
126   // Basic HLT data types
127   //
128   //////////////////////////////////////////////////////////////////////////
129
130   typedef unsigned char AliHLTUInt8_t;
131
132   typedef signed char AliHLTInt8_t;
133
134   typedef unsigned short AliHLTUInt16_t;
135
136   typedef signed short AliHLTInt16_t;
137
138   typedef unsigned int AliHLTUInt32_t;
139
140   typedef signed int AliHLTInt32_t;
141
142   typedef unsigned long long AliHLTUInt64_t;
143
144   typedef signed long long AliHLTInt64_t;
145
146   typedef float AliHLTFloat32_t;
147
148   typedef double AliHLTFloat64_t;
149
150   typedef AliHLTUInt64_t AliHLTEventID_t;
151
152   //////////////////////////////////////////////////////////////////////////
153   //
154   // HLT logging levels
155   //
156   //////////////////////////////////////////////////////////////////////////
157
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    */
180   struct AliHLTComponentEventData
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
189   /**
190    * @struct AliHLTComponentShmData
191    * Shared memory descriptor.
192    * Irrelevant for analysis components.
193    */
194   struct AliHLTComponentShmData
195   {
196     AliHLTUInt32_t fStructSize;
197     AliHLTUInt32_t fShmType;
198     AliHLTUInt64_t fShmID;
199   };
200
201   /**
202    * @struct AliHLTComponentDataType
203    * Data type descriptor for data blocks transferred through the processing
204    * chain.
205    */
206   struct AliHLTComponentDataType
207   {
208     AliHLTUInt32_t fStructSize;
209     char fID[kAliHLTComponentDataTypefIDsize];                      //!
210     char fOrigin[kAliHLTComponentDataTypefOriginSize];              //!
211   };
212
213   /**
214    * @struct AliHLTComponentBlockData
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.
224    */
225   struct AliHLTComponentBlockData
226   {
227     /* size and version of the struct */
228     AliHLTUInt32_t fStructSize;
229     /* shared memory key, ignored by processing components */
230     AliHLTComponentShmData fShmKey;
231     /* offset of output data relative to the output buffer */
232     AliHLTUInt32_t fOffset;
233     /* start of the data for input data blocks, fOffset to be ignored*/
234     void* fPtr;
235     /* size of the data block */
236     AliHLTUInt32_t fSize;
237     /* data type of the data block */
238     AliHLTComponentDataType fDataType;
239     /* data specification of the data block */
240     AliHLTUInt32_t fSpecification;
241   };
242
243   /**
244    * @struct AliHLTComponentEventDoneData
245    * 
246    */
247   struct AliHLTComponentEventDoneData
248   {
249     AliHLTUInt32_t fStructSize;
250     AliHLTUInt32_t fDataSize;
251     void* fData;
252   };
253
254   /**
255    * @struct AliHLTRunDesc
256    * Event descriptor.
257    * The struct is send with the SOR and EOR events.
258    */
259   struct AliHLTRunDesc
260   {
261     AliHLTUInt32_t fStructSize;
262     AliHLTUInt32_t fRunNo;
263     AliHLTUInt32_t fRunType;
264   };
265
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
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.
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  )
288    */
289   struct AliHLTEventDDL
290   {
291     AliHLTUInt32_t fCount;
292     AliHLTUInt32_t fList[gkAliHLTDDLListSize];
293   };
294
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
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
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,
401     kAliHLTDataOriginVoid
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,
412     kAliHLTDataOriginAny
413   };
414
415   /** multiple output data types */
416   extern const AliHLTComponentDataType kAliHLTMultipleDataType;
417
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;
429
430   /** Event type specification */
431   extern const AliHLTComponentDataType kAliHLTDataTypeEvent;
432
433   /** RAW DDL data specification, data publisher will set type id and origin correctly */
434   extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw;
435
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    */
474   struct AliHLTComponentEnvironment
475   {
476     AliHLTUInt32_t fStructSize;
477     void* fParam;
478     void* (*fAllocMemoryFunc)( void* param, unsigned long size );
479 #if 0
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 );
484 #endif
485     int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd );
486     AliHLTfctLogging fLoggingFunc;
487   };
488 }
489
490 //////////////////////////////////////////////////////////////////////////
491 //
492 // Data type helper functions
493 //
494 //////////////////////////////////////////////////////////////////////////
495
496 inline bool operator==( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
497     {
498     for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
499         if ( dt1.fID[i] != dt2.fID[i] )
500             return false;
501     for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
502         if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
503             return false;
504     return true;
505     }
506
507 inline bool operator!=( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
508     {
509     for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
510         if ( dt1.fID[i] != dt2.fID[i] )
511             return true;
512     for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
513         if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
514             return true;
515     return false;
516     }
517
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     }
525
526 #endif