CMS 3D CMS Logo

Functions | Variables
logintpack Namespace Reference

Functions

int16_t pack16log (double x, double lmin, double lmax, uint16_t base=32768)
 
int16_t pack16logCeil (double x, double lmin, double lmax, uint16_t base=32768)
 
int16_t pack16logClosed (double x, double lmin, double lmax, uint16_t base=32768)
 
int8_t pack8log (double x, double lmin, double lmax, uint8_t base=128)
 
int8_t pack8logCeil (double x, double lmin, double lmax, uint8_t base=128)
 
int8_t pack8logClosed (double x, double lmin, double lmax, uint8_t base=128)
 
double unpack16log (int16_t i, double lmin, double lmax, uint16_t base=32768)
 
double unpack16logClosed (int16_t i, double lmin, double lmax, uint16_t base=32768)
 reverse of pack8logClosed More...
 
double unpack8log (int8_t i, double lmin, double lmax, uint8_t base=128)
 
double unpack8logClosed (int8_t i, double lmin, double lmax, uint8_t base=128)
 reverse of pack8logClosed More...
 

Variables

constexpr int8_t smallestNegative = -1
 
constexpr int8_t smallestPositive = 0
 

Function Documentation

◆ pack16log()

int16_t logintpack::pack16log ( double  x,
double  lmin,
double  lmax,
uint16_t  base = 32768 
)
inline

Definition at line 27 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, dumpMFGeometry_cfg::delta, JetChargeProducer_cfi::exp, MainPageGenerator::l, dqm-mbProfile::log, and x.

Referenced by CompressionElement::pack(), and mtd_digitizer::saveSimHitAccumulator().

27  {
28  if (base > 32768)
29  base = 32768;
30  const float delta = (log(1. + exp((lmax - lmin) / base)) - log(2.)) * base / (lmax - lmin);
31  const double l = std::log(std::abs(x));
32  const double centered = (l - lmin) / (lmax - lmin) * base;
33  int16_t r = std::floor(centered);
34  if (centered - r > delta)
35  r += 1;
36  if (centered >= base - 1)
37  r = base - 1;
38  if (centered < 0)
39  r = 0;
40  if (x < 0)
41  r = r == 0 ? -1 : -r;
42  return r;
43  }
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float x

◆ pack16logCeil()

int16_t logintpack::pack16logCeil ( double  x,
double  lmin,
double  lmax,
uint16_t  base = 32768 
)
inline

Definition at line 12 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, reco::ceil(), MainPageGenerator::l, dqm-mbProfile::log, and x.

12  {
13  if (base > 32768)
14  base = 32768;
15  const double l = std::log(std::abs(x));
16  const double centered = (l - lmin) / (lmax - lmin) * base;
17  int16_t r = std::ceil(centered);
18  if (centered >= base - 1)
19  r = base - 1;
20  if (centered < 0)
21  r = 0;
22  if (x < 0)
23  r = r == 0 ? -1 : -r;
24  return r;
25  }
constexpr int32_t ceil(float num)
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float x

◆ pack16logClosed()

int16_t logintpack::pack16logClosed ( double  x,
double  lmin,
double  lmax,
uint16_t  base = 32768 
)
inline

pack a value x distributed in [-1,1], with guarantee that -1 and 1 are preserved exactly in packing and unpacking. tries to keep the best precision for x close to the endpoints, sacrifying that in the middle

Definition at line 47 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, MainPageGenerator::l, dqm-mbProfile::log, and x.

47  {
48  if (base > 32768)
49  base = 32768;
50  const double l = std::log(std::abs(x));
51  const double centered = (l - lmin) / (lmax - lmin) * (base - 1);
52  int16_t r = round(centered);
53  if (centered >= base - 1)
54  r = base - 1;
55  if (centered < 0)
56  r = 0;
57  if (x < 0)
58  r = r == 0 ? -1 : -r;
59  return r;
60  }
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float x

◆ pack8log()

int8_t logintpack::pack8log ( double  x,
double  lmin,
double  lmax,
uint8_t  base = 128 
)
inline

Definition at line 104 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, MainPageGenerator::l, dqm-mbProfile::log, and x.

104  {
105  if (base > 128)
106  base = 128;
107  const double l = std::log(std::abs(x));
108  const double centered = (l - lmin) / (lmax - lmin) * base;
109  int8_t r = centered;
110  if (centered >= base - 1)
111  r = base - 1;
112  if (centered < 0)
113  r = 0;
114  if (x < 0)
115  r = r == 0 ? -1 : -r;
116  return r;
117  }
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float x

◆ pack8logCeil()

int8_t logintpack::pack8logCeil ( double  x,
double  lmin,
double  lmax,
uint8_t  base = 128 
)
inline

Definition at line 89 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, reco::ceil(), MainPageGenerator::l, dqm-mbProfile::log, and x.

89  {
90  if (base > 128)
91  base = 128;
92  const double l = std::log(std::abs(x));
93  const double centered = (l - lmin) / (lmax - lmin) * base;
94  int8_t r = std::ceil(centered);
95  if (centered >= base - 1)
96  r = base - 1;
97  if (centered < 0)
98  r = 0;
99  if (x < 0)
100  r = r == 0 ? -1 : -r;
101  return r;
102  }
constexpr int32_t ceil(float num)
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float x

◆ pack8logClosed()

int8_t logintpack::pack8logClosed ( double  x,
double  lmin,
double  lmax,
uint8_t  base = 128 
)
inline

pack a value x distributed in [-1,1], with guarantee that -1 and 1 are preserved exactly in packing and unpacking. tries to keep the best precision for x close to the endpoints, sacrifying that in the middle

Definition at line 121 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, MainPageGenerator::l, dqm-mbProfile::log, and x.

121  {
122  if (base > 128)
123  base = 128;
124  const double l = std::log(std::abs(x));
125  const double centered = (l - lmin) / (lmax - lmin) * (base - 1);
126  int8_t r = round(centered);
127  if (centered >= base - 1)
128  r = base - 1;
129  if (centered < 0)
130  r = 0;
131  if (x < 0)
132  r = r == 0 ? -1 : -r;
133  return r;
134  }
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float x

◆ unpack16log()

double logintpack::unpack16log ( int16_t  i,
double  lmin,
double  lmax,
uint16_t  base = 32768 
)
inline

Definition at line 62 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, JetChargeProducer_cfi::exp, mps_fire::i, MainPageGenerator::l, and heppy_batch::val.

Referenced by mtd_digitizer::loadSimHitAccumulator(), and CompressionElement::unpack().

62  {
63  if (base > 32768)
64  base = 32768;
65  const double basef = base;
66  const double l = lmin + std::abs(i) / basef * (lmax - lmin);
67  const double val = std::exp(l);
68  if (i < 0)
69  return -val;
70  else
71  return val;
72  }
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ unpack16logClosed()

double logintpack::unpack16logClosed ( int16_t  i,
double  lmin,
double  lmax,
uint16_t  base = 32768 
)
inline

reverse of pack8logClosed

Definition at line 75 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, JetChargeProducer_cfi::exp, mps_fire::i, MainPageGenerator::l, and heppy_batch::val.

75  {
76  if (base > 32768)
77  base = 32768;
78  const double basef = base - 1;
79  double l = lmin + std::abs(i) / basef * (lmax - lmin);
80  if (std::abs(i) == base - 1)
81  l = lmax;
82  const double val = std::exp(l);
83  if (i < 0)
84  return -val;
85  else
86  return val;
87  }
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ unpack8log()

double logintpack::unpack8log ( int8_t  i,
double  lmin,
double  lmax,
uint8_t  base = 128 
)
inline

Definition at line 136 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, JetChargeProducer_cfi::exp, mps_fire::i, MainPageGenerator::l, and heppy_batch::val.

136  {
137  if (base > 128)
138  base = 128;
139  const double basef = base;
140  const double l = lmin + std::abs(i) / basef * (lmax - lmin);
141  const double val = std::exp(l);
142  if (i < 0)
143  return -val;
144  else
145  return val;
146  }
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ unpack8logClosed()

double logintpack::unpack8logClosed ( int8_t  i,
double  lmin,
double  lmax,
uint8_t  base = 128 
)
inline

reverse of pack8logClosed

Definition at line 149 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, JetChargeProducer_cfi::exp, mps_fire::i, MainPageGenerator::l, and heppy_batch::val.

149  {
150  if (base > 128)
151  base = 128;
152  const double basef = base - 1;
153  double l = lmin + std::abs(i) / basef * (lmax - lmin);
154  if (std::abs(i) == base - 1)
155  l = lmax;
156  const double val = std::exp(l);
157  if (i < 0)
158  return -val;
159  else
160  return val;
161  }
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

Variable Documentation

◆ smallestNegative

constexpr int8_t logintpack::smallestNegative = -1

Definition at line 11 of file liblogintpack.h.

◆ smallestPositive

constexpr int8_t logintpack::smallestPositive = 0

Definition at line 8 of file liblogintpack.h.