Hello ROOTers,
I have the root file which is attached with x1_x2.root.
I am trying TLegend as
leg = new TLegend(0.1,0.7,0.48,0.9);
leg->AddEntry(h2,"x1 ",“l”);
leg->AddEntry(h1,“x2”,“l”);
leg->Draw();
but I am not getting results as I want.
Can anybody suggest me where I am wrong?
Thanks in Advance,
Summit.
x1_x2.root (73.9 KB)
brun
2
see code below
Rene
void x1x2() {
TFile *f = TFile::Open("x1_x2.root");
TCanvas *c1 = (TCanvas*)f->Get("c1");
c1->Draw();
TH1 *h1 = (TH1*)c1->GetPrimitive("h1");
TH1 *h2 = (TH1*)c1->GetPrimitive("h2");
TLegend *leg = new TLegend(0.1,0.7,0.48,0.9);
leg->AddEntry(h2,"x1 ","l");
leg->AddEntry(h1,"x2","l");
leg->Draw();
}