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