#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tdiff(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {-42.091, 22.6633, -1.16054, -0.784213, -0.00299602, 0.0330077, -0.00290217}, // layer 1 {-96.5425, 63.857, -13.0189, 0.152476, 0.266558, -0.0321849, 0.00115725}, // layer 2 {53.315, -41.8008, 11.2752, -0.777142, -0.163096, 0.0306444, -0.00144429}, // layer 3 {2891.89, -3179.12, 1432.47, -338.968, 44.4712, -3.06978, 0.0871732}, // 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]))))); }