Saving TStack to ROOT file

I would like to save a TStack to a ROOT file. I can do this straightforwardly enough with

TFile *fout = new TFile(“hist.root”, “RECREATE”);

I do not see a bug it is more that I have a question.
The TStack is saved as I expect and I can inspect it in the ROOT file through TBrowser. However, what is shown is the total histogram not the stacked histograms. The colours, legends and other details appear not to be retained.
Is there a way to save the TStack as it is?
I am aware that I can Write the canvas to the file which does have the stack and legend, etc. However, I would like to merge histograms later so I would like to save the stack to file.
How can I do this?
Thank you for your assistance

_ROOT Version: 6.20/04
_Platform: Centos7
_Compiler: gcc 4.8.5

Hi @jnugent,
thanks for reaching out!
Could you please provide us with a complete code snippet so we can replicate your situation?


@mdessole thank you for responsing. After further digging and discussion this is actually due to a particular feature of my collaborations drawing macros and nothing to do with the underlying ROOT code. I was able to confirm this but writing my own simple macro as you suggested which works exactly as I expected. Thank you for your help.

1 Like

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