ATLAS Offline Software
ErrorMatrixCompressor.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * ErrorMatrixCompressor.h
7  *
8  * Created by Dmitry Emeliyanov on 12/11/2008.
9  * <Dmitry.Emeliyanov@cern.ch>
10  *
11  */
12 
13 #ifndef EVENTCOMMONTPCNV_ERROR_MATRIX_COMPRESSOR_H
14 #define EVENTCOMMONTPCNV_ERROR_MATRIX_COMPRESSOR_H
15 
16 #include <vector>
17 #include <iostream>
18 
19 
21 {
22 
24 {
25  float f;
26  unsigned int l;
27 };
28 
29  public:
31  {
32  m_data.f=0.0;
33  }
35  void setF(float f)
36  {
37  m_data.f=f;
38  }
39  float getF()
40  {
41  if(m_data.l==(unsigned int)0x80000000)
42  return 0.0;
43  else
44  return m_data.f;
45  }
46  void setL( int l)
47  {
48  m_data.l=l;
49  }
50  unsigned int getL()
51  {
52  return m_data.l;
53  }
54  void print();
55  short int getExponent();
56  unsigned int getMantissa();
57  void setExponent(short int);
58  void setSign(int);
59 
61 };
62 
63 class FloatRep
64 {
65 public:
66  FloatRep(char s, unsigned short e, unsigned int m) :
67  m_sign(s), m_exp(e), m_mant(m)
68  {
69 
70  }
71  ~FloatRep(){};
72  float restore()
73  {
74  union FL {
75  float m_f;
76  unsigned int m_l;
77  } decoder;
78 
79  if((m_mant==0)&&(m_sign!=0))
80  return 0.0;
81 
82  unsigned int buf=0x00000000;
83 
84  buf = m_mant;
85  buf = buf | (m_exp << 23);
86  if (m_sign!=0)
87  buf = buf | 0x80000000;
88  decoder.m_l=buf;
89  return decoder.m_f;
90  }
91  char sign() const
92  {
93  return m_sign;
94  }
95  unsigned short exponent() const
96  {
97  return m_exp;
98  }
99  unsigned int mantissa() const
100  {
101  return m_mant;
102  }
103  void sign(char s)
104  {
105  m_sign=(s==0)?0:1;
106  }
107  void exponent(unsigned short int e)
108  {
109  m_exp=e;
110  }
111  void mantissa(unsigned int m)
112  {
113  m_mant=m;
114  }
115 
116 private:
117  char m_sign;
118  unsigned int m_exp;
119  unsigned int m_mant;
120 };
121 
122 
123 
125 
126 class Triplet {
127 
128  public :
129  Triplet(int d, int nd1, int nd2) : m_d(d), m_nd1(nd1), m_nd2(nd2)
130  {
131 
132  }
133  ~Triplet(){};
135 };
136 
137  public:
138 
141 
142  bool compress(const std::vector<double>&, std::vector<unsigned int>&);
143  bool restore(const std::vector<unsigned int>&, std::vector<double>&);
144  void setBiases(const int b[6]);
145  void setUpperLimits(const int l[2]);
146 
147  protected:
148 
149  bool CholeskyDecomposition(double a[5][5], double L[5][5]);
150  bool compressFR(const std::vector<FloatRep>&,std::vector<unsigned short>&);
151  bool restoreFR(const std::vector<unsigned short>&,std::vector<FloatRep>&);
152 
153  short int m_biases[6];
154  short int m_limits[2];
155  double m_scales[5];
156 
158 
159  private:
161  unsigned int m_srcMasks[16];
162  std::vector<Triplet> m_tripVec;
163 };
164 
165 #endif
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
ErrorMatrixCompressor::restoreFR
bool restoreFR(const std::vector< unsigned short > &, std::vector< FloatRep > &)
Definition: ErrorMatrixCompressor.cxx:444
FloatRep::mantissa
void mantissa(unsigned int m)
Definition: ErrorMatrixCompressor.h:111
ErrorMatrixCompressor::compress
bool compress(const std::vector< double > &, std::vector< unsigned int > &)
Definition: ErrorMatrixCompressor.cxx:173
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ErrorMatrixCompressor::m_bitStrip
int m_bitStrip
Definition: ErrorMatrixCompressor.h:157
DecoderFloat_IEEE754::setExponent
void setExponent(short int)
Definition: ErrorMatrixCompressor.cxx:61
DecoderFloat_IEEE754::getExponent
short int getExponent()
Definition: ErrorMatrixCompressor.cxx:48
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
FloatRep::exponent
unsigned short exponent() const
Definition: ErrorMatrixCompressor.h:95
DecoderFloat_IEEE754::FloatLongIntUnion::f
float f
Definition: ErrorMatrixCompressor.h:25
ErrorMatrixCompressor::~ErrorMatrixCompressor
~ErrorMatrixCompressor()
Definition: ErrorMatrixCompressor.h:140
python.LArCondContChannels.decoder
decoder
def channelSelection(self, channelList, groupType): if groupType == self.SingleGroup: pass elif group...
Definition: LArCondContChannels.py:618
FloatRep::mantissa
unsigned int mantissa() const
Definition: ErrorMatrixCompressor.h:99
hist_file_dump.d
d
Definition: hist_file_dump.py:137
ErrorMatrixCompressor::m_biases
short int m_biases[6]
Definition: ErrorMatrixCompressor.h:153
DecoderFloat_IEEE754::setSign
void setSign(int)
Definition: ErrorMatrixCompressor.cxx:69
DecoderFloat_IEEE754::getL
unsigned int getL()
Definition: ErrorMatrixCompressor.h:50
FloatRep::m_exp
unsigned int m_exp
Definition: ErrorMatrixCompressor.h:118
ErrorMatrixCompressor
Definition: ErrorMatrixCompressor.h:124
DecoderFloat_IEEE754
Definition: ErrorMatrixCompressor.h:21
FloatRep::m_mant
unsigned int m_mant
Definition: ErrorMatrixCompressor.h:119
FloatRep::FloatRep
FloatRep(char s, unsigned short e, unsigned int m)
Definition: ErrorMatrixCompressor.h:66
ErrorMatrixCompressor::CholeskyDecomposition
bool CholeskyDecomposition(double a[5][5], double L[5][5])
Definition: ErrorMatrixCompressor.cxx:141
ErrorMatrixCompressor::m_srcMasks
unsigned int m_srcMasks[16]
Definition: ErrorMatrixCompressor.h:161
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
ErrorMatrixCompressor::setUpperLimits
void setUpperLimits(const int l[2])
Definition: ErrorMatrixCompressor.cxx:132
ErrorMatrixCompressor::m_decoder
DecoderFloat_IEEE754 m_decoder
Definition: ErrorMatrixCompressor.h:160
DecoderFloat_IEEE754::FloatLongIntUnion::l
unsigned int l
Definition: ErrorMatrixCompressor.h:26
DecoderFloat_IEEE754::getMantissa
unsigned int getMantissa()
Definition: ErrorMatrixCompressor.cxx:54
ErrorMatrixCompressor::setBiases
void setBiases(const int b[6])
Definition: ErrorMatrixCompressor.cxx:124
DecoderFloat_IEEE754::getF
float getF()
Definition: ErrorMatrixCompressor.h:39
ErrorMatrixCompressor::Triplet::Triplet
Triplet(int d, int nd1, int nd2)
Definition: ErrorMatrixCompressor.h:129
DecoderFloat_IEEE754::m_data
FloatLongIntUnion m_data
Definition: ErrorMatrixCompressor.h:60
ErrorMatrixCompressor::Triplet
Definition: ErrorMatrixCompressor.h:126
ErrorMatrixCompressor::m_tripVec
std::vector< Triplet > m_tripVec
Definition: ErrorMatrixCompressor.h:162
DecoderFloat_IEEE754::DecoderFloat_IEEE754
DecoderFloat_IEEE754()
Definition: ErrorMatrixCompressor.h:30
FloatRep::exponent
void exponent(unsigned short int e)
Definition: ErrorMatrixCompressor.h:107
ErrorMatrixCompressor::restore
bool restore(const std::vector< unsigned int > &, std::vector< double > &)
Definition: ErrorMatrixCompressor.cxx:249
DecoderFloat_IEEE754::FloatLongIntUnion
Definition: ErrorMatrixCompressor.h:24
FloatRep::sign
void sign(char s)
Definition: ErrorMatrixCompressor.h:103
ErrorMatrixCompressor::m_scales
double m_scales[5]
Definition: ErrorMatrixCompressor.h:155
DecoderFloat_IEEE754::print
void print()
Definition: ErrorMatrixCompressor.cxx:24
hist_file_dump.f
f
Definition: hist_file_dump.py:135
ErrorMatrixCompressor::ErrorMatrixCompressor
ErrorMatrixCompressor(int)
Definition: ErrorMatrixCompressor.cxx:82
ErrorMatrixCompressor::Triplet::~Triplet
~Triplet()
Definition: ErrorMatrixCompressor.h:133
DecoderFloat_IEEE754::~DecoderFloat_IEEE754
~DecoderFloat_IEEE754()
Definition: ErrorMatrixCompressor.h:34
FloatRep::~FloatRep
~FloatRep()
Definition: ErrorMatrixCompressor.h:71
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
FloatRep
Definition: ErrorMatrixCompressor.h:64
a
TList * a
Definition: liststreamerinfos.cxx:10
ErrorMatrixCompressor::Triplet::m_nd1
int m_nd1
Definition: ErrorMatrixCompressor.h:134
ErrorMatrixCompressor::Triplet::m_nd2
int m_nd2
Definition: ErrorMatrixCompressor.h:134
ErrorMatrixCompressor::Triplet::m_d
int m_d
Definition: ErrorMatrixCompressor.h:133
ErrorMatrixCompressor::m_limits
short int m_limits[2]
Definition: ErrorMatrixCompressor.h:154
ErrorMatrixCompressor::compressFR
bool compressFR(const std::vector< FloatRep > &, std::vector< unsigned short > &)
Definition: ErrorMatrixCompressor.cxx:308
DecoderFloat_IEEE754::setF
void setF(float f)
Definition: ErrorMatrixCompressor.h:35
FloatRep::restore
float restore()
Definition: ErrorMatrixCompressor.h:72
DecoderFloat_IEEE754::setL
void setL(int l)
Definition: ErrorMatrixCompressor.h:46
FloatRep::m_sign
char m_sign
Definition: ErrorMatrixCompressor.h:117
FloatRep::sign
char sign() const
Definition: ErrorMatrixCompressor.h:91