#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tdiff(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {-86.4162, 69.3821, -18.3512, 1.07928, 0.308769, -0.0537258, 0.00247848}, // layer 1 {-500.135, 549.577, -248.069, 58.8461, -7.73426, 0.534002, -0.0151361}, // layer 2 {-182.66, 137.445, -31.9108, 0.0359604, 1.04127, -0.148554, 0.00653135}, // layer 3 {-1179.08, 938.408, -218.305, -11.3776, 12.4656, -1.8791, 0.0926652}, // layer 4 {0, 0, 0, 0, 0, 0, 0}, // layer 5 {0, 0, 0, 0, 0, 0, 0}, // layer 6 {0, 0, 0, 0, 0, 0, 0}, // layer 7 {0, 0, 0, 0, 0, 0, 0}, // layer 8 {0, 0, 0, 0, 0, 0, 0}, // layer 9 {0, 0, 0, 0, 0, 0, 0} // layer 10 }; layer = layer<1 ? 1:layer>NLAYERS_BCAL ? NLAYERS_BCAL:layer; double *p = tw_par[layer-1]; double x = log(geometric_mean); return p[0]+x*(p[1]+x*(p[2]+x*(p[3]+x*(p[4]+x*(p[5]+x*p[6]))))); }