ATLAS Offline Software
Loading...
Searching...
No Matches
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
64{
65public:
66 FloatRep(char s, unsigned short e, unsigned int m) :
67 m_sign(s), m_exp(e), m_mant(m)
68 {
69
70 }
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
116private:
117 char m_sign;
118 unsigned int m_exp;
119 unsigned int m_mant;
120};
121
122
123
125
126class Triplet {
127
128 public :
129 Triplet(int d, int nd1, int nd2) : m_d(d), m_nd1(nd1), m_nd2(nd2)
130 {
131
132 }
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
static Double_t a
bool compressFR(const std::vector< FloatRep > &, std::vector< unsigned short > &)
void setUpperLimits(const int l[2])
bool restore(const std::vector< unsigned int > &, std::vector< double > &)
std::vector< Triplet > m_tripVec
bool compress(const std::vector< double > &, std::vector< unsigned int > &)
DecoderFloat_IEEE754 m_decoder
bool CholeskyDecomposition(double a[5][5], double L[5][5])
bool restoreFR(const std::vector< unsigned short > &, std::vector< FloatRep > &)
void setBiases(const int b[6])
void exponent(unsigned short int e)
unsigned short exponent() const
char sign() const
void sign(char s)
void mantissa(unsigned int m)
unsigned int m_mant
unsigned int m_exp
FloatRep(char s, unsigned short e, unsigned int m)
unsigned int mantissa() const