CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
liblogintpack.h
Go to the documentation of this file.
1 #ifndef liblogintpack_h
2 #define liblogintpack_h
3 
4 #include <cmath>
5 
6 namespace logintpack
7 {
8  int8_t pack8logCeil(double x,double lmin, double lmax, uint8_t base=128)
9  {
10  if(base>128) base=128;
11  float l =log(fabs(x));
12  float centered = (l-lmin)/(lmax-lmin)*base;
13  int8_t r=ceil(centered);
14  if(centered >= base-1) return r=base-1;
15  if(centered < 0) return r=0;
16  if(x<0) r=-r;
17  return r;
18  }
19 
20  int8_t pack8log(double x,double lmin, double lmax, uint8_t base=128)
21  {
22  if(base>128) base=128;
23  float l =log(fabs(x));
24  float centered = (l-lmin)/(lmax-lmin)*base;
25  int8_t r=centered;
26  if(centered >= base-1) return r=base-1;
27  if(centered < 0) return r=0;
28  if(x<0) r=-r;
29  return r;
30  }
31 
32  double unpack8log(int8_t i,double lmin, double lmax, uint8_t base=128)
33  {
34  if(base>128) base=128;
35  float basef=base;
36  float l=lmin+abs(i)/basef*(lmax-lmin);
37  float val=exp(l);
38  if(i<0) return -val; else return val;
39  }
40 }
41 #endif
tuple base
Main Program
Definition: newFWLiteAna.py:92
int i
Definition: DBlmapReader.cc:9
double unpack8log(int8_t i, double lmin, double lmax, uint8_t base=128)
Definition: liblogintpack.h:32
int8_t pack8log(double x, double lmin, double lmax, uint8_t base=128)
Definition: liblogintpack.h:20
int8_t pack8logCeil(double x, double lmin, double lmax, uint8_t base=128)
Definition: liblogintpack.h:8
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: DDAxes.h:10