]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTDataTypes.h
Adding a switch to turn on/off the gain calibration
[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| (AliHLTComponentDataType)
28  *           2007-11-24 added trigger structs and ESD tree data type
29  *   4       Component configuration event added
30  */
31 #define ALIHLT_DATA_TYPES_VERSION 4
32
33 //////////////////////////////////////////////////////////////////////////
34 //
35 // HLT data origin variables.
36 //
37 // By converting from defines to variables, the origins can be used with
38 // the operator|
39 //
40 // AliHLTComponentDataType dt;
41 // dt = kAliHLTDataTypeDDLRaw | gkAliHLTDataOriginTPC;
42 //
43 //////////////////////////////////////////////////////////////////////////
44
45 /** field size of datat type origin */
46 const int kAliHLTComponentDataTypefOriginSize=4;
47
48
49 /** invalid data origin */
50 # define kAliHLTDataOriginVoid "\0\0\0"
51 /** old invalid data origin, kept for backward compatibility */
52 # define kAliHLTVoidDataOrigin "\0\0\0"
53
54 /** wildcard data type origin */
55 # define kAliHLTDataOriginAny "***"
56 /** old wildcard data type origin, kept for backward compatibility */
57 # define kAliHLTAnyDataOrigin "***"
58
59 /** HLT out */
60 extern const char kAliHLTDataOriginOut[kAliHLTComponentDataTypefOriginSize];
61
62 /** HLT/PubSub private internal */
63 extern const char kAliHLTDataOriginPrivate[kAliHLTComponentDataTypefOriginSize];
64
65 /** TPC */
66 extern const char kAliHLTDataOriginTPC[kAliHLTComponentDataTypefOriginSize];
67
68 /** PHOS */
69 extern const char kAliHLTDataOriginPHOS[kAliHLTComponentDataTypefOriginSize];
70
71 /** MUON */
72 extern const char kAliHLTDataOriginMUON[kAliHLTComponentDataTypefOriginSize];
73
74 /** TRD */
75 extern const char kAliHLTDataOriginTRD[kAliHLTComponentDataTypefOriginSize];
76
77 /** ITS */
78 extern const char kAliHLTDataOriginITS[kAliHLTComponentDataTypefOriginSize];
79
80 //////////////////////////////////////////////////////////////////////////
81 //
82 // HLT common data type defines
83 //
84 //////////////////////////////////////////////////////////////////////////
85
86 /** field size of data type id */
87 const int kAliHLTComponentDataTypefIDsize=8;
88
89
90 /** invalid data type id */
91 # define kAliHLTVoidDataTypeID "\0\0\0\0\0\0\0"
92
93 /** special id for any data type id */
94 # define kAliHLTAnyDataTypeID "*******"
95
96 /** DDL RAW data */
97 # define kAliHLTDDLRawDataTypeID   {'D','D','L','_','R','A','W',' '}
98
99 /** calibration data for file exchange subscriber */
100 # define kAliHLTFXSCalibDataTypeID {'F','X','S','_','C','A','L',' '}
101
102 /** start of run (SOR) event 
103  * @ref AliHLTRunDesc
104  */
105 # define kAliHLTSORDataTypeID      {'S','T','A','R','T','O','F','R'}
106
107 /** end of run (EOR) event 
108  * @ref AliHLTRunDesc
109  */
110 # define kAliHLTEORDataTypeID      {'E','N','D','O','F','R','U','N'}
111
112 /** DDL list event 
113  * @ref AliHLTEventDDL
114  */
115 # define kAliHLTDDLDataTypeID      {'D','D','L','L','I','S','T',' '}
116
117 /** EventType event 
118  * - empty payload, specification gives eventType
119  */
120 # define kAliHLTEventDataTypeID    {'E','V','E','N','T','T','Y','P'}
121
122 /** ComponentConfiguration event
123  * - payload contains the ID of the component in the analysis chain
124  */
125 # define kAliHLTComConfDataTypeID  {'C','O','M','_','C','O','N','F'}
126
127 /** ESD data block
128  * an AliESD object of varying origin
129  * The 'V0' at the end allows a versioning
130  */
131 # define kAliHLTESDObjectDataTypeID    {'A','L','I','E','S','D','V','0'}
132
133 /** ESD tree data block
134  * TTree with an AliESD object of varying origin
135  */
136 # define kAliHLTESDTreeDataTypeID      {'E','S','D','_','T','R','E','E'}
137
138 /** HW Address selection data block
139  * - a selection list for 16 bit HW addresses
140  * - varying origin
141  */
142 # define kAliHLTHwAddr16DataTypeID     {'H','W','A','D','D','R','1','6'}
143
144 using namespace std;
145
146 extern "C" {
147   //////////////////////////////////////////////////////////////////////////
148   //
149   // Basic HLT data types
150   //
151   //////////////////////////////////////////////////////////////////////////
152
153   typedef unsigned char AliHLTUInt8_t;
154
155   typedef signed char AliHLTInt8_t;
156
157   typedef unsigned short AliHLTUInt16_t;
158
159   typedef signed short AliHLTInt16_t;
160
161   typedef unsigned int AliHLTUInt32_t;
162
163   typedef signed int AliHLTInt32_t;
164
165   typedef unsigned long long AliHLTUInt64_t;
166
167   typedef signed long long AliHLTInt64_t;
168
169   typedef float AliHLTFloat32_t;
170
171   typedef double AliHLTFloat64_t;
172
173   typedef AliHLTUInt64_t AliHLTEventID_t;
174
175   //////////////////////////////////////////////////////////////////////////
176   //
177   // HLT logging levels
178   //
179   //////////////////////////////////////////////////////////////////////////
180
181   enum AliHLTComponentLogSeverity { 
182     kHLTLogNone      = 0,
183     kHLTLogBenchmark = 0x1,
184     kHLTLogDebug     = 0x2,
185     kHLTLogInfo      = 0x4,
186     kHLTLogWarning   = 0x8,
187     kHLTLogError     = 0x10,
188     kHLTLogFatal     = 0x20,
189     kHLTLogAll       = 0x3f,
190     kHLTLogDefault   = 0x3d 
191 };
192
193   //////////////////////////////////////////////////////////////////////////
194   //
195   // HLT data structures for data exchange and external interface
196   //
197   //////////////////////////////////////////////////////////////////////////
198
199   /**
200    * @struct AliHLTComponentEventData
201    * Event descriptor
202    */
203   struct AliHLTComponentEventData
204   {
205     AliHLTUInt32_t fStructSize;
206     AliHLTEventID_t fEventID;
207     AliHLTUInt32_t fEventCreation_s;
208     AliHLTUInt32_t fEventCreation_us;
209     AliHLTUInt32_t fBlockCnt;
210   };
211
212   /**
213    * @struct AliHLTComponentShmData
214    * Shared memory descriptor.
215    * Irrelevant for analysis components.
216    */
217   struct AliHLTComponentShmData
218   {
219     AliHLTUInt32_t fStructSize;
220     AliHLTUInt32_t fShmType;
221     AliHLTUInt64_t fShmID;
222   };
223
224   /**
225    * @struct AliHLTComponentDataType
226    * Data type descriptor for data blocks transferred through the processing
227    * chain.
228    */
229   struct AliHLTComponentDataType
230   {
231     AliHLTUInt32_t fStructSize;
232     char fID[kAliHLTComponentDataTypefIDsize];                      //!
233     char fOrigin[kAliHLTComponentDataTypefOriginSize];              //!
234   };
235
236   /**
237    * @struct AliHLTComponentBlockData
238    * This is the decription of data blocks exchanged between components.
239    * \b IMPORTANT: The validity of fPtr and fOffset is different for input and
240    * output blocks:
241    * - input blocks: The \em fPtr member always points to the beginning of the data
242    *                 of size \em fSize. fOffset is ignored and should be in most
243    *                 case 0.
244    * - output blocks: The \em fPtr member is ignored by the framework. \em fOffset
245    *                  must specify the start of the data relative to the output
246    *                  buffer. The data block has size \em fSize.
247    */
248   struct AliHLTComponentBlockData
249   {
250     /* size and version of the struct */
251     AliHLTUInt32_t fStructSize;
252     /* shared memory key, ignored by processing components */
253     AliHLTComponentShmData fShmKey;
254     /* offset of output data relative to the output buffer */
255     AliHLTUInt32_t fOffset;
256     /* start of the data for input data blocks, fOffset to be ignored*/
257     void* fPtr;
258     /* size of the data block */
259     AliHLTUInt32_t fSize;
260     /* data type of the data block */
261     AliHLTComponentDataType fDataType;
262     /* data specification of the data block */
263     AliHLTUInt32_t fSpecification;
264   };
265
266   /**
267    * @struct AliHLTComponentEventDoneData
268    * 
269    */
270   struct AliHLTComponentEventDoneData
271   {
272     AliHLTUInt32_t fStructSize;
273     AliHLTUInt32_t fDataSize;
274     void* fData;
275   };
276
277   /**
278    * @struct AliHLTRunDesc
279    * Event descriptor.
280    * The struct is send with the SOR and EOR events.
281    */
282   struct AliHLTRunDesc
283   {
284     AliHLTUInt32_t fStructSize;
285     AliHLTUInt32_t fRunNo;
286     AliHLTUInt32_t fRunType;
287   };
288
289   //////////////////////////////////////////////////////////////////////////
290   //
291   // Trigger meta information
292   //
293   //////////////////////////////////////////////////////////////////////////
294
295   /** field size of fAttribute */
296   static const int gkAliHLTBlockDAttributeCount = 8;
297
298   /** field size of fCommonHeader */
299   static const int gkAliHLTCommonHeaderCount = 8;
300
301   /** size of the DDL list */
302   static const int gkAliHLTDDLListSize = 29;
303
304   /**
305    * @struct AliHLTEventDDL
306    * DDL list event.
307    * The struct is send with the DDLLIST event.
308    * Used in the trigger structure for internal apperance of 
309    * the DLLs as well as for the HLT readout list send to DAQ 
310    * ( as DataType : kAliHLTDataTypeDDL )
311    */
312   struct AliHLTEventDDL
313   {
314     AliHLTUInt32_t fCount;
315     AliHLTUInt32_t fList[gkAliHLTDDLListSize];
316   };
317
318   /**
319    * @struct AliHLTEventTriggerData
320    */
321   struct AliHLTEventTriggerData
322   {
323     AliHLTUInt8_t  fAttributes[gkAliHLTBlockDAttributeCount]; 
324     AliHLTUInt64_t fHLTStatus; // Bit field 
325     AliHLTUInt32_t fCommonHeaderWordCnt;
326     AliHLTUInt32_t fCommonHeader[gkAliHLTCommonHeaderCount]; 
327     AliHLTEventDDL fReadoutList;
328   };
329
330   /**
331    * @struct AliHLTComponentTriggerData
332    * Trigger data
333    */
334   struct AliHLTComponentTriggerData
335   {
336     AliHLTUInt32_t fStructSize;
337     AliHLTUInt32_t fDataSize;
338     void* fData;
339   };
340
341   //////////////////////////////////////////////////////////////////////////
342   //
343   // HLT Event Type Specification
344   //
345   //////////////////////////////////////////////////////////////////////////
346
347   /** Unknown eventType specification */
348   static const AliHLTUInt32_t gkAliEventTypeUnknown = ~(AliHLTUInt32_t)0;
349   /** SOR eventType specification */ 
350   static const AliHLTUInt32_t gkAliEventTypeStartOfRun=1;
351   /** Data eventType specification */
352   static const AliHLTUInt32_t gkAliEventTypeData=2;
353   /** EOR eventType specification */ 
354   static const AliHLTUInt32_t gkAliEventTypeEndOfRun=4;
355   /** Corrupt eventType specification */
356   static const AliHLTUInt32_t gkAliEventTypeCorruptID=8;
357   /** Calibration eventType specification */ 
358   static const AliHLTUInt32_t gkAliEventTypeCalibration=16;
359   /** DataReplay eventType specification */
360   static const AliHLTUInt32_t gkAliEventTypeDataReplay=32;
361   /** Tick eventType specification */ 
362   static const AliHLTUInt32_t gkAliEventTypeTick=64;
363   /** Max eventType specification */ 
364   static const AliHLTUInt32_t gkAliEventTypeMax=64;
365
366   //////////////////////////////////////////////////////////////////////////
367   //
368   // HLT defines and defaults
369   //
370   //////////////////////////////////////////////////////////////////////////
371
372   /** invalid event id */
373   const AliHLTEventID_t kAliHLTVoidEventID=~(AliHLTEventID_t)0;
374
375   /** invalid data specification */
376   const AliHLTUInt32_t kAliHLTVoidDataSpec = ~(AliHLTUInt32_t)0;
377
378   /** invalid shared memory type */
379   const AliHLTUInt32_t gkAliHLTComponentInvalidShmType = 0;
380
381   /** invalid shared memory id */
382   const AliHLTUInt64_t gkAliHLTComponentInvalidShmID = ~(AliHLTUInt64_t)0;
383
384   /** invalid data type */
385   const AliHLTComponentDataType kAliHLTVoidDataType = {
386     sizeof(AliHLTComponentDataType),
387     kAliHLTVoidDataTypeID,
388     kAliHLTDataOriginVoid
389   };
390
391   // there is currently a problem with rootcint if the predefined ids
392   // (commented below) are used. rootcint does not find the id if they
393   // are char arrays defined with {} and individual chars. If strings
394   // are used it works fine
395   /** any data type */
396   const AliHLTComponentDataType kAliHLTAnyDataType = {
397     sizeof(AliHLTComponentDataType),
398     kAliHLTAnyDataTypeID,
399     kAliHLTDataOriginAny
400   };
401
402   /** multiple output data types */
403   extern const AliHLTComponentDataType kAliHLTMultipleDataType;
404
405   /** data to file exchange subscriber */
406   extern const AliHLTComponentDataType kAliHLTDataTypeFXSCalib;
407
408   /** DDL list data type */
409   extern const AliHLTComponentDataType kAliHLTDataTypeDDL;
410
411   /** SOR data type */
412   extern const AliHLTComponentDataType kAliHLTDataTypeSOR;
413
414   /** EOR data type */
415   extern const AliHLTComponentDataType kAliHLTDataTypeEOR;
416
417   /** Event type specification */
418   extern const AliHLTComponentDataType kAliHLTDataTypeEvent;
419
420   /** Configuration event data type */
421   extern const AliHLTComponentDataType kAliHLTDataTypeComConf;
422
423   /** RAW DDL data specification, origin is 'any', data publisher origin correctly */
424   extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw;
425
426   /** ESD object data specification, origin is 'any' */
427   extern const AliHLTComponentDataType kAliHLTDataTypeESDObject;
428
429   /** ESD Tree data specification, origin is 'any' */
430   extern const AliHLTComponentDataType kAliHLTDataTypeESDTree;
431
432   /** 16 bit Hardware address selection data specification, origin is 'any' */
433   extern const AliHLTComponentDataType kAliHLTDataTypeHwAddr16;
434
435   //////////////////////////////////////////////////////////////////////////
436   //
437   // FXS subscriber meta information
438   //
439   //////////////////////////////////////////////////////////////////////////
440
441   static const int gkAliHLTFXSHeaderfOriginSize = 4;
442   static const int gkAliHLTFXSHeaderfFileIDSize = 128;
443   static const int gkAliHLTFXSHeaderfDDLNumberSize = 64;
444
445   /** Header in front of the data payload, in order to sent data to the FXS. */
446   struct AliHLTFXSHeader
447   {
448     AliHLTUInt32_t fHeaderVersion;
449     AliHLTUInt32_t fRunNumber;
450     char fOrigin[gkAliHLTFXSHeaderfOriginSize];
451     char fFileID[gkAliHLTFXSHeaderfFileIDSize];
452     char fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize];
453   };  
454
455   //////////////////////////////////////////////////////////////////////////
456   //
457   // Component running environment
458   //
459   //////////////////////////////////////////////////////////////////////////
460
461   /** logging function */
462   typedef int (*AliHLTfctLogging)( void* param, 
463                                    AliHLTComponentLogSeverity severity,
464                                    const char* origin,
465                                    const char* keyword,
466                                    const char* message);
467
468   /**
469    * @struct AliHLTComponentEnvironment
470    * Running environment for analysis components.
471    * The struct describes function callbacks for 
472    */
473   struct AliHLTComponentEnvironment
474   {
475     AliHLTUInt32_t fStructSize;
476     void* fParam;
477     void* (*fAllocMemoryFunc)( void* param, unsigned long size );
478 #if 0
479     // future addition already foreseen/envisioned
480     // IMPORTANT: don not just remove the defines as this breaks the binary
481     // compatibility
482     int (*fAllocShmMemoryFunc)( void* param, unsigned long size, AliHLTComponentBlockData* blockLocation );
483 #endif
484     int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd );
485     AliHLTfctLogging fLoggingFunc;
486   };
487 }
488
489 //////////////////////////////////////////////////////////////////////////
490 //
491 // Data type helper functions
492 //
493 //////////////////////////////////////////////////////////////////////////
494
495 inline bool operator==( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
496 {
497   bool any1=true, any2=true, void1=true, void2=true, match=true;
498   for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) {
499     any1&=(dt1.fOrigin[i]==kAliHLTDataOriginAny[i]);
500     any2&=(dt2.fOrigin[i]==kAliHLTDataOriginAny[i]);
501     void1&=(dt1.fOrigin[i]==kAliHLTDataOriginVoid[i]);
502     void2&=(dt2.fOrigin[i]==kAliHLTDataOriginVoid[i]);
503     match&=dt1.fOrigin[i]==dt2.fOrigin[i];
504     if (!(match || (any2 && !void1) || (any1 && !void2)))
505       return false;
506   }
507
508   any1=true, any2=true, match=true;
509   for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) {
510     any1&=(dt1.fID[i]==kAliHLTAnyDataTypeID[i]);
511     any2&=(dt2.fID[i]==kAliHLTAnyDataTypeID[i]);
512     void1&=(dt1.fID[i]==kAliHLTVoidDataTypeID[i]);
513     void2&=(dt2.fID[i]==kAliHLTVoidDataTypeID[i]);
514     match&=dt1.fID[i]==dt2.fID[i];
515     if (!(match || (any2 && !void1) || (any1 && !void2)))
516       return false;
517   }
518   return true;
519 }
520
521 inline bool operator!=( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
522 {
523   return !(dt1==dt2);
524 }
525
526 inline AliHLTComponentDataType operator|(const AliHLTComponentDataType srcdt, const char origin[kAliHLTComponentDataTypefOriginSize])
527 {
528   AliHLTComponentDataType dt=srcdt;
529   for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
530     dt.fOrigin[i]=origin[i];
531   return dt;
532 }
533
534 #endif