Hello, I fit histogram and want to print result values on TCanvas.
Fit:
TFitResultPtr res_fit_mD = mass_D->Fit(f_total, "RSNQ");
Draw:
make_grid(his_Dp[i]);
DrwFun(list_fun[i]);
where:
void make_grid(TH1* his){
gStyle->SetOptStat(10);
gStyle->SetOptFit(112);
gPad->SetGrid();
his->SetMinimum(0);
}
void DrwFun(vector<TF1*> list_of_function){
list_of_function.at(0)->SetLineColor(kRed);
list_of_function.at(1)->SetLineColor(kGreen+2);
list_of_function.at(2)->SetLineColor(kGray+2);
list_of_function.at(0)->Draw("same");
list_of_function.at(1)->Draw("same");
list_of_function.at(2)->Draw("same");
}
Result:
I don’t see the result values of fit under “Entries 906198”. How to do this?
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.26/06
Platform: Ubuntu
Compiler: Not Provided
@couet can hep you with that
couet
February 28, 2023, 9:04am
3
What do you see when you use the default setting:
gStyle->SetOptFit(1);
?
couet
February 28, 2023, 9:11am
4
With this simple example it is fine:
{
auto h1 = new TH1F("h1","h1",200,-10,10);
for (int i=0;i<=10000;i++) h1->Fill(gRandom->Gaus(0,1));
gStyle -> SetOptFit(112);
h1->Fit("gaus");
}
couet
February 28, 2023, 9:13am
6
So, can you provide a reproducer we ca run ?
As you see the simple example I posted is working.
There must be something special in your case.
When I delete N
option from TFitResultPtr res_fit_mD = mass_D->Fit(f_total, "RSNQ");
root build two histograms:
I think the problem connect N
option in Fit()
. I make this option because I don’t wont to print first auto Draw.
I can give you all code (it’s big) and data. Next message.
Sorry, file with data too big. Code files. build_his.C is main.
build_his.C (14.7 KB)
Data_D0.C (1.4 KB)
Data_D0.h (5.7 KB)
Data_Dp.C (1.4 KB)
Data_Dp.h (6.7 KB)
couet
February 28, 2023, 9:27am
10
I cannot run your macro. I get: DTag_4180.root does not exist
May be try 0
instead of N
.
File “DTag_4180.root” more 3 MB. How can I upload it?
Yes, then I change 0 for N the problem is disappear. But new problem is born. The window with parameters is too small.
couet
February 28, 2023, 10:06am
15
It looks like you are fixing the box size somewhere . When it is fixed by the user it uses
that size. The automatic size occurs only if you let it free.
What if I don’t do it anywhere? This box size is created when I enter gStyle->SetOptStat(10);
. And after size the box size is saved?
If I swap gStyle->SetOptFit(1);
and gStyle->SetOptStat(10);
then I get this
system
Closed
March 14, 2023, 10:33am
18
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.