LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTDataDeflater.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 9 11.1 %
Date: 2016-06-14 17:26:59 Functions: 1 13 7.7 %

          Line data    Source code
       1             : //-*- Mode: C++ -*-
       2             : // $Id$
       3             : #ifndef ALIHLTDATADEFLATER_H
       4             : #define ALIHLTDATADEFLATER_H
       5             : //* This file is property of and copyright by the ALICE HLT Project        * 
       6             : //* ALICE Experiment at CERN, All rights reserved.                         *
       7             : //* See cxx source for full Copyright notice                               *
       8             : 
       9             : /// @file   AliHLTDataDeflater.h
      10             : /// @author Matthias Richter, Timm Steinbeck
      11             : /// @date   2011-08-10
      12             : /// @brief  Data deflater class storing only necessary bits
      13             : /// @note   Code original from AliHLTTPCCompModelDeflater
      14             : 
      15             : #include "AliHLTLogging.h"
      16             : #include "AliHLTDataTypes.h"
      17             : #include "AliHLTStdIncludes.h"
      18             : #include <bitset>
      19             : 
      20             : class TObjArray;
      21             : class TH1;
      22             : class TH2;
      23             : 
      24             : /**
      25             :  * @class AliHLTDataDeflater
      26             :  * Data deflater class to write a bitstream into a buffer. The necessary
      27             :  * number of bits for each value is written to a stream without gaps.
      28             :  * The buffer can be padded to fill full bytes and continue writing at the
      29             :  * next byte.
      30             :  *
      31             :  * @ingroup alihlt_base
      32             :  */
      33             : class AliHLTDataDeflater : public AliHLTLogging
      34             : {
      35             : public:
      36             :   /// standard constructor
      37             :   AliHLTDataDeflater();
      38             :   /// destructor
      39             :   ~AliHLTDataDeflater();
      40             : 
      41             :   /** function to initialise bit data output
      42             :    * @param output AliHLTUInt8_t* pointer to output data
      43             :    * @param outputSize UInt_t output size
      44             :    */
      45             :   int InitBitDataOutput( AliHLTUInt8_t* output, UInt_t outputSize );
      46             : 
      47             :   /** function to close bit data output */
      48             :   void CloseBitDataOutput();
      49             : 
      50             :   /** function to get current byte output position
      51             :    * @return unsigned long value for current byte output position
      52             :    */
      53             :   unsigned long GetCurrentByteOutputPosition() const
      54             :   {
      55           0 :     return (unsigned long)( fBitDataCurrentOutput - fBitDataCurrentOutputStart );
      56             :   }
      57             : 
      58             :   /** function to get current bit output position
      59             :    * @return unsigned long value for current bit output position
      60             :    */
      61             :   unsigned GetCurrentBitOutputPosition() const
      62             :   {
      63           0 :     return fBitDataCurrentPosInWord;
      64             :   }
      65             : 
      66             :   /** function to get current output byte
      67             :    * @param offset Int_t (set to zero if not specified explicitly)
      68             :    * @return AliHLTUInt8_t value for current output byte
      69             :    */
      70             :   AliHLTUInt8_t GetCurrentOutputByte( Int_t offset=0 ) const;
      71             :       
      72             :   /** function to get bit data output size bytes
      73             :    * @return UInt_t value of bit data output size bytes
      74             :    */
      75             :   UInt_t GetBitDataOutputSizeBytes() const
      76             :   {
      77           0 :     return fBitDataCurrentOutput-fBitDataCurrentOutputStart;
      78             :   }
      79             :       
      80             :   /** function for output bit
      81             :    * @param value  AliHLTUInt32_t const & input
      82             :    * @return boolean (output bit)
      83             :    */
      84             :   bool OutputBit( AliHLTUInt32_t const & value );
      85             : 
      86             :   /** function to output bits 
      87             :    * @param value     AliHLTUInt64_t const &
      88             :    * @param bitCount  UInt_t const &
      89             :    * @return zero upon success
      90             :    */
      91             :   bool OutputBits( AliHLTUInt64_t const & value, UInt_t const & bitCount );
      92             : 
      93             :   /** function to output bits from a bitset
      94             :    * @param value     AliHLTUInt64_t const &
      95             :    * @param bitCount  UInt_t const &
      96             :    * @return zero upon success
      97             :    */
      98             :   bool OutputBits( std::bitset<64> const & value, UInt_t const & bitCount );
      99             : 
     100             :   /* function pad 8 bits */
     101             :   void Pad8Bits();
     102             : 
     103             :   /** function to output bytes
     104             :    * @param data  AliHLTUInt8_t const *
     105             :    * @param byteCount UInt_t const &
     106             :    * @return boolean (output bytes)
     107             :    */
     108             :   bool OutputBytes( AliHLTUInt8_t const * data, UInt_t const & byteCount );      
     109             : 
     110             :   /// add a histogram for deflater statistic of the corresponding parameter
     111             :   /// a histogram is created with default settings if h is not specified; if
     112             :   /// provided, the ownership goes over to the base class
     113             :   int AddHistogram(int id, const char* name, int bitWidth, TH1* h=NULL);
     114             : 
     115             :   /// enable statistics accounting
     116             :   int EnableStatistics();
     117             : 
     118             :   /// check if statistics writing is enabled
     119           0 :   bool DoStatistics() const {return fHistograms!=NULL;}
     120             : 
     121             :   /// fill statistics for a parameter
     122             :   /// @param id           id of the parameter
     123             :   /// @param value        value
     124             :   /// @param length       bit length
     125             :   /// @param codingWeight fraction of bit lenght used for this value
     126             :   int FillStatistics(int id, AliHLTUInt64_t value, unsigned length, float codingWeight=0.0);
     127             : 
     128             :   static float CalcEntropy(TH1* histo, const char* option="", int mode=0);
     129             : 
     130             :   /// save data according to option
     131             :   virtual void SaveAs(const char *filename="",Option_t *option="") const;
     132             : 
     133             :   /// clear the object and reset pointer references
     134             :   virtual void Clear(Option_t * /*option*/ ="");
     135             : 
     136             :   /// print info
     137             :   virtual void Print(Option_t *option="") const;
     138             : 
     139             :   /// print info
     140             :   virtual void Print(ostream& out, Option_t *option="") const;
     141             : 
     142             :   /// find object
     143           0 :   virtual TObject *FindObject(const char */*name*/) const {return NULL;}
     144             : 
     145             :   /// write bit pattern of a parameter to the current byte and position
     146             :   virtual bool OutputParameterBits( int parameterId, AliHLTUInt64_t const & value );
     147             : 
     148             :   /// write bit pattern of a parameter to the current byte and position
     149             :   virtual bool OutputParameterBits( int parameterId, AliHLTUInt64_t const & value, int lengthOffset );
     150             : 
     151             :   /// return unique version of the deflater, base class has version 0
     152           0 :   virtual int GetDeflaterVersion() const {return 0;}
     153             : 
     154             :   /// start the encoding of a new sequence
     155           0 :   virtual int StartEncoder() { return 0; };
     156             : 
     157             :   /// stop the encoding current sequence
     158           0 :   virtual int StopEncoder() { return 0; };
     159             : 
     160             : protected:
     161             : 
     162             : private:
     163             :   /// copy constructor prohibited
     164             :   AliHLTDataDeflater(const AliHLTDataDeflater&);
     165             :   /// assignment operator prohibited
     166             :   AliHLTDataDeflater& operator=(const AliHLTDataDeflater&);
     167             : 
     168             :   /// bit data current word
     169             :   AliHLTUInt8_t fBitDataCurrentWord; //! bit data current word
     170             :   /// bit data current position in word
     171             :   UInt_t fBitDataCurrentPosInWord; //! data current position in word
     172             :   /// bit data current output
     173             :   AliHLTUInt8_t *fBitDataCurrentOutput; //! bit data current output
     174             :   /// bit data current output start
     175             :   AliHLTUInt8_t *fBitDataCurrentOutputStart; //! bit data current output start
     176             :   /// bit data current output end
     177             :   AliHLTUInt8_t *fBitDataCurrentOutputEnd; //! bit data current output end 
     178             : 
     179             :   TObjArray* fHistograms; //! list of histograms for parameters
     180             :   TH2* fParameterCompression; //! compression for individual parameters
     181             :   TH2* fParameterSize; //! accumulated size for individual parameters
     182             : 
     183         126 :   ClassDef(AliHLTDataDeflater, 0)
     184             : };
     185             : 
     186             : ostream& operator<<(ostream &out, const AliHLTDataDeflater& me);
     187             : 
     188             : #endif

Generated by: LCOV version 1.11