How to write superimposed histograms in file without drawing them?

Hi, ROOTers.
Suppose I want to save two superimposed histograms in root file. NOTE: I do not want to save those histograms separately one by one. I want to have one canvas with two histograms in that file. And also I do not want to Draw() those histograms before writing in file.
Thanks in advance.

I you want to save them as a TCanvas, you will need to Draw them (in the ROOT sense) . But you can Draw them in batch mode. That way no graphics will appear on screen (if that’s what you mean by “Draw”) .

And other possibility will be to put them in a THStack and save the THStack.

Thanks. But what if I get histograms from different files and they have different binning?

If they have different binning then use the first solution.

There is one more problem. When I write THStack I get the first given histogram and sum of two given histograms. How to use option nostack in this case?

Specify nostack when you draw the histogram

But I do not draw a histogram. I just add them to THStack and save it to the file.

Yes fine … so the histograms are in the THStack … what do you want to do with them if you do not draw them ?

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