#include "drawAsymSysErrOme.h" #include "TCanvas.h" #include "TAxis.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include #include #include string DoubleToString(double a) { ostringstream temp; temp<Sumw2(); hPPSum->Add(hPERPSub, hPARASub, 1, norm); // set max-min and get normalization double maximum = hPERPSub->GetMaximum(); if(hPARASub->GetMaximum() > maximum) maximum = hPARASub->GetMaximum(); maximum *= 2.0; hPERPSub->SetMinimum(0); hPARASub->SetMinimum(0); hPERPSub->SetMaximum(maximum); hPARASub->SetMaximum(maximum); cout<<"maximum= "<GetMaximum(); maximumSum *= 3.5; hPPSum->SetMinimum(0); hPPSum->SetMaximum(maximumSum); // make asymmetry TH1I* hAsym = hPERPSub->GetAsymmetry(hPARASub, norm); double maximumAsym = hAsym->GetMaximum(); maximumAsym *= 4.0; hAsym->SetMaximum(maximumAsym); TCanvas *cc = new TCanvas("cc", "cc", 900, 760); cc->Divide(2,2); cc->cd(1); TF1* fitPERP = new TF1("psiFitPERP", "[0]*(1.0 + [1]*cos(2*(x + [2])))"); fitPERP->SetLineColor(color); hPERPSub->GetYaxis()->SetTitle("Counts/0.314"); hPERPSub->Fit(fitPERP, ""); hPERPSub->SetMarkerStyle(20); hPERPSub->SetMarkerColor(color); hPERPSub->Draw("e"); TPavesText *paves = new TPavesText(-2.75, 0.8*maximum, -1.4, 0.9*maximum); paves->AddText(rebin_s); paves->SetFillColor(19); paves->Draw(); cc->cd(2); TF1* fitPARA = new TF1("psiFitPARA", "[0]*(1.0 + [1]*cos(2*(x + [2])))"); fitPARA->SetLineColor(color); hPARASub->GetYaxis()->SetTitle("Counts/0.314"); hPARASub->Fit(fitPARA, ""); hPARASub->Draw("e"); hPARASub->SetMarkerStyle(20); hPARASub->SetMarkerColor(color); cc->cd(3); TF1* fitAsym = new TF1("asymFit", "[0]*cos(2*(x + [1]))"); fitAsym->FixParameter(1, -0.07774); fitAsym->SetLineColor(color); hAsym->GetYaxis()->SetTitle("Asymmetry"); hAsym->Fit(fitAsym, ""); hAsym->SetMarkerStyle(20); hAsym->SetMarkerColor(color); hAsym->Draw("e"); cout<GetParError(0)<<";"<GetParameter(0); Errtmp = fitAsym->GetParError(0); cc->cd(4); TF1* fitSum = new TF1("sumFit", "[0]*(1.0 + [1]*cos(2*(x + [2])))"); fitSum->FixParameter(2, -0.07774); fitSum->SetLineColor(color); hPPSum->GetYaxis()->SetTitle("Counts/0.314"); hPPSum->Fit(fitSum, ""); hPPSum->SetMarkerStyle(20); hPPSum->SetMarkerColor(color); hPPSum->Draw("e"); cc->Print(figName+".pdf"); cc->Print(figName+".ps"); delete hPPSum; delete fitPERP; delete fitPARA; delete fitAsym; delete fitSum; delete paves; delete cc; return Asymtmp; } void drawbinnedPSigma3_sys(double xx[][nsysSc][3][6], double yy[][nsysSc][3][6], double eyy[][nsysSc][3][6], const int n, const int nrebin, const int nsysSc, const int ncutsRg, const int nPS, TString figName) { gStyle->SetOptStat(0); double x[5][nsysSc][3][3], y[5][nsysSc][3][3], ey[5][nsysSc][3][3]; double exx[n] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; double ex[3] = {0.0, 0.0, 0.0}; for(int m = 1; mDivide(1,1); c1->cd(1); TH1F* h = new TH1F("h", "h", 100, 0., 2.0); h->Draw(); h->SetMinimum(-0.60); h->SetMaximum(0.80); h->GetXaxis()->SetTitle("m_{2#gamma} (GeV^{2})"); h->GetYaxis()->SetTitle("P #Sigma"); h->GetXaxis()->SetRangeUser(0.0,2.0); h->GetYaxis()->SetTitleOffset(1.2); h->SetTitle("The P#Sigma of #eta photoproduction for TSubR"); TString rebin_s = "different bins standard cut"; TString note_color = "black for 100, blue for 50, red for 25, green for 20, yellow for 10"; TPavesText *paves = new TPavesText(0.4, 0.7, 1.2, 0.9); paves->AddText(rebin_s); paves->AddText(note_color); paves->SetFillColor(19); paves->Draw(); for(int l=0; l<3; l++) { cout<<__LINE__<SetMarkerStyle(20); gr0->SetMarkerSize(1); gr0->SetMarkerColor(kBlack); gr0->SetLineColor(kBlack); gr0->Draw("same P"); gr1->SetMarkerStyle(21); gr1->SetMarkerSize(1); gr1->SetMarkerColor(kBlue); gr1->SetLineColor(kBlue); gr1->Draw("same P"); gr2->SetMarkerStyle(22); gr2->SetMarkerSize(1); gr2->SetMarkerColor(kRed); gr2->SetLineColor(kRed); gr2->Draw("same P"); gr3->SetMarkerStyle(23); gr3->SetMarkerSize(1); gr3->SetMarkerColor(kGreen); gr3->SetLineColor(kGreen); gr3->Draw("same P"); gr4->SetMarkerStyle(24); gr4->SetMarkerSize(1); gr4->SetMarkerColor(kYellow); gr4->SetLineColor(kYellow); gr4->Draw("same P"); c1->Print(figName + fig_bins_index + ".ps"); c1->Print(figName + fig_bins_index + ".pdf"); delete gr0; delete gr1; delete gr2; delete gr3; delete gr4; delete h; delete c1; delete paves; } for(int m = 1; mDivide(1,1); //double ex[n] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; c1->cd(1); TH1F* h = new TH1F("h", "h", 100, 0., 2.0); h->Draw(); h->SetMinimum(-0.60); h->SetMaximum(0.80); h->GetXaxis()->SetTitle("<-t> (GeV^{2})"); h->GetYaxis()->SetTitle("P #Sigma"); h->GetXaxis()->SetRangeUser(0.0,2.0); h->GetYaxis()->SetTitleOffset(1.2); h->SetTitle("The P#Sigma of #pi^{0} photoproduction for total"); TString rebin_s = bin_s + "bins" + titleSc[i]; TString note_color = "black for cuta, blue for cutb, red for cutc"; TPavesText *paves = new TPavesText(0.4, 0.7, 1.2, 0.9); paves->AddText(rebin_s); paves->AddText(note_color); paves->SetFillColor(19); paves->Draw(); for(int l=0; l<3; l++) { cout<SetMarkerStyle(20); gr0->SetMarkerSize(1); gr0->SetMarkerColor(kBlack); gr0->SetLineColor(kBlack); gr0->Draw("same P"); gr1->SetMarkerStyle(21); gr1->SetMarkerSize(1); gr1->SetMarkerColor(kBlue); gr1->SetLineColor(kBlue); gr1->Draw("same P"); gr2->SetMarkerStyle(22); gr2->SetMarkerSize(1); gr2->SetMarkerColor(kRed); gr2->SetLineColor(kRed); gr2->Draw("same P"); cout<<__LINE__<Print(figName + fig_index + ".ps"); c1->Print(figName + fig_index + ".pdf"); cout<<__LINE__<SetOptStat(0); TCanvas *c1 = new TCanvas("c1", "The centroid with error bars", 100, 5, 1000, 600); c1->Divide(1,1); double ex[n] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; c1->cd(1); TH1F* h = new TH1F("h", "h", 100, 0., 2.0); h->Draw(); TGraphErrors *gr = new TGraphErrors(n, x, y, ex, ey); //gr->Draw("AP*"); h->SetMinimum(0.00); h->SetMaximum(1.00); gr->SetMarkerStyle(20); gr->SetMarkerSize(1); gr->SetMarkerColor(kBlack); gr->SetLineColor(kBlack); h->GetXaxis()->SetTitle("<-t> (GeV^{2})"); h->GetYaxis()->SetTitle("P #Sigma"); h->GetXaxis()->SetRangeUser(0.0,2.0); h->GetYaxis()->SetTitleOffset(1.2); h->SetTitle("The P#Sigma of #pi^{0} photoproduction for total"); //c1->Update(); gr->Draw("same P"); //c1->Print("figPhiP/PSigma.pdf"); c1->Print(figName); delete c1; delete h; delete gr; return; } */ double Meanmt(TString datafileName, TString Hist2DName, double minx, double maxx, int i) { cout<<"beginning of Meanmt"<Get(Hist2DName); cout<SetOptStat("nemr"); //Double_t ylow = 0.0; //Double_t yup = 0.2; Double_t ylow = -3.14; Double_t yup = 3.14; cout<<__LINE__<Divide(1,1); double maximum=0.0; int binMiny = h->GetYaxis()->FindBin(ylow); int binMaxy = h->GetYaxis()->FindBin(yup); cout<<__LINE__<ProjectionX(Form("E2gamma_%d", i),binMiny,binMaxy); cout<<__LINE__<GetMaximum(); maximum *= 3.6; h1->SetMaximum(maximum); cout<<__LINE__<GetXaxis()->FindBin(minx); int binMaxx = h->GetXaxis()->FindBin(maxx); h1->GetXaxis()->SetRange(binMinx,binMaxx); cout<<"min_x="<GetMean(1)<cd(1); h1->Draw(""); double meantmp = h1->GetMean(1); //cc_ave->Print(figsName); delete cc_ave; delete fdata; return meantmp; } void drawomegaAsymSysErr(double norm) { cout<<"beginning of drawomegaAsymSysErr"<SetOptStat(0); gStyle->SetOptFit(1111); TString hist2DName_head = "Phi_Proton_vs_IM2g_cutBE_sys_"; TString perpfileName = "./histroot/ana_p2gamma_phip_perp.root"; TString parafileName = "./histroot/ana_p2gamma_phip_para.root"; TString figsName_head = "./figPhiP/m2gbin/asym_m2gbin_TSubR_"; cout<<__LINE__<2) continue; int rebin = rebin_i[m-1]; int bin = 100/rebin; for(int i=0; i2) continue; for(int j=0; jGet(hist2DName); TH2D* h2PERPBkg = (TH2D*)fPERP->Get("Acci_" + hist2DName); TFile *fPARA = TFile::Open(parafileName); if(!fPARA) return; TH2D* h2PARA = (TH2D*)fPARA->Get(hist2DName); TH2D* h2PARABkg = (TH2D*)fPARA->Get("Acci_" + hist2DName); TString figsName_mid = IntToString(ii); figName = figsName_head + "rebin_" + title_rebin[m-1] + titleSc[i] + titleRg[j] + figsName_mid; int jj=ii-1; cout<<"jj="<Sumw2(); //hPERP->Rebin(rebin); int binMinPERPBkg = h2PERPBkg->GetXaxis()->FindBin(Array_t[jj]); int binMaxPERPBkg = h2PERPBkg->GetXaxis()->FindBin(Array_t[ii]); TH1D *hPERPBkg = (TH1D*)h2PERPBkg->ProjectionY(Form("phi_p_perp_bkg_%d", ii),binMinPERPBkg,binMaxPERPBkg); hPERPBkg->Sumw2(); //hPERPBkg->Rebin(rebin); hPERPBkg->Scale(normC); TH1D* hPERPSub = new TH1D("hPERPSub", "Phi_Proton_pi_cutBE_sub", 100, minx, maxx); hPERPSub->Sumw2(); hPERPSub->Add(hPERP, hPERPBkg, 1, -1); hPERPSub->Draw(); int binMinPARA = h2PARA->GetXaxis()->FindBin(Array_t[jj]); int binMaxPARA = h2PARA->GetXaxis()->FindBin(Array_t[ii]); TH1D *hPARA = (TH1D*)h2PARA->ProjectionY(Form("phi_p_para_%d", ii),binMinPARA,binMaxPARA); hPARA->Sumw2(); //hPARA->Rebin(rebin); int binMinPARABkg = h2PARABkg->GetXaxis()->FindBin(Array_t[jj]); int binMaxPARABkg = h2PARABkg->GetXaxis()->FindBin(Array_t[ii]); TH1D *hPARABkg = (TH1D*)h2PARABkg->ProjectionY(Form("phi_p_para_bkg_%d", ii),binMinPARABkg,binMaxPARABkg); hPARABkg->Sumw2(); //hPARABkg->Rebin(rebin); hPARABkg->Scale(normC); TH1D* hPARASub = new TH1D(Form("hPARASub_%d", ii), "Phi_Proton_pi_cutBE_sub", 100, minx, maxx); hPARASub->Sumw2(); hPARASub->Add(hPARA, hPARABkg, 1, -1); hPERPSub->Rebin(rebin); hPARASub->Rebin(rebin); Asym_m2g_bin[m-1][i][j][jj] = drawBeamAsymmetry_bin(hPERPSub, hPARASub, bin, norm, minx, maxx, color[2], figName, histName_h); Err_m2g_bin[m-1][i][j][jj] = Errtmp; //cout<<"x[j]="<GetXaxis(); int bmin = axis->FindBin(xmin); int bmax = axis->FindBin(xmax); double para = histdata->Integral(bmin, bmax); return para; } void drawTH1D2Compare(TH1D* hist1, TH1D* hist2, TString figName) { Int_t w = 960; Int_t h = 600; double minimum = 0.1; double maximum = 50*hist1->GetMaximum(); TString title_c = "Im_2g_omega"; TCanvas *c = new TCanvas("c", title_c, w, h); c->Divide(1,1); hist1->SetMinimum(minimum); gPad->SetLogy(); hist1->SetMaximum(maximum); hist1->SetLineColor(kRed); hist1->SetLineStyle(1); hist2->SetLineColor(kBlue); hist2->SetLineStyle(2); hist1->Draw(); hist2->Draw("SAME"); TLegend *leg = new TLegend(0.42,0.72, 0.72, 0.86); leg->SetHeader("The omega background"); leg->SetTextSize(0.04); leg->AddEntry(hist1, "data", "f"); leg->AddEntry(hist2, "#omega mc", "f"); leg->Draw(); c->Print(figName + ".pdf"); c->Print(figName + ".ps"); delete c; delete leg; return; } double drawomega(TString histName, TString figName) { TString fileNamedata = "./histroot/ana_p2gamma_Cuts_NewData.root"; TFile *fdata = TFile::Open(fileNamedata); TString fileNameinmc = "./histroot/hist_p2gamma_inc_010000.root"; TFile *finmc = TFile::Open(fileNameinmc); TString fileNameomega = "./histroot/hist_p2gamma_omega_010000.root"; TFile *fomega = TFile::Open(fileNameomega); cout<<"root file is: "<Get(histName); TH1D* histomega = (TH1D*)fomega->Get(histName); double paradata = integ(histdata, xmin, xmax); double paraomega = integ(histomega, xmin, xmax); double paraomega_eta_bf = integ(histomega, eta_min, eta_max); cout<<"paraomega_eta_bf = "<Scale(norm); double paraomega_eta = integ(histomega, eta_min, eta_max); double paradata_eta = integ(histdata, eta_min, eta_max); double fraction = paraomega_eta/paradata_eta; cout<<"paraomega_eta_af = "<Sumw2(); hPPSum->Add(hPERPSub, hPARASub, 1, norm); // set max-min and get normalization double maximum = hPERPSub->GetMaximum(); if(hPARASub->GetMaximum() > maximum) maximum = hPARASub->GetMaximum(); maximum *= 2.0; hPERPSub->SetMinimum(0); hPARASub->SetMinimum(0); hPERPSub->SetMaximum(maximum); hPARASub->SetMaximum(maximum); cout<<"maximum= "<GetMaximum(); maximumSum *= 3.5; hPPSum->SetMinimum(0); hPPSum->SetMaximum(maximumSum); // make asymmetry TH1I* hAsym = hPERPSub->GetAsymmetry(hPARASub, norm); double maximumAsym = hAsym->GetMaximum(); maximumAsym *= 4.0; hAsym->SetMaximum(maximumAsym); TCanvas *cc = new TCanvas("cc", "cc", 900, 760); cc->Divide(2,2); cc->cd(1); TF1* fitPERP = new TF1("psiFitPERP", "[0]*(1.0 + [1]*cos(2*(x + [2])))"); fitPERP->SetLineColor(color); hPERPSub->GetYaxis()->SetTitle("Counts/0.314"); hPERPSub->Fit(fitPERP, ""); hPERPSub->SetMarkerStyle(20); hPERPSub->SetMarkerColor(color); hPERPSub->Draw("e"); //NPERP_btmp = hPERPSub->Integral(); //NPERP_btmp = fitPERP->Integral(minx, maxx); //NPERP_btmp = fitPERP->GetNpar(); TPavesText *paves = new TPavesText(-2.75, 0.8*maximum, -1.4, 0.9*maximum); paves->AddText(rebin_s); paves->SetFillColor(19); paves->Draw(); cc->cd(2); TF1* fitPARA = new TF1("psiFitPARA", "[0]*(1.0 + [1]*cos(2*(x + [2])))"); fitPARA->SetLineColor(color); hPARASub->GetYaxis()->SetTitle("Counts/0.314"); hPARASub->Fit(fitPARA, ""); hPARASub->Draw("e"); hPARASub->SetMarkerStyle(20); hPARASub->SetMarkerColor(color); //NPARA_btmp = fitPARA->GetNpar(); NPARA_btmp = fitPARA->Integral(minx, maxx); //NPARA_btmp = hPARASub->Integral(); cc->cd(3); TF1* fitAsym = new TF1("asymFit", "[0]*cos(2*(x + [1]))"); fitAsym->FixParameter(1, -0.07774); fitAsym->SetLineColor(color); hAsym->GetYaxis()->SetTitle("Asymmetry"); hAsym->Fit(fitAsym, ""); hAsym->SetMarkerStyle(20); hAsym->SetMarkerColor(color); hAsym->Draw("e"); cout<GetParError(0)<<";"<GetParameter(0); Errtmp = fitAsym->GetParError(0); cc->cd(4); TF1* fitSum = new TF1("sumFit", "[0]*(1.0 + [1]*cos(2*(x + [2])))"); fitSum->FixParameter(2, -0.07774); fitSum->SetLineColor(color); hPPSum->GetYaxis()->SetTitle("Counts/0.314"); hPPSum->Fit(fitSum, ""); hPPSum->SetMarkerStyle(20); hPPSum->SetMarkerColor(color); hPPSum->Draw("e"); cc->Print(figName+".pdf"); cc->Print(figName+".ps"); delete hPPSum; delete fitPERP; delete fitPARA; delete fitAsym; delete fitSum; delete paves; delete cc; return Asymtmp; } void drawAsymSysErrOme() { cout<<"beginning"<SetOptStat(0); gStyle->SetOptFit(1111); TString headfileName = "./histroot/ana_p2gamma_phip"; TString histName_head = "Phi_Proton_"; // add any TH1D histogram name TString hist2DName_head = "Phi_Proton_vs_IM2g_cutBE_sys_"; // add any TH1D histogram name //TString hist2DName_head = "Phi_Proton_vs_t_sys_"; // add any TH1D histogram name TString tailfileName = ".root"; TString figsName_head = "./figPhiP/standard/asym_"; //const int nsysSc=9; //The number of the source of systematic errors, such as accidentals, coherent beam energy, cut conditions const int ncutsRg=3; //The number of the different cut ranges of one source of systematic errors const int nPS=2; const int maxAsyNum = 3; const int nrebin=5; //const int nrebin=10; TString titleSc[nsysSc] = {"standard_", "accidentals_", "coherent BE_", "MMsq_", "Delta_phi_", "ME_", "MMXp_", "IM_2gamma_", "dEdx_"}; TString titleRg[ncutsRg] = {"cuta_", "cutb_", "cutc_"}; TString titlePS[nPS] = {"pi0_", "eta_"}; TString figsName_sec[maxAsyNum] = {"Tot", "Ran", "TSubR"}; TString title_rebin[nrebin] = {"01_", "02_", "04_", "05_", "10_"}; int rebin_i[nrebin] = {1, 2, 4, 5, 10}; //TString title_rebin[nrebin] = {"01_", "02_", "03_", "04_", "05_", "06_", "07_", "08_", "09_", "10_"}; int color[maxAsyNum] = {1, 4, 2}; TString figsDir = "./figsomega/"; TString histName_ome_head = "S_IM_2gamma_sys_"; TString figName_ome_head = figsDir + "Im_2g_omega"; cout<<__LINE__<2) continue; int rebin = rebin_i[m-1]; int bin = 100/rebin; for(int i=0; i2) continue; //for(int i=0; i<1; i++) // { for(int j=0; jGet(histName); hPERP->Sumw2(); TH1D* hPERPBkg = (TH1D*)fPERP->Get("Acci_" + histName); hPERPBkg->Sumw2(); hPERPBkg->Scale(normC); TH1D* hPERPSub = new TH1D("hPERPSub", histName + "_sub", 100, minx, maxx); hPERPSub->Sumw2(); hPERPSub->Add(hPERP, hPERPBkg, 1, -1); hPERPSub->Draw(); TFile *fPARA = TFile::Open(parafileName); if(!fPARA) return; TH1D* hPARA = (TH1D*)fPARA->Get(histName); hPARA->Sumw2(); TH1D* hPARABkg = (TH1D*)fPARA->Get("Acci_" + histName); hPARABkg->Sumw2(); hPARABkg->Scale(normC); TH1D* hPARASub = new TH1D("hPARASub", histName + "_sub", 100, minx, maxx); hPARASub->Sumw2(); hPARASub->Add(hPARA, hPARABkg, 1, -1); hPERPlist[0]=hPERP; hPERPlist[1]=hPERPBkg; hPERPlist[2]=hPERPSub; hPARAlist[0]=hPARA; hPARAlist[1]=hPARABkg; hPARAlist[2]=hPARASub; hPERPlist[l]->Rebin(rebin); hPARAlist[l]->Rebin(rebin); NPERP_a[m-1][i][j][k][l] = hPERPlist[l]->Integral(); NPARA_a[m-1][i][j][k][l] = hPARAlist[l]->Integral(); Norm_a[m-1][i][j][k][l] = NPERP_a[m-1][i][j][k][l]/NPARA_a[m-1][i][j][k][l]; Asym[m-1][i][j][k][l] = drawBeamAsymmetry(maxAsyNum, hPERPlist[l], hPARAlist[l], bin, norm, minx, maxx, color[l], figName[l], histName_h); Asymsig[m-1][i][j][k][l] = Asym[m-1][i][j][k][l]; if((l == 2)&&(k == 1)) { cout<<"Before correction: "<max_Asym_pi0_50bins[i]) { max_Asym_pi0_50bins[i] = Asym[1][i][j][0][2]; } cout<max_Asym_eta_50bins[i]) { max_Asym_eta_50bins[i] = Asymsig[1][i][j][1][2]; } cout<max_Sigma_pi0_50bins[i]) { max_Sigma_pi0_50bins[i] = Sigma_pi0[1][i][j]; } if(Sigma_eta[1][i][j]max_Sigma_eta_50bins[i]) { max_Sigma_eta_50bins[i] = Sigma_eta[1][i][j]; } } } min_Sigma_pi0_50bins_all = min_Sigma_pi0_50bins[0]; min_Sigma_eta_50bins_all = min_Sigma_eta_50bins[0]; max_Sigma_pi0_50bins_all = max_Sigma_pi0_50bins[0]; max_Sigma_eta_50bins_all = max_Sigma_eta_50bins[0]; for(int i=0; i