How to fit the data by integral function

Hi,

I could nor reproduce the error you have, however as I mentioned before the definition of your fit function is wrong.

I have updated it from the formula you sent to me. I am not sure it is 100% correct, please verify it. The fit converges now to some result.

The new macro with many other corrections (like I remove the usage of global variables x) is attached.

Lorenzo
bwfit02_3.C (11.6 KB)

Hi,

Thank you for your message and your code runs in my ROOT system. I don’t know why the your previous code does not run in my ROOT package.

I am not mature about ROOT, yet. So, I have a question about the compilation of ROOT. I often write the ROOT macro and run it, but I don’t understand why I have to compile the code and run it in this case.

In other word, can I write the ROOT macro for this integral calculation and the fitting without the compilation (alternative way)?

Anyway, thank you so much.

Hi Nobu,

sorry for my late reply on your posting - I just forgot to press the “submit” button :slight_smile:

[quote=“Nobu”]I could compile this, but would you tell me how to use it after compiling?
I see “bwfit02_2_C.so” file.
What is “bwfit02_2_C.d” file?[/quote]The .d file contains information for ACLiC when it’s needed to rebuild the file. Only then will a subsequent “.L bwfit02_2.C+” actually call the compiler and linker - otherwise it will just load the file.

You can simply call its functions after the .L …+, just like for the .L without the “+”.

[quote=“Nobu”]In addition,

just to clarify: it MUST NOT BE USED in a named macro!
What does it mean? Would you explain about it to use the example?[/quote]As I said in the sentence following this one the rule is very simple: as soon as your code has one single function you must not use gROOT->Reset().

[quote=“Nobu”]In other word, can I write the ROOT macro for this integral calculation and the fitting without the compilation (alternative way)?[/quote]You can try, but it’s much more reliable and also faster when it comes to execution to use the “.L …+”, i.e. to compile it. So the rule of thumb is: for simple cases use CINT to interpret it; if it’s complex or performance matters or you get errors that you don’t understand then compile the code using “.L …+”

OK. Submit.

Cheers, Axel.

Hi thank you all,

I am sorry to reply to you. I have another question about these integral function call. I could compile the previous code and run it.

But it has the fixed integral constant or the fixed normalization constant (con) and con ~= 1000. Now, I want to vary the constant and fit it. So, I changed the constant con to the fitting parameter par[3] for that purpose. The code is attached with this message.

Line 142: out = par[3] * x[0] * mt …
instead of out = con * x[0] * mt …
and
Line 134: Double_t mt = par[4];
instead of Double_t mt = par[3];

Line 161: std::copy(p, p + 4, param);
Line 162: param[4] = *x;

Line 168: double param[5];

So, I added one extra parameter par[3] = con and par[4] = mt.
I can compile this code and run it.

The questions are that

  1. What does Line 161 mean? copy parameters?

  2. How about Line 168? I need only par[0] ~ par[4], five parameters.
    But what does param[5] mean?

Thank you!
bwfitpiplus02.C (7.63 KB)

Hi,

your fitting function is f(x,p) = Integral( g(t,q(x,p))dt )

where q, the parameters of the integrand function g are related to p, the parameters of the fitting function f as:

q[0:3] = p[0:3]
q[4] = x

You need therefore to copy the parameters p and x of f(x,p) in q (x,p).
This explains the lines 161 and 162.

The line :

It declares the array as a data member of MyIntegFunc.
If you need param[0] to param[4] you need to declare somewhere a param[5].

Best Regards

Lorenzo

Hi,

Thank you for your nice explanation and I understood it.

I have a question about the radius variable.

I attached the code which I modified a little about
Double_t radius = 13.0;

Line 159: Double_t radius = 13.0;

Line 178: Double_t radius = 13.0;

I changed from radius = 13.0 to radius = 5.0 in struct MyIntegFunc (Line 159), then the fitting parameters are changed.

I wrote the code Double_t radius = 13.0 in Line 178 and integral from 0.0 to radius+2.0 (skin thickness, 2.0 fm, so total 15.0 fm).
The integral fitting should not affect Line 159: radius = 5.0 since the real calculation depends on the TF1 *functions in the fitexample() code.

I thought the Line 159: Double_t radius = …; is just dummy variable.
Is it wrong?

I want to integral just from 0.0 to 13.0 + skin thickness (~= 2.0 fm)
Would you explain what is going on this code for me?
Thank you so much for your help!
/Nobu/
bwfitpiplus02.C (7.63 KB)

Hi,

the integral limits depend on what you put as argument in the TF1::Integral method. It is called at the line 162, and the integration is done between 0 and the value of radius, which is defined at line 159.

	return fFunc->Integral(0.0, radius, param);

At the line 180,

	TF1 *funcx = new TF1("funcx", bwfitfunc, 0.0, radius+2.0, 5);

the function is created. There are passed as arguments the plotting range values (xmin = 0, xmax = radius+2.). These values have nothing to do with the integration limits.

Regards

Lorenzo

Hi,

Thank you for the explanation about the integral limits.
You say “the plotting range values”. What does it mean?

I appreciate your reply.
/Nobu/

When you plot the function (using TF1::Draw() ), it is shown in the axis range
[xmin,xmax]. These values are given when constructing the TF1 object.
See also the TF1 doc:

root.cern.ch/root/htmldoc/TF1.html

Hi,

Thank you so much for your lots of reply and the answer!
I really appreciate that.
/Nobu/

Hello,

I have started learning ROOT and using blast wave fit for my work. I wanted to know whether there is any way in which we can properly set the parameter limits? Or we have to do that by trial and error seeing the chi-square/ndf value?
Thanks!
Sinjini

Could you please post a new topic, instead of resurrecting a 9 year old topic?

In there, could you show the code you use? In general you can leave the parameter limits unset - but I don’t know the “blast wave fit”.