Is it possible to convert a function into a histogram?

Hi,
Using functions in root, I made a gaussian function as below:

{
TF1 *f12 = new TF1(“f12”,“[0]exp(-0.5((x-[1])/[2])**2)”,45,130);
f12->SetFillColor(4);

f12->SetParameter(0,10000);
f12->SetParLimits(0,0,100000);

f12->SetParameter(1, 88);
f12->SetParLimits(1,0,150);

f12->SetParameter(2, 13);
f12->SetParLimits(2,0,20);

f12->Draw(“”);
}

I would like to add 3.5 units resolution for each of the points in the gaussian function. For which I think I need to convert the plotted function into a histogram. Is it possible ?

Create a new empty histogram and then use your function to “fill” it with the help of one of the following:
TH1::Add
TH1::Eval

I am not sure about how to do it. Could you please elaborate on how to convert the function f1 to a histogram ?

I am not sure that’s what you are looking for, but when a function is drawn an underlying histogram is created. May be that’s enough for you ?

{
TF1 *f12 = new TF1("f12","[0]*exp(-0.5*((x-[1])/[2])**2)",45,130);
f12->SetFillColor(4);

f12->SetParameter(0,10000);
f12->SetParLimits(0,0,100000);

f12->SetParameter(1, 88);
f12->SetParLimits(1,0,150);

f12->SetParameter(2, 13);
f12->SetParLimits(2,0,20);

f12->Draw("");
auto h1 = (TH1D*)f12->GetHistogram();
h1->Draw();
}

Yes, thats what I was looking for. Thanks you @couet !