18 #include "GaudiKernel/StatusCode.h"
19 #include "GaudiKernel/GaudiException.h"
25 const int ONEBILLION = 1000000000;
26 const int HUNDREDMIL = 100000000;
27 enum { NUMP_EXPP, NUMNOTP_EXPP, NUMP_EXPNOTP, NUMNOTP_EXPNOTP };
33 short d_pref = (
short)(binnedWeight/ONEBILLION);
34 int d_rest = (
int)(binnedWeight % ONEBILLION);
35 short d_exp = (
short)(d_rest/HUNDREDMIL);
36 int d_prec = d_rest % HUNDREDMIL;
52 double wt_decode=d_prec*
pow(10,d_exp-NPLACES+1);
55 std::cout <<
"d_pref=" << d_pref << std::endl;
56 std::cout <<
" d_exp=" << d_exp << std::endl;
57 std::cout <<
"d_prec=" << d_prec << std::endl;
58 printf(
"decodd=%.8g \n",wt_decode);
66 int exponent =
int(floor(log10(fabs(
weight)))+1);
67 if ( abs(exponent) > 9 ) {
68 throw GaudiException(
"The MC weight abs value is bigger than 1E9,encoding failed",
"AtlasMcWeight", StatusCode::FAILURE );
74 int e_sign = ( exponent > 0. ? 0 : 1 );
78 snprintf(senc,13,
"%u%u%u",wt_pref, wt_exp, wt_prec);
82 std::cout <<
" AtlasMcWeight::encode weight = " <<
weight << std::endl;
83 printf(
"encode parts =%d %d %d \n", wt_pref, wt_exp, wt_prec);
84 printf(
"encoded string=%s \n", senc);
85 std::cout <<
" weight=" <<
weight << std::endl;
86 std::cout <<
" str weight=" << senc << std::endl;
87 std::cout <<
" exp weight=" << atoll(senc) << std::endl;
88 std::cout <<
" encoded weight=" << wt_encode << std::endl;