]>
Commit | Line | Data |
---|---|---|
80fb7693 | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
10 | //* Permission to use, copy, modify and distribute this software and its * | |
11 | //* documentation strictly for non-commercial purposes is hereby granted * | |
12 | //* without fee, provided that the above copyright notice appears in all * | |
13 | //* copies and that both the copyright notice and this permission notice * | |
14 | //* appear in the supporting documentation. The authors make no claims * | |
15 | //* about the suitability of this software for any purpose. It is * | |
16 | //* provided "as is" without express or implied warranty. * | |
17 | //************************************************************************** | |
18 | ||
19 | /// @file AliHLTDataDeflaterSimple.cxx | |
20 | /// @author Matthias Richter | |
21 | /// @date 2011-08-10 | |
22 | /// @brief Simple deflater implementation storing frequent values below a | |
23 | /// maximum value with a reduced bit number and others with the full | |
24 | /// number of bits. | |
25 | ||
26 | #include "AliHLTDataDeflaterSimple.h" | |
27 | #include <memory> | |
28 | #include <algorithm> | |
29 | #include <iostream> | |
30 | ||
31 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
32 | ClassImp(AliHLTDataDeflaterSimple) | |
33 | ||
34 | AliHLTDataDeflaterSimple::AliHLTDataDeflaterSimple() | |
35 | : AliHLTDataDeflater() | |
36 | , fParameterDefinitions() | |
37 | { | |
38 | // see header file for class documentation | |
39 | // or | |
40 | // refer to README to build package | |
41 | // or | |
42 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
43 | } | |
44 | ||
45 | AliHLTDataDeflaterSimple::~AliHLTDataDeflaterSimple() | |
46 | { | |
47 | // destructor | |
48 | Clear(); | |
49 | } | |
50 | ||
51 | bool AliHLTDataDeflaterSimple::OutputParameterBits( int memberId, AliHLTUInt64_t const & value ) | |
52 | { | |
53 | // write bit pattern of a member to the current byte and position | |
54 | if (memberId>=(int)fParameterDefinitions.size()) return false; | |
55 | ||
56 | AliHLTUInt32_t switchBit=fParameterDefinitions[memberId].SwitchBit(value); // 0 -> reduced, 1 -> full | |
57 | AliHLTUInt64_t v=fParameterDefinitions[memberId].Value(value); | |
58 | AliHLTUInt32_t length=fParameterDefinitions[memberId].ValueLength(value); | |
59 | fParameterDefinitions[memberId].IncrementBitCount(value); | |
60 | ||
61 | if (!OutputBit(switchBit)) return false; | |
62 | return OutputBits(v, length); | |
63 | } | |
64 | ||
65 | void AliHLTDataDeflaterSimple::Clear(Option_t * /*option*/) | |
66 | { | |
67 | // internal cleanup | |
68 | } | |
69 | ||
70 | void AliHLTDataDeflaterSimple::Print(Option_t *option) const | |
71 | { | |
72 | // print info | |
73 | Print(cout, option); | |
74 | } | |
75 | ||
76 | void AliHLTDataDeflaterSimple::Print(ostream& out, Option_t *option) const | |
77 | { | |
78 | // print to stream | |
79 | out << "AliHLTDataDeflaterSimple:" << endl; | |
80 | AliHLTUInt64_t bitCount=0; | |
81 | AliHLTUInt64_t fullSize=0; | |
82 | for (vector<AliHLTDataDeflaterParameter>::const_iterator m=fParameterDefinitions.begin(); | |
83 | m!=fParameterDefinitions.end(); m++) { | |
84 | cout << " "; m->Print(option); | |
85 | bitCount+=m->GetBitCount(); | |
86 | fullSize+=m->GetValueCount()*m->GetBitLength(); | |
87 | } | |
88 | out << " total: " << bitCount << "/" << fullSize << " " << (fullSize>0?float(bitCount)/fullSize:0.0) << endl; | |
89 | } | |
90 | ||
91 | void AliHLTDataDeflaterSimple::AliHLTDataDeflaterParameter::Print(const char* /*option*/) const | |
92 | { | |
93 | // print info | |
94 | cout << fName << " (" << fFullBitLength << "," << fReducedBitLength << "): " | |
95 | << fValueCount << " entries " | |
96 | << fBitCount << "/" << fFullBitLength*fValueCount; | |
97 | if (fFullBitLength && fValueCount) { | |
98 | cout << " " << float(fBitCount)/(fValueCount*fFullBitLength); | |
99 | } | |
100 | cout << endl; | |
101 | } | |
102 | ||
103 | ostream& operator<<(ostream &out, const AliHLTDataDeflaterSimple& me) | |
104 | { | |
105 | me.Print(out); | |
106 | return out; | |
107 | } |