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

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

Definition at line 26 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, delta, JetChargeProducer_cfi::exp, checklumidiff::l, cmsBatch::log, and alignCSCRings::r.

Referenced by CompressionElement::pack().

27  {
28  if(base>32768) base=32768;
29  const float delta=(log(1.+exp((lmax-lmin)/base))-log(2.))*base/(lmax-lmin);
30  const double l = std::log(std::abs(x));
31  const double centered = (l-lmin)/(lmax-lmin)*base;
32  int16_t r=std::floor(centered);
33  if(centered-r>delta) r+=1;
34  if(centered >= base-1) r=base-1;
35  if(centered < 0) r=0;
36  if(x<0) r = r==0 ? -1 : -r;
37  return r;
38  }
dbl * delta
Definition: mlp_gen.cc:36
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.
int16_t logintpack::pack16logCeil ( double  x,
double  lmin,
double  lmax,
uint16_t  base = 32768 
)
inline

Definition at line 13 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, checklumidiff::l, cmsBatch::log, and alignCSCRings::r.

14  {
15  if(base>32768) base=32768;
16  const double l = std::log(std::abs(x));
17  const double centered = (l-lmin)/(lmax-lmin)*base;
18  int16_t r=std::ceil(centered);
19  if(centered >= base-1) r=base-1;
20  if(centered < 0) r=0;
21  if(x<0) r = r==0 ? -1 : -r;
22  return r;
23  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.
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 42 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, checklumidiff::l, cmsBatch::log, and alignCSCRings::r.

43  {
44  if(base>32768) base=32768;
45  const double l = std::log(std::abs(x));
46  const double centered = (l-lmin)/(lmax-lmin)*(base-1);
47  int16_t r=round(centered);
48  if(centered >= base-1) r=base-1;
49  if(centered < 0) r=0;
50  if(x<0) r = r==0 ? -1 : -r;
51  return r;
52  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.
int8_t logintpack::pack8log ( double  x,
double  lmin,
double  lmax,
uint8_t  base = 128 
)
inline

Definition at line 91 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, checklumidiff::l, cmsBatch::log, and alignCSCRings::r.

92  {
93  if(base>128) base=128;
94  const double l = std::log(std::abs(x));
95  const double centered = (l-lmin)/(lmax-lmin)*base;
96  int8_t r=centered;
97  if(centered >= base-1) r=base-1;
98  if(centered < 0) r=0;
99  if(x<0) r = r==0 ? -1 : -r;
100  return r;
101  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.
int8_t logintpack::pack8logCeil ( double  x,
double  lmin,
double  lmax,
uint8_t  base = 128 
)
inline

Definition at line 78 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, checklumidiff::l, cmsBatch::log, and alignCSCRings::r.

79  {
80  if(base>128) base=128;
81  const double l = std::log(std::abs(x));
82  const double centered = (l-lmin)/(lmax-lmin)*base;
83  int8_t r=std::ceil(centered);
84  if(centered >= base-1) r=base-1;
85  if(centered < 0) r=0;
86  if(x<0) r = r==0 ? -1 : -r;
87  return r;
88  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.
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 106 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, checklumidiff::l, cmsBatch::log, and alignCSCRings::r.

107  {
108  if(base>128) base=128;
109  const double l = std::log(std::abs(x));
110  const double centered = (l-lmin)/(lmax-lmin)*(base-1);
111  int8_t r=round(centered);
112  if(centered >= base-1) r=base-1;
113  if(centered < 0) r=0;
114  if(x<0) r = r==0 ? -1 : -r;
115  return r;
116  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.
double logintpack::unpack16log ( int16_t  i,
double  lmin,
double  lmax,
uint16_t  base = 32768 
)
inline

Definition at line 55 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, JetChargeProducer_cfi::exp, checklumidiff::l, and heppy_batch::val.

Referenced by CompressionElement::unpack().

56  {
57  if(base>32768) base=32768;
58  const double basef=base;
59  const double l=lmin+std::abs(i)/basef*(lmax-lmin);
60  const double val=std::exp(l);
61  if(i<0) return -val; else return val;
62  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.
double logintpack::unpack16logClosed ( int16_t  i,
double  lmin,
double  lmax,
uint16_t  base = 32768 
)
inline

reverse of pack8logClosed

Definition at line 65 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, JetChargeProducer_cfi::exp, checklumidiff::l, and heppy_batch::val.

66  {
67  if(base>32768) base=32768;
68  const double basef=base-1;
69  double l=lmin+std::abs(i)/basef*(lmax-lmin);
70  if (std::abs(i) == base-1) l = lmax;
71  const double val=std::exp(l);
72  if(i<0) return -val; else return val;
73  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.
double logintpack::unpack8log ( int8_t  i,
double  lmin,
double  lmax,
uint8_t  base = 128 
)
inline

Definition at line 119 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, JetChargeProducer_cfi::exp, checklumidiff::l, and heppy_batch::val.

120  {
121  if(base>128) base=128;
122  const double basef=base;
123  const double l=lmin+std::abs(i)/basef*(lmax-lmin);
124  const double val=std::exp(l);
125  if(i<0) return -val; else return val;
126  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.
double logintpack::unpack8logClosed ( int8_t  i,
double  lmin,
double  lmax,
uint8_t  base = 128 
)
inline

reverse of pack8logClosed

Definition at line 130 of file liblogintpack.h.

References funct::abs(), runEdmFileComparison::base, JetChargeProducer_cfi::exp, checklumidiff::l, and heppy_batch::val.

131  {
132  if(base>128) base=128;
133  const double basef=base-1;
134  double l=lmin+std::abs(i)/basef*(lmax-lmin);
135  if (std::abs(i) == base-1) l = lmax;
136  const double val=std::exp(l);
137  if(i<0) return -val; else return val;
138  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
base
Make Sure CMSSW is Setup ##.

Variable Documentation

constexpr int8_t logintpack::smallestNegative = -1

Definition at line 12 of file liblogintpack.h.

constexpr int8_t logintpack::smallestPositive = 0

Definition at line 9 of file liblogintpack.h.