string str1[4] = {"MonteCarlo/ntpl_jpsi_incl.root", "Bes/umcinc.root", "Bes/udata.root", "mcsig_09jpsi_phieta.root"}; string str2[4] = {"MCBadger", "MCBes", "DataBes", "NewMCBadger"}; void SetISN(TH1D* his); void CoreBg(TF1* sum, TF1* graph1, TF1* graph2); void DrwHis(TH1D* his, TF1* core, TF1* bg); static Double_t inf, sup, nor; void SetISN(TH1D* his) { inf = his->GetXaxis()->GetXmin(); sup = his->GetXaxis()->GetXmax(); nor = (sup - inf)/his->GetNbinsX(); } void CoreBg(TF1* sum, TF1* graph1, TF1* graph2) { graph1->SetParameter(0, sum->GetParameter(0)*nor); for ( Int_t i = 1; i < graph1->GetNpar(); i++) graph1->SetParameter(i, sum->GetParameter(i)); for ( Int_t i = 0; i < sum->GetNpar() - graph1->GetNpar(); i++ ) graph2->SetParameter(i, sum->GetParameter(graph1->GetNpar() + i)); graph1->SetLineColor(4); graph1->SetLineStyle(2); graph2->SetLineColor(620); graph2->SetLineStyle(2); } void DrwHis(TH1D* his, TF1* total, TF1* core, TF1* bg) { CoreBg(total, core, bg); gStyle->SetOptStat(10); gStyle->SetOptFit(112); gPad->SetGrid(); his->SetMinimum(0); his->Draw("E"); TLegend* legend = new TLegend(0.1,0.7,0.4,0.9); legend->SetHeader("Designations","C"); legend->AddEntry(his,"Data"); legend->AddEntry(core, "Core"); legend->AddEntry(bg, "Background"); legend->Draw(); core->Draw("same"); bg->Draw("same"); }