ATLAS Offline Software
Loading...
Searching...
No Matches
Compressor.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 * Compressor.h
7 * Compressor
8 *
9 * Created by Ilija Vukotic on 05/07/07.
10 * <ivukotic@cern.ch>
11 *
12 */
13
14
15#ifndef ATHENAPOOLCNVSVC_COMPRESSOR_H
16#define ATHENAPOOLCNVSVC_COMPRESSOR_H
17
18// TO DO :
19// add double to int compressor
20// enable 32 bit "compression"
21// should be smart enough to call compression to short when 16 bits required. or maybe people should be aware that 16 bits is faster than 17?
22
23#include <vector>
24#include <iostream>
25
27
28public:
30 m_sign=false;
31 m_bits=16;
32 m_bitStrip = false;
33 }
34 ~Compressor() = default;
35
36 void setNrBits(int bits){
37 m_bits=bits;
38 m_bitStrip=true; // will be used to disable compression (already programmed for compressor but not decompressor.)
39 if (bits<12){
40 std::cout<<"WARNING -> Too large compression requested. Will leave 12 bits instead!"<<std::endl;
41 m_bits=12;
42 }
43 else if(bits>=32 || bits==0){
44 std::cout<<"WARNING -> Compression to "<<bits<<" bits is not possible. Compressing to 31 bits !"<<std::endl;
45 m_bits=31;
46 }
47 }
48
49 void setIgnoreSign(){m_sign=true;}
50
51 // standard compression 32 to 16 bits - precision is better than 0.4%
52 void reduceToUS(const std::vector<float> &vf, std::vector<unsigned short> &vi);
53
54 // standard uncompression from 16 bits to 32
55 void expandFromUStoFloat(const std::vector<unsigned short> &vi, std::vector<float>&vf);
56
57 //------------
58
59 // compression with variable sign, range and precision
60 void reduce(const std::vector<float> & vf, std::vector<unsigned int> &vi);
61
62 // uncompression with variable sign,range and precision
63 void expandToFloat(const std::vector<unsigned int> & vc, std::vector<float> & vf);
64
65private:
66 int m_bits;
67 bool m_sign;
69};
70
71#endif // not ATHENAPOOLCNVSVC_COMPRESSOR_H
bool m_sign
Definition Compressor.h:67
void setIgnoreSign()
Definition Compressor.h:49
void expandFromUStoFloat(const std::vector< unsigned short > &vi, std::vector< float > &vf)
void reduceToUS(const std::vector< float > &vf, std::vector< unsigned short > &vi)
bool m_bitStrip
Definition Compressor.h:68
void expandToFloat(const std::vector< unsigned int > &vc, std::vector< float > &vf)
void setNrBits(int bits)
Definition Compressor.h:36
void reduce(const std::vector< float > &vf, std::vector< unsigned int > &vi)
~Compressor()=default