When I run the code, I receive the following error message:
RooFit v3.60 – Developed by Wouter Verkerke and David Kirkby
Copyright (C) 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]
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.
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]