A utility to perform a linear fit without ROOT
During testing of OT-2S-service hybrids, a calibration of the lpGBT's ADC is performed via an external DAC. In order to perform a kind of automated evaluation a fit or chi^2 test was proposed. A natural choice would be using the ROOT toolkit, especially considering the fact that this test is not to be performed inside the detector.
However, I started working on a utility for this purpose (somewhat as a personal exercise). It is now able to perform a linear fit from two vectors (option to include a y-error vector) of the same datatype and also provides the errors on the parameters. The math is based on https://pages.mtu.edu/~fmorriso/cm3215/UncertaintySlopeInterceptOfLeastSquaresFit.pdf and gives the same result as ROOT does.
You can find the code here:
an example use here:
Stuff to potentially add in the future depending on the needs: Different data types for std::vector<T> datasetX, std::vector<T> datasetY, and std::vector<T> datasetYerrors
include calculation of chi^2 and NDF, use of x-errors ...