# Empty histogram but shows entries

**URL:** <https://root-forum.cern.ch/t/empty-histogram-but-shows-entries/46159>\
**Category:** Newbie\
**Created:** [August 4, 2021, 1:20am UTC](https://root-forum.cern.ch/t/empty-histogram-but-shows-entries/46159 "2021-08-04T01:20:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheScientist](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/82dd89/32.png) [@TheScientist](https://root-forum.cern.ch/u/TheScientist)\
**Post date:** [August 4, 2021, 1:20am UTC](https://root-forum.cern.ch/t/empty-histogram-but-shows-entries/46159/1 "2021-08-04T01:20:02Z")

</div>

I am trying to read the data from the ROOT file, store that data in the vector and fill the histogram. However, my histogram is showing empty but the entry number is as I expected for that specific particle. Here’s my code:

```auto
void KEhist()
{
        TFile* file1 = new TFile("TargetVStudy_1cm_POT1000.root", "READ");
        TTree* tree1 = (TTree*)file1->Get("DUNETargetSim");

        Double_t Energy1;
        Char_t pid1[32];
        vector<double>nue_1cm;

        tree1->SetBranchAddress("kineticEnergy", &Energy1);
        tree1->SetBranchAddress("pid", &pid1);

        TH1D* hist1 = new TH1D("nu_e_1cm", "nu_e_1cm Hist", 12000, 0, 120);

        Int_t nentries = tree1->GetEntries("kineticEnergy");
// cout << nentries << endl;

        for(Int_t i = 0; i < nentries; i++)
        {
                tree1->GetEntry(i);
                if (strcmp(pid1 , "nu_e") == 0) { nue_1cm.push_back(i); }
        }

// cout << nue_1cm.size() << endl;

        for(Int_t j = 0; j < nue_1cm.size(); j++)
        {
                hist1->Fill(nue_1cm[j]);
        }

        hist1->Draw();
}

```

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/8/d/8d09bbfd540114a717a8d5d8ba55d2c80252cffe.png)  
 ![image](https://root-forum.cern.ch/uploads/default/original/3X/8/e/8e0acdec16c784557cba751281a761ecf68cdd23.png)

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [August 4, 2021, 4:54am UTC](https://root-forum.cern.ch/t/empty-histogram-but-shows-entries/46159/2 "2021-08-04T04:54:50Z")

</div>

Maybe check  
[https://root-forum.cern.ch/search?q=underflow%20overflow](https://root-forum.cern.ch/search?q=underflow%20overflow)

---

<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:** [August 4, 2021, 7:31am UTC](https://root-forum.cern.ch/t/empty-histogram-but-shows-entries/46159/3 "2021-08-04T07:31:42Z")

</div>

Try with:

```cpp
TH1D* hist1 = new TH1D("nu_e_1cm", "nu_e_1cm Hist", 100, 0., 0.); // automatic binning

```
