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 25 of file liblogintpack.h.

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

Referenced by CompressionElement::pack().

26  {
27  if(base>32768) base=32768;
28  const float delta=(log(1.+exp((lmax-lmin)/base))-log(2.))*base/(lmax-lmin);
29  const double l = std::log(std::abs(x));
30  const double centered = (l-lmin)/(lmax-lmin)*base;
31  int16_t r=std::floor(centered);
32  if(centered-r>delta) r+=1;
33  if(centered >= base-1) r=base-1;
34  if(centered < 0) r=0;
35  if(x<0) r = r==0 ? -1 : -r;
36  return r;
37  }
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 12 of file liblogintpack.h.

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

13  {
14  if(base>32768) 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) r=base-1;
19  if(centered < 0) r=0;
20  if(x<0) r = r==0 ? -1 : -r;
21  return r;
22  }
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 41 of file liblogintpack.h.

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

42  {
43  if(base>32768) base=32768;
44  const double l = std::log(std::abs(x));
45  const double centered = (l-lmin)/(lmax-lmin)*(base-1);
46  int16_t r=round(centered);
47  if(centered >= base-1) r=base-1;
48  if(centered < 0) r=0;
49  if(x<0) r = r==0 ? -1 : -r;
50  return r;
51  }
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 90 of file liblogintpack.h.

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

91  {
92  if(base>128) base=128;
93  const double l = std::log(std::abs(x));
94  const double centered = (l-lmin)/(lmax-lmin)*base;
95  int8_t r=centered;
96  if(centered >= base-1) r=base-1;
97  if(centered < 0) r=0;
98  if(x<0) r = r==0 ? -1 : -r;
99  return r;
100  }
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 77 of file liblogintpack.h.

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

78  {
79  if(base>128) base=128;
80  const double l = std::log(std::abs(x));
81  const double centered = (l-lmin)/(lmax-lmin)*base;
82  int8_t r=std::ceil(centered);
83  if(centered >= base-1) r=base-1;
84  if(centered < 0) r=0;
85  if(x<0) r = r==0 ? -1 : -r;
86  return r;
87  }
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 105 of file liblogintpack.h.

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

Referenced by pat::PackedCandidate::setPuppiWeight().

106  {
107  if(base>128) base=128;
108  const double l = std::log(std::abs(x));
109  const double centered = (l-lmin)/(lmax-lmin)*(base-1);
110  int8_t r=round(centered);
111  if(centered >= base-1) r=base-1;
112  if(centered < 0) r=0;
113  if(x<0) r = r==0 ? -1 : -r;
114  return r;
115  }
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 54 of file liblogintpack.h.

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

Referenced by CompressionElement::unpack().

55  {
56  if(base>32768) base=32768;
57  const double basef=base;
58  const double l=lmin+std::abs(i)/basef*(lmax-lmin);
59  const double val=std::exp(l);
60  if(i<0) return -val; else return val;
61  }
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 64 of file liblogintpack.h.

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

65  {
66  if(base>32768) base=32768;
67  const double basef=base-1;
68  double l=lmin+std::abs(i)/basef*(lmax-lmin);
69  if (std::abs(i) == base-1) l = lmax;
70  const double val=std::exp(l);
71  if(i<0) return -val; else return val;
72  }
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 118 of file liblogintpack.h.

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

119  {
120  if(base>128) base=128;
121  const double basef=base;
122  const double l=lmin+std::abs(i)/basef*(lmax-lmin);
123  const double val=std::exp(l);
124  if(i<0) return -val; else return val;
125  }
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 129 of file liblogintpack.h.

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

Referenced by pat::PackedCandidate::puppiWeight(), and pat::PackedCandidate::puppiWeightNoLep().

130  {
131  if(base>128) base=128;
132  const double basef=base-1;
133  double l=lmin+std::abs(i)/basef*(lmax-lmin);
134  if (std::abs(i) == base-1) l = lmax;
135  const double val=std::exp(l);
136  if(i<0) return -val; else return val;
137  }
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 11 of file liblogintpack.h.

constexpr int8_t logintpack::smallestPositive = 0

Definition at line 8 of file liblogintpack.h.