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