#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_TimeWalkUp(double fADC, int layer) { double tw_par[NLAYERS_BCAL][4] ={ {36.4999, 4.25184, 0.247931, -1.92186}, // layer 1 {37.5069, 8.05775, 0.388135, -2.93428}, // layer 2 {39.0135, 15.852, 0.639154, -7.53701}, // layer 3 {40.225, 526.055, 1.50624, -126.235}, // layer 4 {41.4518, 5.799e+07, 4.55306, 6.51533e+06}, // layer 5 {22.2594, 1.5223e+07, 2.29933, 757401}, // layer 6 {35.2718, 88056.2, 1.75815, 12361.6}, // layer 7 {43.0896, -3.59366e+09, 5.09932, 7.82194e+08}, // layer 8 {35.8256, 2.25355e+09, 6.45882, -8.1414e+09}, // layer 9 {39.4482, 64165.4, 0.190807, -1.67214e+06} // layer 10 }; layer = layer<1 ? 1:layer>NLAYERS_BCAL ? NLAYERS_BCAL:layer; double *p = tw_par[layer-1]; return p[0]+p[1]/(pow(fADC,p[2])+p[3]); } double BCAL_TimeWalkDn(double fADC, int layer) { double tw_par[NLAYERS_BCAL][4] ={ {16.889, 0.428371, 0.0570095, -1.18269}, // layer 1 {16.7379, 0.381006, 0.0484299, -1.14446}, // layer 2 {16.5039, 0.385776, 0.0456332, -1.13238}, // layer 3 {16.6521, 0.483155, 0.0629947, -1.20333}, // layer 4 {17.0844, 0.980027, 0.124159, -1.45963}, // layer 5 {17.7297, 16.1552, 0.525494, -4.86558}, // layer 6 {18.1123, 22.1669, 0.605974, -6.47314}, // layer 7 {17.7781, 22.5382, 0.583122, -5.96305}, // layer 8 {17.9126, 9.92269, 0.463774, -4.42761}, // layer 9 {17.8541, 11.1338, 0.465893, -4.4777} // layer 10 }; layer = layer<1 ? 1:layer>NLAYERS_BCAL ? NLAYERS_BCAL:layer; double *p = tw_par[layer-1]; return p[0]+p[1]/(pow(fADC,p[2])+p[3]); }