# Copying a histogram to a branch of a new root file

**URL:** <https://root-forum.cern.ch/t/copying-a-histogram-to-a-branch-of-a-new-root-file/46292>\
**Category:** Newbie\
**Created:** [August 13, 2021, 6:00am UTC](https://root-forum.cern.ch/t/copying-a-histogram-to-a-branch-of-a-new-root-file/46292 "2021-08-13T06:00:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reshma246](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/reshma246/32/27118_2.png) [@Reshma246](https://root-forum.cern.ch/u/Reshma246)\
**Post date:** [August 13, 2021, 6:00am UTC](https://root-forum.cern.ch/t/copying-a-histogram-to-a-branch-of-a-new-root-file/46292/1 "2021-08-13T06:00:42Z")

</div>

I had a question which might appear simple to many experienced users.  
I have a root file and a histogram in it.I want to create a separate new root file, add a tree in it and then a branch in it.Then I wish to copy my histogram to the branch of my new root file.  
Can you tell me how to copy a histogram from a root file to the branch of a new root file?If possible please help me with the code.  
Thanks in advance!!

---

<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 13, 2021, 9:42am UTC](https://root-forum.cern.ch/t/copying-a-histogram-to-a-branch-of-a-new-root-file/46292/2 "2021-08-13T09:42:36Z")

</div>

It’s unclear what you want (“ROOT files” have no “branches”).

You can easily copy ROOT objects (e.g., trees and histograms). Try: `rootcp --help`

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [August 24, 2021, 9:16am UTC](https://root-forum.cern.ch/t/copying-a-histogram-to-a-branch-of-a-new-root-file/46292/3 "2021-08-24T09:16:17Z")

</div>

Hi @Reshma246 ,  
and welcome to the ROOT forum.

May I ask why you want to store a histogram as a branch of a TTree?

Cheers,  
Enrico
