a655eae3 |
1 | //-*- Mode: C++ -*- |
f23a6e1a |
2 | // @(#) $Id$ |
3 | |
4 | #ifndef ALIHLTCOMPONENT_H |
5 | #define ALIHLTCOMPONENT_H |
79c114b5 |
6 | /* This file is property of and copyright by the ALICE HLT Project * |
7 | * ALICE Experiment at CERN, All rights reserved. * |
f23a6e1a |
8 | * See cxx source for full Copyright notice */ |
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 |
30338a30 |
16 | |
17 | // see below for class documentation |
18 | // or |
19 | // refer to README to build package |
20 | // or |
21 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt |
b22e91eb |
22 | */ |
23 | /** |
24 | * @defgroup alihlt_component Component handling of the HLT module |
25 | * This section describes the the component handling for the HLT module. |
26 | */ |
8ede8717 |
27 | |
28 | #include <vector> |
9ce4bf4a |
29 | #include <string> |
5ec8e281 |
30 | #include "AliHLTLogging.h" |
f23a6e1a |
31 | #include "AliHLTDataTypes.h" |
66043029 |
32 | //#include "AliHLTDefinitions.h" |
f23a6e1a |
33 | |
2d7ff710 |
34 | /* Matthias Dec 2006 |
35 | * The names have been changed for Aliroot's coding conventions sake |
36 | * The old names are defined for backward compatibility with the |
37 | * stand alone SampleLib package |
38 | */ |
39 | typedef AliHLTComponentLogSeverity AliHLTComponent_LogSeverity; |
40 | typedef AliHLTComponentEventData AliHLTComponent_EventData; |
41 | typedef AliHLTComponentShmData AliHLTComponent_ShmData; |
42 | typedef AliHLTComponentDataType AliHLTComponent_DataType; |
43 | typedef AliHLTComponentBlockData AliHLTComponent_BlockData; |
44 | typedef AliHLTComponentTriggerData AliHLTComponent_TriggerData; |
45 | typedef AliHLTComponentEventDoneData AliHLTComponent_EventDoneData; |
46 | |
f23a6e1a |
47 | class AliHLTComponentHandler; |
a655eae3 |
48 | class TObjArray; |
90ebac25 |
49 | class TStopwatch; |
2be3f004 |
50 | class AliHLTComponent; |
79c114b5 |
51 | class AliHLTMemoryFile; |
f23a6e1a |
52 | |
2be3f004 |
53 | /** list of component data type structures */ |
54 | typedef vector<AliHLTComponentDataType> AliHLTComponentDataTypeList; |
55 | /** list of component block data structures */ |
56 | typedef vector<AliHLTComponentBlockData> AliHLTComponentBlockDataList; |
57 | /** list of component pointers */ |
58 | typedef vector<AliHLTComponent*> AliHLTComponentPList; |
59 | /** list of memory file pointers */ |
60 | typedef vector<AliHLTMemoryFile*> AliHLTMemoryFilePList; |
61 | |
bfccbf68 |
62 | /** |
63 | * @class AliHLTComponent |
64 | * Base class of HLT data processing components. |
65 | * The class provides a common interface for HLT data processing components. |
66 | * The interface can be accessed from the online HLT framework or the AliRoot |
67 | * offline analysis framework. |
a655eae3 |
68 | * @section alihltcomponent-properties Component identification and properties |
69 | * Each component must provide a unique ID, input and output data type indications, |
70 | * and a spawn function. |
71 | * @subsection alihltcomponent-req-methods Required property methods |
72 | * - @ref GetComponentID |
73 | * - @ref GetInputDataTypes (see @ref alihltcomponent-type for default |
74 | * implementations.) |
75 | * - @ref GetOutputDataType (see @ref alihltcomponent-type for default |
76 | * implementations.) |
77 | * - @ref GetOutputDataSize (see @ref alihltcomponent-type for default |
78 | * implementations.) |
79 | * - @ref Spawn |
bfccbf68 |
80 | * |
a655eae3 |
81 | * @subsection alihltcomponent-opt-mehods Optional handlers |
82 | * - @ref DoInit |
83 | * - @ref DoDeinit |
de6593d0 |
84 | * - @ref GetOutputDataTypes |
85 | * If the component has multiple output data types @ref GetOutputDataType |
86 | * should return @ref kAliHLTMultipleDataType. The framework will invoke |
87 | * @ref GetOutputDataTypes, a list can be filled. |
a655eae3 |
88 | * |
89 | * @subsection alihltcomponent-processing-mehods Data processing |
90 | * |
91 | * |
92 | * @subsection alihltcomponent-type Component type |
93 | * Components can be of type |
90ebac25 |
94 | * - @ref kSource components which only produce data |
95 | * - @ref kProcessor components which consume and produce data |
96 | * - @ref kSink components which only consume data |
a655eae3 |
97 | * |
98 | * where data production and consumption refer to the analysis data stream. In |
99 | * order to indicate the type, a child component can overload the |
100 | * @ref GetComponentType function. |
101 | * @subsubsection alihltcomponent-type-std Standard implementations |
102 | * Components in general do not need to implement this function, standard |
103 | * implementations of the 3 types are available: |
104 | * - AliHLTDataSource for components of type @ref kSource <br> |
105 | * All types of data sources can inherit from AliHLTDataSource and must |
106 | * implement the @ref AliHLTDataSource::GetEvent method. The class |
107 | * also implements a standard method for @ref GetInputDataTypes. |
108 | * |
109 | * - AliHLTProcessor for components of type @ref kProcessor <br> |
110 | * All types of data processors can inherit from AliHLTDataSource and must |
111 | * implement the @ref AliHLTProcessor::DoEvent method. |
112 | * |
113 | * - AliHLTDataSink for components of type @ref kSink <br> |
114 | * All types of data processors can inherit from AliHLTDataSource and must |
115 | * implement the @ref AliHLTDataSink::DumpEvent method. The class |
116 | * also implements a standard method for @ref GetOutputDataType and @ref |
117 | * GetOutputDataSize. |
118 | * |
119 | * @subsection alihltcomponent-environment Running environment |
bfccbf68 |
120 | * |
121 | * In order to adapt to different environments (on-line/off-line), the component |
122 | * gets an environment structure with function pointers. The base class provides |
123 | * member functions for those environment dependend functions. The member |
124 | * functions are used by the component implementation and are re-mapped to the |
125 | * corresponding functions. |
b6800be0 |
126 | * |
a655eae3 |
127 | * @section alihltcomponent-interfaces Component interfaces |
128 | * Each of the 3 standard component base classes AliHLTProcessor, AliHLTDataSource |
129 | * and AliHLTDataSink provides it's own processing method (see |
130 | * @ref alihltcomponent-type-std), which splits into a high and a low-level |
131 | * method. For the @ref alihltcomponent-low-level-interface, all parameters are |
132 | * shipped as function arguments, the component is supposed to dump data to the |
133 | * output buffer and handle all block descriptors. |
134 | * The @ref alihltcomponent-high-level-interface is the standard processing |
135 | * method and will be used whenever the low-level method is not overloaded. |
136 | * |
b6800be0 |
137 | * In both cases it is necessary to calculate/estimate the size of the output |
138 | * buffer before the processing. Output buffers can never be allocated inside |
139 | * the component because of the push-architecture of the HLT. |
140 | * For that reason the @ref GetOutputDataSize function should return a rough |
141 | * estimatian of the data to be produced by the component. The component is |
142 | * responsible for checking the memory size and must return -ENOSPC if the |
143 | * available buffer is to small, and update the estimator respectively. The |
144 | * framework will allocate a buffer of appropriate size and call the processing |
145 | * again. |
146 | * |
b426991e |
147 | * @subsection alihltcomponent-error-codes Data processing |
148 | * For return codes, the following scheme applies: |
149 | * - The data processing methods have to indicate error conditions by a negative |
150 | * error/return code. Preferably the system error codes are used like |
151 | * e.g. -EINVAL. This requires to include the header |
152 | * <pre> |
616eb170 |
153 | * \#include \<cerrno\> |
b426991e |
154 | * </pre> |
155 | * - If no suitable input block could be found (e.g. no clusters for the TPC cluster |
156 | * finder) set size to 0, block list is empty, return 0 |
157 | * - If no ususable or significant signal could be found in the input blocks |
158 | * return an empty output block, set size accordingly, and return 0. An empty output |
159 | * block here could be either a real empty one of size 0 (in which case size also |
160 | * would have to be set to zero) or a block filled with just the minimum necessary |
161 | * accounting/meta-structures. E.g. in the TPC |
162 | * |
a655eae3 |
163 | * @subsection alihltcomponent-high-level-interface High-level interface |
164 | * The high-level component interface provides functionality to exchange ROOT |
165 | * structures between components. In contrast to the |
166 | * @ref alihltcomponent-low-level-interface, a couple of functions can be used |
167 | * to access data blocks of the input stream |
168 | * and send data blocks or ROOT TObject's to the output stream. The functionality |
169 | * is hidden from the user and is implemented by using ROOT's TMessage class. |
170 | * |
171 | * @subsubsection alihltcomponent-high-level-int-methods Interface methods |
172 | * The interface provides a couple of methods in order to get objects from the |
173 | * input, data blocks (non TObject) from the input, and to push back objects and |
174 | * data blocks to the output. For convenience there are several functions of |
175 | * identical name (and similar behavior) with different parameters defined. |
176 | * Please refer to the function documentation. |
177 | * - @ref GetNumberOfInputBlocks <br> |
178 | * return the number of data blocks in the input stream |
179 | * - @ref GetFirstInputObject <br> |
180 | * get the first object of a specific data type |
181 | * - @ref GetNextInputObject <br> |
182 | * get the next object of same data type as last GetFirstInputObject/Block call |
183 | * - @ref GetFirstInputBlock <br> |
184 | * get the first block of a specific data type |
185 | * - @ref GetNextInputBlock <br> |
186 | * get the next block of same data type as last GetFirstInputBlock/Block call |
187 | * - @ref PushBack <br> |
188 | * insert an object or data buffer into the output |
189 | * - @ref CreateEventDoneData <br> |
190 | * add event information to the output |
191 | * |
192 | * In addition, the processing methods are simplified a bit by cutting out most of |
79c114b5 |
193 | * the parameters. |
194 | * @see |
195 | * - @ref AliHLTProcessor::DoEvent |
196 | * - @ref AliHLTDataSource::GetEvent |
197 | * - @ref AliHLTDataSink::DumpEvent |
a655eae3 |
198 | * |
8451168b |
199 | * \em IMPORTANT: objects and block descriptors provided by the high-level interface |
200 | * <b>MUST NOT BE DELETED</b> by the caller. |
201 | * |
a655eae3 |
202 | * @subsubsection alihltcomponent-high-level-int-guidelines High-level interface guidelines |
203 | * - Structures must inherit from the ROOT object base class TObject in order be |
204 | * transported by the transportation framework. |
205 | * - all pointer members must be transient (marked <tt>//!</tt> behind the member |
206 | * definition), i.e. will not be stored/transported, or properly marked |
207 | * (<tt>//-></tt>) in order to call the streamer of the object the member is pointing |
208 | * to. The latter is not recomended. Structures to be transported between components |
209 | * should be streamlined. |
210 | * - no use of stl vectors/strings, use appropriate ROOT classes instead |
211 | * |
212 | * @subsection alihltcomponent-low-level-interface Low-level interface |
213 | * The low-level component interface consists of the specific data processing |
214 | * methods for @ref AliHLTProcessor, @ref AliHLTDataSource, and @ref AliHLTDataSink. |
215 | * - @ref AliHLTProcessor::DoEvent |
216 | * - @ref AliHLTDataSource::GetEvent |
217 | * - @ref AliHLTDataSink::DumpEvent |
218 | * |
219 | * |
220 | * @section alihltcomponent-handling Component handling |
221 | * The handling of HLT analysis components is carried out by the AliHLTComponentHandler. |
222 | * Component are registered automatically at load-time of the component shared library |
223 | * under the following suppositions: |
224 | * - the component library has to be loaded from the AliHLTComponentHandler using the |
225 | * @ref AliHLTComponentHandler::LoadLibrary method. |
226 | * - the component implementation defines one global object (which is generated |
227 | * when the library is loaded) |
228 | * |
229 | * @subsection alihltcomponent-design-rules General design considerations |
230 | * The analysis code should be implemented in one or more destict class(es). A |
231 | * \em component should be implemented which interface the destict analysis code to the |
232 | * component interface. This component generates the analysis object dynamically. <br> |
233 | * |
234 | * Assume you have an implemetation <tt> AliHLTDetMyAnalysis </tt>, another class <tt> |
235 | * AliHLTDetMyAnalysisComponent </tt> contains: |
236 | * <pre> |
237 | * private: |
238 | * AliHLTDetMyAnalysis* fMyAnalysis; //! |
239 | * </pre> |
240 | * The object should then be instantiated in the DoInit handler of |
241 | * <tt>AliHLTDetMyAnalysisComponent </tt>, and cleaned in the DoDeinit handler. |
242 | * |
243 | * Further rules: |
244 | * - avoid big static arrays in the component, allocate the memory at runtime |
245 | * |
b22e91eb |
246 | * @ingroup alihlt_component |
a655eae3 |
247 | * @section alihltcomponent-members Class members |
bfccbf68 |
248 | */ |
5ec8e281 |
249 | class AliHLTComponent : public AliHLTLogging { |
f23a6e1a |
250 | public: |
bfccbf68 |
251 | /** standard constructor */ |
f23a6e1a |
252 | AliHLTComponent(); |
bfccbf68 |
253 | /** standard destructor */ |
f23a6e1a |
254 | virtual ~AliHLTComponent(); |
255 | |
bfccbf68 |
256 | /** component type definitions */ |
f23a6e1a |
257 | enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 }; |
bfccbf68 |
258 | |
259 | /** |
260 | * Init function to prepare data processing. |
261 | * Initialization of common data structures for a sequence of events. |
262 | * The call is redirected to the internal method @ref DoInit which can be |
263 | * overridden by the child class.<br> |
264 | * During Init also the environment structure is passed to the component. |
265 | * @param environ environment pointer with environment dependend function |
266 | * calls |
70ed7d01 |
267 | * @param environParam additionel parameter for function calls, the pointer |
bfccbf68 |
268 | * is passed as it is |
269 | * @param argc size of the argument array |
270 | * @param argv agument array for component initialization |
271 | */ |
70ed7d01 |
272 | virtual int Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv ); |
bfccbf68 |
273 | |
274 | /** |
275 | * Clean-up function to terminate data processing. |
276 | * Clean-up of common data structures after data processing. |
277 | * The call is redirected to the internal method @ref DoDeinit which can be |
278 | * overridden by the child class. |
279 | */ |
f23a6e1a |
280 | virtual int Deinit(); |
bfccbf68 |
281 | |
282 | /** |
283 | * Processing of one event. |
3cde846d |
284 | * The method is the entrance of the event processing. The parameters are |
285 | * cached for uses with the high-level interface and the DoProcessing |
286 | * implementation is called. |
287 | * |
288 | * @param evtData |
289 | * @param blocks |
290 | * @param trigData |
291 | * @param outputPtr |
292 | * @param size |
293 | * @param outputBlockCnt out: size of the output block array, set by the component |
294 | * @param outputBlocks out: the output block array is allocated internally |
295 | * @param edd |
296 | * @return neg. error code if failed |
297 | */ |
298 | int ProcessEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
299 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, |
300 | AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt, |
301 | AliHLTComponentBlockData*& outputBlocks, |
302 | AliHLTComponentEventDoneData*& edd ); |
303 | |
304 | /** |
305 | * Internal processing of one event. |
bfccbf68 |
306 | * The method is pure virtual and implemented by the child classes |
307 | * - @ref AliHLTProcessor |
308 | * - @ref AliHLTDataSource |
309 | * - @ref AliHLTDataSink |
310 | * |
311 | * @param evtData |
312 | * @param blocks |
313 | * @param trigData |
314 | * @param outputPtr |
315 | * @param size |
2d7ff710 |
316 | * @param outputBlocks out: the output block array is allocated internally |
bfccbf68 |
317 | * @param edd |
318 | * @return neg. error code if failed |
319 | */ |
3cde846d |
320 | virtual int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
8ede8717 |
321 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, |
a655eae3 |
322 | AliHLTUInt32_t& size, |
2be3f004 |
323 | AliHLTComponentBlockDataList& outputBlocks, |
8ede8717 |
324 | AliHLTComponentEventDoneData*& edd ) = 0; |
f23a6e1a |
325 | |
579d9eb7 |
326 | /** |
327 | * Init the CDB. |
328 | * The function must not be called when running in AliRoot unless it it |
329 | * really wanted. The CDB path will be set to the specified path, which might |
330 | * override the path initialized at the beginning of the AliRoot reconstruction. |
331 | * |
332 | * The method is used from the external interface in order to set the correct |
82c58a87 |
333 | * path when running on-line. The function also initializes the function |
334 | * callback for setting the run no during operation. |
335 | * |
336 | * A separation of library and component handling is maybe appropriate in the |
337 | * future. Using the global component handler here is maybe not the cleanest |
338 | * solution. |
339 | * @param cdbPath path of the CDB |
340 | * @param pHandler the component handler used for llibrary handling. |
579d9eb7 |
341 | */ |
82c58a87 |
342 | int InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler); |
579d9eb7 |
343 | |
344 | /** |
345 | * Set the run no for the CDB. |
346 | * The function must not be called when running in AliRoot unless it it |
347 | * really wanted. The CDB path will be set to the specified path, which might |
348 | * override the run no initialized at the beginning of the AliRoot reconstruction. |
349 | * |
350 | * The method is used from the external interface in order to set the correct |
351 | * path when running on-line. |
352 | */ |
353 | int SetCDBRunNo(int runNo); |
354 | |
f23a6e1a |
355 | // Information member functions for registration. |
bfccbf68 |
356 | |
357 | /** |
358 | * Get the type of the component. |
359 | * The function is pure virtual and must be implemented by the child class. |
360 | * @return component type id |
361 | */ |
f23a6e1a |
362 | virtual TComponentType GetComponentType() = 0; // Source, sink, or processor |
bfccbf68 |
363 | |
364 | /** |
365 | * Get the id of the component. |
366 | * Each component is identified by a unique id. |
367 | * The function is pure virtual and must be implemented by the child class. |
368 | * @return component id (string) |
369 | */ |
f23a6e1a |
370 | virtual const char* GetComponentID() = 0; |
bfccbf68 |
371 | |
372 | /** |
373 | * Get the input data types of the component. |
374 | * The function is pure virtual and must be implemented by the child class. |
375 | * @return list of data types in the vector reference |
376 | */ |
2be3f004 |
377 | virtual void GetInputDataTypes( AliHLTComponentDataTypeList& ) = 0; |
bfccbf68 |
378 | |
379 | /** |
380 | * Get the output data type of the component. |
381 | * The function is pure virtual and must be implemented by the child class. |
382 | * @return output data type |
383 | */ |
8ede8717 |
384 | virtual AliHLTComponentDataType GetOutputDataType() = 0; |
bfccbf68 |
385 | |
de6593d0 |
386 | /** |
387 | * Get the output data types of the component. |
388 | * The function can be implemented to indicate multiple output data types |
389 | * in the target array. |
390 | * @ref GetOutputDataType must return @ref kAliHLTMultipleDataType in order |
391 | * to invoke this method. |
392 | * @param tgtList list to receive the data types |
393 | * @return no of output data types, data types in the target list |
394 | */ |
2be3f004 |
395 | virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList); |
de6593d0 |
396 | |
bfccbf68 |
397 | /** |
398 | * Get a ratio by how much the data volume is shrinked or enhanced. |
399 | * The function is pure virtual and must be implemented by the child class. |
400 | * @param constBase <i>return</i>: additive part, independent of the |
401 | * input data volume |
402 | * @param inputMultiplier <i>return</i>: multiplication ratio |
403 | * @return values in the reference variables |
404 | */ |
71d7c760 |
405 | virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0; |
f23a6e1a |
406 | |
bfccbf68 |
407 | /** |
408 | * Spawn function. |
409 | * Each component must implement a spawn function to create a new instance of |
410 | * the class. Basically the function must return <i>new <b>my_class_name</b></i>. |
411 | * @return new class instance |
412 | */ |
f23a6e1a |
413 | virtual AliHLTComponent* Spawn() = 0; |
0c0c9d99 |
414 | |
bfccbf68 |
415 | /** |
416 | * Find matching data types between this component and a consumer component. |
417 | * Currently, a component can produce only one type of data. This restriction is most |
418 | * likely to be abolished in the future. |
419 | * @param pConsumer a component and consumer of the data produced by this component |
420 | * @param tgtList reference to a vector list to receive the matching data types. |
421 | * @return >= 0 success, neg. error code if failed |
422 | */ |
2be3f004 |
423 | int FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList); |
f23a6e1a |
424 | |
bfccbf68 |
425 | /** |
426 | * Set the global component handler. |
427 | * The static method is needed for the automatic registration of components. |
428 | */ |
85869391 |
429 | static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0); |
bfccbf68 |
430 | |
431 | /** |
432 | * Clear the global component handler. |
433 | * The static method is needed for the automatic registration of components. |
434 | */ |
85869391 |
435 | static int UnsetGlobalComponentHandler(); |
bfccbf68 |
436 | |
9ce4bf4a |
437 | /** |
438 | * Helper function to convert the data type to a string. |
fbdb63fd |
439 | * @param type data type structure |
440 | * @param mode 0 print string origin:type <br> |
441 | * 1 print chars <br> |
442 | * 2 print numbers |
9ce4bf4a |
443 | */ |
fbdb63fd |
444 | static string DataType2Text( const AliHLTComponentDataType& type, int mode=0); |
9ce4bf4a |
445 | |
5f5b708b |
446 | /** |
447 | * Helper function to print content of data type. |
448 | */ |
449 | void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL) const; |
450 | |
9ce4bf4a |
451 | /** |
452 | * helper function to initialize AliHLTComponentEventData structure |
453 | */ |
454 | static void FillEventData(AliHLTComponentEventData& evtData); |
455 | |
456 | /** |
457 | * Print info on an AliHLTComponentDataType structure |
458 | * This is just a helper function to examine an @ref AliHLTComponentDataType |
459 | * structur. |
460 | */ |
461 | void PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt); |
462 | |
fbdb63fd |
463 | /** |
464 | * Fill AliHLTComponentBlockData structure with default values. |
465 | * @param blockData reference to data structure |
466 | */ |
467 | static void FillBlockData( AliHLTComponentBlockData& blockData ); |
468 | |
469 | /** |
470 | * Fill AliHLTComponentShmData structure with default values. |
471 | * @param shmData reference to data structure |
472 | */ |
473 | static void FillShmData( AliHLTComponentShmData& shmData ); |
474 | |
475 | /** |
476 | * Fill AliHLTComponentDataType structure with default values. |
477 | * @param dataType reference to data structure |
478 | */ |
479 | static void FillDataType( AliHLTComponentDataType& dataType ); |
480 | |
481 | /** |
482 | * Copy data type structure |
483 | * Copies the value an AliHLTComponentDataType structure to another one |
484 | * @param[out] tgtdt target structure |
485 | * @param[in] srcdt source structure |
486 | */ |
487 | static void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt); |
488 | |
489 | /** |
490 | * Set the ID and Origin of an AliHLTComponentDataType structure. |
491 | * The function sets the fStructureSize member and copies the strings |
492 | * to the ID and Origin. Only characters from the valid part of the string |
7e3efc8f |
493 | * are copied, the rest is filled with 0's. <br> |
fbdb63fd |
494 | * Please note that the fID and fOrigin members are not strings, just arrays of |
495 | * chars of size @ref kAliHLTComponentDataTypefIDsize and |
496 | * @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with |
7e3efc8f |
497 | * a terminating zero. <br> |
498 | * It is possible to pass NULL pointers as id or origin argument, in that case they |
499 | * are just ignored. |
fbdb63fd |
500 | * @param tgtdt target data type structure |
501 | * @param id ID string |
502 | * @param origin Origin string |
503 | */ |
504 | static void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin); |
505 | |
90ebac25 |
506 | /** |
507 | * Stopwatch type for benchmarking. |
508 | */ |
509 | enum AliHLTStopwatchType { |
510 | /** total time for event processing */ |
511 | kSWBase, |
512 | /** detector algorithm w/o interface callbacks */ |
513 | kSWDA, |
514 | /** data sources */ |
515 | kSWInput, |
516 | /** data sinks */ |
517 | kSWOutput, |
518 | /** number of types */ |
519 | kSWTypeCount |
520 | }; |
521 | |
522 | /** |
523 | * Helper class for starting and stopping a stopwatch. |
524 | * The guard can be used by instantiating an object in a function. The |
525 | * specified stopwatch is started and the previous stopwatch put on |
526 | * hold. When the function is terminated, the object is deleted automatically |
527 | * deleted, stopping the stopwatch and starting the one on hold.<br> |
528 | * \em IMPORTANT: never create dynamic objects from this guard as this violates |
529 | * the idea of a guard. |
530 | */ |
531 | class AliHLTStopwatchGuard { |
532 | public: |
533 | /** standard constructor (not for use) */ |
534 | AliHLTStopwatchGuard(); |
535 | /** constructor */ |
536 | AliHLTStopwatchGuard(TStopwatch* pStart); |
537 | /** copy constructor (not for use) */ |
e419b223 |
538 | AliHLTStopwatchGuard(const AliHLTStopwatchGuard&); |
539 | /** assignment operator (not for use) */ |
540 | AliHLTStopwatchGuard& operator=(const AliHLTStopwatchGuard&); |
90ebac25 |
541 | /** destructor */ |
542 | ~AliHLTStopwatchGuard(); |
543 | |
544 | private: |
545 | /** |
546 | * Hold the previous guard for the existence of this guard. |
547 | * Checks whether this guard controls a new stopwatch. In that case, the |
548 | * previous guard and its stopwatch are put on hold. |
549 | * @param pSucc instance of the stopwatch of the new guard |
550 | * @return 1 if pSucc is a different stopwatch which should |
551 | * be started<br> |
552 | * 0 if it controls the same stopwatch |
553 | */ |
554 | int Hold(TStopwatch* pSucc); |
555 | |
556 | /** |
557 | * Resume the previous guard. |
558 | * Checks whether the peceeding guard controls a different stopwatch. In that |
559 | * case, the its stopwatch is resumed. |
560 | * @param pSucc instance of the stopwatch of the new guard |
561 | * @return 1 if pSucc is a different stopwatch which should |
562 | * be stopped<br> |
563 | * 0 if it controls the same stopwatch |
564 | */ |
565 | int Resume(TStopwatch* pSucc); |
566 | |
567 | /** the stopwatch controlled by this guard */ |
568 | TStopwatch* fpStopwatch; //!transient |
569 | |
570 | /** previous stopwatch guard, put on hold during existence of the guard */ |
571 | AliHLTStopwatchGuard* fpPrec; //!transient |
572 | |
573 | /** active stopwatch guard */ |
574 | static AliHLTStopwatchGuard* fgpCurrent; //!transient |
575 | }; |
576 | |
577 | /** |
578 | * Set a stopwatch for a given purpose. |
579 | * @param pSW stopwatch object |
580 | * @param type type of the stopwatch |
581 | */ |
582 | int SetStopwatch(TObject* pSW, AliHLTStopwatchType type=kSWBase); |
583 | |
584 | /** |
585 | * Init a set of stopwatches. |
586 | * @param pStopwatches object array of stopwatches |
587 | */ |
588 | int SetStopwatches(TObjArray* pStopwatches); |
a655eae3 |
589 | |
f23a6e1a |
590 | protected: |
71d7c760 |
591 | |
bfccbf68 |
592 | /** |
593 | * Default method for the internal initialization. |
594 | * The method is called by @ref Init |
595 | */ |
53feaef5 |
596 | virtual int DoInit( int argc, const char** argv ); |
f23a6e1a |
597 | |
bfccbf68 |
598 | /** |
599 | * Default method for the internal clean-up. |
600 | * The method is called by @ref Deinit |
601 | */ |
53feaef5 |
602 | virtual int DoDeinit(); |
f23a6e1a |
603 | |
579d9eb7 |
604 | /** |
605 | * Reconfigure the component. |
606 | * The method is called when an event of type @ref kAliHLTDataTypeComConf |
607 | * {COM_CONF:PRIV} is received by the component. If the event is sent as |
608 | * part of a normal event, the component configuration is called first. |
609 | * |
610 | * The CDB path parameter specifies the path in the CDB, i.e. without |
611 | * leading absolute path of the CDB location. The framework might alse |
612 | * provide the id of the component in the analysis chain. |
613 | * |
614 | * \b Note: The CDB will be initialized by the framework, either already set |
615 | * from AliRoot or from the wrapper interface during initialization. |
616 | * |
617 | * @param cdbEntry path of the cdbEntry |
618 | * @param chainId the id of the component in the analysis chain |
619 | * @note both parameters can be NULL, check before usage |
620 | */ |
621 | virtual int Reconfigure(const char* cdbEntry, const char* chainId); |
622 | |
bfccbf68 |
623 | /** |
624 | * General memory allocation method. |
625 | * All memory which is going to be used 'outside' of the interface must |
626 | * be provided by the framework (online or offline). |
627 | * The method is redirected to a function provided by the current |
628 | * framework. Function pointers are transferred via the @ref |
629 | * AliHLTComponentEnvironment structure. |
630 | */ |
85869391 |
631 | void* AllocMemory( unsigned long size ); |
f23a6e1a |
632 | |
bfccbf68 |
633 | /** |
634 | * Helper function to create a monolithic BlockData description block out |
635 | * of a list BlockData descriptors. |
636 | * For convenience, inside the interface vector lists are used, to make the |
637 | * interface pure C style, monilithic blocks must be exchanged. |
638 | * The method is redirected to a function provided by the current |
639 | * framework. Function pointers are transferred via the @ref |
640 | * AliHLTComponentEnvironment structure. |
641 | */ |
2be3f004 |
642 | int MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount, |
8ede8717 |
643 | AliHLTComponentBlockData** outputBlocks ); |
f23a6e1a |
644 | |
bfccbf68 |
645 | /** |
646 | * Fill the EventDoneData structure. |
647 | * The method is redirected to a function provided by the current |
648 | * framework. Function pointers are transferred via the @ref |
649 | * AliHLTComponentEnvironment structure. |
650 | */ |
8ede8717 |
651 | int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd ); |
f23a6e1a |
652 | |
bfccbf68 |
653 | /** |
654 | * Helper function to convert the data type to a string. |
655 | */ |
70ed7d01 |
656 | void DataType2Text(const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]) const; |
fa2e9b7c |
657 | |
3cde846d |
658 | /** |
659 | * Get event number. |
660 | * @return value of the internal event counter |
661 | */ |
70ed7d01 |
662 | int GetEventCount() const; |
3cde846d |
663 | |
a655eae3 |
664 | /** |
665 | * Get the number of input blocks. |
666 | * @return number of input blocks |
667 | */ |
66043029 |
668 | int GetNumberOfInputBlocks() const; |
a655eae3 |
669 | |
670 | /** |
671 | * Get the first object of a specific data type from the input data. |
672 | * The hight-level methods provide functionality to transfer ROOT data |
673 | * structures which inherit from TObject. |
674 | * The method looks for the first ROOT object of type dt in the input stream. |
675 | * If also the class name is provided, the object is checked for the right |
676 | * class type. The input data block needs a certain structure, namely the |
677 | * buffer size as first word. If the cross check fails, the retrieval is |
8451168b |
678 | * silently abondoned, unless the \em bForce parameter is set.<br> |
679 | * \em Note: THE OBJECT MUST NOT BE DELETED by the caller. |
a655eae3 |
680 | * @param dt data type of the object |
681 | * @param classname class name of the object |
682 | * @param bForce force the retrieval of an object, error messages |
683 | * are suppressed if \em bForce is not set |
684 | * @return pointer to @ref TObject, NULL if no objects of specified type |
685 | * available |
686 | */ |
687 | const TObject* GetFirstInputObject(const AliHLTComponentDataType& dt=kAliHLTAnyDataType, |
688 | const char* classname=NULL, |
689 | int bForce=0); |
690 | |
691 | /** |
692 | * Get the first object of a specific data type from the input data. |
693 | * The hight-level methods provide functionality to transfer ROOT data |
694 | * structures which inherit from TObject. |
695 | * The method looks for the first ROOT object of type specified by the ID and |
696 | * Origin strings in the input stream. |
697 | * If also the class name is provided, the object is checked for the right |
698 | * class type. The input data block needs a certain structure, namely the |
699 | * buffer size as first word. If the cross check fails, the retrieval is |
8451168b |
700 | * silently abondoned, unless the \em bForce parameter is set.<br> |
701 | * \em Note: THE OBJECT MUST NOT BE DELETED by the caller. |
a655eae3 |
702 | * @param dtID data type ID of the object |
703 | * @param dtOrigin data type origin of the object |
704 | * @param classname class name of the object |
705 | * @param bForce force the retrieval of an object, error messages |
706 | * are suppressed if \em bForce is not set |
707 | * @return pointer to @ref TObject, NULL if no objects of specified type |
708 | * available |
709 | */ |
710 | const TObject* GetFirstInputObject(const char* dtID, |
711 | const char* dtOrigin, |
712 | const char* classname=NULL, |
713 | int bForce=0); |
714 | |
715 | /** |
716 | * Get the next object of a specific data type from the input data. |
717 | * The hight-level methods provide functionality to transfer ROOT data |
718 | * structures which inherit from TObject. |
719 | * The method looks for the next ROOT object of type and class specified |
8451168b |
720 | * to the previous @ref GetFirstInputObject call.<br> |
721 | * \em Note: THE OBJECT MUST NOT BE DELETED by the caller. |
a655eae3 |
722 | * @param bForce force the retrieval of an object, error messages |
723 | * are suppressed if \em bForce is not set |
724 | * @return pointer to @ref TObject, NULL if no more objects available |
725 | */ |
726 | const TObject* GetNextInputObject(int bForce=0); |
727 | |
728 | /** |
729 | * Get data type of an input block. |
730 | * Get data type of the object previously fetched via |
731 | * GetFirstInputObject/NextInputObject or the last one if no object |
732 | * specified. |
733 | * @param pObject pointer to TObject |
734 | * @return data specification, kAliHLTVoidDataSpec if failed |
735 | */ |
736 | AliHLTComponentDataType GetDataType(const TObject* pObject=NULL); |
737 | |
738 | /** |
739 | * Get data specification of an input block. |
740 | * Get data specification of the object previously fetched via |
741 | * GetFirstInputObject/NextInputObject or the last one if no object |
742 | * specified. |
743 | * @param pObject pointer to TObject |
744 | * @return data specification, kAliHLTVoidDataSpec if failed |
745 | */ |
746 | AliHLTUInt32_t GetSpecification(const TObject* pObject=NULL); |
747 | |
748 | /** |
749 | * Get the first block of a specific data type from the input data. |
750 | * The method looks for the first block of type dt in the input stream. It is intended |
8451168b |
751 | * to be used within the high-level interface.<br> |
752 | * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller. |
a655eae3 |
753 | * @param dt data type of the block |
754 | * @return pointer to @ref AliHLTComponentBlockData |
755 | */ |
756 | const AliHLTComponentBlockData* GetFirstInputBlock(const AliHLTComponentDataType& dt=kAliHLTAnyDataType); |
757 | |
758 | /** |
759 | * Get the first block of a specific data type from the input data. |
760 | * The method looks for the first block of type specified by the ID and |
761 | * Origin strings in the input stream. It is intended |
8451168b |
762 | * to be used within the high-level interface.<br> |
763 | * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller. |
a655eae3 |
764 | * @param dtID data type ID of the block |
765 | * @param dtOrigin data type origin of the block |
766 | * @return pointer to @ref AliHLTComponentBlockData |
767 | */ |
768 | const AliHLTComponentBlockData* GetFirstInputBlock(const char* dtID, |
769 | const char* dtOrigin); |
770 | |
771 | /** |
8451168b |
772 | * Get input block by index.<br> |
773 | * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller. |
a655eae3 |
774 | * @return pointer to AliHLTComponentBlockData, NULL if index out of range |
775 | */ |
776 | const AliHLTComponentBlockData* GetInputBlock(int index); |
777 | |
778 | /** |
779 | * Get the next block of a specific data type from the input data. |
780 | * The method looks for the next block of type and class specified |
781 | * to the previous @ref GetFirstInputBlock call. |
8451168b |
782 | * To be used within the high-level interface.<br> |
783 | * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller. |
a655eae3 |
784 | */ |
785 | const AliHLTComponentBlockData* GetNextInputBlock(); |
786 | |
787 | /** |
788 | * Get data specification of an input block. |
789 | * Get data specification of the input bblock previously fetched via |
790 | * GetFirstInputObject/NextInputObject or the last one if no block |
791 | * specified. |
792 | * @param pBlock pointer to input block |
793 | * @return data specification, kAliHLTVoidDataSpec if failed |
794 | */ |
795 | AliHLTUInt32_t GetSpecification(const AliHLTComponentBlockData* pBlock=NULL); |
796 | |
c7e9e2f2 |
797 | /** |
798 | * Forward an input object to the output. |
799 | * Forward the input block of an object previously fetched via |
800 | * GetFirstInputObject/NextInputObject or the last one if no object |
801 | * specified. |
802 | * The block descriptor of the input block is forwarded to the |
803 | * output block list. |
804 | * @param pObject pointer to TObject |
805 | * @return neg. error code if failed |
806 | */ |
807 | int Forward(const TObject* pObject); |
808 | |
809 | /** |
810 | * Forward an input block to the output. |
811 | * Forward the input block fetched via GetFirstInputObject/ |
812 | * NextInputBlock or the last one if no block specified. |
813 | * The block descriptor of the input block is forwarded to the |
814 | * output block list. |
815 | * @param pBlock pointer to input block |
816 | * @return neg. error code if failed |
817 | */ |
818 | int Forward(const AliHLTComponentBlockData* pBlock=NULL); |
819 | |
a655eae3 |
820 | /** |
821 | * Insert an object into the output. |
79c114b5 |
822 | * If header is specified, it will be inserted before the root object, |
823 | * default is no header. |
a655eae3 |
824 | * @param pObject pointer to root object |
825 | * @param dt data type of the object |
826 | * @param spec data specification |
79c114b5 |
827 | * @param pHeader pointer to header |
828 | * @param headerSize size of Header |
a655eae3 |
829 | * @return neg. error code if failed |
830 | */ |
831 | int PushBack(TObject* pObject, const AliHLTComponentDataType& dt, |
79c114b5 |
832 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec, |
833 | void* pHeader=NULL, int headerSize=0); |
a655eae3 |
834 | |
835 | /** |
836 | * Insert an object into the output. |
79c114b5 |
837 | * If header is specified, it will be inserted before the root object, |
838 | * default is no header. |
a655eae3 |
839 | * @param pObject pointer to root object |
840 | * @param dtID data type ID of the object |
841 | * @param dtOrigin data type origin of the object |
842 | * @param spec data specification |
79c114b5 |
843 | * @param pHeader pointer to header |
844 | * @param headerSize size of Header |
a655eae3 |
845 | * @return neg. error code if failed |
846 | */ |
847 | int PushBack(TObject* pObject, const char* dtID, const char* dtOrigin, |
79c114b5 |
848 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec, |
849 | void* pHeader=NULL, int headerSize=0); |
850 | |
a655eae3 |
851 | /** |
852 | * Insert an object into the output. |
853 | * @param pBuffer pointer to buffer |
854 | * @param iSize size of the buffer |
855 | * @param dt data type of the object |
856 | * @param spec data specification |
9d9ffd37 |
857 | * @param pHeader pointer to header |
7c4091c1 |
858 | * @param headerSize size of Header |
a655eae3 |
859 | * @return neg. error code if failed |
860 | */ |
861 | int PushBack(void* pBuffer, int iSize, const AliHLTComponentDataType& dt, |
9d9ffd37 |
862 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec, |
863 | void* pHeader=NULL, int headerSize=0); |
a655eae3 |
864 | |
865 | /** |
866 | * Insert an object into the output. |
867 | * @param pBuffer pointer to buffer |
868 | * @param iSize size of the buffer |
869 | * @param dtID data type ID of the object |
870 | * @param dtOrigin data type origin of the object |
871 | * @param spec data specification |
9d9ffd37 |
872 | * @param pHeader pointer to header |
7c4091c1 |
873 | * @param headerSize size of Header |
a655eae3 |
874 | * @return neg. error code if failed |
875 | */ |
876 | int PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin, |
9d9ffd37 |
877 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec, |
878 | void* pHeader=NULL, int headerSize=0); |
a655eae3 |
879 | |
8451168b |
880 | /** |
881 | * Estimate size of a TObject |
882 | * @param pObject |
883 | * @return buffer size in byte |
884 | */ |
885 | int EstimateObjectSize(TObject* pObject) const; |
886 | |
79c114b5 |
887 | /** |
888 | * Create a memory file in the output stream. |
889 | * This method creates a TFile object which stores all data in |
890 | * memory instead of disk. The TFile object is published as binary data. |
891 | * The instance can be used like a normal TFile object. The TFile::Close |
892 | * or @ref CloseMemoryFile method has to be called in order to flush the |
893 | * output stream. |
894 | * |
895 | * \b Note: The returned object is deleted by the framework. |
896 | * @param capacity total size reserved for the memory file |
897 | * @param dtID data type ID of the file |
898 | * @param dtOrigin data type origin of the file |
899 | * @param spec data specification |
900 | * @return file handle, NULL if failed |
901 | */ |
902 | AliHLTMemoryFile* CreateMemoryFile(int capacity, const char* dtID, const char* dtOrigin, |
903 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec); |
904 | |
905 | /** |
906 | * Create a memory file in the output stream. |
907 | * This method creates a TFile object which stores all data in |
908 | * memory instead of disk. The TFile object is published as binary data. |
909 | * The instance can be used like a normal TFile object. The TFile::Close |
910 | * or @ref CloseMemoryFile method has to be called in order to flush the |
911 | * output stream. |
912 | * |
913 | * \b Note: The returned object is deleted by the framework. |
914 | * @param capacity total size reserved for the memory file |
915 | * @param dt data type of the file |
916 | * @param spec data specification |
917 | * @return file handle, NULL if failed |
918 | */ |
919 | AliHLTMemoryFile* CreateMemoryFile(int capacity, |
920 | const AliHLTComponentDataType& dt=kAliHLTAnyDataType, |
921 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec); |
922 | |
923 | /** |
924 | * Create a memory file in the output stream. |
925 | * This method creates a TFile object which stores all data in |
926 | * memory instead of disk. The TFile object is published as binary data. |
927 | * The instance can be used like a normal TFile object. The TFile::Close |
928 | * or @ref CloseMemoryFile method has to be called in order to flush the |
929 | * output stream. |
930 | * |
931 | * \b Note: The returned object is deleted by the framework. |
932 | * @param dtID data type ID of the file |
933 | * @param dtOrigin data type origin of the file |
934 | * @param spec data specification |
935 | * @param capacity fraction of the available output buffer size |
936 | * @return file handle, NULL if failed |
937 | */ |
938 | AliHLTMemoryFile* CreateMemoryFile(const char* dtID, const char* dtOrigin, |
939 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec, |
940 | float capacity=1.0); |
941 | |
942 | /** |
943 | * Create a memory file in the output stream. |
944 | * This method creates a TFile object which stores all data in |
945 | * memory instead of disk. The TFile object is published as binary data. |
946 | * The instance can be used like a normal TFile object. The TFile::Close |
947 | * or @ref CloseMemoryFile method has to be called in order to flush the |
948 | * output stream. |
949 | * |
950 | * \b Note: The returned object is deleted by the framework. |
951 | * @param dt data type of the file |
952 | * @param spec data specification |
953 | * @param capacity fraction of the available output buffer size |
954 | * @return file handle, NULL if failed |
955 | */ |
956 | AliHLTMemoryFile* CreateMemoryFile(const AliHLTComponentDataType& dt=kAliHLTAnyDataType, |
957 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec, |
958 | float capacity=1.0); |
959 | |
960 | /** |
961 | * Write an object to memory file in the output stream. |
962 | * @param pFile file handle |
963 | * @param pObject pointer to root object |
964 | * @param key key in ROOT file |
965 | * @param option options, see TObject::Write |
966 | * @return neg. error code if failed |
967 | * - -ENOSPC no space left |
968 | */ |
969 | int Write(AliHLTMemoryFile* pFile, const TObject* pObject, const char* key=NULL, int option=TObject::kOverwrite); |
970 | |
971 | /** |
972 | * Close object memory file. |
973 | * @param pFile file handle |
974 | * @return neg. error code if failed |
975 | * - -ENOSPC buffer size too small |
976 | */ |
977 | int CloseMemoryFile(AliHLTMemoryFile* pFile); |
978 | |
a655eae3 |
979 | /** |
980 | * Insert event-done data information into the output. |
981 | * @param edd event-done data information |
982 | */ |
983 | int CreateEventDoneData(AliHLTComponentEventDoneData edd); |
984 | |
559631d5 |
985 | /** |
986 | * Get current run number |
987 | */ |
988 | AliHLTUInt32_t GetRunNo() const; |
989 | |
990 | /** |
991 | * Get the current run type. |
992 | */ |
993 | AliHLTUInt32_t GetRunType() const; |
994 | |
ed504011 |
995 | /** |
996 | * Set a bit to 1 in a readout list ( = AliHLTEventDDL ) |
997 | * -> enable DDL for readout |
998 | * @param list readout list |
999 | * @param ddlId DDL Id to be turned on ( Decimal ) |
1000 | */ |
1001 | void EnableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const { |
1002 | SetDDLBit( list, ddlId, kTRUE ); |
1003 | } |
1004 | |
1005 | /** |
1006 | * Set a bit to 0 in a readout list ( = AliHLTEventDDL ) |
1007 | * -> disable DDL for readout |
1008 | * @param list readout list |
1009 | * @param ddlId DDL Id to be turned on ( Decimal ) |
1010 | */ |
1011 | void DisableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const { |
1012 | SetDDLBit( list, ddlId, kFALSE ); |
1013 | } |
1014 | |
1015 | /** |
1016 | * Set or unset bit a readout list ( = AliHLTEventDDL ) |
1017 | * -> enable or disable DDL for readout |
1018 | * @param list readout list |
1019 | * @param ddlId DDL Id to be turned on ( Decimal ) |
1020 | * @param state kTRUE sets it, kFALSE unsets it |
1021 | */ |
1022 | void SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const; |
1023 | |
1024 | /** |
1025 | * Get the first word of a detector, which has a set DDL bit. |
1026 | * Beware, this only works if DDLs of 1 detector are set. In the |
1027 | * case of the TPC and TOF, which use 8 and 3 words, the first |
1028 | * word is returned. |
1029 | * @param list readout list |
1030 | * @return returns the detector index, -1 if no bit is set |
1031 | * at all or several detectors (=error) |
1032 | */ |
1033 | Int_t GetFirstUsedDDLWord(AliHLTEventDDL &list) const; |
1034 | |
559631d5 |
1035 | /** |
1036 | * Copy a struct from block data. |
1037 | * The function checks for block size and struct size. The least common |
1038 | * size will be copied to the target struct, remaining fields are initialized |
1039 | * to zero.<br> |
1040 | * The target struct must have a 32bit struct size indicator as first member. |
1041 | * @param pStruct target struct |
1042 | * @param iStructSize size of the struct |
559631d5 |
1043 | * @param iBlockNo index of input block |
1044 | * @param structname name of the struct (log messages) |
1045 | * @param eventname name of the event (log messages) |
1046 | * @return size copied, neg. error if failed |
1047 | */ |
83fec083 |
1048 | int CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo, |
559631d5 |
1049 | const char* structname="", const char* eventname=""); |
1050 | |
f23a6e1a |
1051 | private: |
b426991e |
1052 | /** copy constructor prohibited */ |
559631d5 |
1053 | AliHLTComponent(const AliHLTComponent&); |
b426991e |
1054 | /** assignment operator prohibited */ |
559631d5 |
1055 | AliHLTComponent& operator=(const AliHLTComponent&); |
1056 | |
3cde846d |
1057 | /** |
1058 | * Increment the internal event counter. |
1059 | * To be used by the friend classes AliHLTProcessor, AliHLTDataSource |
1060 | * and AliHLTDataSink. |
1061 | * @return new value of the internal event counter |
a655eae3 |
1062 | * @internal |
3cde846d |
1063 | */ |
1064 | int IncrementEventCounter(); |
1065 | |
a655eae3 |
1066 | /** |
1067 | * Find the first input block of specified data type beginning at index. |
1edbbe49 |
1068 | * Input blocks containing a TObject have the size of the object as an |
1069 | * unsigned 32 bit number in the first 4 bytes. This has to match the block |
1070 | * size minus 4. |
a655eae3 |
1071 | * @param dt data type |
1072 | * @param startIdx index to start the search |
1edbbe49 |
1073 | * @param bObject check if this is an object |
a655eae3 |
1074 | * @return index of the block, -ENOENT if no block found |
1075 | * |
1076 | * @internal |
1077 | */ |
1edbbe49 |
1078 | int FindInputBlock(const AliHLTComponentDataType& dt, int startIdx=-1, int bObject=0) const; |
a655eae3 |
1079 | |
1080 | /** |
1081 | * Get index in the array of input bocks. |
1082 | * Calculate index and check integrety of a block data structure pointer. |
1083 | * @param pBlock pointer to block data |
1084 | * @return index of the block, -ENOENT if no block found |
1085 | * |
1086 | * @internal |
1087 | */ |
66043029 |
1088 | int FindInputBlock(const AliHLTComponentBlockData* pBlock) const; |
a655eae3 |
1089 | |
1090 | /** |
1091 | * Create an object from a specified input block. |
1092 | * @param idx index of the input block |
1093 | * @param bForce force the retrieval of an object, error messages |
1094 | * are suppressed if \em bForce is not set |
1095 | * @return pointer to TObject, caller must delete the object after use |
1096 | * |
1097 | * @internal |
1098 | */ |
1099 | TObject* CreateInputObject(int idx, int bForce=0); |
1100 | |
1101 | /** |
1102 | * Get input object |
8451168b |
1103 | * Get object from the input block list. The methods first checks whether the |
1104 | * object was already created. If not, it is created by @ref CreateInputObject |
1105 | * and inserted into the list of objects. |
a655eae3 |
1106 | * @param idx index in the input block list |
1107 | * @param classname name of the class, object is checked for correct class |
1108 | * name if set |
1109 | * @param bForce force the retrieval of an object, error messages |
1110 | * are suppressed if \em bForce is not set |
1111 | * @return pointer to TObject |
1112 | * |
1113 | * @internal |
1114 | */ |
1115 | TObject* GetInputObject(int idx, const char* classname=NULL, int bForce=0); |
1116 | |
8451168b |
1117 | /** |
1118 | * Clean the list of input objects. |
1119 | * Cleanup is done at the end of each event processing. |
1120 | */ |
1121 | int CleanupInputObjects(); |
1122 | |
a655eae3 |
1123 | /** |
1124 | * Insert a buffer into the output block stream. |
1125 | * This is the only method to insert blocks into the output stream, called |
1126 | * from all types of the Pushback method. The actual data might have been |
1127 | * written to the output buffer already. In that case NULL can be provided |
79c114b5 |
1128 | * as buffer, only the block descriptor will be build. If a header is specified, |
1129 | * it will be inserted before the buffer, default is no header. |
a655eae3 |
1130 | * @param pBuffer pointer to buffer |
32db4144 |
1131 | * @param iBufferSize size of the buffer in byte |
a655eae3 |
1132 | * @param dt data type |
1133 | * @param spec data specification |
79c114b5 |
1134 | * @param pHeader pointer to header |
1135 | * @param iHeaderSize size of Header |
b6800be0 |
1136 | * @return neg. error code if failed |
a655eae3 |
1137 | */ |
79c114b5 |
1138 | int InsertOutputBlock(void* pBuffer, int iBufferSize, |
a655eae3 |
1139 | const AliHLTComponentDataType& dt, |
79c114b5 |
1140 | AliHLTUInt32_t spec, |
1141 | void* pHeader=NULL, int iHeaderSize=0); |
a655eae3 |
1142 | |
bfccbf68 |
1143 | /** The global component handler instance */ |
a655eae3 |
1144 | static AliHLTComponentHandler* fgpComponentHandler; //! transient |
70ed7d01 |
1145 | |
bfccbf68 |
1146 | /** The environment where the component is running in */ |
a655eae3 |
1147 | AliHLTComponentEnvironment fEnvironment; // see above |
f23a6e1a |
1148 | |
a655eae3 |
1149 | /** Set by ProcessEvent before the processing starts */ |
1150 | AliHLTEventID_t fCurrentEvent; // see above |
f23a6e1a |
1151 | |
3cde846d |
1152 | /** internal event no */ |
a655eae3 |
1153 | int fEventCount; // see above |
1154 | |
1155 | /** the number of failed events */ |
1156 | int fFailedEvents; // see above |
1157 | |
1158 | /** event data struct of the current event under processing */ |
1159 | AliHLTComponentEventData fCurrentEventData; // see above |
1160 | |
1161 | /** array of input data blocks of the current event */ |
1162 | const AliHLTComponentBlockData* fpInputBlocks; //! transient |
1163 | |
1164 | /** index of the current input block */ |
1165 | int fCurrentInputBlock; // see above |
1166 | |
1167 | /** data type of the last block search */ |
1168 | AliHLTComponentDataType fSearchDataType; // see above |
1169 | |
1170 | /** name of the class for the object to search for */ |
1171 | string fClassName; // see above |
1172 | |
1173 | /** array of generated input objects */ |
1174 | TObjArray* fpInputObjects; //! transient |
1175 | |
1176 | /** the output buffer */ |
1177 | AliHLTUInt8_t* fpOutputBuffer; //! transient |
1178 | |
1179 | /** size of the output buffer */ |
1180 | AliHLTUInt32_t fOutputBufferSize; // see above |
1181 | |
1182 | /** size of data written to output buffer */ |
1183 | AliHLTUInt32_t fOutputBufferFilled; // see above |
1184 | |
1185 | /** list of ouput block data descriptors */ |
2be3f004 |
1186 | AliHLTComponentBlockDataList fOutputBlocks; // see above |
3cde846d |
1187 | |
90ebac25 |
1188 | /** stopwatch array */ |
1189 | TObjArray* fpStopwatches; //! transient |
1190 | |
79c114b5 |
1191 | /** array of memory files AliHLTMemoryFile */ |
2be3f004 |
1192 | AliHLTMemoryFilePList fMemFiles; //! transient |
79c114b5 |
1193 | |
559631d5 |
1194 | /** descriptor of the current run */ |
1195 | AliHLTRunDesc* fpRunDesc; //! transient |
1196 | |
1197 | /** the current DDL list */ |
1198 | AliHLTEventDDL* fpDDLList; //! transient |
1199 | |
82c58a87 |
1200 | /** external fct to set CDB run no, indicates external CDB initialization */ |
1201 | void* fCDBSetRunNoFunc; //! transient |
579d9eb7 |
1202 | |
1203 | /** id of the component in the analysis chain */ |
1204 | string fChainId; //! transient |
1205 | |
82c58a87 |
1206 | ClassDef(AliHLTComponent, 5) |
f23a6e1a |
1207 | }; |
1208 | #endif |