Double_t aaa(Double_t *x, Double_t *par){ double bin = 0.0125; double mult = 1./par[2]/sqrt(2*3.1415); double func1 = par[0]*mult*exp(-0.5* pow((x[0]-par[1])/par[2],2)); double mult1 = 1./par[5]/sqrt(2*3.1415); double norm = 0.5*(erf(sqrt(0.5/par[5])*(1.-par[4]))-erf(sqrt(0.5/par[5])*(-2.5-par[4]))); double func2 = par[3]*norm*exp(-0.5* pow((x[0]-par[4])/par[5],2)); // double func3 = par[6] + par[7]*x[0] + par[8]*x[0]*x[0] + par[9]*x[0]*x[0]*x[0]; double func3 = par[6] + par[7]*x[0] + par[8]*x[0]*x[0]; double func = bin*(func1 + func2 + func3); return func; } void plot_compton_nim(){ gROOT->Reset(); gROOT->SetStyle("Plain"); gROOT->ForceStyle(); gStyle->SetOptStat(0); gStyle->SetOptFit(11); gStyle->SetTitleX(0.1f); gStyle->SetTitleW(0.8f); gStyle->SetTextSize(1.5); gStyle->SetTitleFont(132,"xy"); gStyle->SetLabelFont(132,"xy"); gStyle->SetLabelSize(0.055,"xy"); gStyle->SetTitleSize(0.06,"xy"); gStyle->SetTitleOffset(1.1,"x"); gStyle->SetTitleOffset(1.1,"y"); gStyle->SetTitleBorderSize(0); TFile *file = new TFile ("61914.root","R"); TFile *file1 = new TFile ("empty_target_all.root","R"); TH1F *comp_e6 = (TH1F*)file->Get("comp_e6"); TH1F *comp_sb_e6 = (TH1F*)file->Get("comp_sb_e6"); TH1F *comp_empty_e6 = (TH1F*)file1->Get("comp_e6"); TH1F *comp_empty_sb_e6 = (TH1F*)file1->Get("comp_sb_e6"); TH1 *comp_e6_subt; TH1 *comp_e6_empty_subt; TCanvas *c3 = new TCanvas("c3","c3", 200, 10, 600, 400); gPad->SetBottomMargin(0.15); gPad->SetTopMargin(0.05); gPad->SetLeftMargin(0.125); gPad->SetRightMargin(0.05); comp_e6_subt = (TH1F*) comp_e6->Clone(); comp_e6_subt->Add(comp_sb_e6,-1.); comp_e6_empty_subt = (TH1F*) comp_empty_e6->Clone(); comp_e6_empty_subt->Add(comp_empty_sb_e6,-1.); comp_e6_empty_subt->Scale(0.03248); comp_e6->Draw(); comp_sb_e6->Draw("same"); comp_e6_subt->SetLineColor(4); comp_e6_subt->Draw("same"); comp_e6_empty_subt->SetLineColor(2); comp_e6_empty_subt->Draw("same"); comp_e6_subt->Add(comp_e6_empty_subt,-1); comp_e6_subt->SetLineColor(1); comp_e6_subt->SetLineWidth(2); comp_e6_subt->SetTitle(""); comp_e6_subt->GetXaxis()->SetRangeUser(-1.2, 1.2); comp_e6_subt->GetXaxis()->SetTitle("E_{CCAL} + E_{FCAL} - E_{beam} (GeV)"); comp_e6_subt->GetYaxis()->SetTitle("Events / 12.5 MeV"); comp_e6_subt->Draw(); TF1 *func1 = new TF1("aaa",aaa,-2,1.,9); func1->SetParameter(0,6e4); func1->SetParameter(1,0); func1->SetParameter(2,0.11); func1->SetParameter(3,1e4*0.05); func1->SetParameter(4,-0.); func1->SetParameter(5,0.2); func1->SetParameter(6,0); func1->SetParameter(7,0); func1->SetParameter(8,0); func1->SetParameter(9,0); func1->SetLineColor(2); comp_e6_subt->Fit("aaa","L","",-2.,1.); comp_e6_subt->Fit("aaa","L","",-2.,1.); comp_e6_subt->Fit("aaa","L","",-2.,1.); comp_e6_subt->Fit("aaa","","",-2.,1.); comp_e6_subt->SetBinContent(400,2491); // comp_e6_subt->Draw("histo"); }