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