// Plot one or more histograms in a single histogram as a single canvas. void write_hist() { TH1F *his = new TH1F("his", "", 10000, 0., 1.0E9); his->GetXaxis()->SetTitle("Energy (GeV)"); his->GetYaxis()->SetTitle("Counts"); TFile *f1 = TFile::Open("muon_energy.root", "READ"); TH1F *h1 = (TH1F*)f1->Get("hs"); h1->SetLineColor(kRed); his->Add(h1); TFile *f2 = TFile::Open("meson_energy.root", "READ"); TH1F *h2 = (TH1F*)f2->Get("hs"); h2->SetLineColor(kBlue); his->Add(h2); TFile *fout = new TFile("energy_hist.root", "RECREATE"); his->Write(); fout->Close(); }