CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
logintpack Namespace Reference

Functions

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 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

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

Definition at line 25 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, cmsLHEtoEOSManager::l, dqm-mbProfile::log, and alignCSCRings::r.

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

26  {
27  if(base>128) base=128;
28  const double l = std::log(std::abs(x));
29  const double centered = (l-lmin)/(lmax-lmin)*base;
30  int8_t r=centered;
31  if(centered >= base-1) r=base-1;
32  if(centered < 0) r=0;
33  if(x<0) r = r==0 ? -1 : -r;
34  return r;
35  }
tuple base
Main Program
Definition: newFWLiteAna.py:91
T x() const
Cartesian x coordinate.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int8_t logintpack::pack8logCeil ( double  x,
double  lmin,
double  lmax,
uint8_t  base = 128 
)

Definition at line 13 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, cmsLHEtoEOSManager::l, dqm-mbProfile::log, and alignCSCRings::r.

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

14  {
15  if(base>128) base=128;
16  const double l = std::log(std::abs(x));
17  const double centered = (l-lmin)/(lmax-lmin)*base;
18  int8_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  }
tuple base
Main Program
Definition: newFWLiteAna.py:91
T x() const
Cartesian x coordinate.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int8_t logintpack::pack8logClosed ( double  x,
double  lmin,
double  lmax,
uint8_t  base = 128 
)

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

References funct::abs(), newFWLiteAna::base, cmsLHEtoEOSManager::l, dqm-mbProfile::log, and alignCSCRings::r.

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

40  {
41  if(base>128) base=128;
42  const double l = std::log(std::abs(x));
43  const double centered = (l-lmin)/(lmax-lmin)*(base-1);
44  int8_t r=round(centered);
45  if(centered >= base-1) r=base-1;
46  if(centered < 0) r=0;
47  if(x<0) r = r==0 ? -1 : -r;
48  return r;
49  }
tuple base
Main Program
Definition: newFWLiteAna.py:91
T x() const
Cartesian x coordinate.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double logintpack::unpack8log ( int8_t  i,
double  lmin,
double  lmax,
uint8_t  base = 128 
)

Definition at line 52 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, create_public_lumi_plots::exp, and cmsLHEtoEOSManager::l.

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

53  {
54  if(base>128) base=128;
55  const double basef=base;
56  const double l=lmin+std::abs(i)/basef*(lmax-lmin);
57  const double val=std::exp(l);
58  if(i<0) return -val; else return val;
59  }
tuple base
Main Program
Definition: newFWLiteAna.py:91
int i
Definition: DBlmapReader.cc:9
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double logintpack::unpack8logClosed ( int8_t  i,
double  lmin,
double  lmax,
uint8_t  base = 128 
)

reverse of pack8logClosed

Definition at line 62 of file liblogintpack.h.

References funct::abs(), newFWLiteAna::base, create_public_lumi_plots::exp, and cmsLHEtoEOSManager::l.

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

63  {
64  if(base>128) base=128;
65  const double basef=base-1;
66  double l=lmin+std::abs(i)/basef*(lmax-lmin);
67  if (std::abs(i) == base-1) l = lmax;
68  const double val=std::exp(l);
69  if(i<0) return -val; else return val;
70  }
tuple base
Main Program
Definition: newFWLiteAna.py:91
int i
Definition: DBlmapReader.cc:9
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

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.