Using histograms from different macros

I’m new to Root and C++ programming.
I have some histograms (h1, h2, h3) in a macro, say macro.C, and I would like to create a new different macro, say newmacro.C, in which I want to use the macro.C’s histograms to make another histogram for different scope. Can I do this in root? What are the commands?

Thank you.

1 Like

Sure it can be done. One way could be to save the histograms in the first macro to a ROOT file, then on the second macro you open the file and read the histograms from there. There’s some sample code in the “File I/O and Parallel Analysis” section of the ROOT Primer (Primer and more tutorials here), or search this forum for many more examples.

1 Like

…and a belated welcome to the ROOT forum @peanuts :smiley: let us know if you need further help/pointers to documentation (in a new topic, marking this as solved).