We made following measurements: at different y_i we measured countrate z_ij at different x_j (x_j are different for each y_i). There are errors for z_ij and y_i.
So, as a result there is TGraph2DErrors object. Each distribution of z via x at concrete y_i is a Gaussian signal with linear background.
We can easily make 1D fit of each that distribution at every y_i (gaus+pol1). After that we draw a distribution of X_c (gaus center) via y and fit it by linear function and extract the slope.
We want to make two consequent fit together. We think that for each y_i (i>=0) the function should look like this:
bg = par[4i+2] + par[4i+3]x[0];
sig = par[4i+4]TMath::Exp(-(x[0]-par[0]-par[1]x[1])(x[0]-par[0]-par[1]x[1])/(2par[4i+5]par[4i+5]));
par[1] should be extracted as a slope.
But how to build this function? The main criterium is to match this global function at points y_i to 1D gaus+pol1.
Or, maybe I can work directly with ChiSquared (TMinuit or TFumili)? But there I should provide a function again.
Any suggestions or questions are welcome!