]>
Commit | Line | Data |
---|---|---|
62bb3cd4 | 1 | //-*- Mode: C++ -*- |
2 | // @(#) $Id$ | |
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 | |
10 | /** @file AliHLTOUT.h | |
11 | @author Matthias Richter | |
12 | @date | |
13 | @brief The control class for HLTOUT data. | |
5db0e774 | 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 | */ | |
40 | class AliHLTOUT : public AliHLTLogging { | |
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 | ||
61 | /** | |
62 | * Delete an instance of the HLTOUT. | |
63 | * Helper function to transparently access classes from the | |
64 | * libHLTrec library. Before deleting, the availability of the | |
65 | * library is checked. | |
66 | */ | |
67 | static void Delete(AliHLTOUT* pInstance); | |
68 | ||
4de7334f | 69 | /** |
70 | * Locking guard for the AliHLTOUT object. | |
71 | * If the object is locked, the selection of data blocks can not be changed. | |
72 | */ | |
73 | class AliHLTOUTLockGuard { | |
74 | public: | |
75 | /** constructor */ | |
76 | AliHLTOUTLockGuard(AliHLTOUT* pInstance) : fpInstance(pInstance) | |
049b43b2 | 77 | {if (fpInstance) fpInstance->SetStatusFlag(kLocked);} |
4de7334f | 78 | /** destructor */ |
79 | ~AliHLTOUTLockGuard() | |
049b43b2 | 80 | {if (fpInstance) fpInstance->ClearStatusFlag(kLocked);} |
4de7334f | 81 | |
82 | private: | |
83 | /** standard constructor prohibited */ | |
84 | AliHLTOUTLockGuard(); | |
85 | /** copy constructor prohibited */ | |
86 | AliHLTOUTLockGuard(const AliHLTOUTLockGuard&); | |
87 | /** assignment operator prohibited */ | |
88 | AliHLTOUTLockGuard& operator=(const AliHLTOUTLockGuard&); | |
89 | ||
90 | /** the AliHLTOUT instance the guard is locking */ | |
91 | AliHLTOUT* fpInstance; //!transient | |
92 | }; | |
93 | ||
4b113031 | 94 | /** |
95 | * The HLT OUT Event Header. | |
96 | * Defined between HLT and DAQ. | |
97 | */ | |
98 | struct AliHLTOUTEventHeader { | |
99 | /**Total length of the data in bytes, including HLT event header, excluding CDH. */ | |
100 | AliHLTUInt32_t fLength; //! see above | |
101 | /** version of the header */ | |
102 | AliHLTUInt32_t fVersion; //! see above | |
c2b283d6 | 103 | /** High 32 bit word of event id */ |
104 | AliHLTUInt32_t fEventIDHigh; //! see above | |
105 | /** Low 32 bit word of event id */ | |
106 | AliHLTUInt32_t fEventIDLow; //! see above | |
4b113031 | 107 | }; |
108 | ||
44dc7683 | 109 | enum { |
110 | /// versions 1 of the HLT header | |
111 | kVersion1 = 1, | |
112 | /// versions 2 of the HLT header | |
113 | kVersion2 = 2 | |
114 | }; | |
115 | ||
116 | enum { | |
117 | /// size of HLT decision in data format version 1: 29x4 | |
118 | kSizeDecisionVersion1 = 116, | |
119 | /// size of HLT decision in data format version 2: 30x4 | |
120 | kSizeDecisionVersion2 = 120 | |
121 | }; | |
122 | ||
4b113031 | 123 | // definitions from ALICE internal notes ALICE-INT-2002-010 and |
124 | // ALICE-INT-2006-XXX | |
13398559 | 125 | enum { |
126 | /** the 32bit word in the CDH containing the status flags */ | |
127 | kCDHStatusWord=4, //! see above | |
128 | /** start of the flags in word fgkCDHStatusWord */ | |
129 | kCDHStatusFlagsOffset=12, //! see above | |
130 | /** bit indicating HLT decision in the HLTOUT*/ | |
131 | kCDHFlagsHLTDecision=6, //! see above | |
132 | /** bit indicating HLT payload in the HLTOUT*/ | |
133 | kCDHFlagsHLTPayload=7 //! see above | |
134 | }; | |
4b113031 | 135 | |
4de7334f | 136 | /** |
137 | * Block descriptor. | |
138 | */ | |
139 | class AliHLTOUTBlockDescriptor { | |
140 | public: | |
0f1882a7 | 141 | AliHLTOUTBlockDescriptor(AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt32_t index, AliHLTOUT* pCollection) |
142 | : fDataType(dt), fSpecification(spec), fIndex(index), fSelected(false), fProcessed(false), fpCollection(pCollection) {}; | |
143 | AliHLTOUTBlockDescriptor(const AliHLTOUTBlockDescriptor& src) | |
144 | : fDataType(src.fDataType), fSpecification(src.fSpecification), fIndex(src.fIndex), fSelected(false), fProcessed(false), fpCollection(src.fpCollection) {} | |
145 | AliHLTOUTBlockDescriptor& operator=(const AliHLTOUTBlockDescriptor& src) | |
146 | { fDataType=src.fDataType; fSpecification=src.fSpecification; fIndex=src.fIndex; fSelected=false; fProcessed=false; fpCollection=src.fpCollection; return *this; } | |
4de7334f | 147 | ~AliHLTOUTBlockDescriptor() {} |
148 | ||
149 | operator AliHLTComponentDataType() const {return fDataType;} | |
150 | operator AliHLTUInt32_t() const {return fSpecification;} | |
151 | int operator==(AliHLTComponentDataType dt) const {return dt==fDataType;} | |
152 | int operator==(AliHLTUInt32_t spec) const {return spec==fSpecification;} | |
0f1882a7 | 153 | int operator==(AliHLTOUT* collection) const {return collection==fpCollection;} |
4de7334f | 154 | |
155 | AliHLTUInt32_t GetIndex() const {return fIndex;} | |
0f1882a7 | 156 | |
157 | bool IsSelected() const {return fSelected;} | |
158 | void Select(bool selected=true) {fSelected=selected;} | |
159 | bool IsProcessed() const {return fSelected;} | |
160 | void MarkProcessed() {fProcessed=true;} | |
161 | ||
162 | /** | |
163 | * Get the data buffer | |
164 | * @param pBuffer [out] buffer of the selected data block | |
165 | * @param size [out] size of the selected data block | |
166 | */ | |
167 | int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size) { | |
168 | if (fpCollection) return fpCollection->GetDataBuffer(GetIndex(), pBuffer, size); | |
169 | return -ENODEV; | |
170 | } | |
171 | ||
172 | private: | |
4de7334f | 173 | /** data type of the block */ |
174 | AliHLTComponentDataType fDataType; //!transient | |
175 | /** data specification of the block */ | |
176 | AliHLTUInt32_t fSpecification; //!transient | |
177 | /** index in the data stream */ | |
178 | AliHLTUInt32_t fIndex; //!transient | |
0f1882a7 | 179 | /** selection flag */ |
180 | bool fSelected; //!transient | |
181 | /** processed flag */ | |
182 | bool fProcessed; //!transient | |
183 | /** the collection */ | |
184 | AliHLTOUT* fpCollection; //!transient | |
4de7334f | 185 | }; |
186 | ||
c5123824 | 187 | class AliHLTOUTHandlerListEntry { |
188 | public: | |
189 | AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler, | |
190 | AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc, | |
191 | AliHLTModuleAgent* pAgent, | |
192 | AliHLTUInt32_t index); | |
193 | ||
194 | /** copy constructor for vector handling */ | |
195 | AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src); | |
196 | ||
197 | /** assignment operator for vector handling */ | |
198 | AliHLTOUTHandlerListEntry& operator=(const AliHLTOUTHandlerListEntry& src); | |
199 | ||
200 | ~AliHLTOUTHandlerListEntry(); | |
201 | ||
202 | static const AliHLTOUTHandlerListEntry fgkVoidHandlerListEntry; //! initializer | |
203 | ||
204 | operator AliHLTOUTHandler*() const {return fpHandler;} | |
205 | ||
206 | // please note that fpHandlerDesc is really a pointer and is created | |
207 | // in the constructor. Thats why it is dereferenced here. The pointer | |
208 | // type is on purpose, even though it is a bit confusing with the | |
209 | // argument by reference in the AliHLTOUTHandlerListEntry constructor. | |
210 | operator const AliHLTModuleAgent::AliHLTOUTHandlerDesc&() const | |
211 | {return fpHandlerDesc?*fpHandlerDesc:AliHLTModuleAgent::fgkVoidHandlerDesc;} | |
212 | operator AliHLTModuleAgent*() const {return fpAgent;} | |
213 | ||
214 | /** | |
215 | * Two list entries are considered to be equal if the handlers | |
216 | * are equal. | |
217 | */ | |
218 | bool operator==(const AliHLTOUTHandlerListEntry& entry) const; | |
219 | ||
220 | bool operator==(const AliHLTModuleAgent::AliHLTOUTHandlerType handlerType) const; | |
221 | ||
222 | AliHLTUInt32_t operator[](int i) const; | |
223 | ||
224 | /** | |
225 | * Add a block index to this descriptor. | |
226 | * One descriptor can serve multiple blocks if the agent returns the | |
227 | * same handler for all of the blocks. Instead of creating a new entry | |
228 | * the block index ist just added | |
229 | */ | |
230 | void AddIndex(AliHLTUInt32_t index); | |
231 | ||
232 | /** | |
233 | * Add all indexes of the descriptor. | |
234 | */ | |
235 | void AddIndex(AliHLTOUTHandlerListEntry &desc); | |
236 | ||
237 | /** | |
238 | * Check if an index is served by this descriptor. | |
239 | * @return true if the index is in the table | |
240 | */ | |
0f1882a7 | 241 | bool HasIndex(AliHLTUInt32_t index) const; |
c5123824 | 242 | |
243 | private: | |
244 | /** standard constructor prohibited */ | |
245 | AliHLTOUTHandlerListEntry(); | |
246 | ||
247 | /** pointer to the handler */ | |
248 | AliHLTOUTHandler* fpHandler; //! transient | |
249 | ||
250 | /** pointer to handler description */ | |
251 | AliHLTModuleAgent::AliHLTOUTHandlerDesc* fpHandlerDesc; //! transient | |
252 | ||
253 | /** pointer to module agent */ | |
254 | AliHLTModuleAgent* fpAgent; //! transient | |
255 | ||
256 | /** list of block indexes */ | |
257 | AliHLTOUTIndexList fBlocks; //!transient | |
258 | }; | |
259 | ||
260 | typedef vector<AliHLTOUTHandlerListEntry> AliHLTOUTHandlerListEntryVector; | |
261 | typedef vector<AliHLTOUTBlockDescriptor> AliHLTOUTBlockDescriptorVector; | |
0f1882a7 | 262 | typedef vector<AliHLTOUT*> AliHLTOUTPVector; |
263 | ||
264 | /** | |
265 | * Selection guard for the AliHLTOUT object. | |
266 | * If the object is locked, the selection of data blocks can not be changed. | |
267 | */ | |
268 | class AliHLTOUTSelectionGuard { | |
269 | public: | |
270 | /** constructor */ | |
271 | AliHLTOUTSelectionGuard(AliHLTOUT* pInstance) : fpInstance(pInstance) | |
272 | {if (fpInstance) fpInstance->SelectDataBlock();} | |
273 | /** constructor */ | |
274 | AliHLTOUTSelectionGuard(AliHLTOUT* pInstance, const AliHLTOUTHandlerListEntry* pHandlerDesc) : fpInstance(pInstance) | |
275 | {if (fpInstance) fpInstance->SelectDataBlocks(pHandlerDesc);} | |
276 | /** destructor */ | |
277 | ~AliHLTOUTSelectionGuard() | |
278 | {if (fpInstance) fpInstance->DisableBlockSelection();} | |
279 | ||
280 | private: | |
281 | /** standard constructor prohibited */ | |
282 | AliHLTOUTSelectionGuard(); | |
283 | /** copy constructor prohibited */ | |
284 | AliHLTOUTSelectionGuard(const AliHLTOUTSelectionGuard&); | |
285 | /** assignment operator prohibited */ | |
286 | AliHLTOUTSelectionGuard& operator=(const AliHLTOUTSelectionGuard&); | |
287 | ||
288 | /** the AliHLTOUT instance the guard is locking */ | |
289 | AliHLTOUT* fpInstance; //!transient | |
290 | }; | |
c5123824 | 291 | |
292 | /** | |
293 | * Init for processing. | |
294 | * The HLTOUT is scanned for all available data blocks and the | |
295 | * AliHLTOUTHandler objects for the data blocks are created according | |
296 | * to the module agents (see AliHLTModuleAgent). | |
297 | */ | |
298 | int Init(); | |
299 | ||
300 | /** | |
301 | * Get number of data blocks in the HLTOUT data | |
302 | */ | |
303 | int GetNofDataBlocks(); | |
304 | ||
305 | /** | |
306 | * Select the first data block of a certain data type and specification. | |
307 | * The selection criteria can be of kAliHLTAnyDataType and/or | |
308 | * kAliHLTVoidDataSpec in order to be ignored and just match any data block. | |
309 | * | |
310 | * The search criteria can be combined with a handler type (e.g. kRawReader) | |
311 | * @param dt [in] data type to match <br> | |
312 | * @param spec [in] data specification to match <br> | |
313 | * @param handlerType [in] type of the handler | |
c1292031 | 314 | * @return block index: >= 0 if success, -ENOENT if no block found <br> |
c5123824 | 315 | * neg. error code if failed <br> |
316 | * -EPERM if access denied (object locked) | |
317 | */ | |
318 | int SelectFirstDataBlock(AliHLTComponentDataType dt=kAliHLTAnyDataType, | |
319 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec, | |
0f1882a7 | 320 | AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=AliHLTModuleAgent::kUnknownOutput, |
321 | bool skipProcessed=true); | |
c5123824 | 322 | |
323 | /** | |
324 | * Select the next data block of data type and specification of the previous | |
325 | * call to @ref SelectFirstDataBlock. | |
c1292031 | 326 | * @return block index: >= 0 if success, -ENOENT if no block found <br> |
c5123824 | 327 | * neg. error code if failed <br> |
328 | * -EPERM if access denied (object locked) | |
329 | */ | |
330 | int SelectNextDataBlock(); | |
331 | ||
332 | /** | |
333 | * Get properties of the selected data block. | |
334 | * @param dt [out] data type of the selected block | |
335 | * @param spec [out] data specification of the selected block | |
336 | */ | |
337 | int GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec); | |
338 | ||
339 | /** | |
340 | * Get handler description of the current data block. | |
341 | */ | |
342 | const AliHLTOUTHandlerListEntry& GetDataBlockHandlerDesc(); | |
343 | ||
344 | /** | |
345 | * Get handler type of the selected data block. | |
346 | * @return handler type for the selected data block | |
347 | */ | |
348 | AliHLTModuleAgent::AliHLTOUTHandlerType GetDataBlockHandlerType(); | |
349 | ||
350 | /** | |
351 | * Get the index of the current data block. | |
352 | * @return index, AliHLTOUTInvalidIndex if no block selected | |
353 | */ | |
354 | AliHLTUInt32_t GetDataBlockIndex(); | |
355 | ||
356 | /** | |
357 | * Get buffer of the selected data block. | |
358 | * @param pBuffer [out] buffer of the selected data block | |
359 | * @param size [out] size of the selected data block | |
360 | */ | |
361 | int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size); | |
362 | ||
363 | /** | |
364 | * Release buffer after use. | |
365 | * @param pBuffer [in] buffer of the selected data block | |
366 | */ | |
367 | int ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer); | |
368 | ||
0f1882a7 | 369 | /** |
370 | * Add the current data block to the selection. | |
371 | * Note: enables also the block selection | |
372 | */ | |
373 | int SelectDataBlock(); | |
374 | ||
375 | /** | |
376 | * Add the all data blocks of a certain handler to the selection. | |
377 | * Note: enables also the block selection | |
378 | */ | |
379 | int SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerDesc); | |
380 | ||
381 | /** | |
382 | * Enable the selection of data blocks. | |
383 | */ | |
384 | int EnableBlockSelection(); | |
385 | ||
386 | /** | |
387 | * Disable the selection of data blocks. | |
388 | */ | |
389 | int DisableBlockSelection(); | |
390 | ||
391 | /** | |
392 | * Reset the data block selection. | |
393 | * Resets the selection list, none of the blocks is selected. | |
394 | */ | |
395 | int ResetBlockSelection(); | |
396 | ||
397 | /** | |
398 | * Mark the current block as processed. | |
399 | */ | |
400 | int MarkDataBlockProcessed(); | |
401 | ||
402 | /** | |
403 | * Mark all data blocks of a certain handler processed. | |
404 | */ | |
405 | int MarkDataBlocksProcessed(const AliHLTOUTHandlerListEntry* pHandlerDesc); | |
406 | ||
407 | /** | |
408 | * Add a sub collection to the HLTOUT. | |
409 | */ | |
410 | int AddSubCollection(AliHLTOUT* pCollection); | |
411 | ||
412 | /** | |
413 | * Release a previously added sub collection. | |
414 | */ | |
415 | int ReleaseSubCollection(AliHLTOUT* pCollection); | |
416 | ||
c5123824 | 417 | /** |
418 | * Get module agent for the selected data block. | |
419 | */ | |
420 | AliHLTModuleAgent* GetAgent(); | |
421 | ||
422 | /** | |
423 | * Get handler for the selected data block. | |
424 | */ | |
425 | AliHLTOUTHandler* GetHandler(); | |
426 | ||
427 | /** | |
428 | * Convert data buffer to ESD. | |
429 | * The buffer is supposed to describe a streamed AliESDEvent object. | |
430 | * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root, | |
431 | * where 'det' is derived from the data type origin. Each time the function is invoked | |
432 | * a new event is created. Dummy events are added if the previous events did not contain | |
433 | * | |
434 | * The function needs AliRoot and might not be implemented by all AliHLTOUT | |
435 | * implementations. | |
436 | * a data block of this specification. | |
437 | * @param pBuffer [in] the data buffer | |
438 | * @param size [in] data buffer size | |
439 | * @param dt [in] data type of the block | |
440 | * @param tgtesd [out] optional target | |
441 | */ | |
442 | virtual int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt, AliESDEvent* tgtesd=NULL) const; | |
443 | ||
13398559 | 444 | enum AliHLTOUTByteOrder { |
049b43b2 | 445 | /** no data block selected */ |
446 | kInvalidByteOrder=-1, | |
447 | kUnknownByteOrder=0, | |
448 | kLittleEndian, | |
449 | kBigEndian | |
450 | }; | |
451 | ||
13398559 | 452 | enum AliHLTOUTDataType { |
049b43b2 | 453 | kUint64 = 0, |
454 | kUint32 = 1, | |
455 | kUint16 = 2, | |
456 | kUint8 = 3, | |
457 | kDouble = 4, | |
458 | kFloat = 5 | |
459 | }; | |
460 | ||
461 | /** | |
462 | * Check byte order of selected block | |
463 | */ | |
13398559 | 464 | AliHLTOUTByteOrder CheckByteOrder(); |
049b43b2 | 465 | |
466 | /** | |
467 | * Check alignment of selected block | |
468 | */ | |
13398559 | 469 | int CheckAlignment(AliHLTOUT::AliHLTOUTDataType type); |
049b43b2 | 470 | |
44dc7683 | 471 | /** |
472 | * Helper function to byte swap a 64 bit value. | |
473 | */ | |
ff3b6fed | 474 | static AliHLTUInt64_t ByteSwap64(AliHLTUInt64_t src); |
44dc7683 | 475 | |
476 | /** | |
477 | * Helper function to byte swap a 32 bit value. | |
478 | */ | |
ff3b6fed | 479 | static AliHLTUInt32_t ByteSwap32(AliHLTUInt32_t src); |
44dc7683 | 480 | |
c5123824 | 481 | /** |
482 | * Insert a handler item. | |
483 | * The current list entries are checked if the handler is already in | |
484 | * the list. It is added if not in the list, otherwise the block index | |
485 | * is added to the existing entry. | |
62ff1e23 | 486 | * @param list the handler list |
c5123824 | 487 | * @param entry handler list entry |
488 | * @return 0 if added, EEXIST (non negative!) if merged with existing entry <br> | |
489 | * neg. error code if failed | |
490 | */ | |
491 | static int InsertHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTOUTHandlerListEntry &entry); | |
492 | ||
62bb3cd4 | 493 | protected: |
4de7334f | 494 | /** |
495 | * Add a block descriptor. | |
496 | * This is done by the child classes generating the index. The AliHLTOUT | |
497 | * object must be locked for index generation. | |
498 | * @param desc the block descriptor | |
499 | * @return 0 if success, -EPERM if access denied | |
500 | */ | |
501 | int AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc); | |
62bb3cd4 | 502 | |
44dc7683 | 503 | /** |
504 | * Print output or suppress. | |
505 | */ | |
506 | bool BeVerbose() {return fbVerbose;} | |
507 | ||
508 | /** | |
509 | * Switch output. | |
510 | */ | |
511 | void SwitchVerbosity(bool verbose) {fbVerbose=verbose;} | |
512 | ||
62bb3cd4 | 513 | private: |
514 | /** copy constructor prohibited */ | |
515 | AliHLTOUT(const AliHLTOUT&); | |
516 | /** assignment operator prohibited */ | |
517 | AliHLTOUT& operator=(const AliHLTOUT&); | |
518 | ||
049b43b2 | 519 | /** |
520 | * Internal status flags | |
521 | */ | |
522 | enum { | |
0f1882a7 | 523 | /** the HLTOUT object is locked with the current data block selection */ |
049b43b2 | 524 | kLocked = 0x1, |
525 | /** childs can add block descriptors */ | |
526 | kCollecting = 0x2, | |
527 | /** user of the data block has checked the byte order */ | |
528 | kByteOrderChecked = 0x4, | |
529 | /** warning on byte order missmatch has been printed */ | |
530 | kByteOrderWarning = 0x8, | |
531 | /** user of the data block has checked the alignment */ | |
532 | kAlignmentChecked = 0x10, | |
533 | /** warning on alignment missmatch has been printed */ | |
0f1882a7 | 534 | kAlignmentWarning = 0x20, |
535 | /** enable block selection list */ | |
536 | kBlockSelection = 0x40, | |
537 | /** skip processed data blocks */ | |
538 | kSkipProcessed = 0x80, | |
539 | /** marked as sub collection */ | |
540 | kIsSubCollection = 0x100 | |
049b43b2 | 541 | }; |
542 | ||
4de7334f | 543 | /** |
544 | * Generate the index of the HLTOUT data. | |
545 | * Must be implemented by the child classes. | |
546 | */ | |
547 | virtual int GenerateIndex()=0; | |
548 | ||
5db0e774 | 549 | /** |
550 | * Find AliHLTOUTHandler objects for the data blocks. | |
551 | * The available AliHLTModuleAgents are probed whether they provide | |
552 | * handlers for data processing. | |
553 | */ | |
554 | int InitHandlers(); | |
555 | ||
4de7334f | 556 | /** |
557 | * Get the data buffer | |
558 | * @param index [in] index of the block | |
559 | * @param pBuffer [out] buffer of the selected data block | |
560 | * @param size [out] size of the selected data block | |
561 | */ | |
562 | virtual int GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer, | |
563 | AliHLTUInt32_t& size)=0; | |
564 | ||
049b43b2 | 565 | /** |
566 | * Check byte order of data block | |
567 | */ | |
13398559 | 568 | virtual AliHLTOUTByteOrder CheckBlockByteOrder(AliHLTUInt32_t index)=0; |
049b43b2 | 569 | |
570 | /** | |
571 | * Check alignment of data block | |
572 | */ | |
13398559 | 573 | virtual int CheckBlockAlignment(AliHLTUInt32_t index, AliHLTOUT::AliHLTOUTDataType type)=0; |
049b43b2 | 574 | |
575 | /** | |
576 | * Select the data block of data type and specification of the previous | |
577 | * call to @ref SelectFirstDataBlock. Core function of @ref SelectFirstDataBlock | |
578 | * and @ref SelectNextDataBlock, starts to find a block at the current list | |
0f1882a7 | 579 | * position. |
580 | * | |
581 | * The data block is searched from the conditions of fSearchDataType, | |
582 | * fSearchSpecification, fSearchHandlerType and the selection list. | |
583 | * | |
049b43b2 | 584 | * @return identifier >=0 if success, neg. error code if failed <br> |
585 | * -ENOENT if no block found <br> | |
586 | * -EPERM if access denied (object locked) | |
587 | */ | |
588 | int FindAndSelectDataBlock(); | |
589 | ||
590 | /** | |
591 | * Set status flag. | |
592 | * @param flag flag to set | |
593 | * @return current status flags | |
594 | */ | |
595 | unsigned int SetStatusFlag(unsigned int flag) {return fFlags|=flag;} | |
596 | ||
597 | /** | |
598 | * Clear status flag. | |
599 | * @param flag flag to clear | |
600 | * @return current status flags | |
601 | */ | |
602 | unsigned int ClearStatusFlag(unsigned int flag) {return fFlags&=~flag;} | |
603 | ||
604 | /** | |
605 | * Check status flag. | |
606 | * @param flag flag to check | |
607 | * @return 1 if flag is set | |
608 | */ | |
609 | int CheckStatusFlag(unsigned int flag) const {return (fFlags&flag)==flag;} | |
610 | ||
626bfcc1 | 611 | /** |
612 | * Find handler description for a certain block index. | |
613 | */ | |
44dc7683 | 614 | const AliHLTOUTHandlerListEntry& FindHandlerDesc(AliHLTUInt32_t blockIndex); |
626bfcc1 | 615 | |
c1292031 | 616 | /** |
617 | * Internal New function for the external HLTOUT instances. | |
618 | * Currently supported classes are AliHLTOUTRawReader and | |
619 | * AliHLTOUTDigitReader, both implemented in libHLTrec.so. | |
620 | */ | |
621 | static AliHLTOUT* New(const char* classname); | |
622 | ||
623 | /** | |
624 | * Set the RawReader as parameter. | |
625 | * The function is for internal use only in conjunction with the | |
626 | * New() functions. | |
627 | */ | |
628 | virtual void SetParam(AliRawReader* pRawReader); | |
629 | ||
630 | /** | |
631 | * Set the RunLoader as parameter | |
632 | * The function is for internal use only in conjunction with the | |
633 | * New() functions. | |
634 | */ | |
635 | virtual void SetParam(TTree* pDigitTree, int event=-1); | |
636 | ||
4de7334f | 637 | /** data type for the current block search, set from @ref SelectFirstDataBlock */ |
638 | AliHLTComponentDataType fSearchDataType; //!transient | |
639 | ||
640 | /** data specification for the current block search */ | |
641 | AliHLTUInt32_t fSearchSpecification; //!transient | |
642 | ||
44dc7683 | 643 | /** handler type for the current block search */ |
644 | AliHLTModuleAgent::AliHLTOUTHandlerType fSearchHandlerType; // !transient | |
645 | ||
049b43b2 | 646 | /** instance flags: locked, collecting, ... */ |
647 | unsigned int fFlags; //!transient | |
4de7334f | 648 | |
649 | /** list of block descriptors */ | |
13398559 | 650 | AliHLTOUTBlockDescriptorVector fBlockDescList; //!transient |
4de7334f | 651 | |
652 | /** current position in the list */ | |
0f1882a7 | 653 | unsigned int fCurrent; //!transient |
4de7334f | 654 | |
655 | /** data buffer under processing */ | |
656 | const AliHLTUInt8_t* fpBuffer; //!transient | |
657 | ||
5db0e774 | 658 | /** list of AliHLTOUTHandlers */ |
13398559 | 659 | AliHLTOUTHandlerListEntryVector fDataHandlers; // !transient |
5db0e774 | 660 | |
44dc7683 | 661 | /** verbose or silent output */ |
662 | bool fbVerbose; //!transient | |
663 | ||
0f1882a7 | 664 | ClassDef(AliHLTOUT, 3) |
62bb3cd4 | 665 | }; |
666 | #endif |