# Double erf fit

Hi all,
I have to fit an histogram with the sum of two gaussian cumulative functions:

``````Double_t doubleerf( Double_t *x, Double_t *par ) {
Double_t val1, val2;

val1 = x-par;
val1 /= TMath::Sqrt(2.);
if (par != 0) {
val1 /= par;
}

val2 = x-par;
val2 /= TMath::Sqrt(2.);
if (par != 0) {
val2 /= par;
}

return 1./2.*(1.+TMath::Erf(val1))+1./2.*(1.+TMath::Erf(val2));
}``````

The fit works fine (see attached ps file).
The problem is the ‘order’ of the parameters: I have 2 means (par & par) and two
sigmas (par & par) and I would like that par < par. In this way I could plot a
meaningful distribution of the par and par.
For the moment the workaround is to check if par < par and then fill the histograms
properly (means1 & means2).
But I would like to know if there is a way to force the fit to always have par < par.

Currently we have no way with TH1::Fit to specify constraints between parameters, although I have somebody in mind (: who promised to implement this functionality in TMinuit.