#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tdiff(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {-1.95554, -16.6392, 8.69029, -1.01706, -0.132453, 0.0341, -0.00181484}, // layer 1 {787.024, -876.486, 400.552, -96.0572, 12.7504, -0.888752, 0.0254369}, // layer 2 {-14.9728, 6.79441, -0.341158, -0.153762, 0.00173204, 0.00411765, -0.000306681}, // layer 3 {3722.22, -4127.48, 1877.9, -449.199, 59.641, -4.17114, 0.120145}, // 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]))))); }