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]