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;
87 /** list of component data type structures */
88 typedef vector<AliHLTComponentDataType> AliHLTComponentDataTypeList;
89 /** list of component block data structures */
90 typedef vector<AliHLTComponentBlockData> AliHLTComponentBlockDataList;
91 /** list of component statistics struct */
92 typedef vector<AliHLTComponentStatistics> AliHLTComponentStatisticsList;
93 /** list of component pointers */
94 typedef vector<AliHLTComponent*> AliHLTComponentPList;
95 /** list of memory file pointers */
96 typedef vector<AliHLTMemoryFile*> AliHLTMemoryFilePList;
99 * @class AliHLTComponent
100 * Base class of HLT data processing components.
101 * The class provides a common interface for HLT data processing components.
102 * The interface can be accessed from the online HLT framework or the AliRoot
103 * offline analysis framework.
104 * @section alihltcomponent-properties Component identification and properties
105 * Each component must provide a unique ID, input and output data type indications,
106 * and a spawn function.
107 * @subsection alihltcomponent-req-methods Required property methods
108 * - @ref GetComponentID
109 * - @ref GetInputDataTypes (see @ref alihltcomponent-type for default
111 * - @ref GetOutputDataType (see @ref alihltcomponent-type for default
113 * - @ref GetOutputDataSize (see @ref alihltcomponent-type for default
117 * @subsection alihltcomponent-opt-mehods Optional handlers
120 * - @ref GetOutputDataTypes
121 * If the component has multiple output data types @ref GetOutputDataType
122 * should return @ref kAliHLTMultipleDataType. The framework will invoke
123 * @ref GetOutputDataTypes, a list can be filled.
125 * This function is invoked by the framework on a special event which
126 * triggers the reconfiguration of the component.
128 * @subsection alihltcomponent-processing-mehods Data processing
131 * @subsection alihltcomponent-type Component type
132 * Components can be of type
133 * - @ref kSource components which only produce data
134 * - @ref kProcessor components which consume and produce data
135 * - @ref kSink components which only consume data
137 * where data production and consumption refer to the analysis data stream. In
138 * order to indicate the type, a child component can overload the
139 * @ref GetComponentType function.
140 * @subsubsection alihltcomponent-type-std Standard implementations
141 * Components in general do not need to implement this function, standard
142 * implementations of the 3 types are available:
143 * - AliHLTDataSource for components of type @ref kSource <br>
144 * All types of data sources can inherit from AliHLTDataSource and must
145 * implement the @ref AliHLTDataSource::GetEvent method. The class
146 * also implements a standard method for @ref GetInputDataTypes.
148 * - AliHLTProcessor for components of type @ref kProcessor <br>
149 * All types of data processors can inherit from AliHLTProcessor and must
150 * implement the @ref AliHLTProcessor::DoEvent method.
152 * - AliHLTDataSink for components of type @ref kSink <br>
153 * All types of data processors can inherit from AliHLTDataSink and must
154 * implement the @ref AliHLTDataSink::DumpEvent method. The class
155 * also implements a standard method for @ref GetOutputDataType and @ref
158 * @subsection alihltcomponent-environment Running environment
160 * In order to adapt to different environments (on-line/off-line), the component
161 * gets an environment structure with function pointers. The base class provides
162 * member functions for those environment dependend functions. The member
163 * functions are used by the component implementation and are re-mapped to the
164 * corresponding functions.
166 * @section alihltcomponent-interfaces Component interfaces
167 * Each of the 3 standard component base classes AliHLTProcessor, AliHLTDataSource
168 * and AliHLTDataSink provides it's own processing method (see
169 * @ref alihltcomponent-type-std), which splits into a high and a low-level
170 * method. For the @ref alihltcomponent-low-level-interface, all parameters are
171 * shipped as function arguments, the component is supposed to write data to the
172 * output buffer and handle all block descriptors.
173 * The @ref alihltcomponent-high-level-interface is the standard processing
174 * method and will be used whenever the low-level method is not overloaded.
176 * In both cases it is necessary to calculate/estimate the size of the output
177 * buffer before the processing. Output buffers can never be allocated inside
178 * the component because of the push-architecture of the HLT.
179 * For that reason the @ref GetOutputDataSize function should return a rough
180 * estimatian of the data to be produced by the component. The component is
181 * responsible for checking the memory size and must return -ENOSPC if the
182 * available buffer is too small, and update the estimator respectively. The
183 * framework will allocate a buffer of appropriate size and call the processing
186 * @subsection alihltcomponent-error-codes Return values/Error codes
187 * For return codes, the following scheme applies:
188 * - The data processing methods have to indicate error conditions by a negative
189 * error/return code. Preferably the system error codes are used like
190 * e.g. -EINVAL. This requires to include the header
192 * \#include \<cerrno\>
194 * This schema aplies to all interface functions of the component base class.
195 * For data processing it is as follows:
196 * - If no suitable input block could be found (e.g. no clusters for the TPC cluster
197 * finder) set size to 0, block list is empty, return 0
198 * - If no ususable or significant signal could be found in the input blocks
199 * return an empty output block, set size accordingly, and return 0. An empty output
200 * block here could be either a real empty one of size 0 (in which case size also
201 * would have to be set to zero) or a block filled with just the minimum necessary
202 * accounting/meta-structures. E.g. in the TPC
204 * @subsection alihltcomponent-high-level-interface High-level interface
205 * The high-level component interface provides functionality to exchange ROOT
206 * structures between components. In contrast to the
207 * @ref alihltcomponent-low-level-interface, a couple of functions can be used
208 * to access data blocks of the input stream
209 * and send data blocks or ROOT TObject's to the output stream. The functionality
210 * is hidden from the user and is implemented by using ROOT's TMessage class.
212 * @subsubsection alihltcomponent-high-level-int-methods Interface methods
213 * The interface provides a couple of methods in order to get objects from the
214 * input, data blocks (non TObject) from the input, and to push back objects and
215 * data blocks to the output. For convenience there are several functions of
216 * identical name (and similar behavior) with different parameters defined.
217 * Please refer to the function documentation.
218 * - @ref GetNumberOfInputBlocks <br>
219 * return the number of data blocks in the input stream
220 * - @ref GetFirstInputObject <br>
221 * get the first object of a specific data type
222 * - @ref GetNextInputObject <br>
223 * get the next object of same data type as last GetFirstInputObject/Block call
224 * - @ref GetFirstInputBlock <br>
225 * get the first block of a specific data type
226 * - @ref GetNextInputBlock <br>
227 * get the next block of same data type as last GetFirstInputBlock/Block call
228 * - @ref PushBack <br>
229 * insert an object or data buffer into the output
230 * - @ref CreateEventDoneData <br>
231 * add event information to the output
233 * In addition, the processing methods are simplified a bit by cutting out most of
236 * - @ref AliHLTProcessor::DoEvent
237 * - @ref AliHLTDataSource::GetEvent
238 * - @ref AliHLTDataSink::DumpEvent
240 * \em IMPORTANT: objects and block descriptors provided by the high-level interface
241 * <b>MUST NOT BE DELETED</b> by the caller.
243 * @subsubsection alihltcomponent-high-level-int-guidelines High-level interface guidelines
244 * - Structures must inherit from the ROOT object base class TObject in order be
245 * transported by the transportation framework.
246 * - all pointer members must be transient (marked <tt>//!</tt> behind the member
247 * definition), i.e. will not be stored/transported, or properly marked
248 * (<tt>//-></tt>) in order to call the streamer of the object the member is pointing
249 * to. The latter is not recomended. Structures to be transported between components
250 * should be streamlined.
251 * - no use of stl vectors/strings, use appropriate ROOT classes instead
253 * @subsection alihltcomponent-low-level-interface Low-level interface
254 * The low-level component interface consists of the specific data processing
255 * methods for @ref AliHLTProcessor, @ref AliHLTDataSource, and @ref AliHLTDataSink.
256 * - @ref AliHLTProcessor::DoEvent
257 * - @ref AliHLTDataSource::GetEvent
258 * - @ref AliHLTDataSink::DumpEvent
260 * The base class passes all relevant parameters for data access directly on to the
261 * component. Input blocks can be accessed by means of the array <tt> blocks </tt>.
262 * Output data are written directly to shared memory provided by the pointer
263 * <tt> outputPtr </tt> and output block descriptors are inserted directly to the
264 * list <tt> outputBlocks </tt>.
266 * \b NOTE: The high-level input data access methods can be used also from the low
267 * level interface. Also the PushBack functions can be used BUT ONLY if no data is
268 * written to the output buffer and no data block descriptors are inserted into the
271 * @section alihltcomponent-initialization Component initialization and configuration
272 * The component interface provides two optional methods for component initialization
273 * and configuration. The @ref DoInit function is called once before the processing.
274 * During the event processing, a special event can trigger a reconfiguration and the
275 * @ref Reconfigure method is called. There are three possible options of initialization
277 * - default values: set directly in the source code
278 * - OCDB objects: all necessary information must be loaded from OCDB objects. The
279 * Offline Conditions Data Base stores objects specifically valid for individual runs
281 * - Component arguments: can be specified for every component in the chain
282 * configuration. The arguments can be used to override specific parameters of the
285 * As a general rule, the three options should be processed in that sequence, i.e
286 * default parameters might be overridden by OCDB configuration, and the latter one
287 * by component arguments.
289 * @subsection alihltcomponent-initialization-arguments Component arguments
290 * In normal operation, components are supposed to run without any additional argument,
291 * however such arguments can be useful for testing and debugging. The idea follows
292 * the format of command line arguments. A keyword is indicated by a dash and an
293 * optional argument might follow, e.g.:
295 * -argument1 0.5 -argument2
297 * In this case argument1 requires an additional parameter whereas argument2 does not.
298 * The arguments will be provided as an array of separated arguments.
300 * Component arguments can be classified into initialization arguments and configuration
301 * arguments. The latter are applicable for both the @ref DoInit and @ref Reconfigure
302 * method whereas initialization arguments are not applicable after DoInit.
304 * @subsection alihltcomponent-initialization-ocdb OCDB objects
305 * OCDB objects are ROOT <tt>TObjects</tt> and can be of any type. This is in particular
306 * useful for complex parameter sets. However in most cases, a simple approach of human
307 * readable command line arguments is appropriate. Such a string can be simply stored
308 * in a TObjString (take note that the TString does not derive from TObject). The
309 * same arguments as for the command line can be used. Take note that in the TObjString
310 * all arguments are separated by blanks, instead of being in an array of separate
313 * The base class provides two functions regarding OCDB objects:
314 * - LoadAndExtractOCDBObject() loads the OCDB entry for the specified path and extracts
315 * the TObject from it.
316 * - ConfigureFromCDBTObjString() can load a number of OCDB objects and calls the
317 * argument parsing ConfigureFromArgumentString
320 * @subsection alihltcomponent-initialization-sequence Initialization sequence
321 * Using the approach of <tt>TObjString</tt>-type configuration objects allows to treat
322 * configuration from both @ref DoInit and @ref Reconfigure in the same way.
324 * The base class provides the function ConfigureFromArgumentString() which loops over
325 * all arguments and calls the child's method ScanConfigurationArgument(). Here the
326 * actual treatment of the argument and its parameters needs to be implemented.
327 * ConfigureFromArgumentString() can treat both arrays of arguments and arguments in
328 * one single string separated by blanks. The two options can be mixed.
330 * A second bas class function ConfigureFromCDBTObjString() allows to configure
331 * directly from a number of OCDB objects. This requires the entries to be of
332 * type TObjString and the child implementation of ScanConfigurationArgument().
334 * @section alihltcomponent-handling Component handling
335 * The handling of HLT analysis components is carried out by the AliHLTComponentHandler.
336 * Component are registered automatically at load-time of the component shared library
337 * under the following suppositions:
338 * - the component library has to be loaded from the AliHLTComponentHandler using the
339 * @ref AliHLTComponentHandler::LoadLibrary method.
340 * - the library defines an AliHLTModuleAgent which registers all components.
341 * See AliHLTModuleAgent::RegisterComponents <br>
343 * - the component implementation defines one global object (which is generated
344 * when the library is loaded) <br>
346 * @subsection alihltcomponent-design-rules General design considerations
347 * The analysis code should be implemented in one or more destict class(es). A
348 * \em component should be implemented which interface the destict analysis code to the
349 * component interface. This component generates the analysis object dynamically. <br>
351 * Assume you have an implemetation <tt> AliHLTDetMyAnalysis </tt>, another class <tt>
352 * AliHLTDetMyAnalysisComponent </tt> contains:
355 * AliHLTDetMyAnalysis* fMyAnalysis; //!
357 * The object should then be instantiated in the DoInit handler of
358 * <tt>AliHLTDetMyAnalysisComponent </tt>, and cleaned in the DoDeinit handler.
361 * - avoid big static arrays in the component, allocate the memory at runtime
362 * - allocate all kind of complex data members (like classes, ROOT TObjects of
363 * any kind) dynamically in DoInit and clean up in DoDeinit
365 * @section alihlt_component_arguments Default arguments
366 * The component base class provides some default arguments:
367 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
368 * \li -loglevel=level <br>
369 * \li -object-compression=level <br>
370 * compression level for ROOT objects, default is defined by
371 * @ref ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION
373 * @ingroup alihlt_component
374 * @section alihltcomponent-members Class members
376 class AliHLTComponent : public AliHLTLogging {
378 /** standard constructor */
380 /** standard destructor */
381 virtual ~AliHLTComponent();
383 /** component type definitions */
384 enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 };
387 * Init function to prepare data processing.
388 * Initialization of common data structures for a sequence of events.
389 * The call is redirected to the internal method DoInit which can be
390 * overridden by the child class.
391 * During Init also the environment structure is passed to the component.
392 * @param comenv environment pointer with environment dependent function
394 * @param environParam additional parameter for function calls, the pointer
396 * @param argc size of the argument array
397 * @param argv augment array for component initialization
399 virtual int Init( const AliHLTAnalysisEnvironment* comenv, void* environParam, int argc, const char** argv );
402 * Clean-up function to terminate data processing.
403 * Clean-up of common data structures after data processing.
404 * The call is redirected to the internal method @ref DoDeinit which can be
405 * overridden by the child class.
407 virtual int Deinit();
410 * Processing of one event.
411 * The method is the entrance of the event processing. The parameters are
412 * cached for uses with the high-level interface and the DoProcessing
413 * implementation is called.
420 * @param outputBlockCnt out: size of the output block array, set by the component
421 * @param outputBlocks out: the output block array is allocated internally
423 * @return neg. error code if failed
425 int ProcessEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
426 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
427 AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt,
428 AliHLTComponentBlockData*& outputBlocks,
429 AliHLTComponentEventDoneData*& edd );
432 * Internal processing of one event.
433 * The method is pure virtual and implemented by the child classes
434 * - @ref AliHLTProcessor
435 * - @ref AliHLTDataSource
436 * - @ref AliHLTDataSink
443 * @param outputBlocks out: the output block array is allocated internally
445 * @return neg. error code if failed
447 virtual int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
448 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
449 AliHLTUInt32_t& size,
450 AliHLTComponentBlockDataList& outputBlocks,
451 AliHLTComponentEventDoneData*& edd ) = 0;
455 * The function must not be called when running in AliRoot unless it it
456 * really wanted. The CDB path will be set to the specified path, which might
457 * override the path initialized at the beginning of the AliRoot reconstruction.
459 * The method is used from the external interface in order to set the correct
460 * path when running on-line. The function also initializes the function
461 * callback for setting the run no during operation.
463 * A separation of library and component handling is maybe appropriate in the
464 * future. Using the global component handler here is maybe not the cleanest
466 * @param cdbPath path of the CDB
467 * @param pHandler the component handler used for llibrary handling.
469 int InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler);
472 * Set the run no for the CDB.
473 * The function must not be called when running in AliRoot unless it it
474 * really wanted. The CDB path will be set to the specified path, which might
475 * override the run no initialized at the beginning of the AliRoot reconstruction.
476 * InitCDB() has to be called before in order to really change the CDB settings.
478 * The method is used from the external interface in order to set the correct
479 * path when running on-line.
481 int SetCDBRunNo(int runNo);
484 * Set the run description.
485 * The run description is set before the call of Init() -> DoInit().
486 * @note: This functionality has been added in Juli 2008. The transmission of
487 * run properties by a special SOR (SOD event in DAQ terminalogy but this was
488 * changed after the HLT interface was designed) event is not sufficient because
489 * the data might be needed already in the DoInit handler of the component.
490 * @param desc run descriptor, currently only the run no member is used
491 * @param runType originally, run type was supposed to be a number and part
492 * of the run descriptor. But it was defined as string later
494 int SetRunDescription(const AliHLTRunDesc* desc, const char* runType);
497 * Set the component description.
498 * The description string can contain tokens separated by blanks, a token
499 * consists of a key and an optional value separated by '='.
501 * \li -chainid=id string id within the chain of the instance
503 * @param desc component description
505 int SetComponentDescription(const char* desc);
508 * Set the running environment for the component.
509 * Originally, the environment was set in the Init function. However, the setup of
510 * the CDB is required before. In order to have proper logging functionality, the
511 * environment is required.
512 * @param comenv environment pointer with environment dependent function
514 * @param environParam additional parameter for function calls, the pointer
517 int SetComponentEnvironment(const AliHLTAnalysisEnvironment* comenv, void* environParam);
519 // Information member functions for registration.
522 * Get the type of the component.
523 * The function is pure virtual and must be implemented by the child class.
524 * @return component type id
526 virtual TComponentType GetComponentType() = 0; // Source, sink, or processor
529 * Get the id of the component.
530 * Each component is identified by a unique id.
531 * The function is pure virtual and must be implemented by the child class.
532 * @return component id (string)
534 virtual const char* GetComponentID() = 0;
537 * Get the input data types of the component.
538 * The function is pure virtual and must be implemented by the child class.
539 * @return list of data types in the vector reference
541 virtual void GetInputDataTypes( AliHLTComponentDataTypeList& ) = 0;
544 * Get the output data type of the component.
545 * The function is pure virtual and must be implemented by the child class.
546 * @return output data type
548 virtual AliHLTComponentDataType GetOutputDataType() = 0;
551 * Get the output data types of the component.
552 * The function can be implemented to indicate multiple output data types
553 * in the target array.
554 * @ref GetOutputDataType must return @ref kAliHLTMultipleDataType in order
555 * to invoke this method.
556 * @param tgtList list to receive the data types
557 * @return no of output data types, data types in the target list
559 virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
562 * Get a ratio by how much the data volume is shrunken or enhanced.
563 * The function is pure virtual and must be implemented by the child class.
564 * @param constBase <i>return</i>: additive part, independent of the
566 * @param inputMultiplier <i>return</i>: multiplication ratio
567 * @return values in the reference variables
569 virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0;
573 * Each component must implement a spawn function to create a new instance of
574 * the class. Basically the function must return <i>new <b>my_class_name</b></i>.
575 * @return new class instance
577 virtual AliHLTComponent* Spawn() = 0;
580 * Find matching data types between this component and a consumer component.
581 * Currently, a component can produce only one type of data. This restriction is most
582 * likely to be abolished in the future.
583 * @param pConsumer a component and consumer of the data produced by this component
584 * @param tgtList reference to a vector list to receive the matching data types.
585 * @return >= 0 success, neg. error code if failed
587 int FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList);
590 * Set the global component handler.
591 * The static method is needed for the automatic registration of components.
593 static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0);
596 * Clear the global component handler.
597 * The static method is needed for the automatic registration of components.
599 static int UnsetGlobalComponentHandler();
602 * Helper function to convert the data type to a string.
603 * @param type data type structure
604 * @param mode 0 print string origin:type <br>
608 static string DataType2Text( const AliHLTComponentDataType& type, int mode=0);
611 * Calculate a CRC checksum of a data buffer.
612 * Polynomial for the calculation is 0xD8.
614 static AliHLTUInt32_t CalculateChecksum(const AliHLTUInt8_t* buffer, int size);
617 * Helper function to print content of data type.
619 static void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL);
622 * helper function to initialize AliHLTComponentEventData structure
624 static void FillEventData(AliHLTComponentEventData& evtData);
627 * Print info on an AliHLTComponentDataType structure
628 * This is just a helper function to examine an @ref AliHLTComponentDataType
631 static void PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt);
634 * Fill AliHLTComponentBlockData structure with default values.
635 * @param blockData reference to data structure
637 static void FillBlockData( AliHLTComponentBlockData& blockData );
640 * Fill AliHLTComponentShmData structure with default values.
641 * @param shmData reference to data structure
643 static void FillShmData( AliHLTComponentShmData& shmData );
646 * Fill AliHLTComponentDataType structure with default values.
647 * @param dataType reference to data structure
649 static void FillDataType( AliHLTComponentDataType& dataType );
652 * Copy data type structure
653 * Copies the value an AliHLTComponentDataType structure to another one
654 * @param[out] tgtdt target structure
655 * @param[in] srcdt source structure
657 static void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt);
660 * Set the ID and Origin of an AliHLTComponentDataType structure.
661 * The function sets the fStructureSize member and copies the strings
662 * to the ID and Origin. Only characters from the valid part of the string
663 * are copied, the rest is filled with 0's. <br>
664 * Please note that the fID and fOrigin members are not strings, just arrays of
665 * chars of size @ref kAliHLTComponentDataTypefIDsize and
666 * @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with
667 * a terminating zero. <br>
668 * It is possible to pass NULL pointers as id or origin argument, in that case they
670 * @param tgtdt target data type structure
671 * @param id ID string
672 * @param origin Origin string
674 static void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin);
677 * Set the ID and Origin of an AliHLTComponentDataType structure.
678 * Given the fact that the data type ID is 64bit wide and origin 32, this helper
679 * function sets the data type from those two parameters.
680 * @param dt target data type structure
682 * @param orig 32bit origin
684 static void SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t orig);
687 * Extract a component table entry from the payload buffer.
688 * The entry consists of the AliHLTComponentTableEntry structure, the array of
689 * parents and a description string of the format 'chain-id{component-id:component-args}'.
690 * The function fills all the variables after a consistency check.
692 static int ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
693 string& chainId, string& compId, string& compParam,
694 vector<AliHLTUInt32_t>& parents);
696 * Stopwatch type for benchmarking.
698 enum AliHLTStopwatchType {
699 /** total time for event processing */
701 /** detector algorithm w/o interface callbacks */
707 /** number of types */
712 * Helper class for starting and stopping a stopwatch.
713 * The guard can be used by instantiating an object in a function. The
714 * specified stopwatch is started and the previous stopwatch put on
715 * hold. When the function is terminated, the object is deleted automatically
716 * deleted, stopping the stopwatch and starting the one on hold.<br>
717 * \em IMPORTANT: never create dynamic objects from this guard as this violates
718 * the idea of a guard.
720 class AliHLTStopwatchGuard {
722 /** standard constructor (not for use) */
723 AliHLTStopwatchGuard();
725 AliHLTStopwatchGuard(TStopwatch* pStart);
726 /** copy constructor (not for use) */
727 AliHLTStopwatchGuard(const AliHLTStopwatchGuard&);
728 /** assignment operator (not for use) */
729 AliHLTStopwatchGuard& operator=(const AliHLTStopwatchGuard&);
731 ~AliHLTStopwatchGuard();
735 * Hold the previous guard for the existence of this guard.
736 * Checks whether this guard controls a new stopwatch. In that case, the
737 * previous guard and its stopwatch are put on hold.
738 * @param pSucc instance of the stopwatch of the new guard
739 * @return 1 if pSucc is a different stopwatch which should
741 * 0 if it controls the same stopwatch
743 int Hold(TStopwatch* pSucc);
746 * Resume the previous guard.
747 * Checks whether the peceeding guard controls a different stopwatch. In that
748 * case, the its stopwatch is resumed.
749 * @param pSucc instance of the stopwatch of the new guard
750 * @return 1 if pSucc is a different stopwatch which should
752 * 0 if it controls the same stopwatch
754 int Resume(TStopwatch* pSucc);
756 /** the stopwatch controlled by this guard */
757 TStopwatch* fpStopwatch; //!transient
759 /** previous stopwatch guard, put on hold during existence of the guard */
760 AliHLTStopwatchGuard* fpPrec; //!transient
762 /** active stopwatch guard */
763 static AliHLTStopwatchGuard* fgpCurrent; //!transient
767 * Set a stopwatch for a given purpose.
768 * @param pSW stopwatch object
769 * @param type type of the stopwatch
771 int SetStopwatch(TObject* pSW, AliHLTStopwatchType type=kSWBase);
774 * Init a set of stopwatches.
775 * @param pStopwatches object array of stopwatches
777 int SetStopwatches(TObjArray* pStopwatches);
780 * Customized logging function.
781 * The chain id, component id and pointer is added at the beginning of each message.
783 int LoggingVarargs(AliHLTComponentLogSeverity severity,
784 const char* originClass, const char* originFunc,
785 const char* file, int line, ... ) const;
788 * Get size of last serialized object.
789 * During PushBack, TObjects are serialized in a separate buffer. The
790 * size of the last object can be retrieved by this function.
792 * This might be especially useful for PushBack failures caused by too
793 * small output buffer.
795 int GetLastObjectSize() const {return fLastObjectSize;}
800 * Default method for the internal initialization.
801 * The method is called by @ref Init
803 virtual int DoInit( int argc, const char** argv );
806 * Default method for the internal clean-up.
807 * The method is called by @ref Deinit
809 virtual int DoDeinit();
812 * Reconfigure the component.
813 * The method is called when an event of type @ref kAliHLTDataTypeComConf
814 * {COM_CONF:PRIV} is received by the component. If the event is sent as
815 * part of a normal event, the component configuration is called first.
817 * The CDB path parameter specifies the path in the CDB, i.e. without
818 * leading absolute path of the CDB location. The framework might also
819 * provide the id of the component in the analysis chain.
821 * The actual sequence of configuration depends on the component. As a
822 * general rule, the component should load the specific OCDB object if
823 * provided as parameter, and load the default objects if the parameter
824 * is NULL. However, other schemes are possible. See @ref
826 * \b Note: The CDB will be initialized by the framework, either already set
827 * from AliRoot or from the wrapper interface during initialization.
829 * @param cdbEntry path of the cdbEntry
830 * @param chainId the id/name of the component in the current analysis
831 * chain. This is not necessarily the same as what is
832 * returned by the GetComponentID() method.
833 * @note both parameters can be NULL, check before usage
835 virtual int Reconfigure(const char* cdbEntry, const char* chainId);
838 * Read the Preprocessor values.
839 * The function is invoked when the component is notified about available/
840 * updated data points from the detector Preprocessors. The 'modules'
841 * argument contains all detectors for which the Preprocessors have
842 * updated data points. The component has to implement the CDB access to
843 * get the desired data points.
844 * @param modules detectors for which the Preprocessors have updated
845 * data points: TPC, TRD, ITS, PHOS, MUON, or ALL if
846 * no argument was received.
847 * @return neg. error code if failed
849 virtual int ReadPreprocessorValues(const char* modules);
852 * Child implementation to scan a number of configuration arguments.
853 * The method is invoked by the framework in conjunction with the
854 * common framework functions ConfigureFromArgumentString and
855 * ConfigureFromCDBTObjString.
856 * Function needs to scan the argument and optional additional
857 * parameters and returns the number of elements in the array which
861 * @return number of arguments which have been scanned or neg error
862 * code if failed <br>
863 * \li -EINVAL unknown argument
864 * \li -EPROTO protocol error, e.g. missing parameter
866 virtual int ScanConfigurationArgument(int argc, const char** argv);
869 * Custom handler for the SOR event.
870 * Is invoked from the base class if an SOR event is in the block list.
871 * The handler is called before the processing function. The processing
872 * function is skipped if there are no other data blocks available.
874 * The SOR event is generated by the PubSub framework in response to
875 * the DAQ start of data (SOD - has been renamed after HLT interface
876 * was designed). The SOD event consists of 3 blocks:
877 * - ::kAliHLTDataTypeEvent block: spec ::gkAliEventTypeStartOfRun
878 * - SOD block of type ::kAliHLTDataTypeSOR, payload: AliHLTRunDesc struct
879 * - run type block ::kAliHLTDataTypeRunType, payload: run type string
881 * Run properties can be retrieved by getters like GetRunNo().
882 * @return neg. error code if failed
884 virtual int StartOfRun();
887 * Custom handler for the EOR event.
888 * Is invoked from the base class if an EOR event is in the block list.
889 * The handler is called before the processing function. The processing
890 * function is skipped if there are no other data blocks available.
892 * See StartOfRun() for more comments of the sequence of steering events.
894 * @return neg. error code if failed
896 virtual int EndOfRun();
899 * Check whether a component requires all steering blocks.
900 * Childs can overload in order to indicate that they want to
901 * receive also the steering data blocks. There is also the
902 * possibility to add the required data types to the input
903 * data type list in GetInputDataTypes().
905 virtual bool RequireSteeringBlocks() const {return false;}
908 * General memory allocation method.
909 * All memory which is going to be used 'outside' of the interface must
910 * be provided by the framework (online or offline).
911 * The method is redirected to a function provided by the current
912 * framework. Function pointers are transferred via the @ref
913 * AliHLTAnalysisEnvironment structure.
915 void* AllocMemory( unsigned long size );
918 * Helper function to create a monolithic BlockData description block out
919 * of a list BlockData descriptors.
920 * For convenience, inside the interface vector lists are used, to make the
921 * interface pure C style, monilithic blocks must be exchanged.
922 * The method is redirected to a function provided by the current
923 * framework. Function pointers are transferred via the @ref
924 * AliHLTAnalysisEnvironment structure.
926 int MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
927 AliHLTComponentBlockData** outputBlocks );
930 * Fill the EventDoneData structure.
931 * The method is redirected to a function provided by the current
932 * framework. Function pointers are transferred via the @ref
933 * AliHLTAnalysisEnvironment structure.
935 int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd );
938 * Allocate an EventDoneData structure for the current event .
939 * The method allocates the memory internally and does not interact with the current Framework.
940 * The allocated data structure is empty initially and can be filled by calls to the
941 * @ref PushEventDoneData method. The memory will be automatically released after the event has been processed.
944 int ReserveEventDoneData( unsigned long size );
947 * Push a 32 bit word of data into event done data for the current event which
948 * has previously been allocated by the @ref ReserveEventDoneData method.
950 int PushEventDoneData( AliHLTUInt32_t eddDataWord );
953 * Release event done data previously reserved by @ref ReserveEventDoneData
955 void ReleaseEventDoneData();
958 * Get the pointer to the event done data available/built so far for the current event via
959 * @ref ReserveEventDoneData and @ref PushEventDoneData
961 AliHLTComponentEventDoneData* GetCurrentEventDoneData()
963 return fEventDoneData;
967 * Helper function to convert the data type to a string.
969 void DataType2Text(const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]) const;
972 * Loop through a list of component arguments.
973 * The list can be either an array of separated strings or one single
974 * string containing blank separated arguments, or both mixed.
975 * ScanConfigurationArgument() is called to allow the component to treat
976 * the individual arguments.
977 * @return neg. error code if failed
979 int ConfigureFromArgumentString(int argc, const char** argv);
982 * Read configuration objects from OCDB and configure from
983 * the content of TObjString entries.
984 * @param entries blank separated list of OCDB paths
985 * @return neg. error code if failed
987 int ConfigureFromCDBTObjString(const char* entries);
990 * Load specified entry from the OCDB and extract the object.
991 * The entry is explicitely unloaded from the cache before it is loaded.
992 * @param path path of the entry under to root of the OCDB
993 * @param version version of the entry
994 * @param subVersion subversion of the entry
996 TObject* LoadAndExtractOCDBObject(const char* path, int version = -1, int subVersion = -1);
1001 * @return value of the internal event counter
1003 int GetEventCount() const;
1006 * Get the number of input blocks.
1007 * @return number of input blocks
1009 int GetNumberOfInputBlocks() const;
1012 * Get id of the current event
1015 AliHLTEventID_t GetEventId() const;
1018 * Get the first object of a specific data type from the input data.
1019 * The High-level methods provide functionality to transfer ROOT data
1020 * structures which inherit from TObject.
1022 * The method looks for the first ROOT object of type dt in the input stream.
1023 * If also the class name is provided, the object is checked for the right
1024 * class type. The input data block needs a certain structure, namely the
1025 * buffer size as first word. If the cross check fails, the retrieval is
1026 * silently abandoned, unless the \em bForce parameter is set.<br>
1027 * \b Note: THE OBJECT MUST NOT BE DELETED by the caller.
1029 * If called without parameters, the function tries to create objects from
1030 * all available input blocks, also the ones of data type kAliHLTVoidDataType
1031 * which are not matched by kAliHLTAnyDataType.
1033 * @param dt data type of the object
1034 * @param classname class name of the object
1035 * @param bForce force the retrieval of an object, error messages
1036 * are suppressed if \em bForce is not set
1037 * @return pointer to @ref TObject, NULL if no objects of specified type
1040 const TObject* GetFirstInputObject(const AliHLTComponentDataType& dt=kAliHLTAllDataTypes,
1041 const char* classname=NULL,
1045 * Get the first object of a specific data type from the input data.
1046 * The High-level methods provide functionality to transfer ROOT data
1047 * structures which inherit from TObject.
1048 * The method looks for the first ROOT object of type specified by the ID and
1049 * Origin strings in the input stream.
1050 * If also the class name is provided, the object is checked for the right
1051 * class type. The input data block needs a certain structure, namely the
1052 * buffer size as first word. If the cross check fails, the retrieval is
1053 * silently abandoned, unless the \em bForce parameter is set.<br>
1054 * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
1055 * @param dtID data type ID of the object
1056 * @param dtOrigin data type origin of the object
1057 * @param classname class name of the object
1058 * @param bForce force the retrieval of an object, error messages
1059 * are suppressed if \em bForce is not set
1060 * @return pointer to @ref TObject, NULL if no objects of specified type
1063 const TObject* GetFirstInputObject(const char* dtID,
1064 const char* dtOrigin,
1065 const char* classname=NULL,
1069 * Get the next object of a specific data type from the input data.
1070 * The High-level methods provide functionality to transfer ROOT data
1071 * structures which inherit from TObject.
1072 * The method looks for the next ROOT object of type and class specified
1073 * to the previous @ref GetFirstInputObject call.<br>
1074 * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
1075 * @param bForce force the retrieval of an object, error messages
1076 * are suppressed if \em bForce is not set
1077 * @return pointer to @ref TObject, NULL if no more objects available
1079 const TObject* GetNextInputObject(int bForce=0);
1082 * Get data type of an input block.
1083 * Get data type of the object previously fetched via
1084 * GetFirstInputObject/NextInputObject or the last one if no object
1086 * @param pObject pointer to TObject
1087 * @return data specification, kAliHLTVoidDataSpec if failed
1089 AliHLTComponentDataType GetDataType(const TObject* pObject=NULL);
1092 * Get data specification of an input block.
1093 * Get data specification of the object previously fetched via
1094 * GetFirstInputObject/NextInputObject or the last one if no object
1096 * @param pObject pointer to TObject
1097 * @return data specification, kAliHLTVoidDataSpec if failed
1099 AliHLTUInt32_t GetSpecification(const TObject* pObject=NULL);
1102 * Get the first block of a specific data type from the input data.
1103 * The method looks for the first block of type dt in the input stream.
1104 * It is intended to be used within the high-level interface.<br>
1105 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
1107 * If called without parameters, the function works on all input blocks,
1108 * also the ones of data type kAliHLTVoidDataType which are not matched by
1109 * kAliHLTAnyDataType.
1111 * @param dt data type of the block
1112 * @return pointer to @ref AliHLTComponentBlockData
1114 const AliHLTComponentBlockData* GetFirstInputBlock(const AliHLTComponentDataType& dt=kAliHLTAllDataTypes);
1117 * Get the first block of a specific data type from the input data.
1118 * The method looks for the first block of type specified by the ID and
1119 * Origin strings in the input stream. It is intended
1120 * to be used within the high-level interface.<br>
1121 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
1122 * @param dtID data type ID of the block
1123 * @param dtOrigin data type origin of the block
1124 * @return pointer to @ref AliHLTComponentBlockData
1126 const AliHLTComponentBlockData* GetFirstInputBlock(const char* dtID,
1127 const char* dtOrigin);
1130 * Get input block by index.<br>
1131 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
1132 * @return pointer to AliHLTComponentBlockData, NULL if index out of range
1134 const AliHLTComponentBlockData* GetInputBlock(int index) const;
1137 * Get the next block of a specific data type from the input data.
1138 * The method looks for the next block of type and class specified
1139 * to the previous @ref GetFirstInputBlock call.
1140 * To be used within the high-level interface.<br>
1141 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
1143 const AliHLTComponentBlockData* GetNextInputBlock();
1146 * Get data specification of an input block.
1147 * Get data specification of the input block previously fetched via
1148 * GetFirstInputObject/NextInputObject or the last one if no block
1150 * @param pBlock pointer to input block
1151 * @return data specification, kAliHLTVoidDataSpec if failed
1153 AliHLTUInt32_t GetSpecification(const AliHLTComponentBlockData* pBlock);
1156 * Forward an input object to the output.
1157 * Forward the input block of an object previously fetched via
1158 * GetFirstInputObject/NextInputObject or the last one if no object
1160 * The block descriptor of the input block is forwarded to the
1161 * output block list.
1162 * @param pObject pointer to TObject
1163 * @return neg. error code if failed
1165 int Forward(const TObject* pObject);
1168 * Forward an input block to the output.
1169 * Forward the input block fetched via GetFirstInputObject/
1170 * NextInputBlock or the last one if no block specified.
1171 * The block descriptor of the input block is forwarded to the
1172 * output block list.
1173 * @param pBlock pointer to input block
1174 * @return neg. error code if failed
1176 int Forward(const AliHLTComponentBlockData* pBlock=NULL);
1179 * Insert an object into the output.
1180 * If header is specified, it will be inserted before the root object,
1181 * default is no header.
1182 * @param pObject pointer to root object
1183 * @param dt data type of the object
1184 * @param spec data specification
1185 * @param pHeader pointer to header
1186 * @param headerSize size of Header
1187 * @return neg. error code if failed
1189 int PushBack(TObject* pObject, const AliHLTComponentDataType& dt,
1190 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1191 void* pHeader=NULL, int headerSize=0);
1194 * Insert an object into the output.
1195 * If header is specified, it will be inserted before the root object,
1196 * default is no header.
1197 * @param pObject pointer to root object
1198 * @param dtID data type ID of the object
1199 * @param dtOrigin data type origin of the object
1200 * @param spec data specification
1201 * @param pHeader pointer to header
1202 * @param headerSize size of Header
1203 * @return neg. error code if failed
1205 int PushBack(TObject* pObject, const char* dtID, const char* dtOrigin,
1206 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1207 void* pHeader=NULL, int headerSize=0);
1210 * Insert an object into the output.
1211 * @param pBuffer pointer to buffer
1212 * @param iSize size of the buffer
1213 * @param dt data type of the object
1214 * @param spec data specification
1215 * @param pHeader pointer to header
1216 * @param headerSize size of Header
1217 * @return neg. error code if failed
1219 int PushBack(const void* pBuffer, int iSize, const AliHLTComponentDataType& dt,
1220 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1221 const void* pHeader=NULL, int headerSize=0);
1224 * Insert an object into the output.
1225 * @param pBuffer pointer to buffer
1226 * @param iSize size of the buffer
1227 * @param dtID data type ID of the object
1228 * @param dtOrigin data type origin of the object
1229 * @param spec data specification
1230 * @param pHeader pointer to header
1231 * @param headerSize size of Header
1232 * @return neg. error code if failed
1234 int PushBack(const void* pBuffer, int iSize, const char* dtID, const char* dtOrigin,
1235 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1236 const void* pHeader=NULL, int headerSize=0);
1239 * Estimate size of a TObject
1241 * @return buffer size in byte
1243 int EstimateObjectSize(TObject* pObject) const;
1246 * Create a memory file in the output stream.
1247 * This method creates a TFile object which stores all data in
1248 * memory instead of disk. The TFile object is published as binary data.
1249 * The instance can be used like a normal TFile object. The TFile::Close
1250 * or @ref CloseMemoryFile method has to be called in order to flush the
1253 * \b Note: The returned object is deleted by the framework.
1254 * @param capacity total size reserved for the memory file
1255 * @param dtID data type ID of the file
1256 * @param dtOrigin data type origin of the file
1257 * @param spec data specification
1258 * @return file handle, NULL if failed
1260 AliHLTMemoryFile* CreateMemoryFile(int capacity, const char* dtID, const char* dtOrigin,
1261 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
1264 * Create a memory file in the output stream.
1265 * This method creates a TFile object which stores all data in
1266 * memory instead of disk. The TFile object is published as binary data.
1267 * The instance can be used like a normal TFile object. The TFile::Close
1268 * or @ref CloseMemoryFile method has to be called in order to flush the
1271 * \b Note: The returned object is deleted by the framework.
1272 * @param capacity total size reserved for the memory file
1273 * @param dt data type of the file
1274 * @param spec data specification
1275 * @return file handle, NULL if failed
1277 AliHLTMemoryFile* CreateMemoryFile(int capacity,
1278 const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
1279 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
1282 * Create a memory file in the output stream.
1283 * This method creates a TFile object which stores all data in
1284 * memory instead of disk. The TFile object is published as binary data.
1285 * The instance can be used like a normal TFile object. The TFile::Close
1286 * or @ref CloseMemoryFile method has to be called in order to flush the
1289 * \b Note: The returned object is deleted by the framework.
1290 * @param dtID data type ID of the file
1291 * @param dtOrigin data type origin of the file
1292 * @param spec data specification
1293 * @param capacity fraction of the available output buffer size
1294 * @return file handle, NULL if failed
1296 AliHLTMemoryFile* CreateMemoryFile(const char* dtID, const char* dtOrigin,
1297 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1298 float capacity=1.0);
1301 * Create a memory file in the output stream.
1302 * This method creates a TFile object which stores all data in
1303 * memory instead of disk. The TFile object is published as binary data.
1304 * The instance can be used like a normal TFile object. The TFile::Close
1305 * or @ref CloseMemoryFile method has to be called in order to flush the
1308 * \b Note: The returned object is deleted by the framework.
1309 * @param dt data type of the file
1310 * @param spec data specification
1311 * @param capacity fraction of the available output buffer size
1312 * @return file handle, NULL if failed
1314 AliHLTMemoryFile* CreateMemoryFile(const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
1315 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1316 float capacity=1.0);
1319 * Write an object to memory file in the output stream.
1320 * @param pFile file handle
1321 * @param pObject pointer to root object
1322 * @param key key in ROOT file
1323 * @param option options, see TObject::Write
1324 * @return neg. error code if failed
1325 * - -ENOSPC no space left
1327 int Write(AliHLTMemoryFile* pFile, const TObject* pObject, const char* key=NULL, int option=TObject::kOverwrite);
1330 * Close object memory file.
1331 * @param pFile file handle
1332 * @return neg. error code if failed
1333 * - -ENOSPC buffer size too small
1335 int CloseMemoryFile(AliHLTMemoryFile* pFile);
1338 * Insert event-done data information into the output.
1339 * @param edd event-done data information
1341 int CreateEventDoneData(AliHLTComponentEventDoneData edd);
1344 * Get current run number
1346 AliHLTUInt32_t GetRunNo() const;
1349 * Get the current run type.
1351 AliHLTUInt32_t GetRunType() const;
1354 * Get the chain id of the component.
1356 const char* GetChainId() const {return fChainId.c_str();}
1359 * Check whether a combination of trigger classes is fired.
1360 * The expression can contain trigger class ids and logic operators
1361 * like &&, ||, !, and ^, and may be grouped by parentheses.
1362 * @param expression a logic expression of trigger class ids
1363 * @param trigData the trigger data data
1365 bool EvaluateCTPTriggerClass(const char* expression, AliHLTComponentTriggerData& trigData) const;
1368 * Check whether the current event is a valid data event.
1369 * @param pTgt optional pointer to get the event type
1370 * @return true if the current event is a real data event
1372 bool IsDataEvent(AliHLTUInt32_t* pTgt=NULL);
1375 * Set a bit to 1 in a readout list ( = AliHLTEventDDL )
1376 * -> enable DDL for readout
1377 * @param list readout list
1378 * @param ddlId DDL Id to be turned on ( Decimal )
1380 void EnableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const {
1381 SetDDLBit( list, ddlId, kTRUE );
1385 * Set a bit to 0 in a readout list ( = AliHLTEventDDL )
1386 * -> disable DDL for readout
1387 * @param list readout list
1388 * @param ddlId DDL Id to be turned on ( Decimal )
1390 void DisableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const {
1391 SetDDLBit( list, ddlId, kFALSE );
1395 * Set or unset bit a readout list ( = AliHLTEventDDL )
1396 * -> enable or disable DDL for readout
1397 * @param list readout list
1398 * @param ddlId DDL Id to be turned on ( Decimal )
1399 * @param state kTRUE sets it, kFALSE unsets it
1401 void SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const;
1404 * Get the first word of a detector, which has a set DDL bit.
1405 * Beware, this only works if DDLs of 1 detector are set. In the
1406 * case of the TPC and TOF, which use 8 and 3 words, the first
1408 * @param list readout list
1409 * @return returns the detector index, -1 if no bit is set
1410 * at all or several detectors (=error)
1412 Int_t GetFirstUsedDDLWord(AliHLTEventDDL &list) const;
1415 * Copy a struct from block data.
1416 * The function checks for block size and struct size. The least common
1417 * size will be copied to the target struct, remaining fields are initialized
1419 * The target struct must have a 32bit struct size indicator as first member.
1420 * @param pStruct target struct
1421 * @param iStructSize size of the struct
1422 * @param iBlockNo index of input block
1423 * @param structname name of the struct (log messages)
1424 * @param eventname name of the event (log messages)
1425 * @return size copied, neg. error if failed
1427 int CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo,
1428 const char* structname="", const char* eventname="");
1431 /** copy constructor prohibited */
1432 AliHLTComponent(const AliHLTComponent&);
1433 /** assignment operator prohibited */
1434 AliHLTComponent& operator=(const AliHLTComponent&);
1437 * Increment the internal event counter.
1438 * To be used by the friend classes AliHLTProcessor, AliHLTDataSource
1439 * and AliHLTDataSink.
1440 * @return new value of the internal event counter
1443 int IncrementEventCounter();
1446 * Find the first input block of specified data type beginning at index.
1447 * Input blocks containing a TObject have the size of the object as an
1448 * unsigned 32 bit number in the first 4 bytes. This has to match the block
1451 * kAliHLTAllDataTypes is a special data type which includes both
1452 * kAliHLTVoidDataType and kAliHLTAnyDataType.
1454 * @param dt data type
1455 * @param startIdx index to start the search
1456 * @param bObject check if this is an object
1457 * @return index of the block, -ENOENT if no block found
1461 int FindInputBlock(const AliHLTComponentDataType& dt, int startIdx=-1, int bObject=0) const;
1464 * Get index in the array of input bocks.
1465 * Calculate index and check integrety of a block data structure pointer.
1466 * @param pBlock pointer to block data
1467 * @return index of the block, -ENOENT if no block found
1471 int FindInputBlock(const AliHLTComponentBlockData* pBlock) const;
1474 * Create an object from a specified input block.
1475 * @param idx index of the input block
1476 * @param bForce force the retrieval of an object, error messages
1477 * are suppressed if \em bForce is not set
1478 * @return pointer to TObject, caller must delete the object after use
1482 TObject* CreateInputObject(int idx, int bForce=0);
1486 * Get object from the input block list. The methods first checks whether the
1487 * object was already created. If not, it is created by @ref CreateInputObject
1488 * and inserted into the list of objects.
1489 * @param idx index in the input block list
1490 * @param classname name of the class, object is checked for correct class
1492 * @param bForce force the retrieval of an object, error messages
1493 * are suppressed if \em bForce is not set
1494 * @return pointer to TObject
1498 TObject* GetInputObject(int idx, const char* classname=NULL, int bForce=0);
1501 * Clean the list of input objects.
1502 * Cleanup is done at the end of each event processing.
1504 int CleanupInputObjects();
1507 * Insert a buffer into the output block stream.
1508 * This is the only method to insert blocks into the output stream, called
1509 * from all types of the Pushback method. The actual data might have been
1510 * written to the output buffer already. In that case NULL can be provided
1511 * as buffer, only the block descriptor will be build. If a header is specified,
1512 * it will be inserted before the buffer, default is no header.
1513 * @param pBuffer pointer to buffer
1514 * @param iBufferSize size of the buffer in byte
1515 * @param dt data type
1516 * @param spec data specification
1517 * @param pHeader pointer to header
1518 * @param iHeaderSize size of Header
1519 * @return neg. error code if failed
1521 int InsertOutputBlock(const void* pBuffer, int iBufferSize,
1522 const AliHLTComponentDataType& dt,
1523 AliHLTUInt32_t spec,
1524 const void* pHeader=NULL, int iHeaderSize=0);
1527 * Add a component statistics block to the output.
1528 * @return size of the added data
1530 int AddComponentStatistics(AliHLTComponentBlockDataList& blocks,
1531 AliHLTUInt8_t* buffer,
1532 AliHLTUInt32_t bufferSize,
1533 AliHLTUInt32_t offset,
1534 AliHLTComponentStatisticsList& stats) const;
1537 * Add a component table entry (descriptor) to the output
1538 * This is done at SOR/EOR. The component table is a list of chain ids
1539 * and 32bit ids calculated by a crc algorithm from the chian id. This
1540 * allows to tag data blocks with the id number rather than the string.
1542 * The kAliHLTDataTypeComponentTable data block currently has the string
1543 * as payload and the crc id as specification.
1544 * @return size of the added data
1546 int AddComponentTableEntry(AliHLTComponentBlockDataList& blocks,
1547 AliHLTUInt8_t* buffer,
1548 AliHLTUInt32_t bufferSize,
1549 AliHLTUInt32_t offset,
1550 const vector<AliHLTUInt32_t>& parents) const;
1553 * Scan the ECS parameter string.
1554 * The framework provides both the parameters of CONFIGURE and ENGAGE
1555 * in one string in a special data block kAliHLTDataTypeECSParam
1556 * {ECSPARAM:PRIV}. The general format is
1557 * <command>;<parameterkey>=<parametervalue>;<parameterkey>=<parametervalue>;...
1559 int ScanECSParam(const char* ecsParam);
1562 * The trigger classes are determined from the trigger and propagated by
1563 * ECS as part of the ENGAGE command parameter which is sent through the
1564 * framework during the SOR event. This function treats the value of the
1565 * parameter key CTP_TRIGGER_CLASS.
1567 int InitCTPTriggerClasses(const char* ctpString);
1569 /** The global component handler instance */
1570 static AliHLTComponentHandler* fgpComponentHandler; //! transient
1572 /** The environment where the component is running in */
1573 AliHLTAnalysisEnvironment fEnvironment; // see above
1575 /** Set by ProcessEvent before the processing starts */
1576 AliHLTEventID_t fCurrentEvent; // see above
1578 /** internal event no */
1579 int fEventCount; // see above
1581 /** the number of failed events */
1582 int fFailedEvents; // see above
1584 /** event data struct of the current event under processing */
1585 AliHLTComponentEventData fCurrentEventData; // see above
1587 /** array of input data blocks of the current event */
1588 const AliHLTComponentBlockData* fpInputBlocks; //! transient
1590 /** index of the current input block */
1591 int fCurrentInputBlock; // see above
1593 /** data type of the last block search */
1594 AliHLTComponentDataType fSearchDataType; // see above
1596 /** name of the class for the object to search for */
1597 string fClassName; // see above
1599 /** array of generated input objects */
1600 TObjArray* fpInputObjects; //! transient
1602 /** the output buffer */
1603 AliHLTUInt8_t* fpOutputBuffer; //! transient
1605 /** size of the output buffer */
1606 AliHLTUInt32_t fOutputBufferSize; // see above
1608 /** size of data written to output buffer */
1609 AliHLTUInt32_t fOutputBufferFilled; // see above
1611 /** list of ouput block data descriptors */
1612 AliHLTComponentBlockDataList fOutputBlocks; // see above
1614 /** stopwatch array */
1615 TObjArray* fpStopwatches; //! transient
1617 /** array of memory files AliHLTMemoryFile */
1618 AliHLTMemoryFilePList fMemFiles; //! transient
1620 /** descriptor of the current run */
1621 AliHLTRunDesc* fpRunDesc; //! transient
1623 /** the current DDL list */
1624 AliHLTEventDDL* fpDDLList; //! transient
1626 /** external fct to set CDB run no, indicates external CDB initialization */
1627 void (*fCDBSetRunNoFunc)(); //! transient
1629 /** id of the component in the analysis chain */
1630 string fChainId; //! transient
1632 /** crc value of the chainid, used as a 32bit id */
1633 AliHLTUInt32_t fChainIdCrc; //! transient
1635 /** optional benchmarking for the component statistics */
1636 TStopwatch* fpBenchmark; //! transient
1638 /** component requires steering data blocks */
1639 bool fRequireSteeringBlocks; //! transient
1641 /** current event type */
1642 AliHLTUInt32_t fEventType; //! transient
1644 /** component arguments */
1645 string fComponentArgs; //! transient
1648 /** event done data */
1649 AliHLTComponentEventDoneData* fEventDoneData; //! transient
1651 /** Reserved size of the memory stored at fEventDoneData */
1652 unsigned long fEventDoneDataSize; //! transient
1654 /** Comression level for ROOT objects */
1655 int fCompressionLevel; //! transient
1657 /** size of last PushBack-serialized object */
1658 int fLastObjectSize; //! transient
1660 /** array of trigger class descriptors */
1661 TObjArray* fpTriggerClasses; //! transient
1663 ClassDef(AliHLTComponent, 11)