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