Hello,

I have two questions about how to fit histograms:

1.- It is possible to add a function to the fitpanel using "+"
e.g. xy->Fit(“Voigt”,“V+”,“ep”);
However this will start a fit. Is there a way to add a function to the
list without any preliminary fit??

2.- I am writing a gui to fit some data and I do not know in advance
how many peaks will be present in the histogram and hence how many parameters
the fit will need.
A user function is declared like:
double Func_To_Fit::Evaluate(Double_t *x, Double_t *par),
the problem that I have is to get the size of par ??

e.g:
for (Int_t p=0;p<???;p++) {
Double_t norm = par[3p+2];
Double_t mean = par[3
p+3];
Double_t sigma = par[3p+4];
result += norm
TMath::Gaus(x[0],mean,sigma);
}

Bertrand Roessli

Hi,

1. Every function created by the User will appear automatically in the Fit Panel under the type “User Func” or you can create it using the Fit Function input text field.
You don;t need to perform a fit before.

2. You can define a function where the number of gaussian is one of the parameter (for example par[0] ). You should however set this parameter constant before doing the Fit. You can do this by calling TF1::FixParameter

Best Regards

Lorenzo

it works thank you

bertrand roessli