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