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)
19 * @defgroup alihlt_component Component handling of the HLT module
20 * This section describes the the component base classes and handling for
23 * @section alihlt_component_intro General remarks
24 * HLT analysis is organized in so called components. Each component can
25 * subscribe to the data produced by other components and can from the
26 * analysis publish new data for the subsequent components. Only the
27 * input data blocks and entries from CDB are available for the analysis.
29 * @section alihlt_component_implementation Component implementation
30 * AliHLTComponent provides the interface for all components, see there
31 * for details. Three types are provided:
36 * The two last represent data sinks and sources for the HLT integration
37 * into AliRoot. When running only, only the processors are relevant,
38 * sources and sinks are provided by the HLT PubSub framework. Please check
39 * AliHLTComponent for detailed description.
41 * @section alihlt_component_registration Component registration
42 * Components need to be registered with the AliHLTComponentHandler in
43 * order to be used with the system. Registration is purely done from the
44 * module library. Two methods are possible:
45 * - the module library implements an AliHLTModuleAgent and overloads the
46 * AliHLTModuleAgent::RegisterComponents() function
47 * - in the implementation file, one object is defined. The global object is
48 * automatically instantiated when the library is loaded for the first
49 * time and the object is used for registration.
51 * In both cases, the library must be loaded via the method
53 * AliHLTComponentHandler::LoadComponentLibraries()
55 * For the global object approach it is important that the library is
56 * not loaded elsewhere before (e.g. a gSystem->Load operation in your
64 #include "AliHLTLogging.h"
65 #include "AliHLTDataTypes.h"
66 #include "AliHLTCommonCDBEntries.h"
69 * The names have been changed for Aliroot's coding conventions sake
70 * The old names are defined for backward compatibility with the
71 * stand alone SampleLib package
73 typedef AliHLTComponentLogSeverity AliHLTComponent_LogSeverity;
74 typedef AliHLTComponentEventData AliHLTComponent_EventData;
75 typedef AliHLTComponentShmData AliHLTComponent_ShmData;
76 typedef AliHLTComponentDataType AliHLTComponent_DataType;
77 typedef AliHLTComponentBlockData AliHLTComponent_BlockData;
78 typedef AliHLTComponentTriggerData AliHLTComponent_TriggerData;
79 typedef AliHLTComponentEventDoneData AliHLTComponent_EventDoneData;
81 class AliHLTComponentHandler;
84 class AliHLTComponent;
85 class AliHLTMemoryFile;
88 /** list of component data type structures */
89 typedef vector<AliHLTComponentDataType> AliHLTComponentDataTypeList;
90 /** list of component block data structures */
91 typedef vector<AliHLTComponentBlockData> AliHLTComponentBlockDataList;
92 /** list of component statistics struct */
93 typedef vector<AliHLTComponentStatistics> AliHLTComponentStatisticsList;
94 /** list of component pointers */
95 typedef vector<AliHLTComponent*> AliHLTComponentPList;
96 /** list of memory file pointers */
97 typedef vector<AliHLTMemoryFile*> AliHLTMemoryFilePList;
100 * @class AliHLTComponent
101 * Base class of HLT data processing components.
102 * The class provides a common interface for HLT data processing components.
103 * The interface can be accessed from the online HLT framework or the AliRoot
104 * offline analysis framework.
105 * @section alihltcomponent-properties Component identification and properties
106 * Each component must provide a unique ID, input and output data type indications,
107 * and a spawn function.
108 * @subsection alihltcomponent-req-methods Required property methods
109 * - @ref GetComponentID
110 * - @ref GetInputDataTypes (see @ref alihltcomponent-type for default
112 * - @ref GetOutputDataType (see @ref alihltcomponent-type for default
114 * - @ref GetOutputDataSize (see @ref alihltcomponent-type for default
118 * @subsection alihltcomponent-opt-mehods Optional handlers
121 * - @ref GetOutputDataTypes
122 * If the component has multiple output data types @ref GetOutputDataType
123 * should return @ref kAliHLTMultipleDataType. The framework will invoke
124 * @ref GetOutputDataTypes, a list can be filled.
126 * This function is invoked by the framework on a special event which
127 * triggers the reconfiguration of the component.
129 * @subsection alihltcomponent-processing-mehods Data processing
132 * @subsection alihltcomponent-type Component type
133 * Components can be of type
134 * - @ref kSource components which only produce data
135 * - @ref kProcessor components which consume and produce data
136 * - @ref kSink components which only consume data
138 * where data production and consumption refer to the analysis data stream. In
139 * order to indicate the type, a child component can overload the
140 * @ref GetComponentType function.
141 * @subsubsection alihltcomponent-type-std Standard implementations
142 * Components in general do not need to implement this function, standard
143 * implementations of the 3 types are available:
144 * - AliHLTDataSource for components of type @ref kSource <br>
145 * All types of data sources can inherit from AliHLTDataSource and must
146 * implement the @ref AliHLTDataSource::GetEvent method. The class
147 * also implements a standard method for @ref GetInputDataTypes.
149 * - AliHLTProcessor for components of type @ref kProcessor <br>
150 * All types of data processors can inherit from AliHLTProcessor and must
151 * implement the @ref AliHLTProcessor::DoEvent method.
153 * - AliHLTDataSink for components of type @ref kSink <br>
154 * All types of data processors can inherit from AliHLTDataSink and must
155 * implement the @ref AliHLTDataSink::DumpEvent method. The class
156 * also implements a standard method for @ref GetOutputDataType and @ref
159 * @subsection alihltcomponent-environment Running environment
161 * In order to adapt to different environments (on-line/off-line), the component
162 * gets an environment structure with function pointers. The base class provides
163 * member functions for those environment dependend functions. The member
164 * functions are used by the component implementation and are re-mapped to the
165 * corresponding functions.
167 * @section alihltcomponent-interfaces Component interfaces
168 * Each of the 3 standard component base classes AliHLTProcessor, AliHLTDataSource
169 * and AliHLTDataSink provides it's own processing method (see
170 * @ref alihltcomponent-type-std), which splits into a high and a low-level
171 * method. For the @ref alihltcomponent-low-level-interface, all parameters are
172 * shipped as function arguments, the component is supposed to write data to the
173 * output buffer and handle all block descriptors.
174 * The @ref alihltcomponent-high-level-interface is the standard processing
175 * method and will be used whenever the low-level method is not overloaded.
177 * In both cases it is necessary to calculate/estimate the size of the output
178 * buffer before the processing. Output buffers can never be allocated inside
179 * the component because of the push-architecture of the HLT.
180 * For that reason the @ref GetOutputDataSize function should return a rough
181 * estimatian of the data to be produced by the component. The component is
182 * responsible for checking the memory size and must return -ENOSPC if the
183 * available buffer is too small, and update the estimator respectively. The
184 * framework will allocate a buffer of appropriate size and call the processing
187 * @subsection alihltcomponent-error-codes Return values/Error codes
188 * For return codes, the following scheme applies:
189 * - The data processing methods have to indicate error conditions by a negative
190 * error/return code. Preferably the system error codes are used like
191 * e.g. -EINVAL. This requires to include the header
193 * \#include \<cerrno\>
195 * This schema aplies to all interface functions of the component base class.
196 * For data processing it is as follows:
197 * - If no suitable input block could be found (e.g. no clusters for the TPC cluster
198 * finder) set size to 0, block list is empty, return 0
199 * - If no ususable or significant signal could be found in the input blocks
200 * return an empty output block, set size accordingly, and return 0. An empty output
201 * block here could be either a real empty one of size 0 (in which case size also
202 * would have to be set to zero) or a block filled with just the minimum necessary
203 * accounting/meta-structures. E.g. in the TPC
205 * @subsection alihltcomponent-high-level-interface High-level interface
206 * The high-level component interface provides functionality to exchange ROOT
207 * structures between components. In contrast to the
208 * @ref alihltcomponent-low-level-interface, a couple of functions can be used
209 * to access data blocks of the input stream
210 * and send data blocks or ROOT TObject's to the output stream. The functionality
211 * is hidden from the user and is implemented by using ROOT's TMessage class.
213 * @subsubsection alihltcomponent-high-level-int-methods Interface methods
214 * The interface provides a couple of methods in order to get objects from the
215 * input, data blocks (non TObject) from the input, and to push back objects and
216 * data blocks to the output. For convenience there are several functions of
217 * identical name (and similar behavior) with different parameters defined.
218 * Please refer to the function documentation.
219 * - @ref GetNumberOfInputBlocks <br>
220 * return the number of data blocks in the input stream
221 * - @ref GetFirstInputObject <br>
222 * get the first object of a specific data type
223 * - @ref GetNextInputObject <br>
224 * get the next object of same data type as last GetFirstInputObject/Block call
225 * - @ref GetFirstInputBlock <br>
226 * get the first block of a specific data type
227 * - @ref GetNextInputBlock <br>
228 * get the next block of same data type as last GetFirstInputBlock/Block call
229 * - @ref PushBack <br>
230 * insert an object or data buffer into the output
231 * - @ref CreateEventDoneData <br>
232 * add event information to the output
234 * In addition, the processing methods are simplified a bit by cutting out most of
237 * - @ref AliHLTProcessor::DoEvent
238 * - @ref AliHLTDataSource::GetEvent
239 * - @ref AliHLTDataSink::DumpEvent
241 * \em IMPORTANT: objects and block descriptors provided by the high-level interface
242 * <b>MUST NOT BE DELETED</b> by the caller.
244 * @subsubsection alihltcomponent-high-level-int-guidelines High-level interface guidelines
245 * - Structures must inherit from the ROOT object base class TObject in order be
246 * transported by the transportation framework.
247 * - all pointer members must be transient (marked <tt>//!</tt> behind the member
248 * definition), i.e. will not be stored/transported, or properly marked
249 * (<tt>//-></tt>) in order to call the streamer of the object the member is pointing
250 * to. The latter is not recomended. Structures to be transported between components
251 * should be streamlined.
252 * - no use of stl vectors/strings, use appropriate ROOT classes instead
254 * @subsection alihltcomponent-low-level-interface Low-level interface
255 * The low-level component interface consists of the specific data processing
256 * methods for @ref AliHLTProcessor, @ref AliHLTDataSource, and @ref AliHLTDataSink.
257 * - @ref AliHLTProcessor::DoEvent
258 * - @ref AliHLTDataSource::GetEvent
259 * - @ref AliHLTDataSink::DumpEvent
261 * The base class passes all relevant parameters for data access directly on to the
262 * component. Input blocks can be accessed by means of the array <tt> blocks </tt>.
263 * Output data are written directly to shared memory provided by the pointer
264 * <tt> outputPtr </tt> and output block descriptors are inserted directly to the
265 * list <tt> outputBlocks </tt>.
267 * \b NOTE: The high-level input data access methods can be used also from the low
268 * level interface. Also the PushBack functions can be used BUT ONLY if no data is
269 * written to the output buffer and no data block descriptors are inserted into the
272 * @section alihltcomponent-initialization Component initialization and configuration
273 * The component interface provides two optional methods for component initialization
274 * and configuration. The @ref DoInit function is called once before the processing.
275 * During the event processing, a special event can trigger a reconfiguration and the
276 * @ref Reconfigure method is called. There are three possible options of initialization
278 * - default values: set directly in the source code
279 * - OCDB objects: all necessary information must be loaded from OCDB objects. The
280 * Offline Conditions Data Base stores objects specifically valid for individual runs
282 * - Component arguments: can be specified for every component in the chain
283 * configuration. The arguments can be used to override specific parameters of the
286 * As a general rule, the three options should be processed in that sequence, i.e
287 * default parameters might be overridden by OCDB configuration, and the latter one
288 * by component arguments.
290 * @subsection alihltcomponent-initialization-arguments Component arguments
291 * In normal operation, components are supposed to run without any additional argument,
292 * however such arguments can be useful for testing and debugging. The idea follows
293 * the format of command line arguments. A keyword is indicated by a dash and an
294 * optional argument might follow, e.g.:
296 * -argument1 0.5 -argument2
298 * In this case argument1 requires an additional parameter whereas argument2 does not.
299 * The arguments will be provided as an array of separated arguments.
301 * Component arguments can be classified into initialization arguments and configuration
302 * arguments. The latter are applicable for both the @ref DoInit and @ref Reconfigure
303 * method whereas initialization arguments are not applicable after DoInit.
305 * @subsection alihltcomponent-initialization-ocdb OCDB objects
306 * OCDB objects are ROOT <tt>TObjects</tt> and can be of any type. This is in particular
307 * useful for complex parameter sets. However in most cases, a simple approach of human
308 * readable command line arguments is appropriate. Such a string can be simply stored
309 * in a TObjString (take note that the TString does not derive from TObject). The
310 * same arguments as for the command line can be used. Take note that in the TObjString
311 * all arguments are separated by blanks, instead of being in an array of separate
314 * The base class provides two functions regarding OCDB objects:
315 * - LoadAndExtractOCDBObject() loads the OCDB entry for the specified path and extracts
316 * the TObject from it.
317 * - ConfigureFromCDBTObjString() can load a number of OCDB objects and calls the
318 * argument parsing ConfigureFromArgumentString
321 * @subsection alihltcomponent-initialization-sequence Initialization sequence
322 * Using the approach of <tt>TObjString</tt>-type configuration objects allows to treat
323 * configuration from both @ref DoInit and @ref Reconfigure in the same way.
325 * The base class provides the function ConfigureFromArgumentString() which loops over
326 * all arguments and calls the child's method ScanConfigurationArgument(). Here the
327 * actual treatment of the argument and its parameters needs to be implemented.
328 * ConfigureFromArgumentString() can treat both arrays of arguments and arguments in
329 * one single string separated by blanks. The two options can be mixed.
331 * A second bas class function ConfigureFromCDBTObjString() allows to configure
332 * directly from a number of OCDB objects. This requires the entries to be of
333 * type TObjString and the child implementation of ScanConfigurationArgument().
335 * @section alihltcomponent-handling Component handling
336 * The handling of HLT analysis components is carried out by the AliHLTComponentHandler.
337 * Component are registered automatically at load-time of the component shared library
338 * under the following suppositions:
339 * - the component library has to be loaded from the AliHLTComponentHandler using the
340 * @ref AliHLTComponentHandler::LoadLibrary method.
341 * - the library defines an AliHLTModuleAgent which registers all components.
342 * See AliHLTModuleAgent::RegisterComponents <br>
344 * - the component implementation defines one global object (which is generated
345 * when the library is loaded) <br>
347 * @subsection alihltcomponent-design-rules General design considerations
348 * The analysis code should be implemented in one or more destict class(es). A
349 * \em component should be implemented which interface the destict analysis code to the
350 * component interface. This component generates the analysis object dynamically. <br>
352 * Assume you have an implemetation <tt> AliHLTDetMyAnalysis </tt>, another class <tt>
353 * AliHLTDetMyAnalysisComponent </tt> contains:
356 * AliHLTDetMyAnalysis* fMyAnalysis; //!
358 * The object should then be instantiated in the DoInit handler of
359 * <tt>AliHLTDetMyAnalysisComponent </tt>, and cleaned in the DoDeinit handler.
362 * - avoid big static arrays in the component, allocate the memory at runtime
363 * - allocate all kind of complex data members (like classes, ROOT TObjects of
364 * any kind) dynamically in DoInit and clean up in DoDeinit
366 * @section alihlt_component_arguments Default arguments
367 * The component base class provides some default arguments:
368 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
369 * \li -loglevel=level <br>
370 * \li -object-compression=level <br>
371 * compression level for ROOT objects, default is defined by
372 * @ref ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION
374 * @ingroup alihlt_component
375 * @section alihltcomponent-members Class members
377 class AliHLTComponent : public AliHLTLogging {
379 /** standard constructor */
381 /** standard destructor */
382 virtual ~AliHLTComponent();
384 /** component type definitions */
385 enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 };
388 * Init function to prepare data processing.
389 * Initialization of common data structures for a sequence of events.
390 * The call is redirected to the internal method DoInit which can be
391 * overridden by the child class.
392 * During Init also the environment structure is passed to the component.
393 * @param comenv environment pointer with environment dependent function
395 * @param environParam additional parameter for function calls, the pointer
397 * @param argc size of the argument array
398 * @param argv augment array for component initialization
400 virtual int Init( const AliHLTAnalysisEnvironment* comenv, void* environParam, int argc, const char** argv );
403 * Clean-up function to terminate data processing.
404 * Clean-up of common data structures after data processing.
405 * The call is redirected to the internal method @ref DoDeinit which can be
406 * overridden by the child class.
408 virtual int Deinit();
411 * Processing of one event.
412 * The method is the entrance of the event processing. The parameters are
413 * cached for uses with the high-level interface and the DoProcessing
414 * implementation is called.
421 * @param outputBlockCnt out: size of the output block array, set by the component
422 * @param outputBlocks out: the output block array is allocated internally
424 * @return neg. error code if failed
426 int ProcessEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
427 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
428 AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt,
429 AliHLTComponentBlockData*& outputBlocks,
430 AliHLTComponentEventDoneData*& edd );
433 * Internal processing of one event.
434 * The method is pure virtual and implemented by the child classes
435 * - @ref AliHLTProcessor
436 * - @ref AliHLTDataSource
437 * - @ref AliHLTDataSink
444 * @param outputBlocks out: the output block array is allocated internally
446 * @return neg. error code if failed
448 virtual int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
449 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
450 AliHLTUInt32_t& size,
451 AliHLTComponentBlockDataList& outputBlocks,
452 AliHLTComponentEventDoneData*& edd ) = 0;
456 * The function must not be called when running in AliRoot unless it it
457 * really wanted. The CDB path will be set to the specified path, which might
458 * override the path initialized at the beginning of the AliRoot reconstruction.
460 * The method is used from the external interface in order to set the correct
461 * path when running on-line. The function also initializes the function
462 * callback for setting the run no during operation.
464 * A separation of library and component handling is maybe appropriate in the
465 * future. Using the global component handler here is maybe not the cleanest
467 * @param cdbPath path of the CDB
468 * @param pHandler the component handler used for llibrary handling.
470 int InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler);
473 * Set the run no for the CDB.
474 * The function must not be called when running in AliRoot unless it it
475 * really wanted. The CDB path will be set to the specified path, which might
476 * override the run no initialized at the beginning of the AliRoot reconstruction.
477 * InitCDB() has to be called before in order to really change the CDB settings.
479 * The method is used from the external interface in order to set the correct
480 * path when running on-line.
482 int SetCDBRunNo(int runNo);
485 * Set the run description.
486 * The run description is set before the call of Init() -> DoInit().
487 * @note: This functionality has been added in Juli 2008. The transmission of
488 * run properties by a special SOR (SOD event in DAQ terminalogy but this was
489 * changed after the HLT interface was designed) event is not sufficient because
490 * the data might be needed already in the DoInit handler of the component.
491 * @param desc run descriptor, currently only the run no member is used
492 * @param runType originally, run type was supposed to be a number and part
493 * of the run descriptor. But it was defined as string later
495 int SetRunDescription(const AliHLTRunDesc* desc, const char* runType);
498 * Set the component description.
499 * The description string can contain tokens separated by blanks, a token
500 * consists of a key and an optional value separated by '='.
502 * \li -chainid=id string id within the chain of the instance
504 * @param desc component description
506 int SetComponentDescription(const char* desc);
509 * Set the running environment for the component.
510 * Originally, the environment was set in the Init function. However, the setup of
511 * the CDB is required before. In order to have proper logging functionality, the
512 * environment is required.
513 * @param comenv environment pointer with environment dependent function
515 * @param environParam additional parameter for function calls, the pointer
518 int SetComponentEnvironment(const AliHLTAnalysisEnvironment* comenv, void* environParam);
520 // Information member functions for registration.
523 * Get the type of the component.
524 * The function is pure virtual and must be implemented by the child class.
525 * @return component type id
527 virtual TComponentType GetComponentType() = 0; // Source, sink, or processor
530 * Get the id of the component.
531 * Each component is identified by a unique id.
532 * The function is pure virtual and must be implemented by the child class.
533 * @return component id (string)
535 virtual const char* GetComponentID() = 0;
538 * Get the input data types of the component.
539 * The function is pure virtual and must be implemented by the child class.
540 * @return list of data types in the vector reference
542 virtual void GetInputDataTypes( AliHLTComponentDataTypeList& ) = 0;
545 * Get the output data type of the component.
546 * The function is pure virtual and must be implemented by the child class.
547 * @return output data type
549 virtual AliHLTComponentDataType GetOutputDataType() = 0;
552 * Get the output data types of the component.
553 * The function can be implemented to indicate multiple output data types
554 * in the target array.
555 * @ref GetOutputDataType must return @ref kAliHLTMultipleDataType in order
556 * to invoke this method.
557 * @param tgtList list to receive the data types
558 * @return no of output data types, data types in the target list
560 virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
563 * Get a ratio by how much the data volume is shrunken or enhanced.
564 * The function is pure virtual and must be implemented by the child class.
565 * @param constBase <i>return</i>: additive part, independent of the
567 * @param inputMultiplier <i>return</i>: multiplication ratio
568 * @return values in the reference variables
570 virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0;
574 * Each component must implement a spawn function to create a new instance of
575 * the class. Basically the function must return <i>new <b>my_class_name</b></i>.
576 * @return new class instance
578 virtual AliHLTComponent* Spawn() = 0;
581 * Find matching data types between this component and a consumer component.
582 * Currently, a component can produce only one type of data. This restriction is most
583 * likely to be abolished in the future.
584 * @param pConsumer a component and consumer of the data produced by this component
585 * @param tgtList reference to a vector list to receive the matching data types.
586 * @return >= 0 success, neg. error code if failed
588 int FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList);
591 * Set the global component handler.
592 * The static method is needed for the automatic registration of components.
594 static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0);
597 * Clear the global component handler.
598 * The static method is needed for the automatic registration of components.
600 static int UnsetGlobalComponentHandler();
603 * Helper function to convert the data type to a string.
604 * @param type data type structure
605 * @param mode 0 print string origin:type <br>
609 static string DataType2Text( const AliHLTComponentDataType& type, int mode=0);
612 * Calculate a CRC checksum of a data buffer.
613 * Polynomial for the calculation is 0xD8.
615 static AliHLTUInt32_t CalculateChecksum(const AliHLTUInt8_t* buffer, int size);
618 * Helper function to print content of data type.
620 static void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL);
623 * helper function to initialize AliHLTComponentEventData structure
625 static void FillEventData(AliHLTComponentEventData& evtData);
628 * Print info on an AliHLTComponentDataType structure
629 * This is just a helper function to examine an @ref AliHLTComponentDataType
632 static void PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt);
635 * Fill AliHLTComponentBlockData structure with default values.
636 * @param blockData reference to data structure
638 static void FillBlockData( AliHLTComponentBlockData& blockData );
641 * Fill AliHLTComponentShmData structure with default values.
642 * @param shmData reference to data structure
644 static void FillShmData( AliHLTComponentShmData& shmData );
647 * Fill AliHLTComponentDataType structure with default values.
648 * @param dataType reference to data structure
650 static void FillDataType( AliHLTComponentDataType& dataType );
653 * Copy data type structure
654 * Copies the value an AliHLTComponentDataType structure to another one
655 * @param[out] tgtdt target structure
656 * @param[in] srcdt source structure
658 static void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt);
661 * Set the ID and Origin of an AliHLTComponentDataType structure.
662 * The function sets the fStructureSize member and copies the strings
663 * to the ID and Origin. Only characters from the valid part of the string
664 * are copied, the rest is filled with 0's. <br>
665 * Please note that the fID and fOrigin members are not strings, just arrays of
666 * chars of size @ref kAliHLTComponentDataTypefIDsize and
667 * @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with
668 * a terminating zero. <br>
669 * It is possible to pass NULL pointers as id or origin argument, in that case they
671 * @param tgtdt target data type structure
672 * @param id ID string
673 * @param origin Origin string
675 static void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin);
678 * Set the ID and Origin of an AliHLTComponentDataType structure.
679 * Given the fact that the data type ID is 64bit wide and origin 32, this helper
680 * function sets the data type from those two parameters.
681 * @param dt target data type structure
683 * @param orig 32bit origin
685 static void SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t orig);
688 * Extract a component table entry from the payload buffer.
689 * The entry consists of the AliHLTComponentTableEntry structure, the array of
690 * parents and a description string of the format 'chain-id{component-id:component-args}'.
691 * The function fills all the variables after a consistency check.
693 static int ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
694 string& chainId, string& compId, string& compParam,
695 vector<AliHLTUInt32_t>& parents);
697 * Stopwatch type for benchmarking.
699 enum AliHLTStopwatchType {
700 /** total time for event processing */
702 /** detector algorithm w/o interface callbacks */
708 /** number of types */
713 * Helper class for starting and stopping a stopwatch.
714 * The guard can be used by instantiating an object in a function. The
715 * specified stopwatch is started and the previous stopwatch put on
716 * hold. When the function is terminated, the object is deleted automatically
717 * deleted, stopping the stopwatch and starting the one on hold.<br>
718 * \em IMPORTANT: never create dynamic objects from this guard as this violates
719 * the idea of a guard.
721 class AliHLTStopwatchGuard {
723 /** standard constructor (not for use) */
724 AliHLTStopwatchGuard();
726 AliHLTStopwatchGuard(TStopwatch* pStart);
727 /** copy constructor (not for use) */
728 AliHLTStopwatchGuard(const AliHLTStopwatchGuard&);
729 /** assignment operator (not for use) */
730 AliHLTStopwatchGuard& operator=(const AliHLTStopwatchGuard&);
732 ~AliHLTStopwatchGuard();
736 * Hold the previous guard for the existence of this guard.
737 * Checks whether this guard controls a new stopwatch. In that case, the
738 * previous guard and its stopwatch are put on hold.
739 * @param pSucc instance of the stopwatch of the new guard
740 * @return 1 if pSucc is a different stopwatch which should
742 * 0 if it controls the same stopwatch
744 int Hold(TStopwatch* pSucc);
747 * Resume the previous guard.
748 * Checks whether the peceeding guard controls a different stopwatch. In that
749 * case, the its stopwatch is resumed.
750 * @param pSucc instance of the stopwatch of the new guard
751 * @return 1 if pSucc is a different stopwatch which should
753 * 0 if it controls the same stopwatch
755 int Resume(TStopwatch* pSucc);
757 /** the stopwatch controlled by this guard */
758 TStopwatch* fpStopwatch; //!transient
760 /** previous stopwatch guard, put on hold during existence of the guard */
761 AliHLTStopwatchGuard* fpPrec; //!transient
763 /** active stopwatch guard */
764 static AliHLTStopwatchGuard* fgpCurrent; //!transient
768 * Set a stopwatch for a given purpose.
769 * @param pSW stopwatch object
770 * @param type type of the stopwatch
772 int SetStopwatch(TObject* pSW, AliHLTStopwatchType type=kSWBase);
775 * Init a set of stopwatches.
776 * @param pStopwatches object array of stopwatches
778 int SetStopwatches(TObjArray* pStopwatches);
781 * Customized logging function.
782 * The chain id, component id and pointer is added at the beginning of each message.
784 int LoggingVarargs(AliHLTComponentLogSeverity severity,
785 const char* originClass, const char* originFunc,
786 const char* file, int line, ... ) const;
789 * Get size of last serialized object.
790 * During PushBack, TObjects are serialized in a separate buffer. The
791 * size of the last object can be retrieved by this function.
793 * This might be especially useful for PushBack failures caused by too
794 * small output buffer.
796 int GetLastObjectSize() const {return fLastObjectSize;}
801 * Default method for the internal initialization.
802 * The method is called by @ref Init
804 virtual int DoInit( int argc, const char** argv );
807 * Default method for the internal clean-up.
808 * The method is called by @ref Deinit
810 virtual int DoDeinit();
813 * Reconfigure the component.
814 * The method is called when an event of type @ref kAliHLTDataTypeComConf
815 * {COM_CONF:PRIV} is received by the component. If the event is sent as
816 * part of a normal event, the component configuration is called first.
818 * The CDB path parameter specifies the path in the CDB, i.e. without
819 * leading absolute path of the CDB location. The framework might also
820 * provide the id of the component in the analysis chain.
822 * The actual sequence of configuration depends on the component. As a
823 * general rule, the component should load the specific OCDB object if
824 * provided as parameter, and load the default objects if the parameter
825 * is NULL. However, other schemes are possible. See @ref
827 * \b Note: The CDB will be initialized by the framework, either already set
828 * from AliRoot or from the wrapper interface during initialization.
830 * @param cdbEntry path of the cdbEntry
831 * @param chainId the id/name of the component in the current analysis
832 * chain. This is not necessarily the same as what is
833 * returned by the GetComponentID() method.
834 * @note both parameters can be NULL, check before usage
836 virtual int Reconfigure(const char* cdbEntry, const char* chainId);
839 * Read the Preprocessor values.
840 * The function is invoked when the component is notified about available/
841 * updated data points from the detector Preprocessors. The 'modules'
842 * argument contains all detectors for which the Preprocessors have
843 * updated data points. The component has to implement the CDB access to
844 * get the desired data points.
845 * @param modules detectors for which the Preprocessors have updated
846 * data points: TPC, TRD, ITS, PHOS, MUON, or ALL if
847 * no argument was received.
848 * @return neg. error code if failed
850 virtual int ReadPreprocessorValues(const char* modules);
853 * Child implementation to scan a number of configuration arguments.
854 * The method is invoked by the framework in conjunction with the
855 * common framework functions ConfigureFromArgumentString and
856 * ConfigureFromCDBTObjString.
857 * Function needs to scan the argument and optional additional
858 * parameters and returns the number of elements in the array which
862 * @return number of arguments which have been scanned or neg error
863 * code if failed <br>
864 * \li -EINVAL unknown argument
865 * \li -EPROTO protocol error, e.g. missing parameter
867 virtual int ScanConfigurationArgument(int argc, const char** argv);
870 * Custom handler for the SOR event.
871 * Is invoked from the base class if an SOR event is in the block list.
872 * The handler is called before the processing function. The processing
873 * function is skipped if there are no other data blocks available.
875 * The SOR event is generated by the PubSub framework in response to
876 * the DAQ start of data (SOD - has been renamed after HLT interface
877 * was designed). The SOD event consists of 3 blocks:
878 * - ::kAliHLTDataTypeEvent block: spec ::gkAliEventTypeStartOfRun
879 * - SOD block of type ::kAliHLTDataTypeSOR, payload: AliHLTRunDesc struct
880 * - run type block ::kAliHLTDataTypeRunType, payload: run type string
882 * Run properties can be retrieved by getters like GetRunNo().
883 * @return neg. error code if failed
885 virtual int StartOfRun();
888 * Custom handler for the EOR event.
889 * Is invoked from the base class if an EOR event is in the block list.
890 * The handler is called before the processing function. The processing
891 * function is skipped if there are no other data blocks available.
893 * See StartOfRun() for more comments of the sequence of steering events.
895 * @return neg. error code if failed
897 virtual int EndOfRun();
900 * Check whether a component requires all steering blocks.
901 * Childs can overload in order to indicate that they want to
902 * receive also the steering data blocks. There is also the
903 * possibility to add the required data types to the input
904 * data type list in GetInputDataTypes().
906 virtual bool RequireSteeringBlocks() const {return false;}
909 * General memory allocation method.
910 * All memory which is going to be used 'outside' of the interface must
911 * be provided by the framework (online or offline).
912 * The method is redirected to a function provided by the current
913 * framework. Function pointers are transferred via the @ref
914 * AliHLTAnalysisEnvironment structure.
916 void* AllocMemory( unsigned long size );
919 * Helper function to create a monolithic BlockData description block out
920 * of a list BlockData descriptors.
921 * For convenience, inside the interface vector lists are used, to make the
922 * interface pure C style, monilithic blocks must be exchanged.
923 * The method is redirected to a function provided by the current
924 * framework. Function pointers are transferred via the @ref
925 * AliHLTAnalysisEnvironment structure.
927 int MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
928 AliHLTComponentBlockData** outputBlocks );
931 * Fill the EventDoneData structure.
932 * The method is redirected to a function provided by the current
933 * framework. Function pointers are transferred via the @ref
934 * AliHLTAnalysisEnvironment structure.
936 int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd );
939 * Allocate an EventDoneData structure for the current event .
940 * The method allocates the memory internally and does not interact with the current Framework.
941 * The allocated data structure is empty initially and can be filled by calls to the
942 * @ref PushEventDoneData method. The memory will be automatically released after the event has been processed.
945 int ReserveEventDoneData( unsigned long size );
948 * Push a 32 bit word of data into event done data for the current event which
949 * has previously been allocated by the @ref ReserveEventDoneData method.
951 int PushEventDoneData( AliHLTUInt32_t eddDataWord );
954 * Release event done data previously reserved by @ref ReserveEventDoneData
956 void ReleaseEventDoneData();
959 * Get the pointer to the event done data available/built so far for the current event via
960 * @ref ReserveEventDoneData and @ref PushEventDoneData
962 AliHLTComponentEventDoneData* GetCurrentEventDoneData()
964 return fEventDoneData;
968 * Helper function to convert the data type to a string.
970 void DataType2Text(const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]) const;
973 * Loop through a list of component arguments.
974 * The list can be either an array of separated strings or one single
975 * string containing blank separated arguments, or both mixed.
976 * ScanConfigurationArgument() is called to allow the component to treat
977 * the individual arguments.
978 * @return neg. error code if failed
980 int ConfigureFromArgumentString(int argc, const char** argv);
983 * Read configuration objects from OCDB and configure from
984 * the content of TObjString entries.
985 * @param entries blank separated list of OCDB paths
986 * @return neg. error code if failed
988 int ConfigureFromCDBTObjString(const char* entries);
991 * Load specified entry from the OCDB and extract the object.
992 * The entry is explicitely unloaded from the cache before it is loaded.
993 * @param path path of the entry under to root of the OCDB
994 * @param version version of the entry
995 * @param subVersion subversion of the entry
997 TObject* LoadAndExtractOCDBObject(const char* path, int version = -1, int subVersion = -1);
1002 * @return value of the internal event counter
1004 int GetEventCount() const;
1007 * Get the number of input blocks.
1008 * @return number of input blocks
1010 int GetNumberOfInputBlocks() const;
1013 * Get id of the current event
1016 AliHLTEventID_t GetEventId() const;
1019 * Get the first object of a specific data type from the input data.
1020 * The High-level methods provide functionality to transfer ROOT data
1021 * structures which inherit from TObject.
1023 * The method looks for the first ROOT object of type dt in the input stream.
1024 * If also the class name is provided, the object is checked for the right
1025 * class type. The input data block needs a certain structure, namely the
1026 * buffer size as first word. If the cross check fails, the retrieval is
1027 * silently abandoned, unless the \em bForce parameter is set.<br>
1028 * \b Note: THE OBJECT MUST NOT BE DELETED by the caller.
1030 * If called without parameters, the function tries to create objects from
1031 * all available input blocks, also the ones of data type kAliHLTVoidDataType
1032 * which are not matched by kAliHLTAnyDataType.
1034 * @param dt data type of the object
1035 * @param classname class name of the object
1036 * @param bForce force the retrieval of an object, error messages
1037 * are suppressed if \em bForce is not set
1038 * @return pointer to @ref TObject, NULL if no objects of specified type
1041 const TObject* GetFirstInputObject(const AliHLTComponentDataType& dt=kAliHLTAllDataTypes,
1042 const char* classname=NULL,
1046 * Get the first object of a specific data type from the input data.
1047 * The High-level methods provide functionality to transfer ROOT data
1048 * structures which inherit from TObject.
1049 * The method looks for the first ROOT object of type specified by the ID and
1050 * Origin strings in the input stream.
1051 * If also the class name is provided, the object is checked for the right
1052 * class type. The input data block needs a certain structure, namely the
1053 * buffer size as first word. If the cross check fails, the retrieval is
1054 * silently abandoned, unless the \em bForce parameter is set.<br>
1055 * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
1056 * @param dtID data type ID of the object
1057 * @param dtOrigin data type origin of the object
1058 * @param classname class name of the object
1059 * @param bForce force the retrieval of an object, error messages
1060 * are suppressed if \em bForce is not set
1061 * @return pointer to @ref TObject, NULL if no objects of specified type
1064 const TObject* GetFirstInputObject(const char* dtID,
1065 const char* dtOrigin,
1066 const char* classname=NULL,
1070 * Get the next object of a specific data type from the input data.
1071 * The High-level methods provide functionality to transfer ROOT data
1072 * structures which inherit from TObject.
1073 * The method looks for the next ROOT object of type and class specified
1074 * to the previous @ref GetFirstInputObject call.<br>
1075 * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
1076 * @param bForce force the retrieval of an object, error messages
1077 * are suppressed if \em bForce is not set
1078 * @return pointer to @ref TObject, NULL if no more objects available
1080 const TObject* GetNextInputObject(int bForce=0);
1083 * Get data type of an input block.
1084 * Get data type of the object previously fetched via
1085 * GetFirstInputObject/NextInputObject or the last one if no object
1087 * @param pObject pointer to TObject
1088 * @return data specification, kAliHLTVoidDataSpec if failed
1090 AliHLTComponentDataType GetDataType(const TObject* pObject=NULL);
1093 * Get data specification of an input block.
1094 * Get data specification of the object previously fetched via
1095 * GetFirstInputObject/NextInputObject or the last one if no object
1097 * @param pObject pointer to TObject
1098 * @return data specification, kAliHLTVoidDataSpec if failed
1100 AliHLTUInt32_t GetSpecification(const TObject* pObject=NULL);
1103 * Get the first block of a specific data type from the input data.
1104 * The method looks for the first block of type dt in the input stream.
1105 * It is intended to be used within the high-level interface.<br>
1106 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
1108 * If called without parameters, the function works on all input blocks,
1109 * also the ones of data type kAliHLTVoidDataType which are not matched by
1110 * kAliHLTAnyDataType.
1112 * @param dt data type of the block
1113 * @return pointer to @ref AliHLTComponentBlockData
1115 const AliHLTComponentBlockData* GetFirstInputBlock(const AliHLTComponentDataType& dt=kAliHLTAllDataTypes);
1118 * Get the first block of a specific data type from the input data.
1119 * The method looks for the first block of type specified by the ID and
1120 * Origin strings in the input stream. It is intended
1121 * to be used within the high-level interface.<br>
1122 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
1123 * @param dtID data type ID of the block
1124 * @param dtOrigin data type origin of the block
1125 * @return pointer to @ref AliHLTComponentBlockData
1127 const AliHLTComponentBlockData* GetFirstInputBlock(const char* dtID,
1128 const char* dtOrigin);
1131 * Get input block by index.<br>
1132 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
1133 * @return pointer to AliHLTComponentBlockData, NULL if index out of range
1135 const AliHLTComponentBlockData* GetInputBlock(int index) const;
1138 * Get the next block of a specific data type from the input data.
1139 * The method looks for the next block of type and class specified
1140 * to the previous @ref GetFirstInputBlock call.
1141 * To be used within the high-level interface.<br>
1142 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
1144 const AliHLTComponentBlockData* GetNextInputBlock();
1147 * Get data specification of an input block.
1148 * Get data specification of the input block previously fetched via
1149 * GetFirstInputObject/NextInputObject or the last one if no block
1151 * @param pBlock pointer to input block
1152 * @return data specification, kAliHLTVoidDataSpec if failed
1154 AliHLTUInt32_t GetSpecification(const AliHLTComponentBlockData* pBlock);
1157 * Forward an input object to the output.
1158 * Forward the input block of an object previously fetched via
1159 * GetFirstInputObject/NextInputObject or the last one if no object
1161 * The block descriptor of the input block is forwarded to the
1162 * output block list.
1163 * @param pObject pointer to TObject
1164 * @return neg. error code if failed
1166 int Forward(const TObject* pObject);
1169 * Forward an input block to the output.
1170 * Forward the input block fetched via GetFirstInputObject/
1171 * NextInputBlock or the last one if no block specified.
1172 * The block descriptor of the input block is forwarded to the
1173 * output block list.
1174 * @param pBlock pointer to input block
1175 * @return neg. error code if failed
1177 int Forward(const AliHLTComponentBlockData* pBlock=NULL);
1180 * Insert an object into the output.
1181 * If header is specified, it will be inserted before the root object,
1182 * default is no header.
1183 * @param pObject pointer to root object
1184 * @param dt data type of the object
1185 * @param spec data specification
1186 * @param pHeader pointer to header
1187 * @param headerSize size of Header
1188 * @return neg. error code if failed
1190 int PushBack(TObject* pObject, const AliHLTComponentDataType& dt,
1191 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1192 void* pHeader=NULL, int headerSize=0);
1195 * Insert an object into the output.
1196 * If header is specified, it will be inserted before the root object,
1197 * default is no header.
1198 * @param pObject pointer to root object
1199 * @param dtID data type ID of the object
1200 * @param dtOrigin data type origin of the object
1201 * @param spec data specification
1202 * @param pHeader pointer to header
1203 * @param headerSize size of Header
1204 * @return neg. error code if failed
1206 int PushBack(TObject* pObject, const char* dtID, const char* dtOrigin,
1207 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1208 void* pHeader=NULL, int headerSize=0);
1211 * Insert an object into the output.
1212 * @param pBuffer pointer to buffer
1213 * @param iSize size of the buffer
1214 * @param dt data type of the object
1215 * @param spec data specification
1216 * @param pHeader pointer to header
1217 * @param headerSize size of Header
1218 * @return neg. error code if failed
1220 int PushBack(const void* pBuffer, int iSize, const AliHLTComponentDataType& dt,
1221 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1222 const void* pHeader=NULL, int headerSize=0);
1225 * Insert an object into the output.
1226 * @param pBuffer pointer to buffer
1227 * @param iSize size of the buffer
1228 * @param dtID data type ID of the object
1229 * @param dtOrigin data type origin of the object
1230 * @param spec data specification
1231 * @param pHeader pointer to header
1232 * @param headerSize size of Header
1233 * @return neg. error code if failed
1235 int PushBack(const void* pBuffer, int iSize, const char* dtID, const char* dtOrigin,
1236 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1237 const void* pHeader=NULL, int headerSize=0);
1240 * Estimate size of a TObject
1242 * @return buffer size in byte
1244 int EstimateObjectSize(TObject* pObject) const;
1247 * Create a memory file in the output stream.
1248 * This method creates a TFile object which stores all data in
1249 * memory instead of disk. The TFile object is published as binary data.
1250 * The instance can be used like a normal TFile object. The TFile::Close
1251 * or @ref CloseMemoryFile method has to be called in order to flush the
1254 * \b Note: The returned object is deleted by the framework.
1255 * @param capacity total size reserved for the memory file
1256 * @param dtID data type ID of the file
1257 * @param dtOrigin data type origin of the file
1258 * @param spec data specification
1259 * @return file handle, NULL if failed
1261 AliHLTMemoryFile* CreateMemoryFile(int capacity, const char* dtID, const char* dtOrigin,
1262 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
1265 * Create a memory file in the output stream.
1266 * This method creates a TFile object which stores all data in
1267 * memory instead of disk. The TFile object is published as binary data.
1268 * The instance can be used like a normal TFile object. The TFile::Close
1269 * or @ref CloseMemoryFile method has to be called in order to flush the
1272 * \b Note: The returned object is deleted by the framework.
1273 * @param capacity total size reserved for the memory file
1274 * @param dt data type of the file
1275 * @param spec data specification
1276 * @return file handle, NULL if failed
1278 AliHLTMemoryFile* CreateMemoryFile(int capacity,
1279 const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
1280 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
1283 * Create a memory file in the output stream.
1284 * This method creates a TFile object which stores all data in
1285 * memory instead of disk. The TFile object is published as binary data.
1286 * The instance can be used like a normal TFile object. The TFile::Close
1287 * or @ref CloseMemoryFile method has to be called in order to flush the
1290 * \b Note: The returned object is deleted by the framework.
1291 * @param dtID data type ID of the file
1292 * @param dtOrigin data type origin of the file
1293 * @param spec data specification
1294 * @param capacity fraction of the available output buffer size
1295 * @return file handle, NULL if failed
1297 AliHLTMemoryFile* CreateMemoryFile(const char* dtID, const char* dtOrigin,
1298 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1299 float capacity=1.0);
1302 * Create a memory file in the output stream.
1303 * This method creates a TFile object which stores all data in
1304 * memory instead of disk. The TFile object is published as binary data.
1305 * The instance can be used like a normal TFile object. The TFile::Close
1306 * or @ref CloseMemoryFile method has to be called in order to flush the
1309 * \b Note: The returned object is deleted by the framework.
1310 * @param dt data type of the file
1311 * @param spec data specification
1312 * @param capacity fraction of the available output buffer size
1313 * @return file handle, NULL if failed
1315 AliHLTMemoryFile* CreateMemoryFile(const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
1316 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1317 float capacity=1.0);
1320 * Write an object to memory file in the output stream.
1321 * @param pFile file handle
1322 * @param pObject pointer to root object
1323 * @param key key in ROOT file
1324 * @param option options, see TObject::Write
1325 * @return neg. error code if failed
1326 * - -ENOSPC no space left
1328 int Write(AliHLTMemoryFile* pFile, const TObject* pObject, const char* key=NULL, int option=TObject::kOverwrite);
1331 * Close object memory file.
1332 * @param pFile file handle
1333 * @return neg. error code if failed
1334 * - -ENOSPC buffer size too small
1336 int CloseMemoryFile(AliHLTMemoryFile* pFile);
1339 * Insert event-done data information into the output.
1340 * @param edd event-done data information
1342 int CreateEventDoneData(AliHLTComponentEventDoneData edd);
1345 * Get current run number
1347 AliHLTUInt32_t GetRunNo() const;
1350 * Get the current run type.
1352 AliHLTUInt32_t GetRunType() const;
1355 * Get the chain id of the component.
1357 const char* GetChainId() const {return fChainId.c_str();}
1360 * Get a timestamp of the current event
1361 * Exact format needs to be documented.
1363 AliHLTUInt32_t GetTimeStamp() const;
1366 * Get the period number.
1367 * Upper 28 bits (36 to 63) of the 64-bit event id
1369 AliHLTUInt32_t GetPeriodNumber() const;
1372 * Get the period number.
1373 * 24 bits, 12 to 35 of the 64-bit event id
1375 AliHLTUInt32_t GetOrbitNumber() const;
1378 * Get the bunch crossing number.
1379 * 12 bits, 0 to 12 of the 64-bit event id
1381 AliHLTUInt16_t GetBunchCrossNumber() const;
1384 * Setup the CTP accounting functionality of the base class.
1385 * The method can be invoked from DoInit() for componenets which want to
1386 * use the CTP functionality of the base class.
1388 * The AliHLTCTPData is initialized with the trigger classes from the ECS
1389 * parameters. The base class automatically increments the counters according
1390 * to the trigger pattern in the CDH before the event processing.
1395 * Get the instance of the CTP data.
1397 const AliHLTCTPData* CTPData() const {return fpCTPData;}
1400 * Check whether a combination of trigger classes is fired.
1401 * The expression can contain trigger class ids and logic operators
1402 * like &&, ||, !, and ^, and may be grouped by parentheses.
1403 * @param expression a logic expression of trigger class ids
1404 * @param trigData the trigger data data
1406 bool EvaluateCTPTriggerClass(const char* expression, AliHLTComponentTriggerData& trigData) const;
1409 * Check whether the current event is a valid data event.
1410 * @param pTgt optional pointer to get the event type
1411 * @return true if the current event is a real data event
1413 bool IsDataEvent(AliHLTUInt32_t* pTgt=NULL);
1416 * Set a bit to 1 in a readout list ( = AliHLTEventDDL )
1417 * -> enable DDL for readout
1418 * @param list readout list
1419 * @param ddlId DDL Id to be turned on ( Decimal )
1421 void EnableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const {
1422 SetDDLBit( list, ddlId, kTRUE );
1426 * Set a bit to 0 in a readout list ( = AliHLTEventDDL )
1427 * -> disable DDL for readout
1428 * @param list readout list
1429 * @param ddlId DDL Id to be turned on ( Decimal )
1431 void DisableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const {
1432 SetDDLBit( list, ddlId, kFALSE );
1436 * Set or unset bit a readout list ( = AliHLTEventDDL )
1437 * -> enable or disable DDL for readout
1438 * @param list readout list
1439 * @param ddlId DDL Id to be turned on ( Decimal )
1440 * @param state kTRUE sets it, kFALSE unsets it
1442 void SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const;
1445 * Get the first word of a detector, which has a set DDL bit.
1446 * Beware, this only works if DDLs of 1 detector are set. In the
1447 * case of the TPC and TOF, which use 8 and 3 words, the first
1449 * @param list readout list
1450 * @return returns the detector index, -1 if no bit is set
1451 * at all or several detectors (=error)
1453 Int_t GetFirstUsedDDLWord(AliHLTEventDDL &list) const;
1456 * Copy a struct from block data.
1457 * The function checks for block size and struct size. The least common
1458 * size will be copied to the target struct, remaining fields are initialized
1460 * The target struct must have a 32bit struct size indicator as first member.
1461 * @param pStruct target struct
1462 * @param iStructSize size of the struct
1463 * @param iBlockNo index of input block
1464 * @param structname name of the struct (log messages)
1465 * @param eventname name of the event (log messages)
1466 * @return size copied, neg. error if failed
1468 int CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo,
1469 const char* structname="", const char* eventname="");
1472 /** copy constructor prohibited */
1473 AliHLTComponent(const AliHLTComponent&);
1474 /** assignment operator prohibited */
1475 AliHLTComponent& operator=(const AliHLTComponent&);
1478 * Increment the internal event counter.
1479 * To be used by the friend classes AliHLTProcessor, AliHLTDataSource
1480 * and AliHLTDataSink.
1481 * @return new value of the internal event counter
1484 int IncrementEventCounter();
1487 * Find the first input block of specified data type beginning at index.
1488 * Input blocks containing a TObject have the size of the object as an
1489 * unsigned 32 bit number in the first 4 bytes. This has to match the block
1492 * kAliHLTAllDataTypes is a special data type which includes both
1493 * kAliHLTVoidDataType and kAliHLTAnyDataType.
1495 * @param dt data type
1496 * @param startIdx index to start the search
1497 * @param bObject check if this is an object
1498 * @return index of the block, -ENOENT if no block found
1502 int FindInputBlock(const AliHLTComponentDataType& dt, int startIdx=-1, int bObject=0) const;
1505 * Get index in the array of input bocks.
1506 * Calculate index and check integrety of a block data structure pointer.
1507 * @param pBlock pointer to block data
1508 * @return index of the block, -ENOENT if no block found
1512 int FindInputBlock(const AliHLTComponentBlockData* pBlock) const;
1515 * Create an object from a specified input block.
1516 * @param idx index of the input block
1517 * @param bForce force the retrieval of an object, error messages
1518 * are suppressed if \em bForce is not set
1519 * @return pointer to TObject, caller must delete the object after use
1523 TObject* CreateInputObject(int idx, int bForce=0);
1527 * Get object from the input block list. The methods first checks whether the
1528 * object was already created. If not, it is created by @ref CreateInputObject
1529 * and inserted into the list of objects.
1530 * @param idx index in the input block list
1531 * @param classname name of the class, object is checked for correct class
1533 * @param bForce force the retrieval of an object, error messages
1534 * are suppressed if \em bForce is not set
1535 * @return pointer to TObject
1539 TObject* GetInputObject(int idx, const char* classname=NULL, int bForce=0);
1542 * Clean the list of input objects.
1543 * Cleanup is done at the end of each event processing.
1545 int CleanupInputObjects();
1548 * Insert a buffer into the output block stream.
1549 * This is the only method to insert blocks into the output stream, called
1550 * from all types of the Pushback method. The actual data might have been
1551 * written to the output buffer already. In that case NULL can be provided
1552 * as buffer, only the block descriptor will be build. If a header is specified,
1553 * it will be inserted before the buffer, default is no header.
1554 * @param pBuffer pointer to buffer
1555 * @param iBufferSize size of the buffer in byte
1556 * @param dt data type
1557 * @param spec data specification
1558 * @param pHeader pointer to header
1559 * @param iHeaderSize size of Header
1560 * @return neg. error code if failed
1562 int InsertOutputBlock(const void* pBuffer, int iBufferSize,
1563 const AliHLTComponentDataType& dt,
1564 AliHLTUInt32_t spec,
1565 const void* pHeader=NULL, int iHeaderSize=0);
1568 * Add a component statistics block to the output.
1569 * @return size of the added data
1571 int AddComponentStatistics(AliHLTComponentBlockDataList& blocks,
1572 AliHLTUInt8_t* buffer,
1573 AliHLTUInt32_t bufferSize,
1574 AliHLTUInt32_t offset,
1575 AliHLTComponentStatisticsList& stats) const;
1578 * Add a component table entry (descriptor) to the output
1579 * This is done at SOR/EOR. The component table is a list of chain ids
1580 * and 32bit ids calculated by a crc algorithm from the chian id. This
1581 * allows to tag data blocks with the id number rather than the string.
1583 * The kAliHLTDataTypeComponentTable data block currently has the string
1584 * as payload and the crc id as specification.
1585 * @return size of the added data
1587 int AddComponentTableEntry(AliHLTComponentBlockDataList& blocks,
1588 AliHLTUInt8_t* buffer,
1589 AliHLTUInt32_t bufferSize,
1590 AliHLTUInt32_t offset,
1591 const vector<AliHLTUInt32_t>& parents) const;
1594 * Scan the ECS parameter string.
1595 * The framework provides both the parameters of CONFIGURE and ENGAGE
1596 * in one string in a special data block kAliHLTDataTypeECSParam
1597 * {ECSPARAM:PRIV}. The general format is
1598 * <command>;<parameterkey>=<parametervalue>;<parameterkey>=<parametervalue>;...
1600 int ScanECSParam(const char* ecsParam);
1603 * The trigger classes are determined from the trigger and propagated by
1604 * ECS as part of the ENGAGE command parameter which is sent through the
1605 * framework during the SOR event. This function treats the value of the
1606 * parameter key CTP_TRIGGER_CLASS.
1608 int InitCTPTriggerClasses(const char* ctpString);
1610 /** The global component handler instance */
1611 static AliHLTComponentHandler* fgpComponentHandler; //! transient
1613 /** The environment where the component is running in */
1614 AliHLTAnalysisEnvironment fEnvironment; // see above
1616 /** Set by ProcessEvent before the processing starts */
1617 AliHLTEventID_t fCurrentEvent; // see above
1619 /** internal event no */
1620 int fEventCount; // see above
1622 /** the number of failed events */
1623 int fFailedEvents; // see above
1625 /** event data struct of the current event under processing */
1626 AliHLTComponentEventData fCurrentEventData; // see above
1628 /** array of input data blocks of the current event */
1629 const AliHLTComponentBlockData* fpInputBlocks; //! transient
1631 /** index of the current input block */
1632 int fCurrentInputBlock; // see above
1634 /** data type of the last block search */
1635 AliHLTComponentDataType fSearchDataType; // see above
1637 /** name of the class for the object to search for */
1638 string fClassName; // see above
1640 /** array of generated input objects */
1641 TObjArray* fpInputObjects; //! transient
1643 /** the output buffer */
1644 AliHLTUInt8_t* fpOutputBuffer; //! transient
1646 /** size of the output buffer */
1647 AliHLTUInt32_t fOutputBufferSize; // see above
1649 /** size of data written to output buffer */
1650 AliHLTUInt32_t fOutputBufferFilled; // see above
1652 /** list of ouput block data descriptors */
1653 AliHLTComponentBlockDataList fOutputBlocks; // see above
1655 /** stopwatch array */
1656 TObjArray* fpStopwatches; //! transient
1658 /** array of memory files AliHLTMemoryFile */
1659 AliHLTMemoryFilePList fMemFiles; //! transient
1661 /** descriptor of the current run */
1662 AliHLTRunDesc* fpRunDesc; //! transient
1664 /** the current DDL list */
1665 AliHLTEventDDL* fpDDLList; //! transient
1667 /** external fct to set CDB run no, indicates external CDB initialization */
1668 void (*fCDBSetRunNoFunc)(); //! transient
1670 /** id of the component in the analysis chain */
1671 string fChainId; //! transient
1673 /** crc value of the chainid, used as a 32bit id */
1674 AliHLTUInt32_t fChainIdCrc; //! transient
1676 /** optional benchmarking for the component statistics */
1677 TStopwatch* fpBenchmark; //! transient
1679 /** component requires steering data blocks */
1680 bool fRequireSteeringBlocks; //! transient
1682 /** current event type */
1683 AliHLTUInt32_t fEventType; //! transient
1685 /** component arguments */
1686 string fComponentArgs; //! transient
1689 /** event done data */
1690 AliHLTComponentEventDoneData* fEventDoneData; //! transient
1692 /** Reserved size of the memory stored at fEventDoneData */
1693 unsigned long fEventDoneDataSize; //! transient
1695 /** Comression level for ROOT objects */
1696 int fCompressionLevel; //! transient
1698 /** size of last PushBack-serialized object */
1699 int fLastObjectSize; //! transient
1701 /** array of trigger class descriptors */
1702 AliHLTCTPData* fpCTPData; //! transient
1704 ClassDef(AliHLTComponent, 12)