According to energy conservation, the energy $E_i$ of scattered electron in event $i$ is:
$E_i = E_b + M_p - E^p_i$
where $E_b$ is the beam energy, $M_p$ is the mass of target proton, $E^p_i$ is the energy of proton detected in the HMS
By comparing $E_i$ with $\Sigma_j C_jA^i_j$
we can build $\chi^2=\Sigma_i(E_i-\Sigma_j C_jA^i_j)^2$
The calibration coefficient $C_j$ can be calculated by minimizing the $\chi^2$:
${\partial\chi^2\over\partial C_k}=-2C_k\Sigma_i(E_i-\Sigma_jC_jA^i_j)A^i_k=0$
which can be witten as:
$\Sigma_iE_iA^i_k=\Sigma_j[\Sigma_iA^i_jA^i_k]C_j$
Then, $C_j$ can be calculated by inverse the matrix $[\Sigma_iA^i_jA^i_k]$ and multiply $\Sigma_iE_iA^i_k$