4 : exponentBits_(conf.getParameter<uint32_t>(
"exponentBits")),
5 mantissaBits_(conf.getParameter<uint32_t>(
"mantissaBits")),
6 rounding_(conf.getParameter<
bool>(
"rounding")) {
8 throw cms::Exception(
"CodespaceCannotFit") <<
"The code space cannot fit into the unsigned 32-bit space.\n";
16 uint32_t& compressedCode,
17 uint32_t& compressedValue) {
27 uint32_t valcopy =
value;
28 for (bitlen = 0; valcopy != 0; valcopy >>= 1, bitlen++) {
31 compressedCode =
value;
32 compressedValue =
value;
38 const uint32_t mantissa = (value >> (exponent - 1)) & ~(1 <<
mantissaBits_);
41 const uint32_t floatval = (exponent <<
mantissaBits_) | mantissa;
45 compressedCode = floatval;
46 compressedValue = ((1 <<
mantissaBits_) | mantissa) << (exponent - 1);
48 const bool roundup = ((value >> (exponent - 2)) & 1) == 1;
50 compressedCode = floatval;
51 compressedValue = ((1 <<
mantissaBits_) | mantissa) << (exponent - 1);
53 compressedCode = floatval + 1;
54 uint32_t rmantissa = mantissa + 1;
56 if (rmantissa >= (1
U << mantissaBits_)) {
60 compressedValue = ((1 <<
mantissaBits_) | rmantissa) << (rexponent - 1);
66 std::unordered_map<uint32_t, std::array<uint32_t, 2> >& compressed_payload) {
67 for (
const auto& item : payload) {
68 const uint32_t
value = item.second;
70 uint32_t compressed_value(0);
72 std::array<uint32_t, 2> compressed_item = {{code, compressed_value}};
73 compressed_payload.emplace(item.first, compressed_item);
HGCalVFECompressionImpl(const edm::ParameterSet &conf)
void compress(const std::unordered_map< uint32_t, uint32_t > &, std::unordered_map< uint32_t, std::array< uint32_t, 2 > > &)
uint32_t saturationValue_
void compressSingle(const uint32_t value, uint32_t &compressedCode, uint32_t &compressedValue)