#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tdiff(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {-837.336, 936.829, -429.221, 103.03, -13.6685, 0.950893, -0.0271269}, // layer 1 {-4.3606, -7.01957, 3.65522, -0.294543, -0.0844843, 0.0157111, -0.00072943}, // layer 2 {-365.355, 288.5, -67.8631, -1.82996, 3.08784, -0.451461, 0.0210304}, // layer 3 {243.577, -151.754, 7.53071, 7.98019, 0.178117, -0.535643, 0.0571827}, // 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]))))); }