Histogram bin content in the user defined fitting function

Hello all,

I am trying to write a user defined fitting function like Double_t Func(doublex, doublep), here for one of the parameter p[0], I need to fix the parameter from a histogram for given time (x) with histogram bin content. Is there is any way to include bincontent to the fitting parameter depending upon x? Thank you so much.

ROOT Version: 6.22/02
Platform: Unix
Compiler: gcc 9.2.0

I’m not sure I understand the question… Maybe @moneta can give you some information


I am not sure I have well understood the problem. A parameter p[] should be a free parameter of your function and you should not set or fix to something else within the user provided function.

You can pass other parameters to the function, for example , histogram bin contents, using several tricks, for example using a global defined histogram or use a lambda function which captures a reference to the histogram


Hi Moneta,

Sorry, I mean, to pass other parameters to the function as you mention. I wrote some vague lines in my earlier post. Especially, I need to send histogram bin content. Can I find any example related to this in the root? It will be more helpful for me.

Thank you,


An example where the histogram is defined as a global object is here:


1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.