#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tdiff(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {252.241, -213.556, 58.3394, -1.99201, -1.77564, 0.306726, -0.0155324}, // layer 1 {-469.968, 362.054, -90.6483, 2.82165, 2.38112, -0.384162, 0.0182787}, // layer 2 {-155.953, 129.828, -34.644, 0.980211, 1.08411, -0.181971, 0.00905403}, // layer 3 {-199.853, 160.144, -39.8656, 0.137643, 1.47673, -0.228978, 0.0109547}, // layer 4 {809.346, -414.548, 6.59404, 19.3379, 0.965198, -1.15876, 0.108721}, // layer 5 {-707.693, 544.759, -126.689, -2.93755, 5.57686, -0.82343, 0.0387892}, // layer 6 {145.691, -72.589, -0.147108, 3.57523, 0.263875, -0.228643, 0.0207137}, // 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]))))); }