Dear all,

I have long code, but I will post the small portion to make the point. Normally, I create and fill a histogram, then I fit these functions on to the histogram. In the end, I need to read a Y value for a corresponding X value from a fitted gaussian function. I don’t want to use GetBinContent(bin) method to get the result from a histogram, instead.

Note that I made up the numbers to simplify the situation.

If I create a gaussian function on a terminal instead of writing in a macro, I can call Y value for any X value with Eval(). It seems getting he value from a fitted gaussian ruins everything. I used to run it OK before.

TF1 *g1 = new TF1(“g1”,“gaus”, 0, 1024 );

TF1 *pol1 = new TF1(“pol1”,“pol1”, 0, 1024 );

TF1 *total = new TF1(“total”,“gaus(0)+pol1(3)”, 0, 1024);

h1->Fit(g1,“R”);

h1->Fit(pol1,“R+”);

double par[5];

g1->GetParameters(&par[0]);

pol1->GetParameters(&par[3]);

total->SetParameters(par);

h1->Fit(total, “RNQ+”);

double p0 = par[0];

double p1 = par[1];

double p2 = par[2];

double p3 = par[3];

double p4 = par[4];

double e0 = g1->GetParError(0);

double e1 = g1->GetParError(1);

double e2 = g1->GetParError(2);

double e3 = pol1->GetParError(0);

double e4 = pol1->GetParError(1);

g1->Draw(“same”);

cout <<"!!!: 310. channel" << g1->Eval(310.) << " 320. channel " << g1->Eval(320.) <<endl;

This last cout line doesn’t read the Y value from a fitted function.