# How to extract a histogram and draw out the histogram from a root file and then divide two histograms?

**URL:** <https://root-forum.cern.ch/t/how-to-extract-a-histogram-and-draw-out-the-histogram-from-a-root-file-and-then-divide-two-histograms/45719>\
**Category:** Newbie\
**Tags:** tree, hist, root\
**Created:** [July 6, 2021, 9:04pm UTC](https://root-forum.cern.ch/t/how-to-extract-a-histogram-and-draw-out-the-histogram-from-a-root-file-and-then-divide-two-histograms/45719 "2021-07-06T21:04:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abaraj48](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@Abaraj48](https://root-forum.cern.ch/u/Abaraj48)\
**Post date:** [July 6, 2021, 9:04pm UTC](https://root-forum.cern.ch/t/how-to-extract-a-histogram-and-draw-out-the-histogram-from-a-root-file-and-then-divide-two-histograms/45719/1 "2021-07-06T21:04:37Z")

</div>

So I have a root file with the path Users/andrewbarajas/output\_IdId\_Mc16a.root and with in this root file I have a TH1D histogram and I need to be able ti draw out a histogram from that root file. The histogram is TH1D wElEta

I tried this but got an error

```auto
TFile *f = new TFile("/Users/andrewbarajas/output_IdId_Mc16a.root");
root [1] TH1D *h = (TH1D*)f->Get("wElEta");
root [2] h->Draw();

```

Error in : Trying to dereference null pointer or trying to call routine taking non-null arguments.  
Execution of your code was aborted.  
ROOT\_prompt\_2:1:1: warning: null passed to a callee that requires a non-null argument [-Wnonnull]  
h-\>Draw();

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 7, 2021, 6:09am UTC](https://root-forum.cern.ch/t/how-to-extract-a-histogram-and-draw-out-the-histogram-from-a-root-file-and-then-divide-two-histograms/45719/2 "2021-07-07T06:09:57Z")

</div>

Try to run: `rootls -l /Users/andrewbarajas/output_IdId_Mc16a.root`
