Copying a histogram to a branch of a new root file

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!!

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

Hi @Reshma246 ,
and welcome to the ROOT forum.

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