]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTOUT.h
correcting a typo in initialization
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOUT.h
1 //-*- Mode: C++ -*-
2 // @(#) $Id$
3
4 #ifndef ALIHLTOUT_H
5 #define ALIHLTOUT_H
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                               *
9
10 /** @file   AliHLTOUT.h
11     @author Matthias Richter
12     @date   
13     @brief  The control class for HLTOUT data.
14 */
15
16 #include <vector>
17 #include "AliHLTLogging.h"
18 #include "AliHLTModuleAgent.h"
19
20 class AliHLTOUTHandler;
21 class AliHLTOUTHandlerDesc; // AliHLTModuleAgent.h
22 class AliESDEvent;
23 class AliHLTReconstructor;
24 class AliRawReader;
25 class TTree;
26
27 #define AliHLTOUTInvalidIndex (~(AliHLTUInt32_t)0)
28
29 typedef vector<AliHLTUInt32_t> AliHLTOUTIndexList;
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 {
41  public:
42   /** standard constructor */
43   AliHLTOUT();
44   /** standard destructor */
45   virtual ~AliHLTOUT();
46
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    * 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
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
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
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)
92     {if (fpInstance) fpInstance->SetStatusFlag(kLocked);}
93     /** destructor */
94     ~AliHLTOUTLockGuard()
95     {if (fpInstance) fpInstance->ClearStatusFlag(kLocked);}
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
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
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
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
151   };
152
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
167   // definitions from ALICE internal notes ALICE-INT-2002-010 and
168   // ALICE-INT-2006-XXX
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   };
179
180   class AliHLTOUTHandlerListEntry;
181   /**
182    * Block descriptor.
183    */
184   class AliHLTOUTBlockDescriptor {
185   public:
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; }
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;}
198     int operator==(AliHLTOUT* collection) const {return collection==fpCollection;}
199
200     AliHLTUInt32_t GetIndex() const {return fIndex;}
201     AliHLTOUT* GetCollection() const {return fpCollection;}
202
203     bool IsSelected() const {return fSelected;}
204     void Select(bool selected=true) {fSelected=selected;}
205     bool IsProcessed() const {return fProcessed;}
206     void MarkProcessed() {fProcessed=true;}
207
208     /**
209      * Get the data buffer
210      * @param [out] pBuffer buffer of the selected data block
211      * @param [out] size    size of the selected data block
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
218     /**
219      * Get the handler descriptor
220      */
221     const AliHLTOUTHandlerListEntry& GetHandlerDesc();
222
223   private:      
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
230     /** selection flag */
231     bool                    fSelected; //!transient
232     /** processed flag */
233     bool                    fProcessed; //!transient
234     /** the collection */
235     AliHLTOUT*              fpCollection; //!transient
236   };
237
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
273     /**
274      * Compare the handler descriptor of this list entry with another
275      * descriptor.
276      * @return true if both handler and agent match
277      */
278     bool operator==(const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc) const; 
279
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     /**
291      * Add all indices of the descriptor.
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      */
299     bool HasIndex(AliHLTUInt32_t index) const;
300
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
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
324     /** list of block indices */
325     AliHLTOUTIndexList fBlocks; //!transient
326   };
327
328   typedef vector<AliHLTOUTHandlerListEntry> AliHLTOUTHandlerListEntryVector;
329   typedef vector<AliHLTOUTBlockDescriptor>  AliHLTOUTBlockDescriptorVector;
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   };
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
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
377   /**
378    * Get the current event id
379    */
380   AliHLTUInt64_t EventId() {return fCurrentEventId;}
381
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)
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
397    * @return block index: >= 0 if success, -ENOENT if no block found      <br>
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,
403                            AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=AliHLTModuleAgent::kUnknownOutput,
404                            bool skipProcessed=true);
405
406   /**
407    * Select the next data block of data type and specification of the previous
408    * call to @ref SelectFirstDataBlock.
409    * @return block index: >= 0 if success, -ENOENT if no block found      <br>
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.
417    * @param [out] dt    data type of the selected block
418    * @param [out] spec  data specification of the selected block
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.
441    * @param [out] pBuffer buffer of the selected data block
442    * @param [out] size    size of the selected data block
443    */
444   int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size);
445
446   /**
447    * Release buffer after use.
448    * @param [in] pBuffer  buffer of the selected data block
449    */
450   int ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer);
451
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
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
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.
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
535    */
536   virtual int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt, AliESDEvent* tgtesd=NULL) const;
537
538   enum AliHLTOUTByteOrder {
539     /** no data block selected */
540     kInvalidByteOrder=-1,
541     kUnknownByteOrder=0,
542     kLittleEndian,
543     kBigEndian
544   };
545
546   enum AliHLTOUTDataType {
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    */
558   AliHLTOUTByteOrder CheckByteOrder();
559
560   /**
561    * Check alignment of selected block
562    */
563   int CheckAlignment(AliHLTOUT::AliHLTOUTDataType type);
564
565   /**
566    * Helper function to byte swap a 64 bit value.
567    */
568   static AliHLTUInt64_t ByteSwap64(AliHLTUInt64_t src);
569
570   /**
571    * Helper function to byte swap a 32 bit value.
572    */
573   static AliHLTUInt32_t ByteSwap32(AliHLTUInt32_t src);
574
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.
580    * @param list     the handler list
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   
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
608  protected:
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);
617
618   /**
619    * Set the event id, only for child classes
620    */
621   void SetEventId(AliHLTUInt64_t id);
622
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
633  private:
634   /** copy constructor prohibited */
635   AliHLTOUT(const AliHLTOUT&);
636   /** assignment operator prohibited */
637   AliHLTOUT& operator=(const AliHLTOUT&);
638
639   /**
640    * Internal status flags
641    */
642   enum {
643     /** the HLTOUT object is locked with the current data block selection */
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 */
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
661   };
662
663   /**
664    * Generate the index of the HLTOUT data.
665    * Must be implemented by the child classes.
666    */
667   virtual int GenerateIndex()=0;
668
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
676   /**
677    * Cleanup and reset the data input.
678    */
679   virtual int ResetInput();
680
681   /**
682    * Get the data buffer
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
686    */
687   virtual int GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer, 
688                             AliHLTUInt32_t& size)=0;
689
690   /**
691    * Check byte order of data block
692    */
693   virtual AliHLTOUTByteOrder CheckBlockByteOrder(AliHLTUInt32_t index)=0;
694
695   /**
696    * Check alignment of data block
697    */
698   virtual int CheckBlockAlignment(AliHLTUInt32_t index, AliHLTOUT::AliHLTOUTDataType type)=0;
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
704    * position.
705    * 
706    * The data block is searched from the conditions of fSearchDataType,
707    * fSearchSpecification, fSearchHandlerType and the selection list.
708    *
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
736   /**
737    * Find handler description for a certain block index.
738    */
739   const AliHLTOUTHandlerListEntry& FindHandlerDesc(AliHLTUInt32_t blockIndex);
740
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
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
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
768   /** handler type for the current block search */
769   AliHLTModuleAgent::AliHLTOUTHandlerType fSearchHandlerType; // !transient
770
771   /** instance flags: locked, collecting, ... */
772   unsigned int fFlags; //!transient
773
774   /** list of block descriptors */
775   AliHLTOUTBlockDescriptorVector fBlockDescList; //!transient
776
777   /** current position in the list */
778   unsigned int fCurrent; //!transient
779
780   /** data buffer under processing */
781   const AliHLTUInt8_t* fpBuffer; //!transient
782
783   /** list of AliHLTOUTHandlers */
784   AliHLTOUTHandlerListEntryVector fDataHandlers; // !transient
785
786   /** verbose or silent output */
787   bool fbVerbose; //!transient
788
789   /** gobal instance set for certain steps of the analysis */
790   static AliHLTOUT* fgGlobalInstance; //! transient
791
792   /** logging methods */
793   AliHLTLogging fLog; //! transient
794
795   /** current buffer converted to a TObject */
796   TObject* fpDataObject; //!
797   const AliHLTUInt8_t* fpObjectBuffer; //!
798   AliHLTUInt32_t fObjectBufferSize; //!
799
800   /** current event id */
801   AliHLTUInt64_t fCurrentEventId; //!
802
803   ClassDef(AliHLTOUT, 6)
804 };
805 #endif