]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTComponent.h
CMake: removing qpythia from the depedencies
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.h
CommitLineData
a655eae3 1//-*- Mode: C++ -*-
45c0a780 2// $Id$
f23a6e1a 3
4#ifndef ALIHLTCOMPONENT_H
5#define ALIHLTCOMPONENT_H
45c0a780 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 *
f23a6e1a 9
0007ed52 10// @file AliHLTComponent.h
11// @author Matthias Richter, Timm Steinbeck
12// @date
13// @brief Base class declaration for HLT components.
14// @note The class is both used in Online (PubSub) and Offline (AliRoot)
15// context
16
30338a30 17
b22e91eb 18/**
19 * @defgroup alihlt_component Component handling of the HLT module
45c0a780 20 * This section describes the the component base classes and handling for
21 * the HLT module.
22 *
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.
28 *
fb345ed7 29 * @section alihlt_component_implementation Component implementation
45c0a780 30 * AliHLTComponent provides the interface for all components, see there
31 * for details. Three types are provided:
32 * - AliHLTProcessor
33 * - AliHLTDataSource
34 * - AliHLTDataSink
35 *
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.
40 *
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.
50 *
51 * In both cases, the library must be loaded via the method
52 * <pre>
53 * AliHLTComponentHandler::LoadComponentLibraries()
54 * </pre>
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
57 * rootlogon.C).
58 *
59 *
b22e91eb 60 */
8ede8717 61
62#include <vector>
9ce4bf4a 63#include <string>
5ec8e281 64#include "AliHLTLogging.h"
f23a6e1a 65#include "AliHLTDataTypes.h"
1ac82ce6 66#include "AliHLTCommonCDBEntries.h"
f23a6e1a 67
2d7ff710 68/* Matthias Dec 2006
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
72 */
73typedef AliHLTComponentLogSeverity AliHLTComponent_LogSeverity;
74typedef AliHLTComponentEventData AliHLTComponent_EventData;
75typedef AliHLTComponentShmData AliHLTComponent_ShmData;
76typedef AliHLTComponentDataType AliHLTComponent_DataType;
77typedef AliHLTComponentBlockData AliHLTComponent_BlockData;
78typedef AliHLTComponentTriggerData AliHLTComponent_TriggerData;
79typedef AliHLTComponentEventDoneData AliHLTComponent_EventDoneData;
80
f23a6e1a 81class AliHLTComponentHandler;
a655eae3 82class TObjArray;
5ef2a37b 83class TMap;
90ebac25 84class TStopwatch;
cc095616 85class TUUID;
2be3f004 86class AliHLTComponent;
79c114b5 87class AliHLTMemoryFile;
adb91bc3 88class AliHLTCTPData;
89413559 89class AliHLTReadoutList;
16e6f752 90class AliHLTCDHWrapper;
f23a6e1a 91
c515df4c 92using std::vector;
93
2be3f004 94/** list of component data type structures */
95typedef vector<AliHLTComponentDataType> AliHLTComponentDataTypeList;
96/** list of component block data structures */
97typedef vector<AliHLTComponentBlockData> AliHLTComponentBlockDataList;
a0aeb701 98/** list of component statistics struct */
99typedef vector<AliHLTComponentStatistics> AliHLTComponentStatisticsList;
2be3f004 100/** list of component pointers */
101typedef vector<AliHLTComponent*> AliHLTComponentPList;
102/** list of memory file pointers */
103typedef vector<AliHLTMemoryFile*> AliHLTMemoryFilePList;
104
bfccbf68 105/**
106 * @class AliHLTComponent
107 * Base class of HLT data processing components.
108 * The class provides a common interface for HLT data processing components.
109 * The interface can be accessed from the online HLT framework or the AliRoot
110 * offline analysis framework.
a655eae3 111 * @section alihltcomponent-properties Component identification and properties
112 * Each component must provide a unique ID, input and output data type indications,
113 * and a spawn function.
114 * @subsection alihltcomponent-req-methods Required property methods
115 * - @ref GetComponentID
116 * - @ref GetInputDataTypes (see @ref alihltcomponent-type for default
117 * implementations.)
118 * - @ref GetOutputDataType (see @ref alihltcomponent-type for default
119 * implementations.)
120 * - @ref GetOutputDataSize (see @ref alihltcomponent-type for default
121 * implementations.)
122 * - @ref Spawn
bfccbf68 123 *
a655eae3 124 * @subsection alihltcomponent-opt-mehods Optional handlers
125 * - @ref DoInit
126 * - @ref DoDeinit
de6593d0 127 * - @ref GetOutputDataTypes
128 * If the component has multiple output data types @ref GetOutputDataType
129 * should return @ref kAliHLTMultipleDataType. The framework will invoke
130 * @ref GetOutputDataTypes, a list can be filled.
02bc7a5f 131 * - @ref Reconfigure
132 * This function is invoked by the framework on a special event which
133 * triggers the reconfiguration of the component.
a655eae3 134 *
135 * @subsection alihltcomponent-processing-mehods Data processing
136 *
137 *
138 * @subsection alihltcomponent-type Component type
139 * Components can be of type
90ebac25 140 * - @ref kSource components which only produce data
141 * - @ref kProcessor components which consume and produce data
142 * - @ref kSink components which only consume data
a655eae3 143 *
144 * where data production and consumption refer to the analysis data stream. In
145 * order to indicate the type, a child component can overload the
146 * @ref GetComponentType function.
147 * @subsubsection alihltcomponent-type-std Standard implementations
148 * Components in general do not need to implement this function, standard
149 * implementations of the 3 types are available:
150 * - AliHLTDataSource for components of type @ref kSource <br>
151 * All types of data sources can inherit from AliHLTDataSource and must
152 * implement the @ref AliHLTDataSource::GetEvent method. The class
153 * also implements a standard method for @ref GetInputDataTypes.
154 *
155 * - AliHLTProcessor for components of type @ref kProcessor <br>
48abe484 156 * All types of data processors can inherit from AliHLTProcessor and must
a655eae3 157 * implement the @ref AliHLTProcessor::DoEvent method.
158 *
159 * - AliHLTDataSink for components of type @ref kSink <br>
48abe484 160 * All types of data processors can inherit from AliHLTDataSink and must
a655eae3 161 * implement the @ref AliHLTDataSink::DumpEvent method. The class
162 * also implements a standard method for @ref GetOutputDataType and @ref
163 * GetOutputDataSize.
164 *
165 * @subsection alihltcomponent-environment Running environment
bfccbf68 166 *
167 * In order to adapt to different environments (on-line/off-line), the component
168 * gets an environment structure with function pointers. The base class provides
169 * member functions for those environment dependend functions. The member
170 * functions are used by the component implementation and are re-mapped to the
171 * corresponding functions.
b6800be0 172 *
a655eae3 173 * @section alihltcomponent-interfaces Component interfaces
174 * Each of the 3 standard component base classes AliHLTProcessor, AliHLTDataSource
175 * and AliHLTDataSink provides it's own processing method (see
176 * @ref alihltcomponent-type-std), which splits into a high and a low-level
177 * method. For the @ref alihltcomponent-low-level-interface, all parameters are
48abe484 178 * shipped as function arguments, the component is supposed to write data to the
a655eae3 179 * output buffer and handle all block descriptors.
180 * The @ref alihltcomponent-high-level-interface is the standard processing
181 * method and will be used whenever the low-level method is not overloaded.
182 *
b6800be0 183 * In both cases it is necessary to calculate/estimate the size of the output
184 * buffer before the processing. Output buffers can never be allocated inside
185 * the component because of the push-architecture of the HLT.
186 * For that reason the @ref GetOutputDataSize function should return a rough
187 * estimatian of the data to be produced by the component. The component is
188 * responsible for checking the memory size and must return -ENOSPC if the
48abe484 189 * available buffer is too small, and update the estimator respectively. The
b6800be0 190 * framework will allocate a buffer of appropriate size and call the processing
191 * again.
192 *
02bc7a5f 193 * @subsection alihltcomponent-error-codes Return values/Error codes
b426991e 194 * For return codes, the following scheme applies:
195 * - The data processing methods have to indicate error conditions by a negative
196 * error/return code. Preferably the system error codes are used like
197 * e.g. -EINVAL. This requires to include the header
198 * <pre>
616eb170 199 * \#include \<cerrno\>
b426991e 200 * </pre>
02bc7a5f 201 * This schema aplies to all interface functions of the component base class.
202 * For data processing it is as follows:
b426991e 203 * - If no suitable input block could be found (e.g. no clusters for the TPC cluster
204 * finder) set size to 0, block list is empty, return 0
205 * - If no ususable or significant signal could be found in the input blocks
206 * return an empty output block, set size accordingly, and return 0. An empty output
207 * block here could be either a real empty one of size 0 (in which case size also
208 * would have to be set to zero) or a block filled with just the minimum necessary
209 * accounting/meta-structures. E.g. in the TPC
210 *
a655eae3 211 * @subsection alihltcomponent-high-level-interface High-level interface
212 * The high-level component interface provides functionality to exchange ROOT
213 * structures between components. In contrast to the
214 * @ref alihltcomponent-low-level-interface, a couple of functions can be used
215 * to access data blocks of the input stream
216 * and send data blocks or ROOT TObject's to the output stream. The functionality
217 * is hidden from the user and is implemented by using ROOT's TMessage class.
218 *
219 * @subsubsection alihltcomponent-high-level-int-methods Interface methods
220 * The interface provides a couple of methods in order to get objects from the
221 * input, data blocks (non TObject) from the input, and to push back objects and
222 * data blocks to the output. For convenience there are several functions of
223 * identical name (and similar behavior) with different parameters defined.
224 * Please refer to the function documentation.
225 * - @ref GetNumberOfInputBlocks <br>
226 * return the number of data blocks in the input stream
227 * - @ref GetFirstInputObject <br>
228 * get the first object of a specific data type
229 * - @ref GetNextInputObject <br>
230 * get the next object of same data type as last GetFirstInputObject/Block call
231 * - @ref GetFirstInputBlock <br>
232 * get the first block of a specific data type
233 * - @ref GetNextInputBlock <br>
234 * get the next block of same data type as last GetFirstInputBlock/Block call
235 * - @ref PushBack <br>
236 * insert an object or data buffer into the output
237 * - @ref CreateEventDoneData <br>
238 * add event information to the output
239 *
240 * In addition, the processing methods are simplified a bit by cutting out most of
79c114b5 241 * the parameters.
242 * @see
243 * - @ref AliHLTProcessor::DoEvent
244 * - @ref AliHLTDataSource::GetEvent
245 * - @ref AliHLTDataSink::DumpEvent
a655eae3 246 *
8451168b 247 * \em IMPORTANT: objects and block descriptors provided by the high-level interface
248 * <b>MUST NOT BE DELETED</b> by the caller.
249 *
a655eae3 250 * @subsubsection alihltcomponent-high-level-int-guidelines High-level interface guidelines
251 * - Structures must inherit from the ROOT object base class TObject in order be
252 * transported by the transportation framework.
253 * - all pointer members must be transient (marked <tt>//!</tt> behind the member
254 * definition), i.e. will not be stored/transported, or properly marked
255 * (<tt>//-></tt>) in order to call the streamer of the object the member is pointing
256 * to. The latter is not recomended. Structures to be transported between components
257 * should be streamlined.
258 * - no use of stl vectors/strings, use appropriate ROOT classes instead
259 *
260 * @subsection alihltcomponent-low-level-interface Low-level interface
261 * The low-level component interface consists of the specific data processing
262 * methods for @ref AliHLTProcessor, @ref AliHLTDataSource, and @ref AliHLTDataSink.
263 * - @ref AliHLTProcessor::DoEvent
264 * - @ref AliHLTDataSource::GetEvent
265 * - @ref AliHLTDataSink::DumpEvent
266 *
02bc7a5f 267 * The base class passes all relevant parameters for data access directly on to the
268 * component. Input blocks can be accessed by means of the array <tt> blocks </tt>.
269 * Output data are written directly to shared memory provided by the pointer
270 * <tt> outputPtr </tt> and output block descriptors are inserted directly to the
271 * list <tt> outputBlocks </tt>.
272 *
273 * \b NOTE: The high-level input data access methods can be used also from the low
274 * level interface. Also the PushBack functions can be used BUT ONLY if no data is
275 * written to the output buffer and no data block descriptors are inserted into the
276 * output block list.
277 *
278 * @section alihltcomponent-initialization Component initialization and configuration
279 * The component interface provides two optional methods for component initialization
280 * and configuration. The @ref DoInit function is called once before the processing.
281 * During the event processing, a special event can trigger a reconfiguration and the
282 * @ref Reconfigure method is called. There are three possible options of initialization
283 * and configuration:
284 * - default values: set directly in the source code
285 * - OCDB objects: all necessary information must be loaded from OCDB objects. The
286 * Offline Conditions Data Base stores objects specifically valid for individual runs
287 * or run ranges.
288 * - Component arguments: can be specified for every component in the chain
289 * configuration. The arguments can be used to override specific parameters of the
290 * component.
291 *
292 * As a general rule, the three options should be processed in that sequence, i.e
293 * default parameters might be overridden by OCDB configuration, and the latter one
294 * by component arguments.
295 *
296 * @subsection alihltcomponent-initialization-arguments Component arguments
297 * In normal operation, components are supposed to run without any additional argument,
298 * however such arguments can be useful for testing and debugging. The idea follows
299 * the format of command line arguments. A keyword is indicated by a dash and an
300 * optional argument might follow, e.g.:
301 * <pre>
302 * -argument1 0.5 -argument2
303 * </pre>
304 * In this case argument1 requires an additional parameter whereas argument2 does not.
305 * The arguments will be provided as an array of separated arguments.
306 *
307 * Component arguments can be classified into initialization arguments and configuration
308 * arguments. The latter are applicable for both the @ref DoInit and @ref Reconfigure
309 * method whereas initialization arguments are not applicable after DoInit.
310 *
311 * @subsection alihltcomponent-initialization-ocdb OCDB objects
312 * OCDB objects are ROOT <tt>TObjects</tt> and can be of any type. This is in particular
313 * useful for complex parameter sets. However in most cases, a simple approach of human
314 * readable command line arguments is appropriate. Such a string can be simply stored
315 * in a TObjString (take note that the TString does not derive from TObject). The
316 * same arguments as for the command line can be used. Take note that in the TObjString
317 * all arguments are separated by blanks, instead of being in an array of separate
318 * strings.
319 *
320 * The base class provides two functions regarding OCDB objects:
321 * - LoadAndExtractOCDBObject() loads the OCDB entry for the specified path and extracts
f651054f 322 * the TObject from it. An optional key allows to access
323 * a TObject within a TMap
02bc7a5f 324 * - ConfigureFromCDBTObjString() can load a number of OCDB objects and calls the
325 * argument parsing ConfigureFromArgumentString
326 *
327 *
328 * @subsection alihltcomponent-initialization-sequence Initialization sequence
329 * Using the approach of <tt>TObjString</tt>-type configuration objects allows to treat
330 * configuration from both @ref DoInit and @ref Reconfigure in the same way.
331 *
332 * The base class provides the function ConfigureFromArgumentString() which loops over
333 * all arguments and calls the child's method ScanConfigurationArgument(). Here the
334 * actual treatment of the argument and its parameters needs to be implemented.
335 * ConfigureFromArgumentString() can treat both arrays of arguments and arguments in
336 * one single string separated by blanks. The two options can be mixed.
337 *
f651054f 338 * A second base class function ConfigureFromCDBTObjString() allows to configure
02bc7a5f 339 * directly from a number of OCDB objects. This requires the entries to be of
340 * type TObjString and the child implementation of ScanConfigurationArgument().
f651054f 341 * The object can also be of type TMap with TObjStrings as key-value pairs. The
342 * key identifier can be chosen by the component implementation. Normally it will
343 * be the run type ("p","A-A", "p-A", ...) or e.g. the trigger code secified by
344 * ECS.
02bc7a5f 345 *
a655eae3 346 * @section alihltcomponent-handling Component handling
347 * The handling of HLT analysis components is carried out by the AliHLTComponentHandler.
348 * Component are registered automatically at load-time of the component shared library
349 * under the following suppositions:
350 * - the component library has to be loaded from the AliHLTComponentHandler using the
351 * @ref AliHLTComponentHandler::LoadLibrary method.
02bc7a5f 352 * - the library defines an AliHLTModuleAgent which registers all components.
353 * See AliHLTModuleAgent::RegisterComponents <br>
354 * or <br>
a655eae3 355 * - the component implementation defines one global object (which is generated
02bc7a5f 356 * when the library is loaded) <br>
a655eae3 357 *
358 * @subsection alihltcomponent-design-rules General design considerations
359 * The analysis code should be implemented in one or more destict class(es). A
360 * \em component should be implemented which interface the destict analysis code to the
361 * component interface. This component generates the analysis object dynamically. <br>
362 *
363 * Assume you have an implemetation <tt> AliHLTDetMyAnalysis </tt>, another class <tt>
364 * AliHLTDetMyAnalysisComponent </tt> contains:
365 * <pre>
366 * private:
367 * AliHLTDetMyAnalysis* fMyAnalysis; //!
368 * </pre>
369 * The object should then be instantiated in the DoInit handler of
370 * <tt>AliHLTDetMyAnalysisComponent </tt>, and cleaned in the DoDeinit handler.
371 *
372 * Further rules:
373 * - avoid big static arrays in the component, allocate the memory at runtime
02bc7a5f 374 * - allocate all kind of complex data members (like classes, ROOT TObjects of
375 * any kind) dynamically in DoInit and clean up in DoDeinit
a655eae3 376 *
9ace7282 377 * @section alihlt_component_arguments Default arguments
378 * The component base class provides some default arguments:
379 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
66108417 380 * \li -loglevel=level <br>
9ace7282 381 * \li -object-compression=level <br>
382 * compression level for ROOT objects, default is defined by
383 * @ref ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION
9d4d4b02 384 * \li -pushback-period=period <br>
385 * scale down for PushBack of objects, shipped only for one event
386 * every <i>period</i> seconds
7e0dd7eb 387 * \li -event-module=number <br>
388 * This option reduces the event processing rate by processing only n'th event
389 * based on the modulo number <i>number</i>. The scale down should be about
390 * 1/<i>number</i>, where <i>number</i> is a positive integer.
9ace7282 391 *
b22e91eb 392 * @ingroup alihlt_component
a655eae3 393 * @section alihltcomponent-members Class members
bfccbf68 394 */
5ec8e281 395class AliHLTComponent : public AliHLTLogging {
f23a6e1a 396 public:
bfccbf68 397 /** standard constructor */
f23a6e1a 398 AliHLTComponent();
bfccbf68 399 /** standard destructor */
f23a6e1a 400 virtual ~AliHLTComponent();
401
bfccbf68 402 /** component type definitions */
f23a6e1a 403 enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 };
bfccbf68 404
405 /**
406 * Init function to prepare data processing.
407 * Initialization of common data structures for a sequence of events.
18e3dbba 408 * The call is redirected to the internal method DoInit which can be
409 * overridden by the child class.
bfccbf68 410 * During Init also the environment structure is passed to the component.
c528fdc6 411 * @param comenv environment pointer with environment dependent function
bfccbf68 412 * calls
18e3dbba 413 * @param environParam additional parameter for function calls, the pointer
bfccbf68 414 * is passed as it is
415 * @param argc size of the argument array
18e3dbba 416 * @param argv augment array for component initialization
bfccbf68 417 */
c528fdc6 418 virtual int Init( const AliHLTAnalysisEnvironment* comenv, void* environParam, int argc, const char** argv );
bfccbf68 419
420 /**
421 * Clean-up function to terminate data processing.
422 * Clean-up of common data structures after data processing.
423 * The call is redirected to the internal method @ref DoDeinit which can be
424 * overridden by the child class.
425 */
f23a6e1a 426 virtual int Deinit();
bfccbf68 427
428 /**
429 * Processing of one event.
3cde846d 430 * The method is the entrance of the event processing. The parameters are
431 * cached for uses with the high-level interface and the DoProcessing
432 * implementation is called.
433 *
434 * @param evtData
435 * @param blocks
436 * @param trigData
437 * @param outputPtr
438 * @param size
439 * @param outputBlockCnt out: size of the output block array, set by the component
440 * @param outputBlocks out: the output block array is allocated internally
441 * @param edd
442 * @return neg. error code if failed
443 */
444 int ProcessEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
445 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
446 AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt,
447 AliHLTComponentBlockData*& outputBlocks,
448 AliHLTComponentEventDoneData*& edd );
449
450 /**
451 * Internal processing of one event.
bfccbf68 452 * The method is pure virtual and implemented by the child classes
453 * - @ref AliHLTProcessor
454 * - @ref AliHLTDataSource
455 * - @ref AliHLTDataSink
456 *
457 * @param evtData
458 * @param blocks
459 * @param trigData
460 * @param outputPtr
461 * @param size
2d7ff710 462 * @param outputBlocks out: the output block array is allocated internally
bfccbf68 463 * @param edd
464 * @return neg. error code if failed
465 */
3cde846d 466 virtual int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
8ede8717 467 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
a655eae3 468 AliHLTUInt32_t& size,
2be3f004 469 AliHLTComponentBlockDataList& outputBlocks,
8ede8717 470 AliHLTComponentEventDoneData*& edd ) = 0;
f23a6e1a 471
579d9eb7 472 /**
473 * Init 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 path initialized at the beginning of the AliRoot reconstruction.
477 *
478 * The method is used from the external interface in order to set the correct
82c58a87 479 * path when running on-line. The function also initializes the function
480 * callback for setting the run no during operation.
481 *
482 * A separation of library and component handling is maybe appropriate in the
483 * future. Using the global component handler here is maybe not the cleanest
484 * solution.
485 * @param cdbPath path of the CDB
486 * @param pHandler the component handler used for llibrary handling.
579d9eb7 487 */
82c58a87 488 int InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler);
579d9eb7 489
490 /**
491 * Set the run no for the CDB.
492 * The function must not be called when running in AliRoot unless it it
493 * really wanted. The CDB path will be set to the specified path, which might
494 * override the run no initialized at the beginning of the AliRoot reconstruction.
45c0a780 495 * InitCDB() has to be called before in order to really change the CDB settings.
579d9eb7 496 *
497 * The method is used from the external interface in order to set the correct
498 * path when running on-line.
499 */
500 int SetCDBRunNo(int runNo);
501
45c0a780 502 /**
503 * Set the run description.
504 * The run description is set before the call of Init() -> DoInit().
505 * @note: This functionality has been added in Juli 2008. The transmission of
506 * run properties by a special SOR (SOD event in DAQ terminalogy but this was
507 * changed after the HLT interface was designed) event is not sufficient because
508 * the data might be needed already in the DoInit handler of the component.
509 * @param desc run descriptor, currently only the run no member is used
510 * @param runType originally, run type was supposed to be a number and part
511 * of the run descriptor. But it was defined as string later
512 */
513 int SetRunDescription(const AliHLTRunDesc* desc, const char* runType);
514
9a0ef890 515 /**
516 * Set the component description.
517 * The description string can contain tokens separated by blanks, a token
518 * consists of a key and an optional value separated by '='.
519 * Possible keys:
520 * \li -chainid=id string id within the chain of the instance
521 *
522 * @param desc component description
523 */
524 int SetComponentDescription(const char* desc);
525
c528fdc6 526 /**
527 * Set the running environment for the component.
528 * Originally, the environment was set in the Init function. However, the setup of
529 * the CDB is required before. In order to have proper logging functionality, the
530 * environment is required.
531 * @param comenv environment pointer with environment dependent function
532 * calls
533 * @param environParam additional parameter for function calls, the pointer
534 * is passed as it is
535 */
536 int SetComponentEnvironment(const AliHLTAnalysisEnvironment* comenv, void* environParam);
537
f23a6e1a 538 // Information member functions for registration.
bfccbf68 539
540 /**
541 * Get the type of the component.
542 * The function is pure virtual and must be implemented by the child class.
543 * @return component type id
544 */
f23a6e1a 545 virtual TComponentType GetComponentType() = 0; // Source, sink, or processor
bfccbf68 546
547 /**
548 * Get the id of the component.
549 * Each component is identified by a unique id.
550 * The function is pure virtual and must be implemented by the child class.
551 * @return component id (string)
552 */
f23a6e1a 553 virtual const char* GetComponentID() = 0;
bfccbf68 554
555 /**
556 * Get the input data types of the component.
557 * The function is pure virtual and must be implemented by the child class.
558 * @return list of data types in the vector reference
559 */
2be3f004 560 virtual void GetInputDataTypes( AliHLTComponentDataTypeList& ) = 0;
bfccbf68 561
562 /**
563 * Get the output data type of the component.
564 * The function is pure virtual and must be implemented by the child class.
565 * @return output data type
566 */
8ede8717 567 virtual AliHLTComponentDataType GetOutputDataType() = 0;
bfccbf68 568
de6593d0 569 /**
570 * Get the output data types of the component.
571 * The function can be implemented to indicate multiple output data types
572 * in the target array.
573 * @ref GetOutputDataType must return @ref kAliHLTMultipleDataType in order
574 * to invoke this method.
575 * @param tgtList list to receive the data types
576 * @return no of output data types, data types in the target list
577 */
2be3f004 578 virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
de6593d0 579
bfccbf68 580 /**
18e3dbba 581 * Get a ratio by how much the data volume is shrunken or enhanced.
bfccbf68 582 * The function is pure virtual and must be implemented by the child class.
583 * @param constBase <i>return</i>: additive part, independent of the
584 * input data volume
585 * @param inputMultiplier <i>return</i>: multiplication ratio
586 * @return values in the reference variables
587 */
71d7c760 588 virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0;
f23a6e1a 589
5ef2a37b 590 /**
591 * Get a list of OCDB object description.
592 * The list of objects is provided in a TMap
593 * - key: complete OCDB path, e.g. GRP/GRP/Data
594 * - value: short description why the object is needed
595 * Key and value objects created inside this class go into ownership of
596 * target TMap.
597 * @param targetMap TMap instance receiving the list
598 * @return void
599 */
600 virtual void GetOCDBObjectDescription( TMap* const targetArray);
601
bfccbf68 602 /**
603 * Spawn function.
604 * Each component must implement a spawn function to create a new instance of
605 * the class. Basically the function must return <i>new <b>my_class_name</b></i>.
606 * @return new class instance
607 */
f23a6e1a 608 virtual AliHLTComponent* Spawn() = 0;
0c0c9d99 609
5ef2a37b 610 /**
611 * check the availability of the OCDB entry descriptions in the TMap
612 * key : complete OCDB path of the entry
613 * value : auxiliary object - short description
614 * if the external map was not provided the function invokes
615 * interface function GetOCDBObjectDescription() to retrieve the list.
616 * @param externList map of entries to be tested
617 * @result 0 if all found, -ENOENT if objects not found
618 */
619 int CheckOCDBEntries(const TMap* const externList=NULL);
620
bfccbf68 621 /**
622 * Find matching data types between this component and a consumer component.
623 * Currently, a component can produce only one type of data. This restriction is most
624 * likely to be abolished in the future.
625 * @param pConsumer a component and consumer of the data produced by this component
626 * @param tgtList reference to a vector list to receive the matching data types.
627 * @return >= 0 success, neg. error code if failed
628 */
2be3f004 629 int FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList);
f23a6e1a 630
bfccbf68 631 /**
632 * Set the global component handler.
633 * The static method is needed for the automatic registration of components.
634 */
85869391 635 static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0);
bfccbf68 636
637 /**
638 * Clear the global component handler.
639 * The static method is needed for the automatic registration of components.
640 */
85869391 641 static int UnsetGlobalComponentHandler();
bfccbf68 642
9ce4bf4a 643 /**
644 * Helper function to convert the data type to a string.
fbdb63fd 645 * @param type data type structure
646 * @param mode 0 print string origin:type <br>
647 * 1 print chars <br>
58f0fd47 648 * 2 print numbers <br>
649 * 3 print 'type' 'origin'
9ce4bf4a 650 */
fbdb63fd 651 static string DataType2Text( const AliHLTComponentDataType& type, int mode=0);
9ce4bf4a 652
48abe484 653 /**
654 * Calculate a CRC checksum of a data buffer.
655 * Polynomial for the calculation is 0xD8.
656 */
657 static AliHLTUInt32_t CalculateChecksum(const AliHLTUInt8_t* buffer, int size);
658
5f5b708b 659 /**
660 * Helper function to print content of data type.
661 */
8b97f4f1 662 static void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL);
5f5b708b 663
9ce4bf4a 664 /**
665 * helper function to initialize AliHLTComponentEventData structure
666 */
667 static void FillEventData(AliHLTComponentEventData& evtData);
668
669 /**
670 * Print info on an AliHLTComponentDataType structure
671 * This is just a helper function to examine an @ref AliHLTComponentDataType
672 * structur.
673 */
8b97f4f1 674 static void PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt);
9ce4bf4a 675
fbdb63fd 676 /**
677 * Fill AliHLTComponentBlockData structure with default values.
678 * @param blockData reference to data structure
679 */
680 static void FillBlockData( AliHLTComponentBlockData& blockData );
681
682 /**
683 * Fill AliHLTComponentShmData structure with default values.
684 * @param shmData reference to data structure
685 */
686 static void FillShmData( AliHLTComponentShmData& shmData );
687
688 /**
689 * Fill AliHLTComponentDataType structure with default values.
690 * @param dataType reference to data structure
691 */
692 static void FillDataType( AliHLTComponentDataType& dataType );
693
694 /**
695 * Copy data type structure
696 * Copies the value an AliHLTComponentDataType structure to another one
9bb806cd 697 * @param [out] tgtdt target structure
698 * @param [in] srcdt source structure
fbdb63fd 699 */
700 static void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt);
701
702 /**
703 * Set the ID and Origin of an AliHLTComponentDataType structure.
704 * The function sets the fStructureSize member and copies the strings
705 * to the ID and Origin. Only characters from the valid part of the string
7e3efc8f 706 * are copied, the rest is filled with 0's. <br>
fbdb63fd 707 * Please note that the fID and fOrigin members are not strings, just arrays of
708 * chars of size @ref kAliHLTComponentDataTypefIDsize and
709 * @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with
7e3efc8f 710 * a terminating zero. <br>
711 * It is possible to pass NULL pointers as id or origin argument, in that case they
712 * are just ignored.
fbdb63fd 713 * @param tgtdt target data type structure
714 * @param id ID string
715 * @param origin Origin string
716 */
717 static void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin);
718
18b56222 719 /**
720 * Set the ID and Origin of an AliHLTComponentDataType structure.
721 * Given the fact that the data type ID is 64bit wide and origin 32, this helper
722 * function sets the data type from those two parameters.
af2ed151 723 * @param dt target data type structure
18b56222 724 * @param id 64bit id
af2ed151 725 * @param orig 32bit origin
18b56222 726 */
727 static void SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t orig);
728
abb52c8f 729 /**
730 * Extract a component table entry from the payload buffer.
731 * The entry consists of the AliHLTComponentTableEntry structure, the array of
732 * parents and a description string of the format 'chain-id{component-id:component-args}'.
733 * The function fills all the variables after a consistency check.
734 */
735 static int ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
736 string& chainId, string& compId, string& compParam,
0622a0f3 737 vector<AliHLTUInt32_t>& parents) {
738 int dummy=0;
739 return ExtractComponentTableEntry(pBuffer, size, chainId, compId, compParam, parents, dummy);
740 }
741
742 static int ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
743 string& chainId, string& compId, string& compParam,
744 vector<AliHLTUInt32_t>& parents, int& level);
89413559 745
746 /**
747 * Extracts the different data parts from the trigger data structure.
9bb806cd 748 * @param [in] trigData The trigger data as passed to the DoProcessing method.
749 * @param [out] attributes The data block attributes given by the HLT framework.
750 * @param [out] status The HLT status bits given by the HLT framework.
751 * @param [out] cdh The common data header received from DDL links.
752 * @param [out] readoutlist The readout list to fill with readout list bits
89413559 753 * passed on by the HLT framework.
9bb806cd 754 * @param [in] printErrors If true then error messages are generated as necessary
89413559 755 * and suppressed otherwise.
756 * @note If any of the output parameters are set to NULL then the field is not set.
757 * For example, the following line will only fill the CDH pointer.
758 * \code
16e6f752 759 * AliHLTCDHWrapper cdh;
89413559 760 * ExtractTriggerData(trigData, NULL, NULL, &cdh, NULL);
761 * \endcode
9e14734f 762 * @return zero on success or one of the following error codes on failure.
89413559 763 * if a non-zero error code is returned then none of the output parameters are
764 * modified.
765 * \li -ENOENT The <i>trigData</i> structure size is wrong.
766 * \li -EBADF The <i>trigData</i> data size is wrong.
767 * \li -EBADMSG The common data header (CDH) in the trigger data has the wrong
768 * number of words indicated.
769 * \li -EPROTO The readout list structure in the trigger data has the wrong
770 * number of words indicated.
771 */
772 static int ExtractTriggerData(
773 const AliHLTComponentTriggerData& trigData,
774 const AliHLTUInt8_t (**attributes)[gkAliHLTBlockDAttributeCount],
775 AliHLTUInt64_t* status,
16e6f752 776 AliHLTCDHWrapper* const cdh,
89413559 777 AliHLTReadoutList* readoutlist,
778 bool printErrors = false
779 );
780
781 /**
782 * Extracts the readout list from a trigger data structure.
9bb806cd 783 * @param [in] trigData The trigger data as passed to the DoProcessing method.
784 * @param [out] list The output readout list to fill.
785 * @param [in] printErrors If true then error messages are generated as necessary
89413559 786 * and suppressed otherwise.
9e14734f 787 * @return zero on success or one of the error codes returned by ExtractTriggerData.
89413559 788 */
789 static int GetReadoutList(
790 const AliHLTComponentTriggerData& trigData, AliHLTReadoutList& list,
791 bool printErrors = false
792 )
793 {
794 return ExtractTriggerData(trigData, NULL, NULL, NULL, &list, printErrors);
795 }
9e14734f 796
797 /**
798 * Extracts the event type from the given Common Data Header.
9bb806cd 799 * @param [in] cdh The Common Data Header to extract the event type from.
9e14734f 800 * @return the event type code from the CDH.
801 */
16e6f752 802 static AliHLTUInt32_t ExtractEventTypeFromCDH(const AliHLTCDHWrapper* const cdh);
89413559 803
90ebac25 804 /**
805 * Stopwatch type for benchmarking.
806 */
807 enum AliHLTStopwatchType {
808 /** total time for event processing */
809 kSWBase,
810 /** detector algorithm w/o interface callbacks */
811 kSWDA,
812 /** data sources */
813 kSWInput,
814 /** data sinks */
815 kSWOutput,
816 /** number of types */
817 kSWTypeCount
818 };
819
820 /**
821 * Helper class for starting and stopping a stopwatch.
822 * The guard can be used by instantiating an object in a function. The
823 * specified stopwatch is started and the previous stopwatch put on
824 * hold. When the function is terminated, the object is deleted automatically
825 * deleted, stopping the stopwatch and starting the one on hold.<br>
826 * \em IMPORTANT: never create dynamic objects from this guard as this violates
827 * the idea of a guard.
828 */
829 class AliHLTStopwatchGuard {
830 public:
831 /** standard constructor (not for use) */
832 AliHLTStopwatchGuard();
833 /** constructor */
834 AliHLTStopwatchGuard(TStopwatch* pStart);
835 /** copy constructor (not for use) */
e419b223 836 AliHLTStopwatchGuard(const AliHLTStopwatchGuard&);
837 /** assignment operator (not for use) */
838 AliHLTStopwatchGuard& operator=(const AliHLTStopwatchGuard&);
90ebac25 839 /** destructor */
840 ~AliHLTStopwatchGuard();
841
842 private:
843 /**
844 * Hold the previous guard for the existence of this guard.
845 * Checks whether this guard controls a new stopwatch. In that case, the
846 * previous guard and its stopwatch are put on hold.
847 * @param pSucc instance of the stopwatch of the new guard
848 * @return 1 if pSucc is a different stopwatch which should
849 * be started<br>
850 * 0 if it controls the same stopwatch
851 */
0007ed52 852 int Hold(const TStopwatch* pSucc);
90ebac25 853
854 /**
855 * Resume the previous guard.
856 * Checks whether the peceeding guard controls a different stopwatch. In that
857 * case, the its stopwatch is resumed.
858 * @param pSucc instance of the stopwatch of the new guard
859 * @return 1 if pSucc is a different stopwatch which should
860 * be stopped<br>
861 * 0 if it controls the same stopwatch
862 */
0007ed52 863 int Resume(const TStopwatch* pSucc);
90ebac25 864
865 /** the stopwatch controlled by this guard */
866 TStopwatch* fpStopwatch; //!transient
867
868 /** previous stopwatch guard, put on hold during existence of the guard */
869 AliHLTStopwatchGuard* fpPrec; //!transient
870
871 /** active stopwatch guard */
872 static AliHLTStopwatchGuard* fgpCurrent; //!transient
873 };
874
875 /**
876 * Set a stopwatch for a given purpose.
877 * @param pSW stopwatch object
878 * @param type type of the stopwatch
879 */
880 int SetStopwatch(TObject* pSW, AliHLTStopwatchType type=kSWBase);
881
882 /**
883 * Init a set of stopwatches.
884 * @param pStopwatches object array of stopwatches
885 */
886 int SetStopwatches(TObjArray* pStopwatches);
97d2b87a 887
888 /**
889 * Customized logging function.
890 * The chain id, component id and pointer is added at the beginning of each message.
891 */
892 int LoggingVarargs(AliHLTComponentLogSeverity severity,
893 const char* originClass, const char* originFunc,
894 const char* file, int line, ... ) const;
a655eae3 895
b3f4766b 896 /**
897 * Get size of last serialized object.
898 * During PushBack, TObjects are serialized in a separate buffer. The
899 * size of the last object can be retrieved by this function.
900 *
901 * This might be especially useful for PushBack failures caused by too
902 * small output buffer.
903 */
904 int GetLastObjectSize() const {return fLastObjectSize;}
905
cc095616 906 /**
907 * This method generates a V4 Globally Unique Identifier (GUID) using the
908 * ROOT TRandom3 pseudo-random number generator with the process' UID, GID
909 * PID and host address as seeds. For good measure MD5 sum hashing is also
910 * applied.
911 * @return the newly generated GUID structure.
912 */
913 static TUUID GenerateGUID();
914
ebdd604d 915 /// get the compression level for TObjects
916 int GetCompressionLevel() const {return fCompressionLevel;}
917
f23a6e1a 918 protected:
71d7c760 919
bfccbf68 920 /**
921 * Default method for the internal initialization.
922 * The method is called by @ref Init
923 */
53feaef5 924 virtual int DoInit( int argc, const char** argv );
f23a6e1a 925
bfccbf68 926 /**
927 * Default method for the internal clean-up.
928 * The method is called by @ref Deinit
929 */
53feaef5 930 virtual int DoDeinit();
f23a6e1a 931
579d9eb7 932 /**
933 * Reconfigure the component.
934 * The method is called when an event of type @ref kAliHLTDataTypeComConf
935 * {COM_CONF:PRIV} is received by the component. If the event is sent as
936 * part of a normal event, the component configuration is called first.
937 *
938 * The CDB path parameter specifies the path in the CDB, i.e. without
18e3dbba 939 * leading absolute path of the CDB location. The framework might also
579d9eb7 940 * provide the id of the component in the analysis chain.
941 *
02bc7a5f 942 * The actual sequence of configuration depends on the component. As a
943 * general rule, the component should load the specific OCDB object if
944 * provided as parameter, and load the default objects if the parameter
945 * is NULL. However, other schemes are possible. See @ref
946 *
579d9eb7 947 * \b Note: The CDB will be initialized by the framework, either already set
948 * from AliRoot or from the wrapper interface during initialization.
949 *
950 * @param cdbEntry path of the cdbEntry
e63b561e 951 * @param chainId the id/name of the component in the current analysis
952 * chain. This is not necessarily the same as what is
953 * returned by the GetComponentID() method.
579d9eb7 954 * @note both parameters can be NULL, check before usage
955 */
956 virtual int Reconfigure(const char* cdbEntry, const char* chainId);
b543e186 957
958 /**
959 * Read the Preprocessor values.
960 * The function is invoked when the component is notified about available/
961 * updated data points from the detector Preprocessors. The 'modules'
962 * argument contains all detectors for which the Preprocessors have
963 * updated data points. The component has to implement the CDB access to
964 * get the desired data points.
965 * @param modules detectors for which the Preprocessors have updated
d6b69874 966 * data points: TPC, TRD, ITS, PHOS, MUON, or ALL if
967 * no argument was received.
b543e186 968 * @return neg. error code if failed
969 */
970 virtual int ReadPreprocessorValues(const char* modules);
579d9eb7 971
02bc7a5f 972 /**
973 * Child implementation to scan a number of configuration arguments.
974 * The method is invoked by the framework in conjunction with the
975 * common framework functions ConfigureFromArgumentString and
976 * ConfigureFromCDBTObjString.
977 * Function needs to scan the argument and optional additional
978 * parameters and returns the number of elements in the array which
979 * have been treated.
980 * @param argc
981 * @param argv
982 * @return number of arguments which have been scanned or neg error
983 * code if failed <br>
984 * \li -EINVAL unknown argument
985 * \li -EPROTO protocol error, e.g. missing parameter
986 */
987 virtual int ScanConfigurationArgument(int argc, const char** argv);
988
45c0a780 989 /**
990 * Custom handler for the SOR event.
991 * Is invoked from the base class if an SOR event is in the block list.
992 * The handler is called before the processing function. The processing
993 * function is skipped if there are no other data blocks available.
994 *
995 * The SOR event is generated by the PubSub framework in response to
996 * the DAQ start of data (SOD - has been renamed after HLT interface
997 * was designed). The SOD event consists of 3 blocks:
998 * - ::kAliHLTDataTypeEvent block: spec ::gkAliEventTypeStartOfRun
999 * - SOD block of type ::kAliHLTDataTypeSOR, payload: AliHLTRunDesc struct
1000 * - run type block ::kAliHLTDataTypeRunType, payload: run type string
1001 *
1002 * Run properties can be retrieved by getters like GetRunNo().
1003 * @return neg. error code if failed
1004 */
1005 virtual int StartOfRun();
1006
1007 /**
1008 * Custom handler for the EOR event.
1009 * Is invoked from the base class if an EOR event is in the block list.
1010 * The handler is called before the processing function. The processing
1011 * function is skipped if there are no other data blocks available.
1012 *
18e3dbba 1013 * See StartOfRun() for more comments of the sequence of steering events.
45c0a780 1014 *
1015 * @return neg. error code if failed
1016 */
1017 virtual int EndOfRun();
1018
48abe484 1019 /**
1020 * Check whether a component requires all steering blocks.
1021 * Childs can overload in order to indicate that they want to
1022 * receive also the steering data blocks. There is also the
1023 * possibility to add the required data types to the input
1024 * data type list in GetInputDataTypes().
1025 */
1026 virtual bool RequireSteeringBlocks() const {return false;}
1027
bfccbf68 1028 /**
1029 * General memory allocation method.
1030 * All memory which is going to be used 'outside' of the interface must
1031 * be provided by the framework (online or offline).
1032 * The method is redirected to a function provided by the current
1033 * framework. Function pointers are transferred via the @ref
a3c9b745 1034 * AliHLTAnalysisEnvironment structure.
bfccbf68 1035 */
85869391 1036 void* AllocMemory( unsigned long size );
f23a6e1a 1037
bfccbf68 1038 /**
1039 * Helper function to create a monolithic BlockData description block out
1040 * of a list BlockData descriptors.
1041 * For convenience, inside the interface vector lists are used, to make the
1042 * interface pure C style, monilithic blocks must be exchanged.
1043 * The method is redirected to a function provided by the current
1044 * framework. Function pointers are transferred via the @ref
a3c9b745 1045 * AliHLTAnalysisEnvironment structure.
bfccbf68 1046 */
2be3f004 1047 int MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
8ede8717 1048 AliHLTComponentBlockData** outputBlocks );
f23a6e1a 1049
bfccbf68 1050 /**
1051 * Fill the EventDoneData structure.
1052 * The method is redirected to a function provided by the current
1053 * framework. Function pointers are transferred via the @ref
a3c9b745 1054 * AliHLTAnalysisEnvironment structure.
bfccbf68 1055 */
0007ed52 1056 int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd ) const;
f23a6e1a 1057
eafbc306 1058 /**
1059 * Allocate an EventDoneData structure for the current event .
1060 * The method allocates the memory internally and does not interact with the current Framework.
1061 * The allocated data structure is empty initially and can be filled by calls to the
1062 * @ref PushEventDoneData method. The memory will be automatically released after the event has been processed.
1063 *
1064 */
1065 int ReserveEventDoneData( unsigned long size );
1066
1067 /**
1068 * Push a 32 bit word of data into event done data for the current event which
1069 * has previously been allocated by the @ref ReserveEventDoneData method.
1070 */
1071 int PushEventDoneData( AliHLTUInt32_t eddDataWord );
1072
1073 /**
1074 * Release event done data previously reserved by @ref ReserveEventDoneData
1075 */
1076 void ReleaseEventDoneData();
1077
1078 /**
1079 * Get the pointer to the event done data available/built so far for the current event via
1080 * @ref ReserveEventDoneData and @ref PushEventDoneData
1081 */
0007ed52 1082 AliHLTComponentEventDoneData* GetCurrentEventDoneData() const
eafbc306 1083 {
1084 return fEventDoneData;
1085 }
1086
bfccbf68 1087 /**
1088 * Helper function to convert the data type to a string.
1089 */
70ed7d01 1090 void DataType2Text(const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]) const;
fa2e9b7c 1091
02bc7a5f 1092 /**
1093 * Loop through a list of component arguments.
1094 * The list can be either an array of separated strings or one single
1095 * string containing blank separated arguments, or both mixed.
1096 * ScanConfigurationArgument() is called to allow the component to treat
1097 * the individual arguments.
1098 * @return neg. error code if failed
1099 */
1100 int ConfigureFromArgumentString(int argc, const char** argv);
1101
1102 /**
1103 * Read configuration objects from OCDB and configure from
1104 * the content of TObjString entries.
1105 * @param entries blank separated list of OCDB paths
f651054f 1106 * @param key if the entry is a TMap, search for the corresponding object
02bc7a5f 1107 * @return neg. error code if failed
1108 */
f651054f 1109 int ConfigureFromCDBTObjString(const char* entries, const char* key=NULL);
02bc7a5f 1110
1111 /**
1112 * Load specified entry from the OCDB and extract the object.
1113 * The entry is explicitely unloaded from the cache before it is loaded.
f651054f 1114 * If parameter key is specified the OCDB object is treated as TMap
1115 * and the TObject associated with 'key' is loaded.
02bc7a5f 1116 * @param path path of the entry under to root of the OCDB
1117 * @param version version of the entry
1118 * @param subVersion subversion of the entry
f651054f 1119 * @param key key of the object within TMap
02bc7a5f 1120 */
56c78cc3 1121 TObject* LoadAndExtractOCDBObject(const char* path, const char* key=NULL) const;
02bc7a5f 1122
3cde846d 1123 /**
1124 * Get event number.
1125 * @return value of the internal event counter
1126 */
70ed7d01 1127 int GetEventCount() const;
3cde846d 1128
a655eae3 1129 /**
1130 * Get the number of input blocks.
1131 * @return number of input blocks
1132 */
66043029 1133 int GetNumberOfInputBlocks() const;
a655eae3 1134
4646c6e3 1135 /**
1136 * Get id of the current event
1137 * @return event id
1138 */
1139 AliHLTEventID_t GetEventId() const;
1140
a655eae3 1141 /**
1142 * Get the first object of a specific data type from the input data.
18e3dbba 1143 * The High-level methods provide functionality to transfer ROOT data
a655eae3 1144 * structures which inherit from TObject.
3dd8541e 1145 *
a655eae3 1146 * The method looks for the first ROOT object of type dt in the input stream.
1147 * If also the class name is provided, the object is checked for the right
1148 * class type. The input data block needs a certain structure, namely the
1149 * buffer size as first word. If the cross check fails, the retrieval is
18e3dbba 1150 * silently abandoned, unless the \em bForce parameter is set.<br>
3dd8541e 1151 * \b Note: THE OBJECT MUST NOT BE DELETED by the caller.
1152 *
1153 * If called without parameters, the function tries to create objects from
1154 * all available input blocks, also the ones of data type kAliHLTVoidDataType
1155 * which are not matched by kAliHLTAnyDataType.
1156 *
a655eae3 1157 * @param dt data type of the object
1158 * @param classname class name of the object
1159 * @param bForce force the retrieval of an object, error messages
1160 * are suppressed if \em bForce is not set
1161 * @return pointer to @ref TObject, NULL if no objects of specified type
1162 * available
1163 */
3dd8541e 1164 const TObject* GetFirstInputObject(const AliHLTComponentDataType& dt=kAliHLTAllDataTypes,
a655eae3 1165 const char* classname=NULL,
1166 int bForce=0);
1167
1168 /**
1169 * Get the first object of a specific data type from the input data.
18e3dbba 1170 * The High-level methods provide functionality to transfer ROOT data
a655eae3 1171 * structures which inherit from TObject.
1172 * The method looks for the first ROOT object of type specified by the ID and
1173 * Origin strings in the input stream.
1174 * If also the class name is provided, the object is checked for the right
1175 * class type. The input data block needs a certain structure, namely the
1176 * buffer size as first word. If the cross check fails, the retrieval is
18e3dbba 1177 * silently abandoned, unless the \em bForce parameter is set.<br>
8451168b 1178 * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
a655eae3 1179 * @param dtID data type ID of the object
1180 * @param dtOrigin data type origin of the object
1181 * @param classname class name of the object
1182 * @param bForce force the retrieval of an object, error messages
1183 * are suppressed if \em bForce is not set
1184 * @return pointer to @ref TObject, NULL if no objects of specified type
1185 * available
1186 */
1187 const TObject* GetFirstInputObject(const char* dtID,
1188 const char* dtOrigin,
1189 const char* classname=NULL,
1190 int bForce=0);
1191
1192 /**
1193 * Get the next object of a specific data type from the input data.
18e3dbba 1194 * The High-level methods provide functionality to transfer ROOT data
a655eae3 1195 * structures which inherit from TObject.
1196 * The method looks for the next ROOT object of type and class specified
8451168b 1197 * to the previous @ref GetFirstInputObject call.<br>
1198 * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
a655eae3 1199 * @param bForce force the retrieval of an object, error messages
1200 * are suppressed if \em bForce is not set
1201 * @return pointer to @ref TObject, NULL if no more objects available
1202 */
1203 const TObject* GetNextInputObject(int bForce=0);
1204
1205 /**
1206 * Get data type of an input block.
1207 * Get data type of the object previously fetched via
1208 * GetFirstInputObject/NextInputObject or the last one if no object
1209 * specified.
1210 * @param pObject pointer to TObject
1211 * @return data specification, kAliHLTVoidDataSpec if failed
1212 */
1213 AliHLTComponentDataType GetDataType(const TObject* pObject=NULL);
1214
1215 /**
1216 * Get data specification of an input block.
1217 * Get data specification of the object previously fetched via
1218 * GetFirstInputObject/NextInputObject or the last one if no object
1219 * specified.
1220 * @param pObject pointer to TObject
1221 * @return data specification, kAliHLTVoidDataSpec if failed
1222 */
1223 AliHLTUInt32_t GetSpecification(const TObject* pObject=NULL);
1224
1225 /**
1226 * Get the first block of a specific data type from the input data.
3dd8541e 1227 * The method looks for the first block of type dt in the input stream.
1228 * It is intended to be used within the high-level interface.<br>
8451168b 1229 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
3dd8541e 1230 *
1231 * If called without parameters, the function works on all input blocks,
1232 * also the ones of data type kAliHLTVoidDataType which are not matched by
1233 * kAliHLTAnyDataType.
1234 *
a655eae3 1235 * @param dt data type of the block
1236 * @return pointer to @ref AliHLTComponentBlockData
1237 */
3dd8541e 1238 const AliHLTComponentBlockData* GetFirstInputBlock(const AliHLTComponentDataType& dt=kAliHLTAllDataTypes);
a655eae3 1239
1240 /**
1241 * Get the first block of a specific data type from the input data.
1242 * The method looks for the first block of type specified by the ID and
1243 * Origin strings in the input stream. It is intended
8451168b 1244 * to be used within the high-level interface.<br>
1245 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
a655eae3 1246 * @param dtID data type ID of the block
1247 * @param dtOrigin data type origin of the block
1248 * @return pointer to @ref AliHLTComponentBlockData
1249 */
1250 const AliHLTComponentBlockData* GetFirstInputBlock(const char* dtID,
1251 const char* dtOrigin);
1252
1253 /**
8451168b 1254 * Get input block by index.<br>
1255 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
a655eae3 1256 * @return pointer to AliHLTComponentBlockData, NULL if index out of range
1257 */
10b9cbf9 1258 const AliHLTComponentBlockData* GetInputBlock(int index) const;
a655eae3 1259
1260 /**
1261 * Get the next block of a specific data type from the input data.
1262 * The method looks for the next block of type and class specified
1263 * to the previous @ref GetFirstInputBlock call.
8451168b 1264 * To be used within the high-level interface.<br>
1265 * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
a655eae3 1266 */
1267 const AliHLTComponentBlockData* GetNextInputBlock();
1268
1269 /**
1270 * Get data specification of an input block.
18e3dbba 1271 * Get data specification of the input block previously fetched via
a655eae3 1272 * GetFirstInputObject/NextInputObject or the last one if no block
1273 * specified.
1274 * @param pBlock pointer to input block
1275 * @return data specification, kAliHLTVoidDataSpec if failed
1276 */
ed510d1b 1277 AliHLTUInt32_t GetSpecification(const AliHLTComponentBlockData* pBlock);
a655eae3 1278
c7e9e2f2 1279 /**
1280 * Forward an input object to the output.
1281 * Forward the input block of an object previously fetched via
1282 * GetFirstInputObject/NextInputObject or the last one if no object
1283 * specified.
1284 * The block descriptor of the input block is forwarded to the
1285 * output block list.
1286 * @param pObject pointer to TObject
1287 * @return neg. error code if failed
1288 */
1289 int Forward(const TObject* pObject);
1290
1291 /**
1292 * Forward an input block to the output.
1293 * Forward the input block fetched via GetFirstInputObject/
1294 * NextInputBlock or the last one if no block specified.
1295 * The block descriptor of the input block is forwarded to the
1296 * output block list.
1297 * @param pBlock pointer to input block
1298 * @return neg. error code if failed
1299 */
1300 int Forward(const AliHLTComponentBlockData* pBlock=NULL);
1301
a655eae3 1302 /**
1303 * Insert an object into the output.
79c114b5 1304 * If header is specified, it will be inserted before the root object,
1305 * default is no header.
9d4d4b02 1306 * The publishing can be downscaled by means of the -pushback-period
1307 * parameter. This is especially useful for histograms which do not
1308 * need to be sent for every event.
a655eae3 1309 * @param pObject pointer to root object
1310 * @param dt data type of the object
1311 * @param spec data specification
79c114b5 1312 * @param pHeader pointer to header
1313 * @param headerSize size of Header
a655eae3 1314 * @return neg. error code if failed
1315 */
ebdd604d 1316 int PushBack(const TObject* pObject, const AliHLTComponentDataType& dt,
79c114b5 1317 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1318 void* pHeader=NULL, int headerSize=0);
a655eae3 1319
1320 /**
1321 * Insert an object into the output.
79c114b5 1322 * If header is specified, it will be inserted before the root object,
1323 * default is no header.
9d4d4b02 1324 * The publishing can be downscaled by means of the -pushback-period
1325 * parameter. This is especially useful for histograms which do not
1326 * need to be sent for every event.
a655eae3 1327 * @param pObject pointer to root object
1328 * @param dtID data type ID of the object
1329 * @param dtOrigin data type origin of the object
1330 * @param spec data specification
79c114b5 1331 * @param pHeader pointer to header
1332 * @param headerSize size of Header
a655eae3 1333 * @return neg. error code if failed
1334 */
ebdd604d 1335 int PushBack(const TObject* pObject, const char* dtID, const char* dtOrigin,
79c114b5 1336 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1337 void* pHeader=NULL, int headerSize=0);
1338
a655eae3 1339 /**
1340 * Insert an object into the output.
1341 * @param pBuffer pointer to buffer
1342 * @param iSize size of the buffer
1343 * @param dt data type of the object
1344 * @param spec data specification
9d9ffd37 1345 * @param pHeader pointer to header
7c4091c1 1346 * @param headerSize size of Header
a655eae3 1347 * @return neg. error code if failed
1348 */
438635e3 1349 int PushBack(const void* pBuffer, int iSize, const AliHLTComponentDataType& dt,
9d9ffd37 1350 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
438635e3 1351 const void* pHeader=NULL, int headerSize=0);
a655eae3 1352
1353 /**
1354 * Insert an object into the output.
1355 * @param pBuffer pointer to buffer
1356 * @param iSize size of the buffer
1357 * @param dtID data type ID of the object
1358 * @param dtOrigin data type origin of the object
1359 * @param spec data specification
9d9ffd37 1360 * @param pHeader pointer to header
7c4091c1 1361 * @param headerSize size of Header
a655eae3 1362 * @return neg. error code if failed
1363 */
438635e3 1364 int PushBack(const void* pBuffer, int iSize, const char* dtID, const char* dtOrigin,
9d9ffd37 1365 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
438635e3 1366 const void* pHeader=NULL, int headerSize=0);
a655eae3 1367
8451168b 1368 /**
1369 * Estimate size of a TObject
1370 * @param pObject
1371 * @return buffer size in byte
1372 */
ebdd604d 1373 int EstimateObjectSize(const TObject* pObject) const;
8451168b 1374
79c114b5 1375 /**
1376 * Create a memory file in the output stream.
1377 * This method creates a TFile object which stores all data in
1378 * memory instead of disk. The TFile object is published as binary data.
1379 * The instance can be used like a normal TFile object. The TFile::Close
1380 * or @ref CloseMemoryFile method has to be called in order to flush the
1381 * output stream.
1382 *
1383 * \b Note: The returned object is deleted by the framework.
1384 * @param capacity total size reserved for the memory file
1385 * @param dtID data type ID of the file
1386 * @param dtOrigin data type origin of the file
1387 * @param spec data specification
1388 * @return file handle, NULL if failed
1389 */
1390 AliHLTMemoryFile* CreateMemoryFile(int capacity, const char* dtID, const char* dtOrigin,
1391 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
1392
1393 /**
1394 * Create a memory file in the output stream.
1395 * This method creates a TFile object which stores all data in
1396 * memory instead of disk. The TFile object is published as binary data.
1397 * The instance can be used like a normal TFile object. The TFile::Close
1398 * or @ref CloseMemoryFile method has to be called in order to flush the
1399 * output stream.
1400 *
1401 * \b Note: The returned object is deleted by the framework.
1402 * @param capacity total size reserved for the memory file
1403 * @param dt data type of the file
1404 * @param spec data specification
1405 * @return file handle, NULL if failed
1406 */
1407 AliHLTMemoryFile* CreateMemoryFile(int capacity,
1408 const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
1409 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
1410
1411 /**
1412 * Create a memory file in the output stream.
1413 * This method creates a TFile object which stores all data in
1414 * memory instead of disk. The TFile object is published as binary data.
1415 * The instance can be used like a normal TFile object. The TFile::Close
1416 * or @ref CloseMemoryFile method has to be called in order to flush the
1417 * output stream.
1418 *
1419 * \b Note: The returned object is deleted by the framework.
1420 * @param dtID data type ID of the file
1421 * @param dtOrigin data type origin of the file
1422 * @param spec data specification
1423 * @param capacity fraction of the available output buffer size
1424 * @return file handle, NULL if failed
1425 */
1426 AliHLTMemoryFile* CreateMemoryFile(const char* dtID, const char* dtOrigin,
1427 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1428 float capacity=1.0);
1429
1430 /**
1431 * Create a memory file in the output stream.
1432 * This method creates a TFile object which stores all data in
1433 * memory instead of disk. The TFile object is published as binary data.
1434 * The instance can be used like a normal TFile object. The TFile::Close
1435 * or @ref CloseMemoryFile method has to be called in order to flush the
1436 * output stream.
1437 *
1438 * \b Note: The returned object is deleted by the framework.
1439 * @param dt data type of the file
1440 * @param spec data specification
1441 * @param capacity fraction of the available output buffer size
1442 * @return file handle, NULL if failed
1443 */
1444 AliHLTMemoryFile* CreateMemoryFile(const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
1445 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
1446 float capacity=1.0);
1447
1448 /**
1449 * Write an object to memory file in the output stream.
1450 * @param pFile file handle
1451 * @param pObject pointer to root object
1452 * @param key key in ROOT file
1453 * @param option options, see TObject::Write
1454 * @return neg. error code if failed
1455 * - -ENOSPC no space left
1456 */
1457 int Write(AliHLTMemoryFile* pFile, const TObject* pObject, const char* key=NULL, int option=TObject::kOverwrite);
1458
1459 /**
1460 * Close object memory file.
1461 * @param pFile file handle
1462 * @return neg. error code if failed
1463 * - -ENOSPC buffer size too small
1464 */
1465 int CloseMemoryFile(AliHLTMemoryFile* pFile);
1466
a655eae3 1467 /**
1468 * Insert event-done data information into the output.
1469 * @param edd event-done data information
1470 */
1471 int CreateEventDoneData(AliHLTComponentEventDoneData edd);
1472
559631d5 1473 /**
1474 * Get current run number
1475 */
1476 AliHLTUInt32_t GetRunNo() const;
1477
1478 /**
1479 * Get the current run type.
1480 */
1481 AliHLTUInt32_t GetRunType() const;
1482
9a0ef890 1483 /**
1484 * Get the chain id of the component.
1485 */
1486 const char* GetChainId() const {return fChainId.c_str();}
1487
6700298e 1488 /**
1489 * Get a timestamp of the current event
1490 * Exact format needs to be documented.
1491 */
1492 AliHLTUInt32_t GetTimeStamp() const;
1493
1494 /**
1495 * Get the period number.
1496 * Upper 28 bits (36 to 63) of the 64-bit event id
1497 */
1498 AliHLTUInt32_t GetPeriodNumber() const;
1499
1500 /**
1501 * Get the period number.
1502 * 24 bits, 12 to 35 of the 64-bit event id
1503 */
1504 AliHLTUInt32_t GetOrbitNumber() const;
1505
1506 /**
1507 * Get the bunch crossing number.
1508 * 12 bits, 0 to 12 of the 64-bit event id
1509 */
1510 AliHLTUInt16_t GetBunchCrossNumber() const;
1511
adb91bc3 1512 /**
1513 * Setup the CTP accounting functionality of the base class.
1514 * The method can be invoked from DoInit() for componenets which want to
1515 * use the CTP functionality of the base class.
1516 *
1517 * The AliHLTCTPData is initialized with the trigger classes from the ECS
1518 * parameters. The base class automatically increments the counters according
1519 * to the trigger pattern in the CDH before the event processing.
1520 */
1521 int SetupCTPData();
1522
1523 /**
1524 * Get the instance of the CTP data.
1525 */
1526 const AliHLTCTPData* CTPData() const {return fpCTPData;}
1527
cf9cf07e 1528 /**
1529 * Check whether a combination of trigger classes is fired.
1530 * The expression can contain trigger class ids and logic operators
1531 * like &&, ||, !, and ^, and may be grouped by parentheses.
3fcb48b8 1532 * @note the function requires the setup of the CTP handling for the component by
1533 * invoking SetupCTPData() from DoInit()
cf9cf07e 1534 * @param expression a logic expression of trigger class ids
1535 * @param trigData the trigger data data
1536 */
1537 bool EvaluateCTPTriggerClass(const char* expression, AliHLTComponentTriggerData& trigData) const;
1538
3fcb48b8 1539 /**
1540 * Check state of a trigger class.
1541 * If the class name is not part of the current trigger setup (i.e. ECS parameter
1542 * does not contain a trigger definition for this class name) the function
1543 * returns -1
1544 * @note the function requires the setup of the CTP handling for the component by
1545 * invoking SetupCTPData() from DoInit()
1546 * @return -1 class name not initialized,
1547 * 0 trigger not active
1548 * 1 trigger active
1549 */
1550 int CheckCTPTrigger(const char* name) const;
1551
a5e775ec 1552 /**
1553 * Get the overall solenoid field.
1554 */
1555 Double_t GetBz();
1556 /**
1557 * Get the solenoid field at point r.
1558 */
1559 Double_t GetBz(const Double_t *r);
1560 /**
1561 * Get the solenoid field components at point r.
1562 */
1563 void GetBxByBz(const Double_t r[3], Double_t b[3]);
1564
48abe484 1565 /**
1566 * Check whether the current event is a valid data event.
1567 * @param pTgt optional pointer to get the event type
1568 * @return true if the current event is a real data event
1569 */
0007ed52 1570 bool IsDataEvent(AliHLTUInt32_t* pTgt=NULL) const;
48abe484 1571
559631d5 1572 /**
1573 * Copy a struct from block data.
1574 * The function checks for block size and struct size. The least common
1575 * size will be copied to the target struct, remaining fields are initialized
1576 * to zero.<br>
1577 * The target struct must have a 32bit struct size indicator as first member.
1578 * @param pStruct target struct
1579 * @param iStructSize size of the struct
559631d5 1580 * @param iBlockNo index of input block
1581 * @param structname name of the struct (log messages)
1582 * @param eventname name of the event (log messages)
1583 * @return size copied, neg. error if failed
1584 */
83fec083 1585 int CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo,
559631d5 1586 const char* structname="", const char* eventname="");
1587
f23a6e1a 1588 private:
b426991e 1589 /** copy constructor prohibited */
559631d5 1590 AliHLTComponent(const AliHLTComponent&);
b426991e 1591 /** assignment operator prohibited */
559631d5 1592 AliHLTComponent& operator=(const AliHLTComponent&);
1593
3cde846d 1594 /**
1595 * Increment the internal event counter.
1596 * To be used by the friend classes AliHLTProcessor, AliHLTDataSource
1597 * and AliHLTDataSink.
1598 * @return new value of the internal event counter
a655eae3 1599 * @internal
3cde846d 1600 */
1601 int IncrementEventCounter();
1602
a655eae3 1603 /**
1604 * Find the first input block of specified data type beginning at index.
1edbbe49 1605 * Input blocks containing a TObject have the size of the object as an
1606 * unsigned 32 bit number in the first 4 bytes. This has to match the block
1607 * size minus 4.
3dd8541e 1608 *
1609 * kAliHLTAllDataTypes is a special data type which includes both
1610 * kAliHLTVoidDataType and kAliHLTAnyDataType.
1611 *
a655eae3 1612 * @param dt data type
1613 * @param startIdx index to start the search
1edbbe49 1614 * @param bObject check if this is an object
a655eae3 1615 * @return index of the block, -ENOENT if no block found
1616 *
1617 * @internal
1618 */
1edbbe49 1619 int FindInputBlock(const AliHLTComponentDataType& dt, int startIdx=-1, int bObject=0) const;
a655eae3 1620
1621 /**
1622 * Get index in the array of input bocks.
1623 * Calculate index and check integrety of a block data structure pointer.
1624 * @param pBlock pointer to block data
1625 * @return index of the block, -ENOENT if no block found
1626 *
1627 * @internal
1628 */
66043029 1629 int FindInputBlock(const AliHLTComponentBlockData* pBlock) const;
a655eae3 1630
1631 /**
1632 * Create an object from a specified input block.
1633 * @param idx index of the input block
1634 * @param bForce force the retrieval of an object, error messages
1635 * are suppressed if \em bForce is not set
1636 * @return pointer to TObject, caller must delete the object after use
1637 *
1638 * @internal
1639 */
1640 TObject* CreateInputObject(int idx, int bForce=0);
1641
1642 /**
1643 * Get input object
8451168b 1644 * Get object from the input block list. The methods first checks whether the
1645 * object was already created. If not, it is created by @ref CreateInputObject
1646 * and inserted into the list of objects.
a655eae3 1647 * @param idx index in the input block list
1648 * @param classname name of the class, object is checked for correct class
1649 * name if set
1650 * @param bForce force the retrieval of an object, error messages
1651 * are suppressed if \em bForce is not set
1652 * @return pointer to TObject
1653 *
1654 * @internal
1655 */
1656 TObject* GetInputObject(int idx, const char* classname=NULL, int bForce=0);
1657
8451168b 1658 /**
1659 * Clean the list of input objects.
1660 * Cleanup is done at the end of each event processing.
1661 */
1662 int CleanupInputObjects();
1663
a655eae3 1664 /**
1665 * Insert a buffer into the output block stream.
1666 * This is the only method to insert blocks into the output stream, called
1667 * from all types of the Pushback method. The actual data might have been
1668 * written to the output buffer already. In that case NULL can be provided
79c114b5 1669 * as buffer, only the block descriptor will be build. If a header is specified,
1670 * it will be inserted before the buffer, default is no header.
a655eae3 1671 * @param pBuffer pointer to buffer
32db4144 1672 * @param iBufferSize size of the buffer in byte
a655eae3 1673 * @param dt data type
1674 * @param spec data specification
79c114b5 1675 * @param pHeader pointer to header
1676 * @param iHeaderSize size of Header
b6800be0 1677 * @return neg. error code if failed
a655eae3 1678 */
438635e3 1679 int InsertOutputBlock(const void* pBuffer, int iBufferSize,
a655eae3 1680 const AliHLTComponentDataType& dt,
79c114b5 1681 AliHLTUInt32_t spec,
438635e3 1682 const void* pHeader=NULL, int iHeaderSize=0);
a655eae3 1683
a0aeb701 1684 /**
1685 * Add a component statistics block to the output.
438635e3 1686 * @return size of the added data
a0aeb701 1687 */
1688 int AddComponentStatistics(AliHLTComponentBlockDataList& blocks,
1689 AliHLTUInt8_t* buffer,
1690 AliHLTUInt32_t bufferSize,
1691 AliHLTUInt32_t offset,
1692 AliHLTComponentStatisticsList& stats) const;
1693
438635e3 1694 /**
1695 * Add a component table entry (descriptor) to the output
1696 * This is done at SOR/EOR. The component table is a list of chain ids
1697 * and 32bit ids calculated by a crc algorithm from the chian id. This
1698 * allows to tag data blocks with the id number rather than the string.
1699 *
1700 * The kAliHLTDataTypeComponentTable data block currently has the string
1701 * as payload and the crc id as specification.
1702 * @return size of the added data
1703 */
1704 int AddComponentTableEntry(AliHLTComponentBlockDataList& blocks,
1705 AliHLTUInt8_t* buffer,
1706 AliHLTUInt32_t bufferSize,
abb52c8f 1707 AliHLTUInt32_t offset,
0622a0f3 1708 const vector<AliHLTUInt32_t>& parents,
1709 int processingLevel) const;
438635e3 1710
cf9cf07e 1711 /**
1712 * Scan the ECS parameter string.
1713 * The framework provides both the parameters of CONFIGURE and ENGAGE
1714 * in one string in a special data block kAliHLTDataTypeECSParam
1715 * {ECSPARAM:PRIV}. The general format is
1716 * <command>;<parameterkey>=<parametervalue>;<parameterkey>=<parametervalue>;...
1717 */
1718 int ScanECSParam(const char* ecsParam);
1719
1720 /**
1721 * The trigger classes are determined from the trigger and propagated by
1722 * ECS as part of the ENGAGE command parameter which is sent through the
1723 * framework during the SOR event. This function treats the value of the
1724 * parameter key CTP_TRIGGER_CLASS.
1725 */
1726 int InitCTPTriggerClasses(const char* ctpString);
1727
78d29060 1728 enum {
1729 kRequireSteeringBlocks = 0x1,
1730 kDisableComponentStat = 0x2
1731 };
1732
bfccbf68 1733 /** The global component handler instance */
a655eae3 1734 static AliHLTComponentHandler* fgpComponentHandler; //! transient
70ed7d01 1735
bfccbf68 1736 /** The environment where the component is running in */
a3c9b745 1737 AliHLTAnalysisEnvironment fEnvironment; // see above
f23a6e1a 1738
a655eae3 1739 /** Set by ProcessEvent before the processing starts */
1740 AliHLTEventID_t fCurrentEvent; // see above
f23a6e1a 1741
3cde846d 1742 /** internal event no */
a655eae3 1743 int fEventCount; // see above
1744
1745 /** the number of failed events */
1746 int fFailedEvents; // see above
1747
1748 /** event data struct of the current event under processing */
1749 AliHLTComponentEventData fCurrentEventData; // see above
1750
1751 /** array of input data blocks of the current event */
1752 const AliHLTComponentBlockData* fpInputBlocks; //! transient
1753
1754 /** index of the current input block */
1755 int fCurrentInputBlock; // see above
1756
1757 /** data type of the last block search */
1758 AliHLTComponentDataType fSearchDataType; // see above
1759
1760 /** name of the class for the object to search for */
1761 string fClassName; // see above
1762
1763 /** array of generated input objects */
1764 TObjArray* fpInputObjects; //! transient
1765
1766 /** the output buffer */
1767 AliHLTUInt8_t* fpOutputBuffer; //! transient
1768
1769 /** size of the output buffer */
1770 AliHLTUInt32_t fOutputBufferSize; // see above
1771
1772 /** size of data written to output buffer */
1773 AliHLTUInt32_t fOutputBufferFilled; // see above
1774
1775 /** list of ouput block data descriptors */
2be3f004 1776 AliHLTComponentBlockDataList fOutputBlocks; // see above
3cde846d 1777
90ebac25 1778 /** stopwatch array */
1779 TObjArray* fpStopwatches; //! transient
1780
79c114b5 1781 /** array of memory files AliHLTMemoryFile */
2be3f004 1782 AliHLTMemoryFilePList fMemFiles; //! transient
79c114b5 1783
559631d5 1784 /** descriptor of the current run */
1785 AliHLTRunDesc* fpRunDesc; //! transient
1786
82c58a87 1787 /** external fct to set CDB run no, indicates external CDB initialization */
d93ec7ca 1788 void (*fCDBSetRunNoFunc)(); //! transient
579d9eb7 1789
1790 /** id of the component in the analysis chain */
1791 string fChainId; //! transient
1792
48abe484 1793 /** crc value of the chainid, used as a 32bit id */
1794 AliHLTUInt32_t fChainIdCrc; //! transient
1795
a0aeb701 1796 /** optional benchmarking for the component statistics */
1797 TStopwatch* fpBenchmark; //! transient
1798
78d29060 1799 /** component flags, cleared in Deinit */
1800 AliHLTUInt32_t fFlags; //! transient
a0aeb701 1801
48abe484 1802 /** current event type */
1803 AliHLTUInt32_t fEventType; //! transient
1804
abb52c8f 1805 /** component arguments */
1806 string fComponentArgs; //! transient
1807
eafbc306 1808
1809 /** event done data */
1810 AliHLTComponentEventDoneData* fEventDoneData; //! transient
1811
1812 /** Reserved size of the memory stored at fEventDoneData */
1813 unsigned long fEventDoneDataSize; //! transient
1814
9ace7282 1815 /** Comression level for ROOT objects */
1816 int fCompressionLevel; //! transient
1817
b3f4766b 1818 /** size of last PushBack-serialized object */
1819 int fLastObjectSize; //! transient
1820
cf9cf07e 1821 /** array of trigger class descriptors */
adb91bc3 1822 AliHLTCTPData* fpCTPData; //! transient
cf9cf07e 1823
9d4d4b02 1824 /// update period for PushBack calls
1825 int fPushbackPeriod; //! transient
1826 /// time of last executed PushBack
1827 int fLastPushBackTime; //! transient
7e0dd7eb 1828
1829 /// Event modulo for down scaling the processing rate.
1830 int fEventModulo; //! transient
9d4d4b02 1831
9383b10c 1832 ClassDef(AliHLTComponent, 0)
f23a6e1a 1833};
1834#endif