"auto" does not name a type in RooFit

Dear Experts,

I am trying to do a RooFit incorporating a particular style for the output. Here’s the macro and the root file:ksks_fit_belle2_style.C (6.7 KB) forfit_mc13b_proc11_large.root (15.0 KB)

When I run the code, I receive the following error message:

RooFit v3.60 – Developed by Wouter Verkerke and David Kirkby
Copyright © 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt

In file included from /home/lenovo/Desktop/PhD/analysis/D0_Ks_Ks/ICHEP_2020/learning_to_fit/ksks_fit_belle2_style_C_ACLiC_dict.h:34:0,
from /home/lenovo/Desktop/PhD/analysis/D0_Ks_Ks/ICHEP_2020/learning_to_fit/ksks_fit_belle2_style_C_ACLiC_dict.cxx:17:
/home/lenovo/Desktop/PhD/analysis/D0_Ks_Ks/ICHEP_2020/learning_to_fit/./ksks_fit_belle2_style.C: In function ‘void ksks_fit_belle2_style()’:
/home/lenovo/Desktop/PhD/analysis/D0_Ks_Ks/ICHEP_2020/learning_to_fit/./ksks_fit_belle2_style.C:202:8: error: ‘logo’ does not name a type
auto logo = new TLatex();
^
/home/lenovo/Desktop/PhD/analysis/D0_Ks_Ks/ICHEP_2020/learning_to_fit/./ksks_fit_belle2_style.C:203:3: error: ‘logo’ was not declared in this scope
logo->SetNDC();
^
/home/lenovo/Desktop/PhD/analysis/D0_Ks_Ks/ICHEP_2020/learning_to_fit/./ksks_fit_belle2_style.C:212:8: error: ‘leg’ does not name a type
auto leg = new TLegend(0.57,0.73,0.78,0.93);
^
/home/lenovo/Desktop/PhD/analysis/D0_Ks_Ks/ICHEP_2020/learning_to_fit/./ksks_fit_belle2_style.C:213:3: error: ‘leg’ was not declared in this scope
leg->SetFillStyle(0);
^
g++: error: /home/lenovo/Desktop/PhD/analysis/D0_Ks_Ks/ICHEP_2020/learning_to_fit/ksks_fit_belle2_style_C_ACLiC_dict.o: No such file or directory
Error in : Compilation failed!
Error: Function ksks_fit_belle2_style() is not defined in current scope :0:
*** Interpreter error recovered ***
root [1]

Would you please help??

Regards,
Sanjeeda

The myRooPolBG.cpp file is missing to be able to run your macro, and those lines:

  leg->AddEntry(pdf,"Data","pe");
  leg->AddEntry(sig,"Fit","l");
  leg->AddEntry(bkg,"Background","l");

Should be:

  leg->AddEntry(&pdf,"Data","pe");
  leg->AddEntry(&sig,"Fit","l");
  leg->AddEntry(&bkg,"Background","l");

Thank you for your message. The code works when I replaced the line auto logo = new TLatex(); by
*TLatex logo = new TLatex(); and

and auto leg = new TLegend(0.57,0.73,0.78,0.93); by
*TLegend leg = new TLegend(0.57,0.73,0.78,0.93);

Sure, but auto should work as well… Which ROOT version? on which platform? with which compiler?

RooFit 3.60 and root ROOT 5.34/38 and compiler is g++. Yes auto works when I dont use RooFit. I was using it here:fit_mc.C (3.4 KB)

Oh, OK, ROOT 5… :wink:

My plot now looks like:Screenshot from 2020-07-09 17-22-28

as you can see I have not been able to get the correct entries in the legend and I am now using this macro ksks_fit_belle2_style.C (7.1 KB)

Can you plese help?. There are no error messages or warnings

When i run this macro I get:

ksks_fit_belle2_style.C:40:10: fatal error: 'myRooPolBG.cpp' file not found

oops!! I am sorry, here re the missing files

myRooPolBG.cpp (1.8 KB) myRooPolBG.h (929 Bytes)

Error in <TFile::TFile>: file forfit_proc11_bucket9to12_bcs.root does not exist

I had attached it in the question. Is it not working??

you attached forfit_mc13b_proc11_large.root
and it is looking for forfit_proc11_bucket9to12_bcs.root is it the same file ?

okay I’m sorry, just noticed it.
Here 's file forfit_proc11_bucket9to12_bcs.root (12.5 KB) . However, it doesn’t matter if one uses the previous file as the structure is the same.

  leg->AddEntry("h_data","Data","pe");
  leg->AddEntry("pdf_Norm[deltaM_after_bcs]","Fit","l");
  leg->AddEntry("pdf_Norm[deltaM_after_bcs]_Comp[bkg]","Background","l");

1 Like

Dear @couet, Thank you very very much, I had been struggling with it for hours. :smiley: :smiley:

Let me explain what I did. The objects you are trying to put in the TLegend are produced by RootFit and their names are defined by Roofit. May be there is a clever to find these names automatically but to make it simpler, I just did a gPad->ls() after executing the macro to see what are the real names of these objects:

root [1] gPad->ls()
Canvas Name=c1 Title= Option=
 TCanvas fXlowNDC=0 fYlowNDC=0 fWNDC=1 fHNDC=1 Name= c1 Title=  Option=
  OBJ: TList	TList	Doubly linked list : 0
   TFrame  X1= 0.139000 Y1=0.000000 X2=0.159000 Y2=68.873708
   OBJ: TH1D	frame_7fb7abcf7d90	A RooPlot of "#it{#Deltam}" : 0 at: 0x7fb7abcf62e0
   OBJ: RooHist	h_data	Histogram of data_plot__deltaM_after_bcs : 0 at: 0x7fb7b8706ef0
   OBJ: RooCurve	pdf_Norm[deltaM_after_bcs]	Projection of two component model : 0 at: 0x7fb7b870f060
   OBJ: RooCurve	pdf_Norm[deltaM_after_bcs]_Comp[bkg]	Projection of two component model : 0 at: 0x7fb7b870fe80
   OBJ: TH1D	frame_7fb7abcf7d90	A RooPlot of "#it{#Deltam}" : 0 at: 0x7fb7abcf62e0
   OBJ: TLegend	TPave  	X1= 0.150750 Y1=54.238045 X2=0.156000 Y2=71.456472
root [2] 

1 Like

That’s nice, I was actually wondering where you got those names form…but as it was very urgent for me, I used it and I saw this comment only now.

Thanks a lot:D

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