# How to merge certain histograms within the same root file?

**URL:** <https://root-forum.cern.ch/t/how-to-merge-certain-histograms-within-the-same-root-file/27185>\
**Category:** ROOT\
**Tags:** hist, documentation\
**Created:** [December 5, 2017, 7:33am UTC](https://root-forum.cern.ch/t/how-to-merge-certain-histograms-within-the-same-root-file/27185 "2017-12-05T07:33:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![suman](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@suman](https://root-forum.cern.ch/u/suman)\
**Post date:** [December 5, 2017, 7:33am UTC](https://root-forum.cern.ch/t/how-to-merge-certain-histograms-within-the-same-root-file/27185/1 "2017-12-05T07:33:10Z")

</div>

I have a root file containing 10 histogram [say bin as 0-5,5-10…55-60], i want to merge only 4 histogram out of them [say bin as 0-5,5-10,10-15.15-20]

How to do that?

Thanx in advance

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [December 5, 2017, 9:48am UTC](https://root-forum.cern.ch/t/how-to-merge-certain-histograms-within-the-same-root-file/27185/3 "2017-12-05T09:48:14Z")

</div>

Hi,

You can use TH1::Merge(list) where in the list you add only the histogram you want to merge

Lorenzo

---

<div class="post-metadata">

**Author:** ![suman](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@suman](https://root-forum.cern.ch/u/suman)\
**Post date:** [December 7, 2017, 10:03am UTC](https://root-forum.cern.ch/t/how-to-merge-certain-histograms-within-the-same-root-file/27185/4 "2017-12-07T10:03:21Z")

</div>

@moneta and for other histograms should i write it separately or in the same program

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [December 21, 2017, 10:08am UTC](https://root-forum.cern.ch/t/how-to-merge-certain-histograms-within-the-same-root-file/27185/5 "2017-12-21T10:08:13Z")

</div>

Closed on December 21, 2017, 10:08am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
