Unable to draw histogram from a root file

Hi,

I am unable to draw a 2D histrogram which is already inside a root file. I want to open this histrogram for fitting it. The following is my macro :

void Gamma_Constraint_187()
{

// DEFINING CANVAS
TCanvas *c1 = new TCanvas("c1","Without constraint",800,600);

gStyle->SetOptStat(2211);
gStyle->SetOptFit(1111);

//TH2D *h1 = new TH2D("h1_new","176Os_With_Constraint",81.0,49.5,130.5, 101.0, 79.5, 180.5);

TFile *file1=new TFile("RAW187OS_treeFF01.root");
TH2D *h1 = (TH2D*)file1->Get("Mass_TKE_Gamma");
h1->Draw();
}

When I run this I get the following Eroor :

It looks like the histogram Mass_TKE_Gamma is not in that file.
you can try:

file1->ls();

to check.

Yes it works… the problem was with the file name. thank you.

1 Like