Fitting a histogram

I am having trouble fitting a histogram with a user-defined function.
I declare a TF1 like this and try to fit it:

TF1 f2("pdf", "280*0.1091196*((x+0.511)*(x+0.511))*((2.4578+0.511-x)*(2.4578+0.511-x)), 0, 2.4578); energyhist->Fit("pdf");

I get this error:

Isn’t x the parameter?

The message is correct. You should define a function with at least one parameter. See examples in tutorials/fit


I looked at the example here:

I am somewhat confused as to the difference between x and par. How would I write my function in this example?

Please disregard, I found my mistake.