]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTDataDeflater.h
correct filling of histogram N maxima vs N MC labels, cosmetics
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDataDeflater.h
CommitLineData
80fb7693 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"
3d961bf8 18#include <bitset>
80fb7693 19
20/**
21 * @class AliHLTDataDeflater
22 * Data deflater class to write a bitstream into a buffer. The necessary
23 * number of bits for each value is written to a stream without gaps.
24 * The buffer can be padded to fill full bytes and continue writing at the
25 * next byte.
26 *
27 * @ingroup alihlt_base
28 */
29class AliHLTDataDeflater : public AliHLTLogging
30{
31public:
32 /// standard constructor
33 AliHLTDataDeflater();
34 /// destructor
35 ~AliHLTDataDeflater();
36
37 /** function to initialise bit data output
38 * @param output AliHLTUInt8_t* pointer to output data
39 * @param outputSize UInt_t output size
40 */
41 int InitBitDataOutput( AliHLTUInt8_t* output, UInt_t outputSize );
42
43 /** function to close bit data output */
f95bc7cd 44 void CloseBitDataOutput();
80fb7693 45
46 /** function to get current byte output position
47 * @return unsigned long value for current byte output position
48 */
49 unsigned long GetCurrentByteOutputPosition() const
50 {
51 return (unsigned long)( fBitDataCurrentOutput - fBitDataCurrentOutputStart );
52 }
53
54 /** function to get current bit output position
55 * @return unsigned long value for current bit output position
56 */
57 unsigned GetCurrentBitOutputPosition() const
58 {
59 return fBitDataCurrentPosInWord;
60 }
61
62 /** function to get current output byte
63 * @param offset Int_t (set to zero if not specified explicitly)
64 * @return AliHLTUInt8_t value for current output byte
65 */
66 AliHLTUInt8_t GetCurrentOutputByte( Int_t offset=0 ) const;
67
68 /** function to get bit data output size bytes
69 * @return UInt_t value of bit data output size bytes
70 */
71 UInt_t GetBitDataOutputSizeBytes() const
72 {
73 return fBitDataCurrentOutput-fBitDataCurrentOutputStart;
74 }
75
76 /** function for output bit
77 * @param value AliHLTUInt32_t const & input
78 * @return boolean (output bit)
79 */
80 bool OutputBit( AliHLTUInt32_t const & value );
81
82 /** function to output bits
83 * @param value AliHLTUInt64_t const &
84 * @param bitCount UInt_t const &
85 * @return zero upon success
86 */
87 bool OutputBits( AliHLTUInt64_t const & value, UInt_t const & bitCount );
88
3d961bf8 89 /** function to output bits from a bitset
90 * @param value AliHLTUInt64_t const &
91 * @param bitCount UInt_t const &
92 * @return zero upon success
93 */
94 bool OutputBits( std::bitset<64> const & value, UInt_t const & bitCount );
95
80fb7693 96 /* function pad 8 bits */
97 void Pad8Bits();
98
99 /** function to output bytes
100 * @param data AliHLTUInt8_t const *
101 * @param byteCount UInt_t const &
102 * @return boolean (output bytes)
103 */
104 bool OutputBytes( AliHLTUInt8_t const * data, UInt_t const & byteCount );
105
106 /// clear the object and reset pointer references
107 virtual void Clear(Option_t * /*option*/ ="");
108
109 /// print info
110 virtual void Print(Option_t *option="") const;
111
112 /// print info
113 virtual void Print(ostream& out, Option_t *option="") const;
114
3d961bf8 115 /// find object
116 virtual TObject *FindObject(const char */*name*/) const {return NULL;}
117
118 /// save data according to option
119 virtual void SaveAs(const char */*filename*/="",Option_t */*option*/="") const {}
120
80fb7693 121 /// write bit pattern of a parameter to the current byte and position
122 virtual bool OutputParameterBits( int parameterId, AliHLTUInt64_t const & value );
123
f95bc7cd 124 /// return unique version of the deflater, base class has version 0
125 virtual int GetDeflaterVersion() const {return 0;}
126
80fb7693 127protected:
128
129private:
130 /// copy constructor prohibited
131 AliHLTDataDeflater(const AliHLTDataDeflater&);
132 /// assignment operator prohibited
133 AliHLTDataDeflater& operator=(const AliHLTDataDeflater&);
134
135 /// bit data current word
136 AliHLTUInt8_t fBitDataCurrentWord; //! bit data current word
137 /// bit data current position in word
138 UInt_t fBitDataCurrentPosInWord; //! data current position in word
139 /// bit data current output
140 AliHLTUInt8_t *fBitDataCurrentOutput; //! bit data current output
141 /// bit data current output start
142 AliHLTUInt8_t *fBitDataCurrentOutputStart; //! bit data current output start
143 /// bit data current output end
144 AliHLTUInt8_t *fBitDataCurrentOutputEnd; //! bit data current output end
145
146 ClassDef(AliHLTDataDeflater, 0)
147};
148
149ostream& operator<<(ostream &out, const AliHLTDataDeflater& me);
150
151#endif