void FConvo() { double var_rand = 0, FWHM = 0, bin_sigma,cont; auto myRand = new TRandom(); TFile *file1 = new TFile("result.root"); TFile *file2 = new TFile("result1.root"); TFile *file3 = new TFile("result2.root"); Int_t binN=500; auto NearDet_edep1 = new TH1D("NearDet_edep1",";Energy (MeV);Counts keV",binN,0,600.0); auto NearDet_edep2 = new TH1D("NearDet_edep2",";Energy (MeV);Counts keV",binN,0,600.0); auto NearDet_edep3 = new TH1D("NearDet_edep3",";Energy (MeV);Counts keV",binN,0,600.0); TH1D *h1 = (TH1D*)file1->Get("Ntuple1;1"); TH2D *h2 = (TH2D*)file2->Get("Ntuple1;1"); TH2D *h3 = (TH2D*)file3->Get("Ntuple1;1"); for (int k = 0; kGetBinCenter(k); Int_t counts = h1->GetBinContent(k); for (int l=0; lGaus(cent,bin_sigma); NearDet_edep1->Fill(var_rand); } } for (int k = 0; kGetBinCenter(k); Int_t counts = h2->GetBinContent(k); for (int l=0; lGaus(cent,bin_sigma); NearDet_edep2->Fill(var_rand); } } for (int k = 0; kGetBinCenter(k); Int_t counts = h3->GetBinContent(k); for (int l=0; lGaus(cent,bin_sigma); NearDet_edep3->Fill(var_rand); } } auto c1 = new TCanvas("c1", "",1800,1400); NearDet_edep1->Draw(); NearDet_edep1->SetStats(0); NearDet_edep2->Draw("SAME"); NearDet_edep2->SetStats(0); NearDet_edep3->Draw("SAME"); NearDet_edep3->SetStats(0); auto leg = new TLegend(0.55,0.7,0.85,0.85); leg->AddEntry(h1,"Material1","L"); leg->AddEntry(h2,"Material2","L"); leg->AddEntry(h2,"Material3","L"); leg->Draw(); }