if I need to write a histogram to a root file I do something like this
TFile f(“histos.root”,“new”);
TH1F *h1;
h1->Fill(somedata);
h1->Write();
f.Close();
But what do I do if I want to superimpose two histograms and then write them to the root file…
Thanks for the fast reply.
I have tried your suggestion and that results in two plots for each of the histogram. What
I am trying to do is get the two histograms superimposed on each other on the same plot.
Hi .
It would go something like this.
TFile f(“histos.root”,“new”);
TH1F *h1, *h2;
h1->Fill(somedata);
h2->Fill(somedata);
h1->Draw();
h2->Draw(“same”);
h2->Write();//Write the superimposed histos.
f.Close();
TCanvas *c1 = new TCanvas("c1");
TH1F *h1, *h2;
h1->Fill(somedata);
h2->Fill(somedata);
h1->Draw();
h2->Draw("same");
c1->Print("amelie.root");
then in a separate session, do something like