]>
Commit | Line | Data |
---|---|---|
62bb3cd4 | 1 | //-*- Mode: C++ -*- |
4c4b4801 | 2 | // $Id$ |
62bb3cd4 | 3 | |
4 | #ifndef ALIHLTOUT_H | |
5 | #define ALIHLTOUT_H | |
5db0e774 | 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 * | |
62bb3cd4 | 9 | |
4c4b4801 | 10 | /// @file AliHLTOUT.h |
11 | /// @author Matthias Richter | |
12 | /// @date | |
13 | /// @brief The control class for HLTOUT data. | |
14 | /// | |
62bb3cd4 | 15 | |
4de7334f | 16 | #include <vector> |
62bb3cd4 | 17 | #include "AliHLTLogging.h" |
5db0e774 | 18 | #include "AliHLTModuleAgent.h" |
19 | ||
20 | class AliHLTOUTHandler; | |
04058ee9 | 21 | class AliHLTOUTHandlerDesc; // AliHLTModuleAgent.h |
c5123824 | 22 | class AliESDEvent; |
23 | class AliHLTReconstructor; | |
c1292031 | 24 | class AliRawReader; |
25 | class TTree; | |
5db0e774 | 26 | |
27 | #define AliHLTOUTInvalidIndex (~(AliHLTUInt32_t)0) | |
28 | ||
29 | typedef vector<AliHLTUInt32_t> AliHLTOUTIndexList; | |
62bb3cd4 | 30 | |
31 | /** | |
32 | * @class AliHLTOUT | |
33 | * The control class for HLTOUT data. | |
34 | * The output of the HLT, either from the HLTOUT nodes or simulated output, | |
35 | * is transferred and stored in the HOMER format. The AliHLTOUT class | |
36 | * implements scanning of the HOMER data for all HLTOUT DDL links and | |
37 | * abstracts access to the complete HLTOUT data. | |
38 | * | |
39 | */ | |
b005ef92 | 40 | class AliHLTOUT { |
62bb3cd4 | 41 | public: |
42 | /** standard constructor */ | |
43 | AliHLTOUT(); | |
44 | /** standard destructor */ | |
45 | virtual ~AliHLTOUT(); | |
46 | ||
c1292031 | 47 | /** |
48 | * Create an AliHLTOUTRawReader instance. | |
49 | * Helper function to transparently access classes from the | |
50 | * libHLTrec library. | |
51 | */ | |
52 | static AliHLTOUT* New(AliRawReader* pRawReader); | |
53 | ||
54 | /** | |
55 | * Create an AliHLTOUTDigitReader instance | |
56 | * Helper function to transparently access classes from the | |
57 | * libHLTrec library. | |
58 | */ | |
59 | static AliHLTOUT* New(TTree* pDigitTree, int event=-1); | |
60 | ||
466d4e62 | 61 | /** |
62 | * Create an AliHLTOUTDigitReader instance | |
63 | * Helper function to transparently access classes from the | |
64 | * libHLTrec library. | |
65 | */ | |
66 | static AliHLTOUT* New(const char* filename, int event=-1); | |
67 | ||
b005ef92 | 68 | /** |
69 | * Get the global instance. | |
70 | * The global instance is set temporarily by the AliHLTOUTGlobalInstanceGuard | |
71 | * mainly for the sake of data input to an analysis chain. The | |
72 | * AliHLTOUTPublisherComponent objects can access the global instance. | |
73 | */ | |
74 | static AliHLTOUT* GetGlobalInstance() {return fgGlobalInstance;} | |
75 | ||
c1292031 | 76 | /** |
77 | * Delete an instance of the HLTOUT. | |
78 | * Helper function to transparently access classes from the | |
79 | * libHLTrec library. Before deleting, the availability of the | |
80 | * library is checked. | |
81 | */ | |
82 | static void Delete(AliHLTOUT* pInstance); | |
83 | ||
4de7334f | 84 | /** |
85 | * Locking guard for the AliHLTOUT object. | |
86 | * If the object is locked, the selection of data blocks can not be changed. | |
87 | */ | |
88 | class AliHLTOUTLockGuard { | |
89 | public: | |
90 | /** constructor */ | |
91 | AliHLTOUTLockGuard(AliHLTOUT* pInstance) : fpInstance(pInstance) | |
049b43b2 | 92 | {if (fpInstance) fpInstance->SetStatusFlag(kLocked);} |
4de7334f | 93 | /** destructor */ |
94 | ~AliHLTOUTLockGuard() | |
049b43b2 | 95 | {if (fpInstance) fpInstance->ClearStatusFlag(kLocked);} |
4de7334f | 96 | |
97 | private: | |
98 | /** standard constructor prohibited */ | |
99 | AliHLTOUTLockGuard(); | |
100 | /** copy constructor prohibited */ | |
101 | AliHLTOUTLockGuard(const AliHLTOUTLockGuard&); | |
102 | /** assignment operator prohibited */ | |
103 | AliHLTOUTLockGuard& operator=(const AliHLTOUTLockGuard&); | |
104 | ||
105 | /** the AliHLTOUT instance the guard is locking */ | |
106 | AliHLTOUT* fpInstance; //!transient | |
107 | }; | |
108 | ||
b005ef92 | 109 | /** |
110 | * Guard for handling of global AliHLTOUT instance. | |
111 | * The global HLTOUT instance can be set for certain steps of the | |
112 | * processing. The initial objective is to support input to the | |
113 | * AliHLTOUTPublisherComponent running in a kChain handler. | |
114 | * | |
115 | * The Guard restores the original instance when closed. | |
116 | */ | |
117 | class AliHLTOUTGlobalInstanceGuard { | |
118 | public: | |
119 | /** constructor */ | |
120 | AliHLTOUTGlobalInstanceGuard(AliHLTOUT* pInstance) : fpLastInstance(AliHLTOUT::fgGlobalInstance) | |
121 | {AliHLTOUT::fgGlobalInstance=pInstance;} | |
122 | /** destructor */ | |
123 | ~AliHLTOUTGlobalInstanceGuard() | |
124 | {AliHLTOUT::fgGlobalInstance=fpLastInstance;} | |
125 | ||
126 | private: | |
127 | /** standard constructor prohibited */ | |
128 | AliHLTOUTGlobalInstanceGuard(); | |
129 | /** copy constructor prohibited */ | |
130 | AliHLTOUTGlobalInstanceGuard(const AliHLTOUTGlobalInstanceGuard&); | |
131 | /** assignment operator prohibited */ | |
132 | AliHLTOUTGlobalInstanceGuard& operator=(const AliHLTOUTGlobalInstanceGuard&); | |
133 | ||
134 | /** the AliHLTOUT instance the guard is locking */ | |
135 | AliHLTOUT* fpLastInstance; //!transient | |
136 | }; | |
137 | ||
4b113031 | 138 | /** |
139 | * The HLT OUT Event Header. | |
140 | * Defined between HLT and DAQ. | |
141 | */ | |
142 | struct AliHLTOUTEventHeader { | |
143 | /**Total length of the data in bytes, including HLT event header, excluding CDH. */ | |
144 | AliHLTUInt32_t fLength; //! see above | |
145 | /** version of the header */ | |
146 | AliHLTUInt32_t fVersion; //! see above | |
c2b283d6 | 147 | /** High 32 bit word of event id */ |
148 | AliHLTUInt32_t fEventIDHigh; //! see above | |
149 | /** Low 32 bit word of event id */ | |
150 | AliHLTUInt32_t fEventIDLow; //! see above | |
4b113031 | 151 | }; |
152 | ||
44dc7683 | 153 | enum { |
154 | /// versions 1 of the HLT header | |
155 | kVersion1 = 1, | |
156 | /// versions 2 of the HLT header | |
157 | kVersion2 = 2 | |
158 | }; | |
159 | ||
160 | enum { | |
161 | /// size of HLT decision in data format version 1: 29x4 | |
162 | kSizeDecisionVersion1 = 116, | |
163 | /// size of HLT decision in data format version 2: 30x4 | |
164 | kSizeDecisionVersion2 = 120 | |
165 | }; | |
166 | ||
4b113031 | 167 | // definitions from ALICE internal notes ALICE-INT-2002-010 and |
168 | // ALICE-INT-2006-XXX | |
13398559 | 169 | enum { |
170 | /** the 32bit word in the CDH containing the status flags */ | |
171 | kCDHStatusWord=4, //! see above | |
172 | /** start of the flags in word fgkCDHStatusWord */ | |
173 | kCDHStatusFlagsOffset=12, //! see above | |
174 | /** bit indicating HLT decision in the HLTOUT*/ | |
175 | kCDHFlagsHLTDecision=6, //! see above | |
176 | /** bit indicating HLT payload in the HLTOUT*/ | |
177 | kCDHFlagsHLTPayload=7 //! see above | |
178 | }; | |
4b113031 | 179 | |
f3c1d403 | 180 | class AliHLTOUTHandlerListEntry; |
4de7334f | 181 | /** |
182 | * Block descriptor. | |
183 | */ | |
184 | class AliHLTOUTBlockDescriptor { | |
185 | public: | |
0f1882a7 | 186 | AliHLTOUTBlockDescriptor(AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt32_t index, AliHLTOUT* pCollection) |
187 | : fDataType(dt), fSpecification(spec), fIndex(index), fSelected(false), fProcessed(false), fpCollection(pCollection) {}; | |
188 | AliHLTOUTBlockDescriptor(const AliHLTOUTBlockDescriptor& src) | |
189 | : fDataType(src.fDataType), fSpecification(src.fSpecification), fIndex(src.fIndex), fSelected(false), fProcessed(false), fpCollection(src.fpCollection) {} | |
190 | AliHLTOUTBlockDescriptor& operator=(const AliHLTOUTBlockDescriptor& src) | |
191 | { fDataType=src.fDataType; fSpecification=src.fSpecification; fIndex=src.fIndex; fSelected=false; fProcessed=false; fpCollection=src.fpCollection; return *this; } | |
4de7334f | 192 | ~AliHLTOUTBlockDescriptor() {} |
193 | ||
194 | operator AliHLTComponentDataType() const {return fDataType;} | |
195 | operator AliHLTUInt32_t() const {return fSpecification;} | |
196 | int operator==(AliHLTComponentDataType dt) const {return dt==fDataType;} | |
197 | int operator==(AliHLTUInt32_t spec) const {return spec==fSpecification;} | |
0f1882a7 | 198 | int operator==(AliHLTOUT* collection) const {return collection==fpCollection;} |
4de7334f | 199 | |
200 | AliHLTUInt32_t GetIndex() const {return fIndex;} | |
b005ef92 | 201 | AliHLTOUT* GetCollection() const {return fpCollection;} |
0f1882a7 | 202 | |
203 | bool IsSelected() const {return fSelected;} | |
204 | void Select(bool selected=true) {fSelected=selected;} | |
d4a18597 | 205 | bool IsProcessed() const {return fProcessed;} |
0f1882a7 | 206 | void MarkProcessed() {fProcessed=true;} |
207 | ||
208 | /** | |
209 | * Get the data buffer | |
9bb806cd | 210 | * @param [out] pBuffer buffer of the selected data block |
211 | * @param [out] size size of the selected data block | |
0f1882a7 | 212 | */ |
213 | int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size) { | |
214 | if (fpCollection) return fpCollection->GetDataBuffer(GetIndex(), pBuffer, size); | |
215 | return -ENODEV; | |
216 | } | |
217 | ||
f3c1d403 | 218 | /** |
219 | * Get the handler descriptor | |
220 | */ | |
221 | const AliHLTOUTHandlerListEntry& GetHandlerDesc(); | |
222 | ||
4c4b4801 | 223 | /// print info |
224 | void Print(const char* option="") const; | |
225 | ||
0f1882a7 | 226 | private: |
4de7334f | 227 | /** data type of the block */ |
228 | AliHLTComponentDataType fDataType; //!transient | |
229 | /** data specification of the block */ | |
230 | AliHLTUInt32_t fSpecification; //!transient | |
231 | /** index in the data stream */ | |
232 | AliHLTUInt32_t fIndex; //!transient | |
0f1882a7 | 233 | /** selection flag */ |
234 | bool fSelected; //!transient | |
235 | /** processed flag */ | |
236 | bool fProcessed; //!transient | |
237 | /** the collection */ | |
238 | AliHLTOUT* fpCollection; //!transient | |
4de7334f | 239 | }; |
240 | ||
c5123824 | 241 | class AliHLTOUTHandlerListEntry { |
242 | public: | |
243 | AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler, | |
244 | AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc, | |
245 | AliHLTModuleAgent* pAgent, | |
246 | AliHLTUInt32_t index); | |
247 | ||
248 | /** copy constructor for vector handling */ | |
249 | AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src); | |
250 | ||
251 | /** assignment operator for vector handling */ | |
252 | AliHLTOUTHandlerListEntry& operator=(const AliHLTOUTHandlerListEntry& src); | |
253 | ||
254 | ~AliHLTOUTHandlerListEntry(); | |
255 | ||
256 | static const AliHLTOUTHandlerListEntry fgkVoidHandlerListEntry; //! initializer | |
257 | ||
258 | operator AliHLTOUTHandler*() const {return fpHandler;} | |
259 | ||
260 | // please note that fpHandlerDesc is really a pointer and is created | |
261 | // in the constructor. Thats why it is dereferenced here. The pointer | |
262 | // type is on purpose, even though it is a bit confusing with the | |
263 | // argument by reference in the AliHLTOUTHandlerListEntry constructor. | |
264 | operator const AliHLTModuleAgent::AliHLTOUTHandlerDesc&() const | |
265 | {return fpHandlerDesc?*fpHandlerDesc:AliHLTModuleAgent::fgkVoidHandlerDesc;} | |
266 | operator AliHLTModuleAgent*() const {return fpAgent;} | |
267 | ||
268 | /** | |
269 | * Two list entries are considered to be equal if the handlers | |
270 | * are equal. | |
271 | */ | |
272 | bool operator==(const AliHLTOUTHandlerListEntry& entry) const; | |
273 | ||
274 | bool operator==(const AliHLTModuleAgent::AliHLTOUTHandlerType handlerType) const; | |
275 | ||
b005ef92 | 276 | /** |
277 | * Compare the handler descriptor of this list entry with another | |
278 | * descriptor. | |
f3c1d403 | 279 | * @return true if both handler and agent match |
b005ef92 | 280 | */ |
281 | bool operator==(const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc) const; | |
282 | ||
c5123824 | 283 | AliHLTUInt32_t operator[](int i) const; |
284 | ||
285 | /** | |
286 | * Add a block index to this descriptor. | |
287 | * One descriptor can serve multiple blocks if the agent returns the | |
288 | * same handler for all of the blocks. Instead of creating a new entry | |
289 | * the block index ist just added | |
290 | */ | |
291 | void AddIndex(AliHLTUInt32_t index); | |
292 | ||
293 | /** | |
b005ef92 | 294 | * Add all indices of the descriptor. |
c5123824 | 295 | */ |
296 | void AddIndex(AliHLTOUTHandlerListEntry &desc); | |
297 | ||
298 | /** | |
299 | * Check if an index is served by this descriptor. | |
300 | * @return true if the index is in the table | |
301 | */ | |
0f1882a7 | 302 | bool HasIndex(AliHLTUInt32_t index) const; |
c5123824 | 303 | |
b005ef92 | 304 | /** |
305 | * Invalidate all block indices | |
306 | */ | |
307 | void InvalidateBlocks() {fBlocks.clear();} | |
308 | ||
309 | /** | |
310 | * Check whether the entry has valid blocks. | |
311 | */ | |
312 | bool IsEmpty() {return fBlocks.size()==0;} | |
313 | ||
4c4b4801 | 314 | /// print info |
315 | void Print(const char* option="") const; | |
316 | ||
c5123824 | 317 | private: |
318 | /** standard constructor prohibited */ | |
319 | AliHLTOUTHandlerListEntry(); | |
320 | ||
321 | /** pointer to the handler */ | |
322 | AliHLTOUTHandler* fpHandler; //! transient | |
323 | ||
324 | /** pointer to handler description */ | |
325 | AliHLTModuleAgent::AliHLTOUTHandlerDesc* fpHandlerDesc; //! transient | |
326 | ||
327 | /** pointer to module agent */ | |
328 | AliHLTModuleAgent* fpAgent; //! transient | |
329 | ||
b005ef92 | 330 | /** list of block indices */ |
c5123824 | 331 | AliHLTOUTIndexList fBlocks; //!transient |
332 | }; | |
333 | ||
334 | typedef vector<AliHLTOUTHandlerListEntry> AliHLTOUTHandlerListEntryVector; | |
335 | typedef vector<AliHLTOUTBlockDescriptor> AliHLTOUTBlockDescriptorVector; | |
0f1882a7 | 336 | typedef vector<AliHLTOUT*> AliHLTOUTPVector; |
337 | ||
338 | /** | |
339 | * Selection guard for the AliHLTOUT object. | |
340 | * If the object is locked, the selection of data blocks can not be changed. | |
341 | */ | |
342 | class AliHLTOUTSelectionGuard { | |
343 | public: | |
344 | /** constructor */ | |
345 | AliHLTOUTSelectionGuard(AliHLTOUT* pInstance) : fpInstance(pInstance) | |
346 | {if (fpInstance) fpInstance->SelectDataBlock();} | |
347 | /** constructor */ | |
348 | AliHLTOUTSelectionGuard(AliHLTOUT* pInstance, const AliHLTOUTHandlerListEntry* pHandlerDesc) : fpInstance(pInstance) | |
349 | {if (fpInstance) fpInstance->SelectDataBlocks(pHandlerDesc);} | |
350 | /** destructor */ | |
351 | ~AliHLTOUTSelectionGuard() | |
352 | {if (fpInstance) fpInstance->DisableBlockSelection();} | |
353 | ||
354 | private: | |
355 | /** standard constructor prohibited */ | |
356 | AliHLTOUTSelectionGuard(); | |
357 | /** copy constructor prohibited */ | |
358 | AliHLTOUTSelectionGuard(const AliHLTOUTSelectionGuard&); | |
359 | /** assignment operator prohibited */ | |
360 | AliHLTOUTSelectionGuard& operator=(const AliHLTOUTSelectionGuard&); | |
361 | ||
362 | /** the AliHLTOUT instance the guard is locking */ | |
363 | AliHLTOUT* fpInstance; //!transient | |
364 | }; | |
c5123824 | 365 | |
366 | /** | |
367 | * Init for processing. | |
368 | * The HLTOUT is scanned for all available data blocks and the | |
369 | * AliHLTOUTHandler objects for the data blocks are created according | |
370 | * to the module agents (see AliHLTModuleAgent). | |
371 | */ | |
372 | int Init(); | |
373 | ||
b005ef92 | 374 | /** |
375 | * Reset and clear all data block descriptors. | |
376 | * @note Since sub-collections are only referred via the block | |
377 | * descriptors, all information on sub-collections is also lost. | |
378 | * Child classes should implement ResetInput in order to cleanup | |
379 | * the input devices. | |
380 | */ | |
381 | int Reset(); | |
382 | ||
c63e8be4 | 383 | /** |
384 | * Get the current event id | |
385 | */ | |
386 | AliHLTUInt64_t EventId() {return fCurrentEventId;} | |
387 | ||
c5123824 | 388 | /** |
389 | * Get number of data blocks in the HLTOUT data | |
390 | */ | |
391 | int GetNofDataBlocks(); | |
392 | ||
393 | /** | |
394 | * Select the first data block of a certain data type and specification. | |
395 | * The selection criteria can be of kAliHLTAnyDataType and/or | |
396 | * kAliHLTVoidDataSpec in order to be ignored and just match any data block. | |
397 | * | |
398 | * The search criteria can be combined with a handler type (e.g. kRawReader) | |
9bb806cd | 399 | * @param [in] dt data type to match <br> |
400 | * @param [in] spec data specification to match <br> | |
401 | * @param [in] handlerType type of the handler | |
402 | * @param [in] skipProcessed skip all block marked processed | |
c1292031 | 403 | * @return block index: >= 0 if success, -ENOENT if no block found <br> |
c5123824 | 404 | * neg. error code if failed <br> |
405 | * -EPERM if access denied (object locked) | |
406 | */ | |
407 | int SelectFirstDataBlock(AliHLTComponentDataType dt=kAliHLTAnyDataType, | |
408 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec, | |
0f1882a7 | 409 | AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=AliHLTModuleAgent::kUnknownOutput, |
410 | bool skipProcessed=true); | |
c5123824 | 411 | |
412 | /** | |
413 | * Select the next data block of data type and specification of the previous | |
414 | * call to @ref SelectFirstDataBlock. | |
c1292031 | 415 | * @return block index: >= 0 if success, -ENOENT if no block found <br> |
c5123824 | 416 | * neg. error code if failed <br> |
417 | * -EPERM if access denied (object locked) | |
418 | */ | |
419 | int SelectNextDataBlock(); | |
420 | ||
421 | /** | |
422 | * Get properties of the selected data block. | |
9bb806cd | 423 | * @param [out] dt data type of the selected block |
424 | * @param [out] spec data specification of the selected block | |
c5123824 | 425 | */ |
426 | int GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec); | |
427 | ||
428 | /** | |
429 | * Get handler description of the current data block. | |
430 | */ | |
431 | const AliHLTOUTHandlerListEntry& GetDataBlockHandlerDesc(); | |
432 | ||
433 | /** | |
434 | * Get handler type of the selected data block. | |
435 | * @return handler type for the selected data block | |
436 | */ | |
437 | AliHLTModuleAgent::AliHLTOUTHandlerType GetDataBlockHandlerType(); | |
438 | ||
439 | /** | |
440 | * Get the index of the current data block. | |
441 | * @return index, AliHLTOUTInvalidIndex if no block selected | |
442 | */ | |
443 | AliHLTUInt32_t GetDataBlockIndex(); | |
444 | ||
445 | /** | |
446 | * Get buffer of the selected data block. | |
9bb806cd | 447 | * @param [out] pBuffer buffer of the selected data block |
448 | * @param [out] size size of the selected data block | |
c5123824 | 449 | */ |
450 | int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size); | |
451 | ||
452 | /** | |
453 | * Release buffer after use. | |
9bb806cd | 454 | * @param [in] pBuffer buffer of the selected data block |
c5123824 | 455 | */ |
456 | int ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer); | |
457 | ||
e5701dcf | 458 | /** |
459 | * Get a TObject from the data buffer | |
460 | * @return TObject pointer if data block is a streamed object | |
461 | */ | |
462 | TObject* GetDataObject(); | |
463 | ||
464 | /** | |
465 | * Release data object | |
466 | */ | |
467 | int ReleaseDataObject(TObject* pObject); | |
468 | ||
0f1882a7 | 469 | /** |
470 | * Add the current data block to the selection. | |
471 | * Note: enables also the block selection | |
472 | */ | |
473 | int SelectDataBlock(); | |
474 | ||
475 | /** | |
476 | * Add the all data blocks of a certain handler to the selection. | |
477 | * Note: enables also the block selection | |
478 | */ | |
479 | int SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerDesc); | |
480 | ||
481 | /** | |
482 | * Enable the selection of data blocks. | |
483 | */ | |
484 | int EnableBlockSelection(); | |
485 | ||
486 | /** | |
487 | * Disable the selection of data blocks. | |
488 | */ | |
489 | int DisableBlockSelection(); | |
490 | ||
491 | /** | |
492 | * Reset the data block selection. | |
493 | * Resets the selection list, none of the blocks is selected. | |
494 | */ | |
495 | int ResetBlockSelection(); | |
496 | ||
497 | /** | |
498 | * Mark the current block as processed. | |
499 | */ | |
500 | int MarkDataBlockProcessed(); | |
501 | ||
502 | /** | |
503 | * Mark all data blocks of a certain handler processed. | |
504 | */ | |
505 | int MarkDataBlocksProcessed(const AliHLTOUTHandlerListEntry* pHandlerDesc); | |
506 | ||
507 | /** | |
508 | * Add a sub collection to the HLTOUT. | |
509 | */ | |
510 | int AddSubCollection(AliHLTOUT* pCollection); | |
511 | ||
512 | /** | |
513 | * Release a previously added sub collection. | |
514 | */ | |
515 | int ReleaseSubCollection(AliHLTOUT* pCollection); | |
516 | ||
c5123824 | 517 | /** |
518 | * Get module agent for the selected data block. | |
519 | */ | |
520 | AliHLTModuleAgent* GetAgent(); | |
521 | ||
522 | /** | |
523 | * Get handler for the selected data block. | |
524 | */ | |
525 | AliHLTOUTHandler* GetHandler(); | |
526 | ||
527 | /** | |
528 | * Convert data buffer to ESD. | |
529 | * The buffer is supposed to describe a streamed AliESDEvent object. | |
530 | * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root, | |
531 | * where 'det' is derived from the data type origin. Each time the function is invoked | |
532 | * a new event is created. Dummy events are added if the previous events did not contain | |
533 | * | |
534 | * The function needs AliRoot and might not be implemented by all AliHLTOUT | |
535 | * implementations. | |
536 | * a data block of this specification. | |
9bb806cd | 537 | * @param [in] pBuffer the data buffer |
538 | * @param [in] size data buffer size | |
539 | * @param [in] dt data type of the block | |
540 | * @param [out] tgtesd optional target | |
c5123824 | 541 | */ |
542 | virtual int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt, AliESDEvent* tgtesd=NULL) const; | |
543 | ||
13398559 | 544 | enum AliHLTOUTByteOrder { |
049b43b2 | 545 | /** no data block selected */ |
546 | kInvalidByteOrder=-1, | |
547 | kUnknownByteOrder=0, | |
548 | kLittleEndian, | |
549 | kBigEndian | |
550 | }; | |
551 | ||
13398559 | 552 | enum AliHLTOUTDataType { |
049b43b2 | 553 | kUint64 = 0, |
554 | kUint32 = 1, | |
555 | kUint16 = 2, | |
556 | kUint8 = 3, | |
557 | kDouble = 4, | |
558 | kFloat = 5 | |
559 | }; | |
560 | ||
561 | /** | |
562 | * Check byte order of selected block | |
563 | */ | |
13398559 | 564 | AliHLTOUTByteOrder CheckByteOrder(); |
049b43b2 | 565 | |
566 | /** | |
567 | * Check alignment of selected block | |
568 | */ | |
13398559 | 569 | int CheckAlignment(AliHLTOUT::AliHLTOUTDataType type); |
049b43b2 | 570 | |
44dc7683 | 571 | /** |
572 | * Helper function to byte swap a 64 bit value. | |
573 | */ | |
ff3b6fed | 574 | static AliHLTUInt64_t ByteSwap64(AliHLTUInt64_t src); |
44dc7683 | 575 | |
576 | /** | |
577 | * Helper function to byte swap a 32 bit value. | |
578 | */ | |
ff3b6fed | 579 | static AliHLTUInt32_t ByteSwap32(AliHLTUInt32_t src); |
44dc7683 | 580 | |
c5123824 | 581 | /** |
582 | * Insert a handler item. | |
583 | * The current list entries are checked if the handler is already in | |
584 | * the list. It is added if not in the list, otherwise the block index | |
585 | * is added to the existing entry. | |
62ff1e23 | 586 | * @param list the handler list |
c5123824 | 587 | * @param entry handler list entry |
588 | * @return 0 if added, EEXIST (non negative!) if merged with existing entry <br> | |
589 | * neg. error code if failed | |
590 | */ | |
591 | static int InsertHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTOUTHandlerListEntry &entry); | |
592 | ||
b005ef92 | 593 | /** |
594 | * Insert all handlers of the specified type to the list. | |
595 | */ | |
596 | int FillHandlerList(AliHLTOUTHandlerListEntryVector& list, AliHLTModuleAgent::AliHLTOUTHandlerType handlerType); | |
597 | ||
598 | /** | |
599 | * Remove empty items which have a duplicate in the list. | |
600 | */ | |
601 | static int RemoveEmptyDuplicateHandlers(AliHLTOUTHandlerListEntryVector& list); | |
602 | ||
603 | /** | |
604 | * Find an entry of a certain description in the list. | |
605 | * @return index of the entry if found, -ENOENT if not found | |
606 | */ | |
607 | static int FindHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc); | |
608 | ||
609 | /** | |
610 | * Invalidate all blocks of the handlers in the list | |
611 | */ | |
612 | static int InvalidateBlocks(AliHLTOUTHandlerListEntryVector& list); | |
613 | ||
62bb3cd4 | 614 | protected: |
4de7334f | 615 | /** |
616 | * Add a block descriptor. | |
617 | * This is done by the child classes generating the index. The AliHLTOUT | |
618 | * object must be locked for index generation. | |
619 | * @param desc the block descriptor | |
620 | * @return 0 if success, -EPERM if access denied | |
621 | */ | |
622 | int AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc); | |
62bb3cd4 | 623 | |
c63e8be4 | 624 | /** |
625 | * Set the event id, only for child classes | |
626 | */ | |
627 | void SetEventId(AliHLTUInt64_t id); | |
628 | ||
44dc7683 | 629 | /** |
630 | * Print output or suppress. | |
631 | */ | |
632 | bool BeVerbose() {return fbVerbose;} | |
633 | ||
634 | /** | |
635 | * Switch output. | |
636 | */ | |
637 | void SwitchVerbosity(bool verbose) {fbVerbose=verbose;} | |
638 | ||
4c4b4801 | 639 | /// print info |
640 | void Print(const char* option="") const; | |
641 | ||
62bb3cd4 | 642 | private: |
643 | /** copy constructor prohibited */ | |
644 | AliHLTOUT(const AliHLTOUT&); | |
645 | /** assignment operator prohibited */ | |
646 | AliHLTOUT& operator=(const AliHLTOUT&); | |
647 | ||
049b43b2 | 648 | /** |
649 | * Internal status flags | |
650 | */ | |
651 | enum { | |
0f1882a7 | 652 | /** the HLTOUT object is locked with the current data block selection */ |
049b43b2 | 653 | kLocked = 0x1, |
654 | /** childs can add block descriptors */ | |
655 | kCollecting = 0x2, | |
656 | /** user of the data block has checked the byte order */ | |
657 | kByteOrderChecked = 0x4, | |
658 | /** warning on byte order missmatch has been printed */ | |
659 | kByteOrderWarning = 0x8, | |
660 | /** user of the data block has checked the alignment */ | |
661 | kAlignmentChecked = 0x10, | |
662 | /** warning on alignment missmatch has been printed */ | |
0f1882a7 | 663 | kAlignmentWarning = 0x20, |
664 | /** enable block selection list */ | |
665 | kBlockSelection = 0x40, | |
666 | /** skip processed data blocks */ | |
667 | kSkipProcessed = 0x80, | |
668 | /** marked as sub collection */ | |
669 | kIsSubCollection = 0x100 | |
049b43b2 | 670 | }; |
671 | ||
4de7334f | 672 | /** |
673 | * Generate the index of the HLTOUT data. | |
674 | * Must be implemented by the child classes. | |
675 | */ | |
676 | virtual int GenerateIndex()=0; | |
677 | ||
5db0e774 | 678 | /** |
679 | * Find AliHLTOUTHandler objects for the data blocks. | |
680 | * The available AliHLTModuleAgents are probed whether they provide | |
681 | * handlers for data processing. | |
682 | */ | |
683 | int InitHandlers(); | |
684 | ||
b005ef92 | 685 | /** |
686 | * Cleanup and reset the data input. | |
687 | */ | |
688 | virtual int ResetInput(); | |
689 | ||
4de7334f | 690 | /** |
691 | * Get the data buffer | |
9bb806cd | 692 | * @param [in] index index of the block |
693 | * @param [out] pBuffer buffer of the selected data block | |
694 | * @param [out] size size of the selected data block | |
4de7334f | 695 | */ |
696 | virtual int GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer, | |
697 | AliHLTUInt32_t& size)=0; | |
698 | ||
049b43b2 | 699 | /** |
700 | * Check byte order of data block | |
701 | */ | |
13398559 | 702 | virtual AliHLTOUTByteOrder CheckBlockByteOrder(AliHLTUInt32_t index)=0; |
049b43b2 | 703 | |
704 | /** | |
705 | * Check alignment of data block | |
706 | */ | |
13398559 | 707 | virtual int CheckBlockAlignment(AliHLTUInt32_t index, AliHLTOUT::AliHLTOUTDataType type)=0; |
049b43b2 | 708 | |
709 | /** | |
710 | * Select the data block of data type and specification of the previous | |
711 | * call to @ref SelectFirstDataBlock. Core function of @ref SelectFirstDataBlock | |
712 | * and @ref SelectNextDataBlock, starts to find a block at the current list | |
0f1882a7 | 713 | * position. |
714 | * | |
715 | * The data block is searched from the conditions of fSearchDataType, | |
716 | * fSearchSpecification, fSearchHandlerType and the selection list. | |
717 | * | |
049b43b2 | 718 | * @return identifier >=0 if success, neg. error code if failed <br> |
719 | * -ENOENT if no block found <br> | |
720 | * -EPERM if access denied (object locked) | |
721 | */ | |
722 | int FindAndSelectDataBlock(); | |
723 | ||
724 | /** | |
725 | * Set status flag. | |
726 | * @param flag flag to set | |
727 | * @return current status flags | |
728 | */ | |
729 | unsigned int SetStatusFlag(unsigned int flag) {return fFlags|=flag;} | |
730 | ||
731 | /** | |
732 | * Clear status flag. | |
733 | * @param flag flag to clear | |
734 | * @return current status flags | |
735 | */ | |
736 | unsigned int ClearStatusFlag(unsigned int flag) {return fFlags&=~flag;} | |
737 | ||
738 | /** | |
739 | * Check status flag. | |
740 | * @param flag flag to check | |
741 | * @return 1 if flag is set | |
742 | */ | |
743 | int CheckStatusFlag(unsigned int flag) const {return (fFlags&flag)==flag;} | |
744 | ||
626bfcc1 | 745 | /** |
746 | * Find handler description for a certain block index. | |
747 | */ | |
44dc7683 | 748 | const AliHLTOUTHandlerListEntry& FindHandlerDesc(AliHLTUInt32_t blockIndex); |
626bfcc1 | 749 | |
c1292031 | 750 | /** |
751 | * Set the RawReader as parameter. | |
752 | * The function is for internal use only in conjunction with the | |
753 | * New() functions. | |
754 | */ | |
755 | virtual void SetParam(AliRawReader* pRawReader); | |
756 | ||
757 | /** | |
758 | * Set the RunLoader as parameter | |
759 | * The function is for internal use only in conjunction with the | |
760 | * New() functions. | |
761 | */ | |
762 | virtual void SetParam(TTree* pDigitTree, int event=-1); | |
763 | ||
466d4e62 | 764 | /** |
765 | * Set name of the digit file as parameter | |
766 | * The function is for internal use only in conjunction with the | |
767 | * New() functions. | |
768 | */ | |
769 | virtual void SetParam(const char* filename, int event=-1); | |
770 | ||
4de7334f | 771 | /** data type for the current block search, set from @ref SelectFirstDataBlock */ |
772 | AliHLTComponentDataType fSearchDataType; //!transient | |
773 | ||
774 | /** data specification for the current block search */ | |
775 | AliHLTUInt32_t fSearchSpecification; //!transient | |
776 | ||
44dc7683 | 777 | /** handler type for the current block search */ |
778 | AliHLTModuleAgent::AliHLTOUTHandlerType fSearchHandlerType; // !transient | |
779 | ||
049b43b2 | 780 | /** instance flags: locked, collecting, ... */ |
781 | unsigned int fFlags; //!transient | |
4de7334f | 782 | |
783 | /** list of block descriptors */ | |
13398559 | 784 | AliHLTOUTBlockDescriptorVector fBlockDescList; //!transient |
4de7334f | 785 | |
786 | /** current position in the list */ | |
0f1882a7 | 787 | unsigned int fCurrent; //!transient |
4de7334f | 788 | |
789 | /** data buffer under processing */ | |
790 | const AliHLTUInt8_t* fpBuffer; //!transient | |
791 | ||
5db0e774 | 792 | /** list of AliHLTOUTHandlers */ |
13398559 | 793 | AliHLTOUTHandlerListEntryVector fDataHandlers; // !transient |
5db0e774 | 794 | |
44dc7683 | 795 | /** verbose or silent output */ |
796 | bool fbVerbose; //!transient | |
797 | ||
b005ef92 | 798 | /** gobal instance set for certain steps of the analysis */ |
799 | static AliHLTOUT* fgGlobalInstance; //! transient | |
800 | ||
801 | /** logging methods */ | |
802 | AliHLTLogging fLog; //! transient | |
803 | ||
e5701dcf | 804 | /** current buffer converted to a TObject */ |
805 | TObject* fpDataObject; //! | |
806 | const AliHLTUInt8_t* fpObjectBuffer; //! | |
807 | AliHLTUInt32_t fObjectBufferSize; //! | |
808 | ||
c63e8be4 | 809 | /** current event id */ |
810 | AliHLTUInt64_t fCurrentEventId; //! | |
811 | ||
812 | ClassDef(AliHLTOUT, 6) | |
62bb3cd4 | 813 | }; |
814 | #endif |