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