Drawing a TF2 integral over one variable as a function of the other

Hello,
I have a function returning me a particle flux as a function of time and energy f(t, E) and I need to procude two plots:

  • fluence, i.e. the time-integrated flux as a function of the energy;
  • the time distribution, i.e. the energy-integrated flux as a function of time.

Is there a logical and simple way to do it using the automatic drawing features of TF1, TF2 etc.?

Here are my considerations:
(1) I “wrapped” my function with a TF2 object and I can make an XY graph where I plot the result of TF2::Integral() over the full range in a variable and a set N of small intervals covering the whole range in the other variable (plotting one point per interval). Should work fine but it’s not “immediate” as I hoped.
(2) I have tried to use TF12 but it does not make it any simpler: I still need to select a “slice” and integrate over the remaining variable and then plot the results of each integral as a function of the first variable. Basically I am adding an additional layer without gaining anything in simplicity.
(3) I could still define a new function which selects a slice in a TF12 object and takes the integral over the remaining variable, then wrap the function with a TF1 object use TF1::Draw, but is it worth to define a new function and two additional objects instead of going “manual” as in (1)?

Am I missing any member function that I could use to make my life simpler?

Please be also aware that I am making this example for one function f(t, E) but actually I will have four of them that I need to draw in the same pad and which I have already in the form of a TF2 vector.

Thank you in advance!

1 Like