# Combining Histograms dealing with Statistics Box

**URL:** <https://root-forum.cern.ch/t/combining-histograms-dealing-with-statistics-box/36664>\
**Category:** Newbie\
**Created:** [November 4, 2019, 12:51pm UTC](https://root-forum.cern.ch/t/combining-histograms-dealing-with-statistics-box/36664 "2019-11-04T12:51:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andi1](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Andi1](https://root-forum.cern.ch/u/Andi1)\
**Post date:** [November 4, 2019, 12:51pm UTC](https://root-forum.cern.ch/t/combining-histograms-dealing-with-statistics-box/36664/1 "2019-11-04T12:51:33Z")

</div>

Dear ROOT-Community,  
currently I am trying to combine TH3F-histograms from two Ttrees from two files generated by GATE. I do have a similar issue with 1D-histograms but I will just show the TH3F-example.  
As already mentioned, I want to combine 3-dim-Histograms, which works but I do not get a proper statistics box. It is empty. I would like to know:

1. How to combine the statistics-box of the two histograms and have the statistics box show the combined number of entries.
2. Have two statistics-boxes for each histogram

So far my Code looks like this:

```auto
 void plot_example(string arg1, string arg2)
 {
     const char* Infile1 = arg1.c_str();
     const char* Infile2 = arg2.c_str();
     auto mycanvas = new TCanvas();
     TLegend *legend = new TLegend();
     auto MyHist1= new TH3F("MyHist1","MyHist1",100,-400,100,100,-150,150,100,-150,150);
     TFile *file0 = TFile::Open(Infile1);
     TFile *file1 = TFile::Open(Infile2);
     TTree *t1;
     TTree *t2;
     file0->GetObject("Singles", t1);
     file1->GetObject("Singles", t2);
     MyHist1->Draw();
     mycanvas->Update();
     t2->Draw("globalPosX:globalPosY:globalPosZ","","same");
     mycanvas->Update();
     t1->Draw("globalPosX:globalPosY:globalPosZ","","same");
     mycanvas->Update();
 }

```

Thanks a lot.  
Best regards,  
Andi

* * *

Compiler: gcc 4.8.5 g++5.4.0  
OS: Ubuntu 16.04  
ROOT 6.14/06

---

<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:** [November 4, 2019, 1:19pm UTC](https://root-forum.cern.ch/t/combining-histograms-dealing-with-statistics-box/36664/2 "2019-11-04T13:19:58Z")

</div>

We do not have your data files.  
Therefore it is difficult for us to try your example.
