# Unable to draw histogram from a root file

**URL:** <https://root-forum.cern.ch/t/unable-to-draw-histogram-from-a-root-file/52687>\
**Category:** Newbie\
**Tags:** tree, hist, root\
**Created:** [December 7, 2022, 4:25pm UTC](https://root-forum.cern.ch/t/unable-to-draw-histogram-from-a-root-file/52687 "2022-12-07T16:25:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gini](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gini/32/29467_2.png) [@gini](https://root-forum.cern.ch/u/gini)\
**Post date:** [December 7, 2022, 4:25pm UTC](https://root-forum.cern.ch/t/unable-to-draw-histogram-from-a-root-file/52687/1 "2022-12-07T16:25:23Z")

</div>

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 :

```auto
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 :

 ![Err](https://root-forum.cern.ch/uploads/default/original/3X/c/4/c40af763261db2ea492d1a92a447869f9ff9c3a8.png)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [December 7, 2022, 4:28pm UTC](https://root-forum.cern.ch/t/unable-to-draw-histogram-from-a-root-file/52687/2 "2022-12-07T16:28:39Z")

</div>

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

```auto
file1->ls();

```

to check.

---

<div class="post-metadata">

**Author:** ![gini](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gini/32/29467_2.png) [@gini](https://root-forum.cern.ch/u/gini)\
**Post date:** [December 7, 2022, 4:30pm UTC](https://root-forum.cern.ch/t/unable-to-draw-histogram-from-a-root-file/52687/3 "2022-12-07T16:30:39Z")

</div>

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