change to S1sTol[0] and add fit function for gain analysis