]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTOUT.h
bugfix: printout using intermediate stringstream is not working, using cout directly...
[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
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
0f1882a7 223 private:
4de7334f 224 /** data type of the block */
225 AliHLTComponentDataType fDataType; //!transient
226 /** data specification of the block */
227 AliHLTUInt32_t fSpecification; //!transient
228 /** index in the data stream */
229 AliHLTUInt32_t fIndex; //!transient
0f1882a7 230 /** selection flag */
231 bool fSelected; //!transient
232 /** processed flag */
233 bool fProcessed; //!transient
234 /** the collection */
235 AliHLTOUT* fpCollection; //!transient
4de7334f 236 };
237
c5123824 238 class AliHLTOUTHandlerListEntry {
239 public:
240 AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler,
241 AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc,
242 AliHLTModuleAgent* pAgent,
243 AliHLTUInt32_t index);
244
245 /** copy constructor for vector handling */
246 AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src);
247
248 /** assignment operator for vector handling */
249 AliHLTOUTHandlerListEntry& operator=(const AliHLTOUTHandlerListEntry& src);
250
251 ~AliHLTOUTHandlerListEntry();
252
253 static const AliHLTOUTHandlerListEntry fgkVoidHandlerListEntry; //! initializer
254
255 operator AliHLTOUTHandler*() const {return fpHandler;}
256
257 // please note that fpHandlerDesc is really a pointer and is created
258 // in the constructor. Thats why it is dereferenced here. The pointer
259 // type is on purpose, even though it is a bit confusing with the
260 // argument by reference in the AliHLTOUTHandlerListEntry constructor.
261 operator const AliHLTModuleAgent::AliHLTOUTHandlerDesc&() const
262 {return fpHandlerDesc?*fpHandlerDesc:AliHLTModuleAgent::fgkVoidHandlerDesc;}
263 operator AliHLTModuleAgent*() const {return fpAgent;}
264
265 /**
266 * Two list entries are considered to be equal if the handlers
267 * are equal.
268 */
269 bool operator==(const AliHLTOUTHandlerListEntry& entry) const;
270
271 bool operator==(const AliHLTModuleAgent::AliHLTOUTHandlerType handlerType) const;
272
b005ef92 273 /**
274 * Compare the handler descriptor of this list entry with another
275 * descriptor.
f3c1d403 276 * @return true if both handler and agent match
b005ef92 277 */
278 bool operator==(const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc) const;
279
c5123824 280 AliHLTUInt32_t operator[](int i) const;
281
282 /**
283 * Add a block index to this descriptor.
284 * One descriptor can serve multiple blocks if the agent returns the
285 * same handler for all of the blocks. Instead of creating a new entry
286 * the block index ist just added
287 */
288 void AddIndex(AliHLTUInt32_t index);
289
290 /**
b005ef92 291 * Add all indices of the descriptor.
c5123824 292 */
293 void AddIndex(AliHLTOUTHandlerListEntry &desc);
294
295 /**
296 * Check if an index is served by this descriptor.
297 * @return true if the index is in the table
298 */
0f1882a7 299 bool HasIndex(AliHLTUInt32_t index) const;
c5123824 300
b005ef92 301 /**
302 * Invalidate all block indices
303 */
304 void InvalidateBlocks() {fBlocks.clear();}
305
306 /**
307 * Check whether the entry has valid blocks.
308 */
309 bool IsEmpty() {return fBlocks.size()==0;}
310
c5123824 311 private:
312 /** standard constructor prohibited */
313 AliHLTOUTHandlerListEntry();
314
315 /** pointer to the handler */
316 AliHLTOUTHandler* fpHandler; //! transient
317
318 /** pointer to handler description */
319 AliHLTModuleAgent::AliHLTOUTHandlerDesc* fpHandlerDesc; //! transient
320
321 /** pointer to module agent */
322 AliHLTModuleAgent* fpAgent; //! transient
323
b005ef92 324 /** list of block indices */
c5123824 325 AliHLTOUTIndexList fBlocks; //!transient
326 };
327
328 typedef vector<AliHLTOUTHandlerListEntry> AliHLTOUTHandlerListEntryVector;
329 typedef vector<AliHLTOUTBlockDescriptor> AliHLTOUTBlockDescriptorVector;
0f1882a7 330 typedef vector<AliHLTOUT*> AliHLTOUTPVector;
331
332 /**
333 * Selection guard for the AliHLTOUT object.
334 * If the object is locked, the selection of data blocks can not be changed.
335 */
336 class AliHLTOUTSelectionGuard {
337 public:
338 /** constructor */
339 AliHLTOUTSelectionGuard(AliHLTOUT* pInstance) : fpInstance(pInstance)
340 {if (fpInstance) fpInstance->SelectDataBlock();}
341 /** constructor */
342 AliHLTOUTSelectionGuard(AliHLTOUT* pInstance, const AliHLTOUTHandlerListEntry* pHandlerDesc) : fpInstance(pInstance)
343 {if (fpInstance) fpInstance->SelectDataBlocks(pHandlerDesc);}
344 /** destructor */
345 ~AliHLTOUTSelectionGuard()
346 {if (fpInstance) fpInstance->DisableBlockSelection();}
347
348 private:
349 /** standard constructor prohibited */
350 AliHLTOUTSelectionGuard();
351 /** copy constructor prohibited */
352 AliHLTOUTSelectionGuard(const AliHLTOUTSelectionGuard&);
353 /** assignment operator prohibited */
354 AliHLTOUTSelectionGuard& operator=(const AliHLTOUTSelectionGuard&);
355
356 /** the AliHLTOUT instance the guard is locking */
357 AliHLTOUT* fpInstance; //!transient
358 };
c5123824 359
360 /**
361 * Init for processing.
362 * The HLTOUT is scanned for all available data blocks and the
363 * AliHLTOUTHandler objects for the data blocks are created according
364 * to the module agents (see AliHLTModuleAgent).
365 */
366 int Init();
367
b005ef92 368 /**
369 * Reset and clear all data block descriptors.
370 * @note Since sub-collections are only referred via the block
371 * descriptors, all information on sub-collections is also lost.
372 * Child classes should implement ResetInput in order to cleanup
373 * the input devices.
374 */
375 int Reset();
376
c63e8be4 377 /**
378 * Get the current event id
379 */
380 AliHLTUInt64_t EventId() {return fCurrentEventId;}
381
c5123824 382 /**
383 * Get number of data blocks in the HLTOUT data
384 */
385 int GetNofDataBlocks();
386
387 /**
388 * Select the first data block of a certain data type and specification.
389 * The selection criteria can be of kAliHLTAnyDataType and/or
390 * kAliHLTVoidDataSpec in order to be ignored and just match any data block.
391 *
392 * The search criteria can be combined with a handler type (e.g. kRawReader)
9bb806cd 393 * @param [in] dt data type to match <br>
394 * @param [in] spec data specification to match <br>
395 * @param [in] handlerType type of the handler
396 * @param [in] skipProcessed skip all block marked processed
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 SelectFirstDataBlock(AliHLTComponentDataType dt=kAliHLTAnyDataType,
402 AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
0f1882a7 403 AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=AliHLTModuleAgent::kUnknownOutput,
404 bool skipProcessed=true);
c5123824 405
406 /**
407 * Select the next data block of data type and specification of the previous
408 * call to @ref SelectFirstDataBlock.
c1292031 409 * @return block index: >= 0 if success, -ENOENT if no block found <br>
c5123824 410 * neg. error code if failed <br>
411 * -EPERM if access denied (object locked)
412 */
413 int SelectNextDataBlock();
414
415 /**
416 * Get properties of the selected data block.
9bb806cd 417 * @param [out] dt data type of the selected block
418 * @param [out] spec data specification of the selected block
c5123824 419 */
420 int GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec);
421
422 /**
423 * Get handler description of the current data block.
424 */
425 const AliHLTOUTHandlerListEntry& GetDataBlockHandlerDesc();
426
427 /**
428 * Get handler type of the selected data block.
429 * @return handler type for the selected data block
430 */
431 AliHLTModuleAgent::AliHLTOUTHandlerType GetDataBlockHandlerType();
432
433 /**
434 * Get the index of the current data block.
435 * @return index, AliHLTOUTInvalidIndex if no block selected
436 */
437 AliHLTUInt32_t GetDataBlockIndex();
438
439 /**
440 * Get buffer of the selected data block.
9bb806cd 441 * @param [out] pBuffer buffer of the selected data block
442 * @param [out] size size of the selected data block
c5123824 443 */
444 int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size);
445
446 /**
447 * Release buffer after use.
9bb806cd 448 * @param [in] pBuffer buffer of the selected data block
c5123824 449 */
450 int ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer);
451
e5701dcf 452 /**
453 * Get a TObject from the data buffer
454 * @return TObject pointer if data block is a streamed object
455 */
456 TObject* GetDataObject();
457
458 /**
459 * Release data object
460 */
461 int ReleaseDataObject(TObject* pObject);
462
0f1882a7 463 /**
464 * Add the current data block to the selection.
465 * Note: enables also the block selection
466 */
467 int SelectDataBlock();
468
469 /**
470 * Add the all data blocks of a certain handler to the selection.
471 * Note: enables also the block selection
472 */
473 int SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerDesc);
474
475 /**
476 * Enable the selection of data blocks.
477 */
478 int EnableBlockSelection();
479
480 /**
481 * Disable the selection of data blocks.
482 */
483 int DisableBlockSelection();
484
485 /**
486 * Reset the data block selection.
487 * Resets the selection list, none of the blocks is selected.
488 */
489 int ResetBlockSelection();
490
491 /**
492 * Mark the current block as processed.
493 */
494 int MarkDataBlockProcessed();
495
496 /**
497 * Mark all data blocks of a certain handler processed.
498 */
499 int MarkDataBlocksProcessed(const AliHLTOUTHandlerListEntry* pHandlerDesc);
500
501 /**
502 * Add a sub collection to the HLTOUT.
503 */
504 int AddSubCollection(AliHLTOUT* pCollection);
505
506 /**
507 * Release a previously added sub collection.
508 */
509 int ReleaseSubCollection(AliHLTOUT* pCollection);
510
c5123824 511 /**
512 * Get module agent for the selected data block.
513 */
514 AliHLTModuleAgent* GetAgent();
515
516 /**
517 * Get handler for the selected data block.
518 */
519 AliHLTOUTHandler* GetHandler();
520
521 /**
522 * Convert data buffer to ESD.
523 * The buffer is supposed to describe a streamed AliESDEvent object.
524 * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root,
525 * where 'det' is derived from the data type origin. Each time the function is invoked
526 * a new event is created. Dummy events are added if the previous events did not contain
527 *
528 * The function needs AliRoot and might not be implemented by all AliHLTOUT
529 * implementations.
530 * a data block of this specification.
9bb806cd 531 * @param [in] pBuffer the data buffer
532 * @param [in] size data buffer size
533 * @param [in] dt data type of the block
534 * @param [out] tgtesd optional target
c5123824 535 */
536 virtual int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt, AliESDEvent* tgtesd=NULL) const;
537
13398559 538 enum AliHLTOUTByteOrder {
049b43b2 539 /** no data block selected */
540 kInvalidByteOrder=-1,
541 kUnknownByteOrder=0,
542 kLittleEndian,
543 kBigEndian
544 };
545
13398559 546 enum AliHLTOUTDataType {
049b43b2 547 kUint64 = 0,
548 kUint32 = 1,
549 kUint16 = 2,
550 kUint8 = 3,
551 kDouble = 4,
552 kFloat = 5
553 };
554
555 /**
556 * Check byte order of selected block
557 */
13398559 558 AliHLTOUTByteOrder CheckByteOrder();
049b43b2 559
560 /**
561 * Check alignment of selected block
562 */
13398559 563 int CheckAlignment(AliHLTOUT::AliHLTOUTDataType type);
049b43b2 564
44dc7683 565 /**
566 * Helper function to byte swap a 64 bit value.
567 */
ff3b6fed 568 static AliHLTUInt64_t ByteSwap64(AliHLTUInt64_t src);
44dc7683 569
570 /**
571 * Helper function to byte swap a 32 bit value.
572 */
ff3b6fed 573 static AliHLTUInt32_t ByteSwap32(AliHLTUInt32_t src);
44dc7683 574
c5123824 575 /**
576 * Insert a handler item.
577 * The current list entries are checked if the handler is already in
578 * the list. It is added if not in the list, otherwise the block index
579 * is added to the existing entry.
62ff1e23 580 * @param list the handler list
c5123824 581 * @param entry handler list entry
582 * @return 0 if added, EEXIST (non negative!) if merged with existing entry <br>
583 * neg. error code if failed
584 */
585 static int InsertHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTOUTHandlerListEntry &entry);
586
b005ef92 587 /**
588 * Insert all handlers of the specified type to the list.
589 */
590 int FillHandlerList(AliHLTOUTHandlerListEntryVector& list, AliHLTModuleAgent::AliHLTOUTHandlerType handlerType);
591
592 /**
593 * Remove empty items which have a duplicate in the list.
594 */
595 static int RemoveEmptyDuplicateHandlers(AliHLTOUTHandlerListEntryVector& list);
596
597 /**
598 * Find an entry of a certain description in the list.
599 * @return index of the entry if found, -ENOENT if not found
600 */
601 static int FindHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc);
602
603 /**
604 * Invalidate all blocks of the handlers in the list
605 */
606 static int InvalidateBlocks(AliHLTOUTHandlerListEntryVector& list);
607
62bb3cd4 608 protected:
4de7334f 609 /**
610 * Add a block descriptor.
611 * This is done by the child classes generating the index. The AliHLTOUT
612 * object must be locked for index generation.
613 * @param desc the block descriptor
614 * @return 0 if success, -EPERM if access denied
615 */
616 int AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc);
62bb3cd4 617
c63e8be4 618 /**
619 * Set the event id, only for child classes
620 */
621 void SetEventId(AliHLTUInt64_t id);
622
44dc7683 623 /**
624 * Print output or suppress.
625 */
626 bool BeVerbose() {return fbVerbose;}
627
628 /**
629 * Switch output.
630 */
631 void SwitchVerbosity(bool verbose) {fbVerbose=verbose;}
632
62bb3cd4 633 private:
634 /** copy constructor prohibited */
635 AliHLTOUT(const AliHLTOUT&);
636 /** assignment operator prohibited */
637 AliHLTOUT& operator=(const AliHLTOUT&);
638
049b43b2 639 /**
640 * Internal status flags
641 */
642 enum {
0f1882a7 643 /** the HLTOUT object is locked with the current data block selection */
049b43b2 644 kLocked = 0x1,
645 /** childs can add block descriptors */
646 kCollecting = 0x2,
647 /** user of the data block has checked the byte order */
648 kByteOrderChecked = 0x4,
649 /** warning on byte order missmatch has been printed */
650 kByteOrderWarning = 0x8,
651 /** user of the data block has checked the alignment */
652 kAlignmentChecked = 0x10,
653 /** warning on alignment missmatch has been printed */
0f1882a7 654 kAlignmentWarning = 0x20,
655 /** enable block selection list */
656 kBlockSelection = 0x40,
657 /** skip processed data blocks */
658 kSkipProcessed = 0x80,
659 /** marked as sub collection */
660 kIsSubCollection = 0x100
049b43b2 661 };
662
4de7334f 663 /**
664 * Generate the index of the HLTOUT data.
665 * Must be implemented by the child classes.
666 */
667 virtual int GenerateIndex()=0;
668
5db0e774 669 /**
670 * Find AliHLTOUTHandler objects for the data blocks.
671 * The available AliHLTModuleAgents are probed whether they provide
672 * handlers for data processing.
673 */
674 int InitHandlers();
675
b005ef92 676 /**
677 * Cleanup and reset the data input.
678 */
679 virtual int ResetInput();
680
4de7334f 681 /**
682 * Get the data buffer
9bb806cd 683 * @param [in] index index of the block
684 * @param [out] pBuffer buffer of the selected data block
685 * @param [out] size size of the selected data block
4de7334f 686 */
687 virtual int GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer,
688 AliHLTUInt32_t& size)=0;
689
049b43b2 690 /**
691 * Check byte order of data block
692 */
13398559 693 virtual AliHLTOUTByteOrder CheckBlockByteOrder(AliHLTUInt32_t index)=0;
049b43b2 694
695 /**
696 * Check alignment of data block
697 */
13398559 698 virtual int CheckBlockAlignment(AliHLTUInt32_t index, AliHLTOUT::AliHLTOUTDataType type)=0;
049b43b2 699
700 /**
701 * Select the data block of data type and specification of the previous
702 * call to @ref SelectFirstDataBlock. Core function of @ref SelectFirstDataBlock
703 * and @ref SelectNextDataBlock, starts to find a block at the current list
0f1882a7 704 * position.
705 *
706 * The data block is searched from the conditions of fSearchDataType,
707 * fSearchSpecification, fSearchHandlerType and the selection list.
708 *
049b43b2 709 * @return identifier >=0 if success, neg. error code if failed <br>
710 * -ENOENT if no block found <br>
711 * -EPERM if access denied (object locked)
712 */
713 int FindAndSelectDataBlock();
714
715 /**
716 * Set status flag.
717 * @param flag flag to set
718 * @return current status flags
719 */
720 unsigned int SetStatusFlag(unsigned int flag) {return fFlags|=flag;}
721
722 /**
723 * Clear status flag.
724 * @param flag flag to clear
725 * @return current status flags
726 */
727 unsigned int ClearStatusFlag(unsigned int flag) {return fFlags&=~flag;}
728
729 /**
730 * Check status flag.
731 * @param flag flag to check
732 * @return 1 if flag is set
733 */
734 int CheckStatusFlag(unsigned int flag) const {return (fFlags&flag)==flag;}
735
626bfcc1 736 /**
737 * Find handler description for a certain block index.
738 */
44dc7683 739 const AliHLTOUTHandlerListEntry& FindHandlerDesc(AliHLTUInt32_t blockIndex);
626bfcc1 740
c1292031 741 /**
742 * Set the RawReader as parameter.
743 * The function is for internal use only in conjunction with the
744 * New() functions.
745 */
746 virtual void SetParam(AliRawReader* pRawReader);
747
748 /**
749 * Set the RunLoader as parameter
750 * The function is for internal use only in conjunction with the
751 * New() functions.
752 */
753 virtual void SetParam(TTree* pDigitTree, int event=-1);
754
466d4e62 755 /**
756 * Set name of the digit file as parameter
757 * The function is for internal use only in conjunction with the
758 * New() functions.
759 */
760 virtual void SetParam(const char* filename, int event=-1);
761
4de7334f 762 /** data type for the current block search, set from @ref SelectFirstDataBlock */
763 AliHLTComponentDataType fSearchDataType; //!transient
764
765 /** data specification for the current block search */
766 AliHLTUInt32_t fSearchSpecification; //!transient
767
44dc7683 768 /** handler type for the current block search */
769 AliHLTModuleAgent::AliHLTOUTHandlerType fSearchHandlerType; // !transient
770
049b43b2 771 /** instance flags: locked, collecting, ... */
772 unsigned int fFlags; //!transient
4de7334f 773
774 /** list of block descriptors */
13398559 775 AliHLTOUTBlockDescriptorVector fBlockDescList; //!transient
4de7334f 776
777 /** current position in the list */
0f1882a7 778 unsigned int fCurrent; //!transient
4de7334f 779
780 /** data buffer under processing */
781 const AliHLTUInt8_t* fpBuffer; //!transient
782
5db0e774 783 /** list of AliHLTOUTHandlers */
13398559 784 AliHLTOUTHandlerListEntryVector fDataHandlers; // !transient
5db0e774 785
44dc7683 786 /** verbose or silent output */
787 bool fbVerbose; //!transient
788
b005ef92 789 /** gobal instance set for certain steps of the analysis */
790 static AliHLTOUT* fgGlobalInstance; //! transient
791
792 /** logging methods */
793 AliHLTLogging fLog; //! transient
794
e5701dcf 795 /** current buffer converted to a TObject */
796 TObject* fpDataObject; //!
797 const AliHLTUInt8_t* fpObjectBuffer; //!
798 AliHLTUInt32_t fObjectBufferSize; //!
799
c63e8be4 800 /** current event id */
801 AliHLTUInt64_t fCurrentEventId; //!
802
803 ClassDef(AliHLTOUT, 6)
62bb3cd4 804};
805#endif