//void b2style_pad() const int belle2_font = 133; const double belle2_tsize = 26; void set_style() { gROOT->SetStyle("Modern"); TStyle *belle2Style = new TStyle("BelleII","Belle II style"); // set the paper & margin sizes belle2Style->SetPaperSize(20,26); // set canvas, pads, etc. //belle2Style->SetCanvasDefW(600); //belle2Style->SetCanvasDefH(600); //belle2Style->SetCanvasDefW(600); //belle2Style->SetCanvasDefH(600); //belle2Style->SetFillColor(1); //belle2Style->SetFillStyle(1001); belle2Style->SetFrameFillColor(0); belle2Style->SetFrameBorderMode(0); belle2Style->SetPadBorderMode(0); belle2Style->SetPadColor(0); belle2Style->SetCanvasBorderMode(0); belle2Style->SetCanvasColor(0); belle2Style->SetStatColor(0); belle2Style->SetLegendBorderSize(0); // set margin sizes belle2Style->SetPadTopMargin(0.05); belle2Style->SetPadRightMargin(0.05); belle2Style->SetPadBottomMargin(0.16); belle2Style->SetPadLeftMargin(0.16); // use large fonts belle2Style->SetTextFont(belle2_font); belle2Style->SetTextSize(belle2_tsize); belle2Style->SetLabelFont(belle2_font,"x"); belle2Style->SetTitleFont(belle2_font,"x"); belle2Style->SetLabelFont(belle2_font,"y"); belle2Style->SetTitleFont(belle2_font,"y"); belle2Style->SetLabelFont(belle2_font,"z"); belle2Style->SetTitleFont(belle2_font,"z"); belle2Style->SetLabelSize(belle2_tsize,"x"); belle2Style->SetLabelSize(belle2_tsize,"y"); belle2Style->SetLabelSize(belle2_tsize,"z"); belle2Style->SetTitleSize(belle2_tsize,"x"); belle2Style->SetTitleSize(belle2_tsize,"y"); belle2Style->SetTitleSize(belle2_tsize,"z"); belle2Style->SetTitleOffset(1.5,"x"); belle2Style->SetTitleOffset(1.5,"y"); belle2Style->SetTitleOffset(1.5,"z"); belle2Style->SetLabelOffset(0.01,"x"); belle2Style->SetLabelOffset(0.01,"y"); belle2Style->SetLabelOffset(0.01,"z"); belle2Style->SetLegendFont(belle2_font); // use bold lines and markers belle2Style->SetMarkerStyle(20); belle2Style->SetMarkerSize(1.0); belle2Style->SetHistLineWidth(2); belle2Style->SetFrameLineWidth(2); belle2Style->SetLineWidth(2); belle2Style->SetFuncWidth(2); belle2Style->SetLineStyleString(2,"[12 12]");// postscript dashes // get rid of X error bars //belle2Style->SetErrorX(0.001); // get rid of error bar caps belle2Style->SetEndErrorSize(0.); // do not display any of the standard histogram decorations belle2Style->SetOptTitle(0); belle2Style->SetOptStat(0); belle2Style->SetOptFit(0); // put tick marks on top and RHS of plots belle2Style->SetPadTickX(1); belle2Style->SetPadTickY(1); // histogram divisions: only 5 in x to avoid label overlaps belle2Style->SetNdivisions(505,"x"); belle2Style->SetNdivisions(510,"y"); // function belle2Style->SetFuncColor(kBlue); belle2Style->SetFuncStyle(0); // legend belle2Style->SetLegendBorderSize(0); belle2Style->SetLegendFillColor(0); belle2Style->SetHistMinimumZero(); std::cout << "-------------------------" << std::endl; std::cout << "Set Belle II Style" << std::endl; std::cout << "-------------------------" << std::endl; gROOT->SetStyle("BelleII"); gROOT->ForceStyle(); TGaxis::SetMaxDigits(4); } TGraph *make_swapped_graph(TH1 *h1) { // copy all points from histogram TGraph *gr = new TGraph(h1); Int_t nbins = gr->GetN(); Double_t x,y; // swap x/y coordinates for (int n=0;nGetPoint(n,x,y); gr->SetPoint(n,y,x); } return gr; } TGraph *make_swapped_graph1(TH1 *h2) { // copy all points from histogram TGraph *gr3 = new TGraph(h2); Int_t nbins1 = gr3->GetN(); Double_t x1,y1; // swap x/y coordinates for (int n=0;nGetPoint(n,x1,y1); //gr3->SetPoint(n,y1,x1); } return gr3; } void DividePad(Int_t nx, Int_t ny, Float_t l, Float_t r, Float_t t, Float_t b, TPad *gpad) { if(!gpad) gpad = (TPad*) gPad; gpad->SetTopMargin(0.); gpad->SetBottomMargin(0.); gpad->SetLeftMargin(0.); gpad->SetRightMargin(0.); Int_t ix, iy, n=0; Double_t x1, x2, y1, y2; Double_t dx = ((1-r)*(1-l))/((1-r)*(1-l)*(nx-2)-r+2-l); Double_t dl = dx/(1-l); Double_t dy = ((1-t)*(1-b))/((1-t)*(1-b)*(ny-2)-t+2-b); Double_t db = dy/(1-b); y1 = 0; y2 = db; for (iy=0; iy x2) continue; n++; const char *name = Form("%s_%d",gpad->GetName(),n); TPad *pad = new TPad(name,name,x1,y1,x2,y2,0); pad->SetTopMargin(0.); pad->SetBottomMargin(0.); pad->SetLeftMargin(0.); pad->SetRightMargin(0.); if (ix==0) pad->SetLeftMargin(l); if (ix==nx-1) pad->SetRightMargin(r); if (iy==ny-1) pad->SetTopMargin(t); if (iy==0) pad->SetBottomMargin(b); x1 = x2; if (ix==nx-2) x2 = 1; else x2 = x1+dx; pad->SetNumber(n ); pad->Draw(); } y1 = y2; if (iy==ny-2) y2 = 1; else y2 = y1+dy; } } void b2_style_pad() { TCanvas *c = new TCanvas("c","c",600,600); DividePad(2,2,0.2,0.2,0.2,0.2); // Create, fill and project a 2D histogram. TH2F *h1 = new TH2F("ks_fde","",100, -50,400,100,-50,400); TH2F *h2 = new TH2F("ks_fde_sig","",100, -50,400,100,-50,400); TLine *l1 = new TLine(20,0,20,1720); TLine *l2 = new TLine(20,0,20,1055); TFile *f = new TFile("for_fds_plots.root"); TTree *tree = (TTree*)f->Get("DstD0PiKSKS"); Double_t KS1_flightDistance, KS1_flightDistanceErr,KS2_flightDistance, KS2_flightDistanceErr, Dst_isSignalAcceptMissingGamma, KS1_mcFlightDistance, KS2_mcFlightDistance; tree->SetBranchAddress("KS1_flightDistance",&KS1_flightDistance); tree->SetBranchAddress("KS2_flightDistance",&KS2_flightDistance); tree->SetBranchAddress("KS1_flightDistanceErr",&KS1_flightDistanceErr); tree->SetBranchAddress("KS2_flightDistanceErr",&KS2_flightDistanceErr); tree->SetBranchAddress("Dst_isSignalAcceptMissingGamma",&Dst_isSignalAcceptMissingGamma); Int_t nentries = (Int_t)tree->GetEntries(); for (Int_t i=0; iGetEntry(i); h1->Fill(KS1_flightDistance/(KS1_flightDistanceErr),KS2_flightDistance/(KS2_flightDistanceErr)); //h1->GetXaxis()->SetTitle("flight distance significance (lower momentum K^{0}_{S})"); //h1->GetXaxis()->SetTitleSize(0.05); //h1->GetYaxis()->SetTitle("flight distance significance (higher momentum K^{0}_{S})"); //h1->GetYaxis()->SetTitleSize(0.04); //h1->GetYaxis()->SetTitleOffset(1); if(Dst_isSignalAcceptMissingGamma==1){ h2->Fill(KS1_flightDistance/(KS1_flightDistanceErr),KS2_flightDistance/(KS2_flightDistanceErr)); } } TH1D * projh2X = h1->ProjectionX(); TH1D * projh2Y = h1->ProjectionY(); TH1D * projh2X_sig = h2->ProjectionX(); TH1D * projh2Y_sig = h2->ProjectionY(); // Drawing //center_pad->cd(); c->cd(1); gStyle->SetPalette(1); h1->SetMarkerColor(kBlue); h1->SetMarkerStyle(20); h1->SetMarkerSize(0.3); h1->Draw(); h2->SetMarkerColor(kRed); h2->SetMarkerStyle(20); h2->SetMarkerSize(1); h2->Draw("same"); /*top_pad->cd(); projh2X->SetLineColor(kBlue); projh2X->SetLineWidth(2); projh2X->Draw(""); projh2X_sig->Scale(50); projh2X_sig->SetLineColor(kRed); projh2X_sig->SetLineWidth(2); projh2X_sig->Draw("same"); l1->Draw("same"); l1->SetLineWidth(2); l1->SetLineStyle(2);*/ c->cd(3); projh2X->SetLineColor(kBlue); projh2X->SetFillStyle(0); projh2X->SetLineStyle(1); projh2X->SetLineWidth(2); // projh2Y->Draw("hbar"); projh2X_sig->Scale(50); //sprojh2Y_sig->Draw(""); // projh2Y_sig->Draw("hbar same"); projh2X_sig->SetLineColor(kRed); projh2X_sig->SetLineStyle(1); projh2X_sig->SetLineWidth(2); l1->Draw("same"); l1->SetLineWidth(2); l1->SetLineStyle(2); TGraph *gr4 = make_swapped_graph1(projh2X); TGraph *gr5 = make_swapped_graph1(projh2X_sig); // draw only for axis gr4->Draw("AL"); gr5->Draw("L"); //top_pad->Update(); padprojx->Draw(); gr5->GetHistogram()->SetMinimum(-50); gr5->GetHistogram()->SetMaximum(400); c->cd(2); projh2Y->SetLineColor(kBlue); projh2Y->SetFillStyle(0); projh2Y->SetLineStyle(1); projh2Y->SetLineWidth(2); // projh2Y->Draw("hbar"); projh2Y_sig->Scale(50); //sprojh2Y_sig->Draw(""); // projh2Y_sig->Draw("hbar same"); projh2Y_sig->SetLineColor(kRed); projh2Y_sig->SetLineStyle(1); projh2Y_sig->SetLineWidth(2); //l2->Draw("same"); //l2->SetLineWidth(2); //l2->SetLineStyle(2); TGraph *gr1 = make_swapped_graph(projh2Y); TGraph *gr2 = make_swapped_graph(projh2Y_sig); // draw only for axis gr1->Draw("AL"); gr2->Draw("L"); //right_pad->Update(); padprojy->Update(); gr1->GetHistogram()->SetMinimum(-50); gr1->GetHistogram()->SetMaximum(400); set_style(); //padprojxy->cd(); cHist->cd(); //c1->cd(); TLatex *logo = new TLatex(); //logo->SetNDC(); //logo->SetTextSize(belle2_tsize); logo->DrawLatex(0.55,0.90, "#bf{#it{Belle II}} simulation"); logo->DrawLatex(0.55,0.84, " #it{#scale[0.6]{#int} L dt} = 70 fb^{#minus1}"); logo->DrawLatex(0.55,0.78,"#it{D}^{0}#rightarrow#it{K}^{0}_{S}#it{K}^{0}_{S}"); TLegend *legend = new TLegend(.75,.80,.95,.95); legend->AddEntry( projh2X_sig,"Signal X50"); //legend->AddEntry(h2,"Signal"); legend->AddEntry( projh2X,"Total"); legend->AddEntry(l1," > 20","l"); legend->Draw(); //center_pad->cd(); c->cd(); /* TLatex *logo = new TLatex(); //logo->SetNDC(); //logo->SetTextSize(belle2_tsize); logo->DrawLatex(0.66,0.90, "#bf{#it{Belle II}} simulation"); logo->DrawLatex(0.64,0.84, " #it{#scale[0.6]{#int} L dt} = 70 fb^{#minus1}"); logo->DrawLatex(0.65,0.78,"#it{D}^{0}#rightarrow#it{K}^{0}_{S}#it{K}^{0}_{S}");*/ TLegend *legend1 = new TLegend(.75,.80,.95,.95); legend1->AddEntry(h2,"Signal"); legend1->AddEntry( h1,"Total"); legend1->Draw(); }