#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tdiff(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {-1203.93, 1289.24, -565.586, 130.172, -16.5902, 1.11108, -0.0305763}, // layer 1 {1351.39, -1165.02, 300.597, 4.71097, -14.2415, 2.23867, -0.110404}, // layer 2 {126.923, -65.3371, 0.440411, 3.10544, 0.198477, -0.193724, 0.0181466}, // layer 3 {-2143.04, 1217.81, -26.6048, -67.9735, -3.70158, 4.99012, -0.516172}, // 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]))))); }