Hi,
I see you create 2 TF1 objects called `“core3”. The first one results from the convolution, while the second is instead a simple addition.
If you are interested in the convolution, you should use the first one .It looks fine to me at first sight, if it does not work, please post your code reproducing the problem, in order to be able to investigate it
Hi,
no, my first TF1 object has name core3_conv. When I run my program I give many many mistakes Error in <TFormula::Eval>: Formula is invalid and not ready to execute and then:
Hi,
I would need your input file to run.
I see however an error in using the NSUM operator. If you want to add a BreitWigner with a normalized gaussian, you should do as following:
TF1 *core3 = new TF1("core3", "NSUM(TMath::BreitWigner(x,[0],[1]), gausn)", inf, sup);
Note you do not have to use gausn(3) and you need to drop the coefficient parameter that will be added automatically by NSUM.
If instead you want to do a convolution, using the same functions, you do:
TF1 *core3 = new TF1("core3", "CONV(TMath::BreitWigner(x,[0],[1]), gausn)", inf, sup);
I changed NSUM on CONV, but it didn’t solve a problem. Input file is too big, and forum doesn’t allow to download it . File with code, whitch i run, above.
HI,
Did you change in your code above NSUM or CONV as I have suggested you in my previous post ?
If yes and you have an error, please post at least the error and the code creating the TF1 object
Hi,
The problem you cannot use core3 as a formula function and use its name as input in a subsequent formula. So if you are doing this:
TF1 *total3 = new TF1("tot3","core3*0.001 + bg3", inf, sup);
and core3 is defined as above, it is not allowed !
What you can do is using a lambda:
TF1 *core3 = new TF1("core3", /*core3_conv*/"CONV([0]*TMath::BreitWigner(x,[1],[2]), gausn)");
TF1 *bg3 = new TF1("bg3","pol1", inf, sup);
int npar3 = core3->GetNpar();
// note when defining a lambda for a TF1 , one needs to use [=] , i.e. capture by value
TF1 *total3 = new TF1("tot3",[=](double*x, double *p){ return core3->EvalPar(x,p)*0.001+bg3->EvalPar(x,p+npar3);}, inf, sup, npar3+bg3->GetNpar());
Hi,
It looks like you get some Nan values in fitting. Either the function is ill defined or the parameters get some un-physical values, where the function return NaN.
Can you please share your latest script and the input files needed to run, so I can understand the problem ?
Cheers
root [0]
Processing script.C...
In file included from input_line_9:1:
/Users/couet/Downloads/script.C:1:10: fatal error: 'fun.h' file not found
#include "fun.h"
^~~~~~~