Hi,
I have written the following macro to plot two histograms (from two different root files) on the same plot after normalizing them :
void Exp_Theo_Mass_Events()
{
Double_t s1, s2, s3;
TCanvas *c1 = new TCanvas("c1","Comparison of Experimental and Theoritical TKE Distribution",800,600);
gStyle->SetOptStat(0);
TFile *file3=TFile::Open("RAW173SM_treeFF01.root");
TTree *tree3=(TTree*)file3->Get("Analysis_Fis");
c1->cd();
TH1D*h1 = new TH1D("h1","Normalised to the total number of events",100.,40.,140.);
h1->SetLineColor(8);
h1->SetLineStyle(1);
h1->SetLineWidth(3);
tree3->Draw("M_Tot>>h1");
s1 = 200./10478.; // Normalised to total number of events
h1->Scale(s1);
h1->Draw("");
TFile *file=TFile::Open("QnmFF_ROOT.root");
TTree *tree=(TTree*)file->Get("DITY");
TH1D*h3 = new TH1D("h3","Au_158.62_MeV,40.7_MeV",100.,40.,140.);
h3->SetLineColor(2);
h3->SetLineStyle(1);
tree->Draw("M_Tot_Res_amu>>h3");
s3 = 200./1236.;
h3->Scale(s3);
h3->Draw("SAME");
auto legend = new TLegend(0.1,0.7,0.48,0.9);
legend->SetHeader("","C");
legend->AddEntry(h1,"Experimental data","l");
legend->AddEntry(h3,"Theoritical data","l");
legend->SetBorderSize(0);
legend->Draw();
}
Unfortunately I am not able to plot two histograms together.
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided