#include #include void FConvo() { char fname1[100], fname2[100], fname3[100]; double var_rand = 0, FWHM = 0, bin_sigma,cont; sprintf(fname1,"result.root"); sprintf(fname2,"result1.root"); sprintf(fname3,"result2.root"); TFile *file1 = new TFile(fname1); TFile *file2 = new TFile(fname2); TFile *file3 = new TFile(fname3); Int_t binN=500; TH1D *NearDet_edep1 = new TH1D("NearDet_edep1",";Energy (MeV);Counts keV",binN,0,600.0); TH1D *NearDet_edep2 = new TH1D("NearDet_edep2",";Energy (MeV);Counts keV",binN,0,600.0); TH1D *NearDet_edep3 = new TH1D("NearDet_edep3",";Energy (MeV);Counts keV",binN,0,600.0); h1 = (TH1D*)file1->Get("ND_eDep"); h2 = (TH2D*)file2->Get("ND_eDep"); h3 = (TH2D*)file3->Get("ND_eDep"); 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); } } TCanvas *c1 = new TCanvas("c1", "",1800,1400); c1->cd(); NearDet_edep1->Draw(); NearDet_edep1->SetStats(0); NearDet_edep2->Draw("SAME"); NearDet_edep2->SetStats(0); NearDet_edep3->Draw("SAME"); NearDet_edep3->SetStats(0); TLegend *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(); }