]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTDataTypes.h
major change in the external component interface: redesigned and moved to libHLTinter...
[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 and DCS update events added
30  *           gkAliHLTDDLListSize set from 29 to 30 according to new PubSub
31  *           specs
32  *   5       Data types for Run and Event summary, and for monitoring added
33  *   6       Common data types for TreeD and TreeR defined
34  *           kAliHLTAllDataTypes and kAliHLTDataOriginSample added
35  *           kAliHLTDataOriginEMCAL added
36  *           kAliHLTDataTypeRunType added
37  *   7       kAliHLTDataTypeComponentStatistics, kAliHLTDataTypeComponentTable,
38  *           and AliHLTComponentStatistics have been added for optional
39  *           component block statistics
40  *   8       new wrapper interface has been introduced, old wrapper interface
41  *           deprecated but kept for backward compatibility, the PubSub
42  *           interface is going to be compiled independently of AliHLT, new
43  *           interface provided by the libHLTinterface.so
44  *           AliHLTComponentEnvironment -> AliHLTAnalysisEnvironment
45  */
46 #define ALIHLT_DATA_TYPES_VERSION 8
47
48 //////////////////////////////////////////////////////////////////////////
49 //
50 // HLT data origin variables.
51 //
52 // By converting from defines to variables, the origins can be used with
53 // the operator|
54 //
55 // AliHLTComponentDataType dt;
56 // dt = kAliHLTDataTypeDDLRaw | gkAliHLTDataOriginTPC;
57 //
58 //////////////////////////////////////////////////////////////////////////
59
60 /** field size of datat type origin 
61  * @ingroup alihlt_component_datatypes
62  */
63 const int kAliHLTComponentDataTypefOriginSize=4;
64
65
66 /** invalid data origin 
67  * @ingroup alihlt_component_datatypes
68  */
69 # define kAliHLTDataOriginVoid "\0\0\0"
70 /** old invalid data origin, kept for backward compatibility */
71 # define kAliHLTVoidDataOrigin "\0\0\0"
72
73 /** wildcard data type origin 
74  * @ingroup alihlt_component_datatypes
75  */
76 # define kAliHLTDataOriginAny "***"
77 /** old wildcard data type origin, kept for backward compatibility */
78 # define kAliHLTAnyDataOrigin "***"
79
80 /** Data origin HLT out 
81  * @ingroup alihlt_component_datatypes
82  */
83 extern const char kAliHLTDataOriginOut[kAliHLTComponentDataTypefOriginSize];
84
85 /** Data origin HLT/PubSub private internal 
86  * @ingroup alihlt_component_datatypes
87  */
88 extern const char kAliHLTDataOriginPrivate[kAliHLTComponentDataTypefOriginSize];
89
90 /** Data origin TPC 
91  * @ingroup alihlt_component_datatypes
92  */
93 extern const char kAliHLTDataOriginTPC[kAliHLTComponentDataTypefOriginSize];
94
95 /** Data origin PHOS 
96  * @ingroup alihlt_component_datatypes
97  */
98 extern const char kAliHLTDataOriginPHOS[kAliHLTComponentDataTypefOriginSize];
99
100 /** Data origin MUON 
101  * @ingroup alihlt_component_datatypes
102  */
103 extern const char kAliHLTDataOriginMUON[kAliHLTComponentDataTypefOriginSize];
104
105 /** Data origin TRD 
106  * @ingroup alihlt_component_datatypes
107  */
108 extern const char kAliHLTDataOriginTRD[kAliHLTComponentDataTypefOriginSize];
109
110 /** Data origin ITS 
111  * @ingroup alihlt_component_datatypes
112  */
113 extern const char kAliHLTDataOriginITS[kAliHLTComponentDataTypefOriginSize];
114
115 /** Data origin for examples 
116  * @ingroup alihlt_component_datatypes
117  */
118 extern const char kAliHLTDataOriginSample[kAliHLTComponentDataTypefOriginSize];
119
120 /** Data origin EMCAL 
121  * @ingroup alihlt_component_datatypes
122  */
123 extern const char kAliHLTDataOriginEMCAL[kAliHLTComponentDataTypefOriginSize];
124
125 //////////////////////////////////////////////////////////////////////////
126 //
127 // HLT common data type defines
128 //
129 //////////////////////////////////////////////////////////////////////////
130
131 /** field size of data type id 
132  * @ingroup alihlt_component_datatypes
133  */
134 const int kAliHLTComponentDataTypefIDsize=8;
135
136
137 /** invalid data type id 
138  * @ingroup alihlt_component_datatypes
139  */
140 # define kAliHLTVoidDataTypeID "\0\0\0\0\0\0\0"
141
142 /** special id for all data types: any + void
143  * @ingroup alihlt_component_datatypes
144  */
145 # define kAliHLTAllDataTypesID "ALLDATA"
146
147 /** special id for any valid data type id
148  * @ingroup alihlt_component_datatypes
149  */
150 # define kAliHLTAnyDataTypeID "*******"
151
152 /** DDL RAW data 
153  * @ingroup alihlt_component_datatypes
154  */
155 # define kAliHLTDDLRawDataTypeID   {'D','D','L','_','R','A','W',' '}
156
157 /** calibration data for file exchange subscriber 
158  * @ingroup alihlt_component_datatypes
159  */
160 # define kAliHLTFXSCalibDataTypeID {'F','X','S','_','C','A','L',' '}
161
162 /** start of run (SOR) event 
163  * @ref AliHLTRunDesc
164  * @ingroup alihlt_component_datatypes
165  */
166 # define kAliHLTSORDataTypeID      {'S','T','A','R','T','O','F','R'}
167
168 /** end of run (EOR) event 
169  * @ref AliHLTRunDesc
170  * @ingroup alihlt_component_datatypes
171  */
172 # define kAliHLTEORDataTypeID      {'E','N','D','O','F','R','U','N'}
173
174 /** run type data block
175  * string with run type as payload
176  * @ingroup alihlt_component_datatypes
177  */
178 # define kAliHLTRunTypeDataTypeID  {'R','U','N','T','Y','P','E',' '}
179
180 /** DDL list event 
181  * @ref AliHLTEventDDL
182  * @ingroup alihlt_component_datatypes
183  */
184 # define kAliHLTDDLDataTypeID      {'D','D','L','L','I','S','T',' '}
185
186 /** EventType event 
187  * - empty payload, specification gives eventType
188  * @ingroup alihlt_component_datatypes
189  */
190 # define kAliHLTEventDataTypeID    {'E','V','E','N','T','T','Y','P'}
191
192 /** ComponentConfiguration event
193  * - payload contains the CDB path as string
194  * @ingroup alihlt_component_datatypes
195  */
196 # define kAliHLTComConfDataTypeID  {'C','O','M','_','C','O','N','F'}
197
198 /** DCS value update event
199  * - payload contains string of relevant detectors
200  * @ingroup alihlt_component_datatypes
201  */
202 # define kAliHLTUpdtDCSDataTypeID  {'U','P','D','T','_','D','C','S'}
203
204 /** ESD data block
205  * an AliESD object of varying origin
206  * The 'V0' at the end allows a versioning
207  * @ingroup alihlt_component_datatypes
208  */
209 # define kAliHLTESDObjectDataTypeID    {'A','L','I','E','S','D','V','0'}
210
211 /** ESD tree data block
212  * TTree with an AliESD object of varying origin
213  * @ingroup alihlt_component_datatypes
214  */
215 # define kAliHLTESDTreeDataTypeID      {'E','S','D','_','T','R','E','E'}
216
217 /** AliRoot TreeD
218  * - the digits tree of an AliRoot module
219  * @ingroup alihlt_component_datatypes
220  */
221 #define kAliHLTTreeDDataTypeID         {'A','L','I','T','R','E','E','D'}
222
223 /** AliRoot TreeR
224  * - the rec points tree of an AliRoot module
225  * @ingroup alihlt_component_datatypes
226  */
227 #define kAliHLTTreeRDataTypeID         {'A','L','I','T','R','E','E','D'}
228
229 /** HW Address selection data block
230  * - a selection list for 16 bit HW addresses
231  * - varying origin
232  * @ingroup alihlt_component_datatypes
233  */
234 # define kAliHLTHwAddr16DataTypeID     {'H','W','A','D','D','R','1','6'}
235
236 /** Event Statistics
237  * - event statistics for given detectors
238  * - varying origin
239  * @ingroup alihlt_component_datatypes
240  */
241 # define kAliHLTEventStatisticsDataTypeID     {'E','V','_','S','T','A','T','I'}
242
243 /** Event Summary
244  * - event summary
245  * - origin : kAliHLTDataOriginOut ( HLT )
246  * @ingroup alihlt_component_datatypes
247  */
248 # define kAliHLTEventSummaryDataTypeID        {'E','V','_','S','U','M','M','A'}
249
250 /** Run Statistics
251  * - run statistics for given detectors
252  * - varying origin
253  * @ingroup alihlt_component_datatypes
254  */
255 # define kAliHLTRunStatisticsDataTypeID       {'R','U','N','S','T','A','T','I'}
256
257 /** Run Summary
258  * - run summary
259  * - origin : kAliHLTDataOriginOut ( HLT )
260  * @ingroup alihlt_component_datatypes
261  */
262 # define kAliHLTRunSummaryDataTypeID          {'R','U','N','S','U','M','M','A'}
263
264 /** Block Statistics
265  * - small block statistics info added to the data stream by
266  *   the component base class
267  * - origin kAliHLTDataOriginPrivate
268  * @ingroup alihlt_component_datatypes
269  */
270 # define kAliHLTComponentStatisticsDataTypeID {'C','O','M','P','S','T','A','T'}
271
272 /** Component table
273  * - list of components in the chain to be percolated through the chain
274  * - each component adds it's chain id string and a generated 32bit id
275  * @ingroup alihlt_component_datatypes
276  */
277 # define kAliHLTComponentTableDataTypeID      {'C','O','M','P','T','A','B','L'}
278
279 /** general ROOT TObject
280  * - a general TObject exported from the HLT analysis
281  * - varying origin
282  * @ingroup alihlt_component_datatypes
283  */
284 #define kAliHLTTObjectDataTypeID              {'R','O','O','T','T','O','B','J'}
285
286 /** ROOT TObjArray
287  * - a TObjArray exported from the HLT analysis
288  * - varying origin
289  * @ingroup alihlt_component_datatypes
290  */
291 #define kAliHLTTObjArrayDataTypeID            {'R','O','O','T','O','B','A','R'}
292
293 /** ROOT TTree
294  * - a TTree object exported from the HLT analysis
295  * - varying origin
296  * @ingroup alihlt_component_datatypes
297  */
298 #define kAliHLTTTreeDataTypeID                {'R','O','O','T','T','R','E','E'}
299
300 /** ROOT histogram
301  * - a histogram object exported from the HLT analysis
302  * - class derives from TH1 (directly or indirectly) and inherits all common functionality
303  * - varying origin
304  * @ingroup alihlt_component_datatypes
305  */
306 #define kAliHLTHistogramDataTypeID            {'R','O','O','T','H','I','S','T'}
307
308 /** ROOT TNtuple
309  * - a TNtupl object exported from the HLT analysis
310  * - varying origin
311  * @ingroup alihlt_component_datatypes
312  */
313 #define kAliHLTTNtupleDataTypeID              {'R','O','O','T','T','U','P','L'}
314
315 using namespace std;
316
317 extern "C" {
318   //////////////////////////////////////////////////////////////////////////
319   //
320   // Basic HLT data types
321   //
322   //////////////////////////////////////////////////////////////////////////
323
324   typedef unsigned char AliHLTUInt8_t;
325
326   typedef signed char AliHLTInt8_t;
327
328   typedef unsigned short AliHLTUInt16_t;
329
330   typedef signed short AliHLTInt16_t;
331
332   typedef unsigned int AliHLTUInt32_t;
333
334   typedef signed int AliHLTInt32_t;
335
336   typedef unsigned long long AliHLTUInt64_t;
337
338   typedef signed long long AliHLTInt64_t;
339
340   typedef float AliHLTFloat32_t;
341
342   typedef double AliHLTFloat64_t;
343
344   typedef AliHLTUInt64_t AliHLTEventID_t;
345
346   //////////////////////////////////////////////////////////////////////////
347   //
348   // HLT logging levels
349   //
350   //////////////////////////////////////////////////////////////////////////
351
352   /**
353    * Logging severities of the HLT
354    */
355   enum AliHLTComponentLogSeverity {
356     /** no logging */
357     kHLTLogNone      = 0,
358     /** benchmark messages */
359     kHLTLogBenchmark = 0x1,
360     /** debug messages */
361     kHLTLogDebug     = 0x2,
362     /** info messages */
363     kHLTLogInfo      = 0x4,
364     /** warning messages */
365     kHLTLogWarning   = 0x8,
366     /** error messages */
367     kHLTLogError     = 0x10,
368     /** fatal error messages */
369     kHLTLogFatal     = 0x20,
370     /** few important messages not to be filtered out.
371      * redirected to kHLTLogInfo in AliRoot
372      */
373     kHLTLogImportant = 0x40,
374     /** special value to enable all messages */
375     kHLTLogAll       = 0x7f,
376     /** the default logging filter */
377     kHLTLogDefault   = 0x79
378   };
379
380   //////////////////////////////////////////////////////////////////////////
381   //
382   // HLT data structures for data exchange and external interface
383   //
384   //////////////////////////////////////////////////////////////////////////
385
386   /**
387    * @struct AliHLTComponentEventData
388    * Event descriptor
389    */
390   struct AliHLTComponentEventData
391   {
392     AliHLTUInt32_t fStructSize;
393     AliHLTEventID_t fEventID;
394     AliHLTUInt32_t fEventCreation_s;
395     AliHLTUInt32_t fEventCreation_us;
396     AliHLTUInt32_t fBlockCnt;
397   };
398
399   /**
400    * @struct AliHLTComponentShmData
401    * Shared memory descriptor.
402    * Irrelevant for analysis components.
403    */
404   struct AliHLTComponentShmData
405   {
406     AliHLTUInt32_t fStructSize;
407     AliHLTUInt32_t fShmType;
408     AliHLTUInt64_t fShmID;
409   };
410
411   /**
412    * @defgroup alihlt_component_datatypes Common Component Data Types
413    * The analysis framework defines a number of common data types for
414    * usage in the detector modules, like e.g. ::kAliHLTAnyDataType
415    * and ::kAliHLTDataTypeDDLRaw. Those data types always have
416    * origin ::kAliHLTDataOriginAny. The correct detector origin can be
417    * set by using operator '|'
418    * <pre>
419    * AliHLTComponentDataType dt=kAliHLTDDLRawDataTypeID|kAliHLTDataOriginTPC
420    * </pre>
421    * @ingroup alihlt_component
422    */
423
424   /**
425    * @struct AliHLTComponentDataType
426    * Data type descriptor for data blocks transferred through the processing
427    * chain.
428    * @ingroup alihlt_component_datatypes
429    */
430   struct AliHLTComponentDataType
431   {
432     AliHLTUInt32_t fStructSize;
433     char fID[kAliHLTComponentDataTypefIDsize];                      //!
434     char fOrigin[kAliHLTComponentDataTypefOriginSize];              //!
435   };
436
437   /**
438    * @struct AliHLTComponentBlockData
439    * This is the decription of data blocks exchanged between components.
440    * \b IMPORTANT: The validity of fPtr and fOffset is different for input and
441    * output blocks:
442    * - input blocks: The \em fPtr member always points to the beginning of the data
443    *                 of size \em fSize. fOffset is ignored and should be in most
444    *                 case 0.
445    * - output blocks: The \em fPtr member is ignored by the framework. \em fOffset
446    *                  must specify the start of the data relative to the output
447    *                  buffer. The data block has size \em fSize.
448    */
449   struct AliHLTComponentBlockData
450   {
451     /* size and version of the struct */
452     AliHLTUInt32_t fStructSize;
453     /* shared memory key, ignored by processing components */
454     AliHLTComponentShmData fShmKey;
455     /* offset of output data relative to the output buffer */
456     AliHLTUInt32_t fOffset;
457     /* start of the data for input data blocks, fOffset to be ignored*/
458     void* fPtr;
459     /* size of the data block */
460     AliHLTUInt32_t fSize;
461     /* data type of the data block */
462     AliHLTComponentDataType fDataType;
463     /* data specification of the data block */
464     AliHLTUInt32_t fSpecification;
465   };
466
467   /**
468    * @struct AliHLTComponentEventDoneData
469    * 
470    */
471   struct AliHLTComponentEventDoneData
472   {
473     AliHLTUInt32_t fStructSize;
474     AliHLTUInt32_t fDataSize;
475     void* fData;
476   };
477
478   /**
479    * @struct AliHLTRunDesc
480    * Event descriptor.
481    * The struct is sent with the SOR and EOR events.
482    *
483    * @note
484    * The name of the member fRunType is a bit misleading. This is not
485    * the ALICE Run Type given by the ECS to the sub-system. The member
486    * is an internal HLT run type and a combination of the HLT running
487    * mode and the beam type.
488    * <pre>
489    * Bit 0-2:   beam type identifier
490    * Bit 3-31:  HLT mode
491    * </pre>
492    */
493   struct AliHLTRunDesc
494   {
495     AliHLTUInt32_t fStructSize;
496     AliHLTUInt32_t fRunNo;
497     AliHLTUInt32_t fRunType;
498   };
499
500   /**
501    * @struct AliHLTComponentStatistics
502    * Small block size summary added by the AliHLTComponent base class
503    * if component statistics are enabled (--enable-compstat).
504    *
505    * fLevel is retrieved from incoming block statistics and incremented. 
506    * Incoming block statistics are appended to the newly added one if
507    * --enable-compstat=full has been chosen.
508    */
509   struct AliHLTComponentStatistics
510   {
511     AliHLTUInt32_t fStructSize;
512     AliHLTUInt32_t fLevel;
513     AliHLTUInt32_t fId;
514     AliHLTUInt32_t fTime;
515     AliHLTUInt32_t fCTime;
516     AliHLTUInt32_t fInputBlockCount;
517     AliHLTUInt32_t fTotalInputSize;
518     AliHLTUInt32_t fOutputBlockCount;
519     AliHLTUInt32_t fTotalOutputSize;
520   };
521
522   /**
523    * @struct AliHLTComponentTableEntry
524    * Structure to be send on SOR event through the chain. Each component
525    * adds its chain id and component arguments to the list.
526    * The 'length' of the structure is variable and depends on the length
527    * of the strings in the buffer at the end.
528    */
529   struct AliHLTComponentTableEntry
530   {
531     AliHLTUInt32_t fStructSize;
532     /** the 32bit Id is generated by a CRC algorithm from the
533         chain Id of the component. This is not a 100% unique id
534         but with a high probability */
535     AliHLTUInt32_t fId;
536     /** size of the chain id string in the appended buffer */
537     AliHLTUInt8_t  fSizeChainId;
538     /** size of the comp argument string in the appended buffer */
539     AliHLTUInt8_t  fSizeCompArgs;
540     /** some reserved size */
541     AliHLTUInt8_t  fSizeReserved;
542     /** the strings: chain id, component args, reserved */
543     AliHLTUInt8_t  fBuffer[1];
544   };
545
546   //////////////////////////////////////////////////////////////////////////
547   //
548   // Trigger meta information
549   //
550   //////////////////////////////////////////////////////////////////////////
551
552   /** field size of fAttribute */
553   const int gkAliHLTBlockDAttributeCount = 8;
554
555   /** field size of fCommonHeader */
556   const int gkAliHLTCommonHeaderCount = 8;
557
558   /** size of the DDL list */
559   const int gkAliHLTDDLListSize = 30;
560
561   /** Number of Trigger Classes of CTP in CDH */
562   const int gkNCTPTriggerClasses = 50;
563
564   /**
565    * @struct AliHLTEventDDL
566    * DDL list event.
567    * The struct is send with the DDLLIST event.
568    * Used in the trigger structure for internal apperance of 
569    * the DLLs as well as for the HLT readout list send to DAQ 
570    * ( as DataType : kAliHLTDataTypeDDL )
571    */
572   struct AliHLTEventDDL
573   {
574     AliHLTUInt32_t fCount;
575     AliHLTUInt32_t fList[gkAliHLTDDLListSize];
576   };
577
578   /**
579    * @struct AliHLTEventTriggerData
580    */
581   struct AliHLTEventTriggerData
582   {
583     AliHLTUInt8_t  fAttributes[gkAliHLTBlockDAttributeCount]; 
584     AliHLTUInt64_t fHLTStatus; // Bit field 
585     AliHLTUInt32_t fCommonHeaderWordCnt;
586     AliHLTUInt32_t fCommonHeader[gkAliHLTCommonHeaderCount]; 
587     AliHLTEventDDL fReadoutList;
588   };
589
590   /**
591    * @struct AliHLTComponentTriggerData
592    * Trigger data
593    */
594   struct AliHLTComponentTriggerData
595   {
596     AliHLTUInt32_t fStructSize;
597     AliHLTUInt32_t fDataSize;
598     void* fData;
599   };
600
601   //////////////////////////////////////////////////////////////////////////
602   //
603   // HLT Event Type Specification
604   //
605   //////////////////////////////////////////////////////////////////////////
606
607   /** Unknown eventType specification */
608   const AliHLTUInt32_t gkAliEventTypeUnknown = ~(AliHLTUInt32_t)0;
609   /** SOR eventType specification */ 
610   const AliHLTUInt32_t gkAliEventTypeStartOfRun=1;
611   /** Data eventType specification */
612   const AliHLTUInt32_t gkAliEventTypeData=2;
613   /** EOR eventType specification */ 
614   const AliHLTUInt32_t gkAliEventTypeEndOfRun=4;
615   /** Corrupt eventType specification */
616   const AliHLTUInt32_t gkAliEventTypeCorruptID=8;
617   /** Calibration eventType specification */ 
618   const AliHLTUInt32_t gkAliEventTypeCalibration=16;
619   /** DataReplay eventType specification */
620   const AliHLTUInt32_t gkAliEventTypeDataReplay=32;
621   /** Configuration eventType specification */
622   const AliHLTUInt32_t gkAliEventTypeConfiguration=34;
623   /** Update DCS eventType specification */
624   const AliHLTUInt32_t gkAliEventTypeReadPreprocessor=35;
625   /** Tick eventType specification */ 
626   const AliHLTUInt32_t gkAliEventTypeTick=64;
627   /** Max eventType specification */ 
628   const AliHLTUInt32_t gkAliEventTypeMax=64;
629
630   //////////////////////////////////////////////////////////////////////////
631   //
632   // HLT defines and defaults
633   //
634   //////////////////////////////////////////////////////////////////////////
635
636   /** invalid event id 
637    * @ingroup alihlt_component_datatypes
638    */
639   const AliHLTEventID_t kAliHLTVoidEventID=~(AliHLTEventID_t)0;
640
641   /** invalid data specification 
642    * @ingroup alihlt_component_datatypes
643    */
644   const AliHLTUInt32_t kAliHLTVoidDataSpec = ~(AliHLTUInt32_t)0;
645
646   /** invalid run no
647    * @ingroup alihlt_component_datatypes
648    */
649   const AliHLTUInt32_t kAliHLTVoidRunNo = ~(AliHLTUInt32_t)0;
650
651   /** invalid run type
652    * @ingroup alihlt_component_datatypes
653    */
654   const AliHLTUInt32_t kAliHLTVoidRunType = ~(AliHLTUInt32_t)0;
655
656   /** invalid run descriptor
657    * @ingroup alihlt_component_datatypes
658    */
659   const AliHLTRunDesc kAliHLTVoidRunDesc={sizeof(AliHLTRunDesc), kAliHLTVoidRunNo, kAliHLTVoidRunType};
660
661   /** invalid shared memory type */
662   const AliHLTUInt32_t gkAliHLTComponentInvalidShmType = 0;
663
664   /** invalid shared memory id */
665   const AliHLTUInt64_t gkAliHLTComponentInvalidShmID = ~(AliHLTUInt64_t)0;
666
667   /** invalid data type 
668    * @ingroup alihlt_component_datatypes
669    */
670   const AliHLTComponentDataType kAliHLTVoidDataType = {
671     sizeof(AliHLTComponentDataType),
672     kAliHLTVoidDataTypeID,
673     kAliHLTDataOriginVoid
674   };
675
676   /** all data types, means any + void data type
677    * @ingroup alihlt_component_datatypes
678    */
679   const AliHLTComponentDataType kAliHLTAllDataTypes = {
680     sizeof(AliHLTComponentDataType),
681     kAliHLTAllDataTypesID,
682     kAliHLTDataOriginAny
683   };
684
685   // there is currently a problem with rootcint if the predefined ids
686   // (commented below) are used. rootcint does not find the id if they
687   // are char arrays defined with {} and individual chars. If strings
688   // are used it works fine
689   /** any data type 
690    * @ingroup alihlt_component_datatypes
691    */
692   const AliHLTComponentDataType kAliHLTAnyDataType = {
693     sizeof(AliHLTComponentDataType),
694     kAliHLTAnyDataTypeID,
695     kAliHLTDataOriginAny
696   };
697
698   /** multiple output data types 
699    * @ingroup alihlt_component_datatypes
700    */
701   extern const AliHLTComponentDataType kAliHLTMultipleDataType;
702
703   /** data to file exchange subscriber 
704    * @ingroup alihlt_component_datatypes
705    */
706   extern const AliHLTComponentDataType kAliHLTDataTypeFXSCalib;
707
708   /** DDL list data type 
709    * @ingroup alihlt_component_datatypes
710    */
711   extern const AliHLTComponentDataType kAliHLTDataTypeDDL;
712
713   /** SOR data type 
714    * @ingroup alihlt_component_datatypes
715    */
716   extern const AliHLTComponentDataType kAliHLTDataTypeSOR;
717
718   /** EOR data type 
719    * @ingroup alihlt_component_datatypes
720    */
721   extern const AliHLTComponentDataType kAliHLTDataTypeEOR;
722
723   /** Run type data block 
724    * @ingroup alihlt_component_datatypes
725    */
726   extern const AliHLTComponentDataType kAliHLTDataTypeRunType;
727
728   /** Event type specification 
729    * @ingroup alihlt_component_datatypes
730    */
731   extern const AliHLTComponentDataType kAliHLTDataTypeEvent;
732
733   /** Configuration event data type 
734    * @ingroup alihlt_component_datatypes
735    */
736   extern const AliHLTComponentDataType kAliHLTDataTypeComConf;
737
738   /** DCS value update event 
739    * @ingroup alihlt_component_datatypes
740    */
741   extern const AliHLTComponentDataType kAliHLTDataTypeUpdtDCS;
742
743   /** RAW DDL data specification, origin is 'any', data publisher origin correctly 
744    * @ingroup alihlt_component_datatypes
745    */
746   extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw;
747
748   /** ESD object data specification, origin is 'any' 
749    * @ingroup alihlt_component_datatypes
750    */
751   extern const AliHLTComponentDataType kAliHLTDataTypeESDObject;
752
753   /** ESD Tree data specification, origin is 'any' 
754    
755   * @ingroup alihlt_component_datatypes
756   */
757   extern const AliHLTComponentDataType kAliHLTDataTypeESDTree;
758
759   /** AliRoot TreeD data specification, origin is 'any' 
760    * @ingroup alihlt_component_datatypes
761    */
762   extern const AliHLTComponentDataType kAliHLTDataTypeAliTreeD;
763
764   /** AliRoot TreeR data specification, origin is 'any' 
765    * @ingroup alihlt_component_datatypes
766    */
767   extern const AliHLTComponentDataType kAliHLTDataTypeAliTreeR;
768
769   /** 16 bit Hardware address selection data specification, origin is 'any' 
770    * @ingroup alihlt_component_datatypes
771    */
772   extern const AliHLTComponentDataType kAliHLTDataTypeHwAddr16;
773
774   /** Event statistics 
775    * @ingroup alihlt_component_datatypes
776    */
777   extern const AliHLTComponentDataType kAliHLTDataTypeEventStatistics;
778
779   /** Event summary 
780    * @ingroup alihlt_component_datatypes
781    */
782   extern const AliHLTComponentDataType kAliHLTDataTypeEventSummary;
783
784   /** Event statistics 
785    * @ingroup alihlt_component_datatypes
786    */
787   extern const AliHLTComponentDataType kAliHLTDataTypeRunStatistics;
788
789   /** Event summary 
790    * @ingroup alihlt_component_datatypes
791    */
792   extern const AliHLTComponentDataType kAliHLTDataTypeRunSummary;
793
794   /** Component block statistics
795    * @ingroup alihlt_component_datatypes
796    */
797   extern const AliHLTComponentDataType kAliHLTDataTypeComponentStatistics;
798
799   /** Component table
800    * To be sent on SOR event, each component adds it's chain id string
801    * and a generated 32bit identifier to the table
802    * @ingroup alihlt_component_datatypes
803    */
804   extern const AliHLTComponentDataType kAliHLTDataTypeComponentTable;
805
806   //////////////////////////////////////////////////////////////////////////
807   //
808   // Data Types for Monitoring objects
809   //
810   //////////////////////////////////////////////////////////////////////////
811
812   /** general ROOT TObject 
813    * @ingroup alihlt_component_datatypes
814    */
815   extern const AliHLTComponentDataType kAliHLTDataTypeTObject;            // {ROOTTOBJ,"***"}
816                                                                                         
817   /** ROOT TObjArray 
818    * @ingroup alihlt_component_datatypes
819    */                                                                   
820   extern const AliHLTComponentDataType kAliHLTDataTypeTObjArray;          // {ROOTOBAR,"***"}
821                                                                                         
822   /** ROOT TTree 
823    * @ingroup alihlt_component_datatypes
824    */                                                                   
825   extern const AliHLTComponentDataType kAliHLTDataTypeTTree;              // {ROOTTREE,"***"}
826                                                                                         
827   /** ROOT TH1 (can be used for all histograms, they derive from TH1) 
828    * @ingroup alihlt_component_datatypes
829    */           
830   extern const AliHLTComponentDataType kAliHLTDataTypeHistogram;          // {ROOTHIST,"***"}
831                                                                                         
832   /** ROOT TNtuple 
833    * @ingroup alihlt_component_datatypes
834    */                                                                   
835   extern const AliHLTComponentDataType kAliHLTDataTypeTNtuple;            // {ROOTTUPL,"***"}
836
837   //////////////////////////////////////////////////////////////////////////
838   //
839   // FXS subscriber meta information
840   //
841   //////////////////////////////////////////////////////////////////////////
842
843   const int gkAliHLTFXSHeaderfOriginSize = 4;
844   const int gkAliHLTFXSHeaderfFileIDSize = 128;
845   const int gkAliHLTFXSHeaderfDDLNumberSize = 64;
846
847   /** Header in front of the data payload, in order to sent data to the FXS. */
848   struct AliHLTFXSHeader
849   {
850     AliHLTUInt32_t fHeaderVersion;
851     AliHLTUInt32_t fRunNumber;
852     char fOrigin[gkAliHLTFXSHeaderfOriginSize];
853     char fFileID[gkAliHLTFXSHeaderfFileIDSize];
854     char fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize];
855   };  
856
857   //////////////////////////////////////////////////////////////////////////
858   //
859   // Component running environment
860   //
861   //////////////////////////////////////////////////////////////////////////
862
863   /** logging function */
864   typedef int (*AliHLTfctLogging)( void* param, 
865                                    AliHLTComponentLogSeverity severity,
866                                    const char* origin,
867                                    const char* keyword,
868                                    const char* message);
869
870   /**
871    * @struct AliHLTAnalysisEnvironment
872    * Running environment for analysis components.
873    * The struct describes function callbacks for actions to be
874    * carried out by the calling framework, like memory allocation,
875    * property callbecks, logging, etc.
876    *
877    * @ingroup alihlt_wrapper_interface
878    */
879   struct AliHLTAnalysisEnvironment
880   {
881     /** size of the structure */
882     AliHLTUInt32_t fStructSize;
883
884     /** the component parameter given by the framework on creation
885      */
886     void* fParam;
887
888     /** allocated memory
889      */
890     void* (*fAllocMemoryFunc)( void* param, unsigned long size );
891
892     /** allocate an EventDoneData structure.
893      */
894     int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd );
895
896     /** logging callback
897      */
898     AliHLTfctLogging fLoggingFunc;
899   };
900 #if 0
901   // I just keep this as a note pad. Has to be added to the end of the structure
902   // future addition already foreseen/envisioned
903   // IMPORTANT: don not just remove the defines as this breaks the binary
904   // compatibility
905   int (*fAllocShmMemoryFunc)( void* param, unsigned long size, AliHLTComponentBlockData* blockLocation );
906 #endif
907
908   /**
909    * @struct AliHLTComponentEnvironment
910    * This was the original definition of the running environment.
911    * Due to a bug in the AliRootWrapperSubscriber/SimpleComponentWrapper,
912    * this structure can not be used any longer but is kept for backward
913    * compatibility. 
914    * @note The external interface provided by the libHLTbase is now kept
915    * frozen but should not be used any more. Use the interface provided
916    * by the libHLTinterface library.
917    *
918    * @ingroup alihlt_wrapper_interface_deprecated
919    */
920   struct AliHLTComponentEnvironment
921   {
922     AliHLTUInt32_t fStructSize;
923     void* fParam;
924     void* (*fAllocMemoryFunc)( void* param, unsigned long size );
925     int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponentEventDoneData** edd );
926     AliHLTfctLogging fLoggingFunc;
927   };
928
929   //////////////////////////////////////////////////////////////////////////
930   //
931   // The external interface definition
932   //
933   //////////////////////////////////////////////////////////////////////////
934
935   /**
936    * The component handle.
937    * Used as indification in the outside world.
938    * @ingroup alihlt_wrapper_interface
939    */
940   typedef void* AliHLTComponentHandle;
941
942   /** @ingroup alihlt_wrapper_interface */
943   const AliHLTComponentHandle kEmptyHLTComponentHandle = 0;
944
945   /**
946    * Get a system call of the interface.
947    * @param function signature
948    * @return pointer to system call
949    * @ingroup alihlt_wrapper_interface
950    */
951   typedef void* (*AliHLTAnalysisFctGetInterfaceCall)(const char*);
952
953 # define ALIHLTANALYSIS_INTERFACE_LIBRARY  "libHLTinterface.so"
954 # define ALIHLTANALYSIS_FCT_GETINTERFACECALL  "AliHLTAnalysisGetInterfaceCall"
955
956   /** @ingroup alihlt_wrapper_interface */
957   typedef int (*AliHLTExtFctInitSystem)( unsigned long version, AliHLTAnalysisEnvironment* externalEnv, unsigned long runNo, const char* runType );
958
959   /** @ingroup alihlt_wrapper_interface */
960   typedef int (*AliHLTExtFctDeinitSystem)();
961
962   /** @ingroup alihlt_wrapper_interface */
963   typedef int (*AliHLTExtFctLoadLibrary)( const char* );
964
965   /** @ingroup alihlt_wrapper_interface */
966   typedef int (*AliHLTExtFctUnloadLibrary)( const char* );
967
968   /** @ingroup alihlt_wrapper_interface */
969   typedef int (*AliHLTExtFctCreateComponent)( const char*, void*, int, const char**, AliHLTComponentHandle*, const char* description );
970
971   /** @ingroup alihlt_wrapper_interface */
972   typedef int (*AliHLTExtFctDestroyComponent)( AliHLTComponentHandle );
973
974   /** @ingroup alihlt_wrapper_interface */
975   typedef int (*AliHLTExtFctProcessEvent)( AliHLTComponentHandle, const AliHLTComponentEventData*, const AliHLTComponentBlockData*, 
976                                            AliHLTComponentTriggerData*, AliHLTUInt8_t*,
977                                            AliHLTUInt32_t*, AliHLTUInt32_t*, 
978                                            AliHLTComponentBlockData**,
979                                            AliHLTComponentEventDoneData** );
980
981   /** @ingroup alihlt_wrapper_interface */
982   typedef int (*AliHLTExtFctGetOutputDataType)( AliHLTComponentHandle, AliHLTComponentDataType* );
983
984   /** @ingroup alihlt_wrapper_interface */
985   typedef int (*AliHLTExtFctGetOutputSize)( AliHLTComponentHandle, unsigned long*, double* );
986
987 }
988
989 //////////////////////////////////////////////////////////////////////////
990 //
991 // Data type helper functions
992 //
993 //////////////////////////////////////////////////////////////////////////
994
995 /** exact comparison of HLT component data types
996  * @ingroup alihlt_component_datatypes
997  */
998 inline bool MatchExactly( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
999 {
1000   for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ )
1001     if ( dt1.fID[i] != dt2.fID[i] )
1002       return false;
1003   for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
1004     if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
1005       return false;
1006   return true;
1007 }
1008
1009 /** Comparison operator for HLT component data types.
1010  * The operator takes wildcards into account, i.e. the ::kAliHLTAnyDataType,
1011  * ::kAliHLTAnyDataTypeID and ::kAliHLTDataOriginAny definitions.
1012  * @ingroup alihlt_component_datatypes
1013  */
1014 inline bool operator==( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
1015 {
1016   if (MatchExactly(dt1, kAliHLTAllDataTypes)) return true;
1017   if (MatchExactly(dt2, kAliHLTAllDataTypes)) return true;
1018
1019   bool any1=true, any2=true, void1=true, void2=true, match=true;
1020   for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) {
1021     any1&=(dt1.fOrigin[i]==kAliHLTDataOriginAny[i]);
1022     any2&=(dt2.fOrigin[i]==kAliHLTDataOriginAny[i]);
1023     void1&=(dt1.fOrigin[i]==kAliHLTDataOriginVoid[i]);
1024     void2&=(dt2.fOrigin[i]==kAliHLTDataOriginVoid[i]);
1025     match&=dt1.fOrigin[i]==dt2.fOrigin[i];
1026     if (!(match || (any2 && !void1) || (any1 && !void2)))
1027       return false;
1028   }
1029
1030   any1=true, any2=true, match=true;
1031   for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) {
1032     any1&=(dt1.fID[i]==kAliHLTAnyDataTypeID[i]);
1033     any2&=(dt2.fID[i]==kAliHLTAnyDataTypeID[i]);
1034     void1&=(dt1.fID[i]==kAliHLTVoidDataTypeID[i]);
1035     void2&=(dt2.fID[i]==kAliHLTVoidDataTypeID[i]);
1036     match&=dt1.fID[i]==dt2.fID[i];
1037     if (!(match || (any2 && !void1) || (any1 && !void2)))
1038       return false;
1039   }
1040   return true;
1041 }
1042
1043 /** Comparison operator for HLT component data types
1044  * Invers of operator==
1045  * @ingroup alihlt_component_datatypes
1046  */
1047 inline bool operator!=( const AliHLTComponentDataType& dt1, const AliHLTComponentDataType& dt2 )
1048 {
1049   return !(dt1==dt2);
1050 }
1051
1052 /** merge operator for HLT component data types and origins
1053  * @ingroup alihlt_component_datatypes
1054  */
1055 inline AliHLTComponentDataType operator|(const AliHLTComponentDataType srcdt, const char origin[kAliHLTComponentDataTypefOriginSize])
1056 {
1057   AliHLTComponentDataType dt=srcdt;
1058   for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ )
1059     dt.fOrigin[i]=origin[i];
1060   return dt;
1061 }
1062
1063 #endif