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