4 #ifndef ALIHLTCOMPONENT_H
5 #define ALIHLTCOMPONENT_H
6 /* This file is property of and copyright by the ALICE HLT Project *
7 * ALICE Experiment at CERN, All rights reserved. *
8 * See cxx source for full Copyright notice */
10 /** @file AliHLTComponent.h
11 @author Matthias Richter, Timm Steinbeck
13 @brief Base class declaration for HLT components.
14 @note The class is both used in Online (PubSub) and Offline (AliRoot)
17 // see below for class documentation
19 // refer to README to build package
21 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
24 * @defgroup alihlt_component Component handling of the HLT module
25 * This section describes the the component handling for the HLT module.
30 #include "AliHLTLogging.h"
31 #include "AliHLTDataTypes.h"
32 //#include "AliHLTDefinitions.h"
35 * The names have been changed for Aliroot's coding conventions sake
36 * The old names are defined for backward compatibility with the
37 * stand alone SampleLib package
39 typedef AliHLTComponentLogSeverity AliHLTComponent_LogSeverity;
40 typedef AliHLTComponentEventData AliHLTComponent_EventData;
41 typedef AliHLTComponentShmData AliHLTComponent_ShmData;
42 typedef AliHLTComponentDataType AliHLTComponent_DataType;
43 typedef AliHLTComponentBlockData AliHLTComponent_BlockData;
44 typedef AliHLTComponentTriggerData AliHLTComponent_TriggerData;
45 typedef AliHLTComponentEventDoneData AliHLTComponent_EventDoneData;
47 class AliHLTComponentHandler;
50 class AliHLTMemoryFile;
53 * @class AliHLTComponent
54 * Base class of HLT data processing components.
55 * The class provides a common interface for HLT data processing components.
56 * The interface can be accessed from the online HLT framework or the AliRoot
57 * offline analysis framework.
58 * @section alihltcomponent-properties Component identification and properties
59 * Each component must provide a unique ID, input and output data type indications,
60 * and a spawn function.
61 * @subsection alihltcomponent-req-methods Required property methods
62 * - @ref GetComponentID
63 * - @ref GetInputDataTypes (see @ref alihltcomponent-type for default
65 * - @ref GetOutputDataType (see @ref alihltcomponent-type for default
67 * - @ref GetOutputDataSize (see @ref alihltcomponent-type for default
71 * @subsection alihltcomponent-opt-mehods Optional handlers
75 * @subsection alihltcomponent-processing-mehods Data processing
78 * @subsection alihltcomponent-type Component type
79 * Components can be of type
80 * - @ref kSource components which only produce data
81 * - @ref kProcessor components which consume and produce data
82 * - @ref kSink components which only consume data
84 * where data production and consumption refer to the analysis data stream. In
85 * order to indicate the type, a child component can overload the
86 * @ref GetComponentType function.
87 * @subsubsection alihltcomponent-type-std Standard implementations
88 * Components in general do not need to implement this function, standard
89 * implementations of the 3 types are available:
90 * - AliHLTDataSource for components of type @ref kSource <br>
91 * All types of data sources can inherit from AliHLTDataSource and must
92 * implement the @ref AliHLTDataSource::GetEvent method. The class
93 * also implements a standard method for @ref GetInputDataTypes.
95 * - AliHLTProcessor for components of type @ref kProcessor <br>
96 * All types of data processors can inherit from AliHLTDataSource and must
97 * implement the @ref AliHLTProcessor::DoEvent method.
99 * - AliHLTDataSink for components of type @ref kSink <br>
100 * All types of data processors can inherit from AliHLTDataSource and must
101 * implement the @ref AliHLTDataSink::DumpEvent method. The class
102 * also implements a standard method for @ref GetOutputDataType and @ref
105 * @subsection alihltcomponent-environment Running environment
107 * In order to adapt to different environments (on-line/off-line), the component
108 * gets an environment structure with function pointers. The base class provides
109 * member functions for those environment dependend functions. The member
110 * functions are used by the component implementation and are re-mapped to the
111 * corresponding functions.
113 * @section alihltcomponent-interfaces Component interfaces
114 * Each of the 3 standard component base classes AliHLTProcessor, AliHLTDataSource
115 * and AliHLTDataSink provides it's own processing method (see
116 * @ref alihltcomponent-type-std), which splits into a high and a low-level
117 * method. For the @ref alihltcomponent-low-level-interface, all parameters are
118 * shipped as function arguments, the component is supposed to dump data to the
119 * output buffer and handle all block descriptors.
120 * The @ref alihltcomponent-high-level-interface is the standard processing
121 * method and will be used whenever the low-level method is not overloaded.
123 * In both cases it is necessary to calculate/estimate the size of the output
124 * buffer before the processing. Output buffers can never be allocated inside
125 * the component because of the push-architecture of the HLT.
126 * For that reason the @ref GetOutputDataSize function should return a rough
127 * estimatian of the data to be produced by the component. The component is
128 * responsible for checking the memory size and must return -ENOSPC if the
129 * available buffer is to small, and update the estimator respectively. The
130 * framework will allocate a buffer of appropriate size and call the processing
133 * @subsection alihltcomponent-high-level-interface High-level interface
134 * The high-level component interface provides functionality to exchange ROOT
135 * structures between components. In contrast to the
136 * @ref alihltcomponent-low-level-interface, a couple of functions can be used
137 * to access data blocks of the input stream
138 * and send data blocks or ROOT TObject's to the output stream. The functionality
139 * is hidden from the user and is implemented by using ROOT's TMessage class.
141 * @subsubsection alihltcomponent-high-level-int-methods Interface methods
142 * The interface provides a couple of methods in order to get objects from the
143 * input, data blocks (non TObject) from the input, and to push back objects and
144 * data blocks to the output. For convenience there are several functions of
145 * identical name (and similar behavior) with different parameters defined.
146 * Please refer to the function documentation.
147 * - @ref GetNumberOfInputBlocks <br>
148 * return the number of data blocks in the input stream
149 * - @ref GetFirstInputObject <br>
150 * get the first object of a specific data type
151 * - @ref GetNextInputObject <br>
152 * get the next object of same data type as last GetFirstInputObject/Block call
153 * - @ref GetFirstInputBlock <br>
154 * get the first block of a specific data type
155 * - @ref GetNextInputBlock <br>
156 * get the next block of same data type as last GetFirstInputBlock/Block call
157 * - @ref PushBack <br>
158 * insert an object or data buffer into the output
159 * - @ref CreateEventDoneData <br>
160 * add event information to the output
162 * In addition, the processing methods are simplified a bit by cutting out most of
165 * - @ref AliHLTProcessor::DoEvent
166 * - @ref AliHLTDataSource::GetEvent
167 * - @ref AliHLTDataSink::DumpEvent
169 * \em IMPORTANT: objects and block descriptors provided by the high-level interface
170 * <b>MUST NOT BE DELETED</b> by the caller.
172 * @subsubsection alihltcomponent-high-level-int-guidelines High-level interface guidelines
173 * - Structures must inherit from the ROOT object base class TObject in order be
174 * transported by the transportation framework.
175 * - all pointer members must be transient (marked <tt>//!</tt> behind the member
176 * definition), i.e. will not be stored/transported, or properly marked
177 * (<tt>//-></tt>) in order to call the streamer of the object the member is pointing
178 * to. The latter is not recomended. Structures to be transported between components
179 * should be streamlined.
180 * - no use of stl vectors/strings, use appropriate ROOT classes instead
182 * @subsection alihltcomponent-low-level-interface Low-level interface
183 * The low-level component interface consists of the specific data processing
184 * methods for @ref AliHLTProcessor, @ref AliHLTDataSource, and @ref AliHLTDataSink.
185 * - @ref AliHLTProcessor::DoEvent
186 * - @ref AliHLTDataSource::GetEvent
187 * - @ref AliHLTDataSink::DumpEvent
190 * @section alihltcomponent-handling Component handling
191 * The handling of HLT analysis components is carried out by the AliHLTComponentHandler.
192 * Component are registered automatically at load-time of the component shared library
193 * under the following suppositions:
194 * - the component library has to be loaded from the AliHLTComponentHandler using the
195 * @ref AliHLTComponentHandler::LoadLibrary method.
196 * - the component implementation defines one global object (which is generated
197 * when the library is loaded)
199 * @subsection alihltcomponent-design-rules General design considerations
200 * The analysis code should be implemented in one or more destict class(es). A
201 * \em component should be implemented which interface the destict analysis code to the
202 * component interface. This component generates the analysis object dynamically. <br>
204 * Assume you have an implemetation <tt> AliHLTDetMyAnalysis </tt>, another class <tt>
205 * AliHLTDetMyAnalysisComponent </tt> contains:
208 * AliHLTDetMyAnalysis* fMyAnalysis; //!
210 * The object should then be instantiated in the DoInit handler of
211 * <tt>AliHLTDetMyAnalysisComponent </tt>, and cleaned in the DoDeinit handler.
214 * - avoid big static arrays in the component, allocate the memory at runtime
216 * @ingroup alihlt_component
217 * @section alihltcomponent-members Class members
219 class AliHLTComponent : public AliHLTLogging {
221 /** standard constructor */
223 /** standard destructor */
224 virtual ~AliHLTComponent();
226 /** component type definitions */
227 enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 };
230 * Init function to prepare data processing.
231 * Initialization of common data structures for a sequence of events.
232 * The call is redirected to the internal method @ref DoInit which can be
233 * overridden by the child class.<br>
234 * During Init also the environment structure is passed to the component.
235 * @param environ environment pointer with environment dependend function
237 * @param environParam additionel parameter for function calls, the pointer
239 * @param argc size of the argument array
240 * @param argv agument array for component initialization
242 virtual int Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv );
245 * Clean-up function to terminate data processing.
246 * Clean-up of common data structures after data processing.
247 * The call is redirected to the internal method @ref DoDeinit which can be
248 * overridden by the child class.
250 virtual int Deinit();
253 * Processing of one event.
254 * The method is the entrance of the event processing. The parameters are
255 * cached for uses with the high-level interface and the DoProcessing
256 * implementation is called.
263 * @param outputBlockCnt out: size of the output block array, set by the component
264 * @param outputBlocks out: the output block array is allocated internally
266 * @return neg. error code if failed
268 int ProcessEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
269 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
270 AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt,
271 AliHLTComponentBlockData*& outputBlocks,
272 AliHLTComponentEventDoneData*& edd );
275 * Internal processing of one event.
276 * The method is pure virtual and implemented by the child classes
277 * - @ref AliHLTProcessor
278 * - @ref AliHLTDataSource
279 * - @ref AliHLTDataSink
286 * @param outputBlocks out: the output block array is allocated internally
288 * @return neg. error code if failed
290 virtual int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
291 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
292 AliHLTUInt32_t& size,
293 vector<AliHLTComponentBlockData>& outputBlocks,
294 AliHLTComponentEventDoneData*& edd ) = 0;
296 // Information member functions for registration.
299 * Get the type of the component.
300 * The function is pure virtual and must be implemented by the child class.
301 * @return component type id
303 virtual TComponentType GetComponentType() = 0; // Source, sink, or processor
306 * Get the id of the component.
307 * Each component is identified by a unique id.
308 * The function is pure virtual and must be implemented by the child class.
309 * @return component id (string)
311 virtual const char* GetComponentID() = 0;
314 * Get the input data types of the component.
315 * The function is pure virtual and must be implemented by the child class.
316 * @return list of data types in the vector reference
318 virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& ) = 0;
321 * Get the output data type of the component.
322 * The function is pure virtual and must be implemented by the child class.
323 * @return output data type
325 virtual AliHLTComponentDataType GetOutputDataType() = 0;
328 * Get a ratio by how much the data volume is shrinked or enhanced.
329 * The function is pure virtual and must be implemented by the child class.
330 * @param constBase <i>return</i>: additive part, independent of the
332 * @param inputMultiplier <i>return</i>: multiplication ratio
333 * @return values in the reference variables
335 virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0;
339 * Each component must implement a spawn function to create a new instance of
340 * the class. Basically the function must return <i>new <b>my_class_name</b></i>.
341 * @return new class instance
343 virtual AliHLTComponent* Spawn() = 0;
346 * Find matching data types between this component and a consumer component.
347 * Currently, a component can produce only one type of data. This restriction is most
348 * likely to be abolished in the future.
349 * @param pConsumer a component and consumer of the data produced by this component
350 * @param tgtList reference to a vector list to receive the matching data types.
351 * @return >= 0 success, neg. error code if failed
353 int FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponentDataType>* tgtList);
356 * Set the global component handler.
357 * The static method is needed for the automatic registration of components.
359 static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0);
362 * Clear the global component handler.
363 * The static method is needed for the automatic registration of components.
365 static int UnsetGlobalComponentHandler();
368 * Helper function to convert the data type to a string.
370 static string DataType2Text( const AliHLTComponentDataType& type );
373 * Helper function to print content of data type.
375 void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL) const;
378 * helper function to initialize AliHLTComponentEventData structure
380 static void FillEventData(AliHLTComponentEventData& evtData);
383 * Print info on an AliHLTComponentDataType structure
384 * This is just a helper function to examine an @ref AliHLTComponentDataType
387 void PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt);
390 * Stopwatch type for benchmarking.
392 enum AliHLTStopwatchType {
393 /** total time for event processing */
395 /** detector algorithm w/o interface callbacks */
401 /** number of types */
406 * Helper class for starting and stopping a stopwatch.
407 * The guard can be used by instantiating an object in a function. The
408 * specified stopwatch is started and the previous stopwatch put on
409 * hold. When the function is terminated, the object is deleted automatically
410 * deleted, stopping the stopwatch and starting the one on hold.<br>
411 * \em IMPORTANT: never create dynamic objects from this guard as this violates
412 * the idea of a guard.
414 class AliHLTStopwatchGuard {
416 /** standard constructor (not for use) */
417 AliHLTStopwatchGuard();
419 AliHLTStopwatchGuard(TStopwatch* pStart);
420 /** copy constructor (not for use) */
421 AliHLTStopwatchGuard(const AliHLTStopwatchGuard&);
422 /** assignment operator (not for use) */
423 AliHLTStopwatchGuard& operator=(const AliHLTStopwatchGuard&);
425 ~AliHLTStopwatchGuard();
429 * Hold the previous guard for the existence of this guard.
430 * Checks whether this guard controls a new stopwatch. In that case, the
431 * previous guard and its stopwatch are put on hold.
432 * @param pSucc instance of the stopwatch of the new guard
433 * @return 1 if pSucc is a different stopwatch which should
435 * 0 if it controls the same stopwatch
437 int Hold(TStopwatch* pSucc);
440 * Resume the previous guard.
441 * Checks whether the peceeding guard controls a different stopwatch. In that
442 * case, the its stopwatch is resumed.
443 * @param pSucc instance of the stopwatch of the new guard
444 * @return 1 if pSucc is a different stopwatch which should
446 * 0 if it controls the same stopwatch
448 int Resume(TStopwatch* pSucc);
450 /** the stopwatch controlled by this guard */
451 TStopwatch* fpStopwatch; //!transient
453 /** previous stopwatch guard, put on hold during existence of the guard */
454 AliHLTStopwatchGuard* fpPrec; //!transient
456 /** active stopwatch guard */
457 static AliHLTStopwatchGuard* fgpCurrent; //!transient
461 * Set a stopwatch for a given purpose.
462 * @param pSW stopwatch object
463 * @param type type of the stopwatch
465 int SetStopwatch(TObject* pSW, AliHLTStopwatchType type=kSWBase);
468 * Init a set of stopwatches.
469 * @param pStopwatches object array of stopwatches
471 int SetStopwatches(TObjArray* pStopwatches);
476 * Fill AliHLTComponentBlockData structure with default values.
477 * @param blockData reference to data structure
479 void FillBlockData( AliHLTComponentBlockData& blockData ) const;
482 * Fill AliHLTComponentShmData structure with default values.
483 * @param shmData reference to data structure
485 void FillShmData( AliHLTComponentShmData& shmData ) const;
488 * Fill AliHLTComponentDataType structure with default values.
489 * @param dataType reference to data structure
491 void FillDataType( AliHLTComponentDataType& dataType ) const;
494 * Copy data type structure
495 * Copies the value an AliHLTComponentDataType structure to another one
496 * @param[out] tgtdt target structure
497 * @param[in] srcdt source structure
499 void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt);
502 * Set the ID and Origin of an AliHLTComponentDataType structure.
503 * The function sets the fStructureSize member and copies the strings
504 * to the ID and Origin. Only characters from the valid part of the string
505 * are copied, the rest is fille with 0's.
506 * Please note that the fID and fOrigin members are not strings, just arrays of
507 * chars of size @ref kAliHLTComponentDataTypefIDsize and
508 * @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with
509 * a terminating zero.
510 * @param tgtdt target data type structure
511 * @param id ID string
512 * @param origin Origin string
514 void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin);
517 * Default method for the internal initialization.
518 * The method is called by @ref Init
520 virtual int DoInit( int argc, const char** argv );
523 * Default method for the internal clean-up.
524 * The method is called by @ref Deinit
526 virtual int DoDeinit();
529 * General memory allocation method.
530 * All memory which is going to be used 'outside' of the interface must
531 * be provided by the framework (online or offline).
532 * The method is redirected to a function provided by the current
533 * framework. Function pointers are transferred via the @ref
534 * AliHLTComponentEnvironment structure.
536 void* AllocMemory( unsigned long size );
539 * Helper function to create a monolithic BlockData description block out
540 * of a list BlockData descriptors.
541 * For convenience, inside the interface vector lists are used, to make the
542 * interface pure C style, monilithic blocks must be exchanged.
543 * The method is redirected to a function provided by the current
544 * framework. Function pointers are transferred via the @ref
545 * AliHLTComponentEnvironment structure.
547 int MakeOutputDataBlockList( const vector<AliHLTComponentBlockData>& blocks, AliHLTUInt32_t* blockCount,
548 AliHLTComponentBlockData** outputBlocks );
551 * Fill the EventDoneData structure.
552 * The method is redirected to a function provided by the current
553 * framework. Function pointers are transferred via the @ref
554 * AliHLTComponentEnvironment structure.
556 int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd );
559 * Helper function to convert the data type to a string.
561 void DataType2Text(const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]) const;
565 * @return value of the internal event counter
567 int GetEventCount() const;
570 * Get the number of input blocks.
571 * @return number of input blocks
573 int GetNumberOfInputBlocks() const;
576 * Get the first object of a specific data type from the input data.
577 * The hight-level methods provide functionality to transfer ROOT data
578 * structures which inherit from TObject.
579 * The method looks for the first ROOT object of type dt in the input stream.
580 * If also the class name is provided, the object is checked for the right
581 * class type. The input data block needs a certain structure, namely the
582 * buffer size as first word. If the cross check fails, the retrieval is
583 * silently abondoned, unless the \em bForce parameter is set.<br>
584 * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
585 * @param dt data type of the object
586 * @param classname class name of the object
587 * @param bForce force the retrieval of an object, error messages
588 * are suppressed if \em bForce is not set
589 * @return pointer to @ref TObject, NULL if no objects of specified type
592 const TObject* GetFirstInputObject(const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
593 const char* classname=NULL,
597 * Get the first object of a specific data type from the input data.
598 * The hight-level methods provide functionality to transfer ROOT data
599 * structures which inherit from TObject.
600 * The method looks for the first ROOT object of type specified by the ID and
601 * Origin strings in the input stream.
602 * If also the class name is provided, the object is checked for the right
603 * class type. The input data block needs a certain structure, namely the
604 * buffer size as first word. If the cross check fails, the retrieval is
605 * silently abondoned, unless the \em bForce parameter is set.<br>
606 * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
607 * @param dtID data type ID of the object
608 * @param dtOrigin data type origin of the object
609 * @param classname class name of the object
610 * @param bForce force the retrieval of an object, error messages
611 * are suppressed if \em bForce is not set
612 * @return pointer to @ref TObject, NULL if no objects of specified type
615 const TObject* GetFirstInputObject(const char* dtID,
616 const char* dtOrigin,
617 const char* classname=NULL,
621 * Get the next object of a specific data type from the input data.
622 * The hight-level methods provide functionality to transfer ROOT data
623 * structures which inherit from TObject.
624 * The method looks for the next ROOT object of type and class specified
625 * to the previous @ref GetFirstInputObject call.<br>
626 * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
627 * @param bForce force the retrieval of an object, error messages
628 * are suppressed if \em bForce is not set
629 * @return pointer to @ref TObject, NULL if no more objects available
631 const TObject* GetNextInputObject(int bForce=0);
634 * Get data type of an input block.
635 * Get data type of the object previously fetched via
636 * GetFirstInputObject/NextInputObject or the last one if no object
638 * @param pObject pointer to TObject
639 * @return data specification, kAliHLTVoidDataSpec if failed
641 AliHLTComponentDataType GetDataType(const TObject* pObject=NULL);
644 * Get data specification of an input block.
645 * Get data specification of the object previously fetched via
646 * GetFirstInputObject/NextInputObject or the last one if no object
648 * @param pObject pointer to TObject
649 * @return data specification, kAliHLTVoidDataSpec if failed
651 AliHLTUInt32_t GetSpecification(const TObject* pObject=NULL);
654 * Get the first block of a specific data type from the input data.
655 * The method looks for the first block of type dt in the input stream. It is intended
656 * to be used within the high-level interface.<br>
657 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
658 * @param dt data type of the block
659 * @return pointer to @ref AliHLTComponentBlockData
661 const AliHLTComponentBlockData* GetFirstInputBlock(const AliHLTComponentDataType& dt=kAliHLTAnyDataType);
664 * Get the first block of a specific data type from the input data.
665 * The method looks for the first block of type specified by the ID and
666 * Origin strings in the input stream. It is intended
667 * to be used within the high-level interface.<br>
668 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
669 * @param dtID data type ID of the block
670 * @param dtOrigin data type origin of the block
671 * @return pointer to @ref AliHLTComponentBlockData
673 const AliHLTComponentBlockData* GetFirstInputBlock(const char* dtID,
674 const char* dtOrigin);
677 * Get input block by index.<br>
678 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
679 * @return pointer to AliHLTComponentBlockData, NULL if index out of range
681 const AliHLTComponentBlockData* GetInputBlock(int index);
684 * Get the next block of a specific data type from the input data.
685 * The method looks for the next block of type and class specified
686 * to the previous @ref GetFirstInputBlock call.
687 * To be used within the high-level interface.<br>
688 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
690 const AliHLTComponentBlockData* GetNextInputBlock();
693 * Get data specification of an input block.
694 * Get data specification of the input bblock previously fetched via
695 * GetFirstInputObject/NextInputObject or the last one if no block
697 * @param pBlock pointer to input block
698 * @return data specification, kAliHLTVoidDataSpec if failed
700 AliHLTUInt32_t GetSpecification(const AliHLTComponentBlockData* pBlock=NULL);
703 * Insert an object into the output.
704 * If header is specified, it will be inserted before the root object,
705 * default is no header.
706 * @param pObject pointer to root object
707 * @param dt data type of the object
708 * @param spec data specification
709 * @param pHeader pointer to header
710 * @param headerSize size of Header
711 * @return neg. error code if failed
713 int PushBack(TObject* pObject, const AliHLTComponentDataType& dt,
714 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
715 void* pHeader=NULL, int headerSize=0);
718 * Insert an object into the output.
719 * If header is specified, it will be inserted before the root object,
720 * default is no header.
721 * @param pObject pointer to root object
722 * @param dtID data type ID of the object
723 * @param dtOrigin data type origin of the object
724 * @param spec data specification
725 * @param pHeader pointer to header
726 * @param headerSize size of Header
727 * @return neg. error code if failed
729 int PushBack(TObject* pObject, const char* dtID, const char* dtOrigin,
730 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
731 void* pHeader=NULL, int headerSize=0);
734 * Insert an object into the output.
735 * @param pBuffer pointer to buffer
736 * @param iSize size of the buffer
737 * @param dt data type of the object
738 * @param spec data specification
739 * @return neg. error code if failed
741 int PushBack(void* pBuffer, int iSize, const AliHLTComponentDataType& dt,
742 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
745 * Insert an object into the output.
746 * @param pBuffer pointer to buffer
747 * @param iSize size of the buffer
748 * @param dtID data type ID of the object
749 * @param dtOrigin data type origin of the object
750 * @param spec data specification
751 * @return neg. error code if failed
753 int PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin,
754 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
757 * Estimate size of a TObject
759 * @return buffer size in byte
761 int EstimateObjectSize(TObject* pObject) const;
764 * Create a memory file in the output stream.
765 * This method creates a TFile object which stores all data in
766 * memory instead of disk. The TFile object is published as binary data.
767 * The instance can be used like a normal TFile object. The TFile::Close
768 * or @ref CloseMemoryFile method has to be called in order to flush the
771 * \b Note: The returned object is deleted by the framework.
772 * @param capacity total size reserved for the memory file
773 * @param dtID data type ID of the file
774 * @param dtOrigin data type origin of the file
775 * @param spec data specification
776 * @return file handle, NULL if failed
778 AliHLTMemoryFile* CreateMemoryFile(int capacity, const char* dtID, const char* dtOrigin,
779 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
782 * Create a memory file in the output stream.
783 * This method creates a TFile object which stores all data in
784 * memory instead of disk. The TFile object is published as binary data.
785 * The instance can be used like a normal TFile object. The TFile::Close
786 * or @ref CloseMemoryFile method has to be called in order to flush the
789 * \b Note: The returned object is deleted by the framework.
790 * @param capacity total size reserved for the memory file
791 * @param dt data type of the file
792 * @param spec data specification
793 * @return file handle, NULL if failed
795 AliHLTMemoryFile* CreateMemoryFile(int capacity,
796 const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
797 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
800 * Create a memory file in the output stream.
801 * This method creates a TFile object which stores all data in
802 * memory instead of disk. The TFile object is published as binary data.
803 * The instance can be used like a normal TFile object. The TFile::Close
804 * or @ref CloseMemoryFile method has to be called in order to flush the
807 * \b Note: The returned object is deleted by the framework.
808 * @param dtID data type ID of the file
809 * @param dtOrigin data type origin of the file
810 * @param spec data specification
811 * @param capacity fraction of the available output buffer size
812 * @return file handle, NULL if failed
814 AliHLTMemoryFile* CreateMemoryFile(const char* dtID, const char* dtOrigin,
815 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
819 * Create a memory file in the output stream.
820 * This method creates a TFile object which stores all data in
821 * memory instead of disk. The TFile object is published as binary data.
822 * The instance can be used like a normal TFile object. The TFile::Close
823 * or @ref CloseMemoryFile method has to be called in order to flush the
826 * \b Note: The returned object is deleted by the framework.
827 * @param dt data type of the file
828 * @param spec data specification
829 * @param capacity fraction of the available output buffer size
830 * @return file handle, NULL if failed
832 AliHLTMemoryFile* CreateMemoryFile(const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
833 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
837 * Write an object to memory file in the output stream.
838 * @param pFile file handle
839 * @param pObject pointer to root object
840 * @param key key in ROOT file
841 * @param option options, see TObject::Write
842 * @return neg. error code if failed
843 * - -ENOSPC no space left
845 int Write(AliHLTMemoryFile* pFile, const TObject* pObject, const char* key=NULL, int option=TObject::kOverwrite);
848 * Close object memory file.
849 * @param pFile file handle
850 * @return neg. error code if failed
851 * - -ENOSPC buffer size too small
853 int CloseMemoryFile(AliHLTMemoryFile* pFile);
856 * Insert event-done data information into the output.
857 * @param edd event-done data information
859 int CreateEventDoneData(AliHLTComponentEventDoneData edd);
862 * Get current run number
864 AliHLTUInt32_t GetRunNo() const;
867 * Get the current run type.
869 AliHLTUInt32_t GetRunType() const;
872 * Copy a struct from block data.
873 * The function checks for block size and struct size. The least common
874 * size will be copied to the target struct, remaining fields are initialized
876 * The target struct must have a 32bit struct size indicator as first member.
877 * @param pStruct target struct
878 * @param iStructSize size of the struct
879 * @param iBlockNo index of input block
880 * @param structname name of the struct (log messages)
881 * @param eventname name of the event (log messages)
882 * @return size copied, neg. error if failed
884 int CopyStruct(void* pStruct, int iStructSize, int iBlockNo,
885 const char* structname="", const char* eventname="");
888 /** not a valid copy constructor, defined according to effective C++ style */
889 AliHLTComponent(const AliHLTComponent&);
890 /** not a valid assignment op, but defined according to effective C++ style */
891 AliHLTComponent& operator=(const AliHLTComponent&);
894 * Increment the internal event counter.
895 * To be used by the friend classes AliHLTProcessor, AliHLTDataSource
896 * and AliHLTDataSink.
897 * @return new value of the internal event counter
900 int IncrementEventCounter();
903 * Find the first input block of specified data type beginning at index.
904 * Input blocks containing a TObject have the size of the object as an
905 * unsigned 32 bit number in the first 4 bytes. This has to match the block
907 * @param dt data type
908 * @param startIdx index to start the search
909 * @param bObject check if this is an object
910 * @return index of the block, -ENOENT if no block found
914 int FindInputBlock(const AliHLTComponentDataType& dt, int startIdx=-1, int bObject=0) const;
917 * Get index in the array of input bocks.
918 * Calculate index and check integrety of a block data structure pointer.
919 * @param pBlock pointer to block data
920 * @return index of the block, -ENOENT if no block found
924 int FindInputBlock(const AliHLTComponentBlockData* pBlock) const;
927 * Create an object from a specified input block.
928 * @param idx index of the input block
929 * @param bForce force the retrieval of an object, error messages
930 * are suppressed if \em bForce is not set
931 * @return pointer to TObject, caller must delete the object after use
935 TObject* CreateInputObject(int idx, int bForce=0);
939 * Get object from the input block list. The methods first checks whether the
940 * object was already created. If not, it is created by @ref CreateInputObject
941 * and inserted into the list of objects.
942 * @param idx index in the input block list
943 * @param classname name of the class, object is checked for correct class
945 * @param bForce force the retrieval of an object, error messages
946 * are suppressed if \em bForce is not set
947 * @return pointer to TObject
951 TObject* GetInputObject(int idx, const char* classname=NULL, int bForce=0);
954 * Clean the list of input objects.
955 * Cleanup is done at the end of each event processing.
957 int CleanupInputObjects();
960 * Insert a buffer into the output block stream.
961 * This is the only method to insert blocks into the output stream, called
962 * from all types of the Pushback method. The actual data might have been
963 * written to the output buffer already. In that case NULL can be provided
964 * as buffer, only the block descriptor will be build. If a header is specified,
965 * it will be inserted before the buffer, default is no header.
966 * @param pBuffer pointer to buffer
967 * @param iBufferSize size of the buffer in byte
968 * @param dt data type
969 * @param spec data specification
970 * @param pHeader pointer to header
971 * @param iHeaderSize size of Header
972 * @return neg. error code if failed
974 int InsertOutputBlock(void* pBuffer, int iBufferSize,
975 const AliHLTComponentDataType& dt,
977 void* pHeader=NULL, int iHeaderSize=0);
979 /** The global component handler instance */
980 static AliHLTComponentHandler* fgpComponentHandler; //! transient
982 /** The environment where the component is running in */
983 AliHLTComponentEnvironment fEnvironment; // see above
985 /** Set by ProcessEvent before the processing starts */
986 AliHLTEventID_t fCurrentEvent; // see above
988 /** internal event no */
989 int fEventCount; // see above
991 /** the number of failed events */
992 int fFailedEvents; // see above
994 /** event data struct of the current event under processing */
995 AliHLTComponentEventData fCurrentEventData; // see above
997 /** array of input data blocks of the current event */
998 const AliHLTComponentBlockData* fpInputBlocks; //! transient
1000 /** index of the current input block */
1001 int fCurrentInputBlock; // see above
1003 /** data type of the last block search */
1004 AliHLTComponentDataType fSearchDataType; // see above
1006 /** name of the class for the object to search for */
1007 string fClassName; // see above
1009 /** array of generated input objects */
1010 TObjArray* fpInputObjects; //! transient
1012 /** the output buffer */
1013 AliHLTUInt8_t* fpOutputBuffer; //! transient
1015 /** size of the output buffer */
1016 AliHLTUInt32_t fOutputBufferSize; // see above
1018 /** size of data written to output buffer */
1019 AliHLTUInt32_t fOutputBufferFilled; // see above
1021 /** list of ouput block data descriptors */
1022 vector<AliHLTComponentBlockData> fOutputBlocks; // see above
1024 /** stopwatch array */
1025 TObjArray* fpStopwatches; //! transient
1027 /** array of memory files AliHLTMemoryFile */
1028 vector<AliHLTMemoryFile*> fMemFiles; //! transient
1030 /** descriptor of the current run */
1031 AliHLTRunDesc* fpRunDesc; //! transient
1033 /** the current DDL list */
1034 AliHLTEventDDL* fpDDLList; //! transient
1036 ClassDef(AliHLTComponent, 3)