Print fit result on TCanvas

Hello, I fit histogram and want to print result values on TCanvas.


TFitResultPtr res_fit_mD = mass_D->Fit(f_total, "RSNQ");




void make_grid(TH1* his){

void DrwFun(vector<TF1*> list_of_function){>SetLineColor(kRed);>SetLineColor(kGreen+2);>SetLineColor(kGray+2);>Draw("same");>Draw("same");>Draw("same");


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

What do you see when you use the default setting:



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);

No changes

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)

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, try …

what about option 0 ?

Yes, then I change 0 for N the problem is disappear. But new problem is born. The window with parameters is too small.

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

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