void plotGraph(map<anabin, TGraphAsymmErrors*> theGraphs, map<anabin, TGraphAsymmErrors*> theGraphs_syst, string xaxis, string outputDir, map<anabin, syst> gsyst) { setTDRStyle(); TCanvas *c1 = NULL; if (xaxis=="cent") c1 = new TCanvas("c1","c1",600/xfrac,600); else c1 = new TCanvas("c1","c1",600,600); // in the case of the centrality dependence, we need the minimum bias panel on the right TPad *padl=NULL, *padr=NULL; if (xaxis=="cent") { padl = new TPad("padl_left","",0,0,xfrac,1); padl->SetLeftMargin(gStyle->GetPadLeftMargin()/xfrac); padl->SetRightMargin(0); // padl->SetBottomMargin(gStyle->GetPadBottomMargin()); // padl->SetTopMargin(gStyle->GetPadTopMargin()); padl->SetFrameBorderMode(0); padl->SetBorderMode(0); padl->SetBorderSize(0); padl->Draw(); padr = new TPad("padr_right","",xfrac,0,1,1); padr->SetRightMargin(gStyle->GetPadRightMargin()/(1.-xfrac)); padr->SetLeftMargin(0); // padr->SetBottomMargin(gStyle->GetPadBottomMargin()); // padr->SetTopMargin(gStyle->GetPadTopMargin()); padr->SetFrameBorderMode(0); padr->SetBorderMode(0); padr->SetBorderSize(0); padr->Draw(); padl->cd(); } // the axes TH1F *haxes=NULL, *haxesr=NULL; TLine line, liner; if (xaxis=="pt") { haxes = new TH1F("haxes","haxes",1,0,30); line = TLine(0,1,30,1); } if (xaxis=="cent") { haxes = new TH1F("haxesl","haxesl",1,0,420); haxes->GetXaxis()->SetTickLength(gStyle->GetTickLength("X")/xfrac); // haxes->GetYaxis()->SetTickLength(gStyle->GetTickLength("Y")*xfrac); line = TLine(0,1,420,1); haxesr = new TH1F("haxesr","haxesr",1,0,420); haxesr->GetXaxis()->SetTickLength(0); haxesr->GetYaxis()->SetTickLength(gStyle->GetTickLength("Y")/(1.-xfrac)); haxesr->GetYaxis()->SetRangeUser(0,1.5); haxesr->GetXaxis()->SetTitleSize(0); haxesr->GetXaxis()->SetLabelSize(0); liner = TLine(0,1,420,1); } haxes->GetYaxis()->SetRangeUser(0,1.5); haxes->GetYaxis()->SetTitle(ylabel); const char* xlabel = (xaxis=="pt") ? "p_{T} (GeV/c)" : "N_{part}"; haxes->GetXaxis()->SetTitle(xlabel); haxes->Draw(); line.Draw(); if (xaxis=="cent") { padr->cd(); haxesr->Draw(); liner.Draw(); padl->cd(); } double xshift=0.; if (xaxis=="cent") xshift=0.05; TLegend *tleg = new TLegend(0.16+xshift,0.73,0.50,0.89); tleg->SetBorderSize(0); tleg->SetTextSize(0.03); // prepare for the printing of the result tables const char* xname = (xaxis=="cent") ? "Centrality" : "\\pt"; gSystem->mkdir(Form("Output/%s/tex/", outputDir.c_str()), kTRUE); char texname[2048]; sprintf(texname, "Output/%s/tex/result_%s.tex",outputDir.c_str(),xaxis.c_str()); string yname("\\doubleratio"); inittex(texname, xname, yname); int cnt=0; map<anabin, TGraphAsymmErrors*>::const_iterator it=theGraphs.begin(); map<anabin, TGraphAsymmErrors*>::const_iterator it_syst=theGraphs_syst.begin(); for (; it!=theGraphs.end(); it++) { anabin thebin = it->first; bool isMB = (thebin.centbin().low()<=0 && thebin.centbin().high()<=0); TGraphAsymmErrors* tg = it->second; TGraphAsymmErrors* tg_syst = it_syst->second; if (!tg || !tg_syst) continue; if (thebin.rapbin() == binF(0.,1.6)) { tg->SetMarkerStyle(kFullSquare); tg->SetMarkerColor(kRed); tg->SetLineColor(kRed); tg_syst->SetFillColorAlpha(kRed, 0.5); } else if (thebin.rapbin() == binF(1.6,2.4)) { tg->SetMarkerStyle(kFullCircle); tg->SetMarkerColor(kBlue); tg->SetLineColor(kBlue); tg_syst->SetFillColorAlpha(kBlue, 0.5); } else { tg->SetMarkerStyle(kFullTriangleUp); tg->SetMarkerColor(kGreen); tg->SetLineColor(kGreen); tg_syst->SetFillColorAlpha(kGreen, 0.5); } if (xaxis=="cent") { if (thebin.centbin().low()<=0 && thebin.centbin().high()<=0) padr->cd(); else padl->cd(); } tg_syst->Draw("2"); tg->Draw("P"); TString raplabel = Form("%.1f < |y| < %.1f, ",it->first.rapbin().low(),it->first.rapbin().high()); TString otherlabel = "BWAA"; if (xaxis == "pt") otherlabel.Form("%i%s-%i%s",(int) (it->first.centbin().low()/2.), "%", (int) (it->first.centbin().high()/2.), "%"); if (xaxis == "cent") otherlabel.Form("%.1f < p_{T} < %.1f GeV/c",it->first.ptbin().low(), it->first.ptbin().high()); if (!isMB) { tleg->AddEntry(tg, (raplabel + otherlabel), "p"); } // print tex ostringstream oss; oss.precision(1); oss.setf(ios::fixed); oss << "$" << it->first.rapbin().low() << "<|y|<" << it->first.rapbin().high() << "$, "; if (xaxis == "pt") oss << (int) (it->first.centbin().low()/2.) << "\\% - " << (int) (it->first.centbin().high()/2.) << "\\%"; if (xaxis == "cent") oss << "$" << it->first.ptbin().low() << "<\\pt<" << it->first.ptbin().high() << "\\GeVc $"; addline(texname,oss.str()); printGraph(tg, tg_syst, texname); // for the centrality dependence: we want Npart plotted, not the centrality if (xaxis == "cent") { centrality2npart(tg, false, isMB, (150./1.6)*it->first.rapbin().low()); centrality2npart(tg_syst, true, isMB, (150./1.6)*it->first.rapbin().low()); } // in the case where the centrality dependence is plotted: treat the PP uncertainties as global systematics if (xaxis == "cent" && !isMB) { double x, dx, y, dy; dx = 10; x = 2*dx*(thebin.rapbin().low()/1.6) + dx; y = 1; anabin thebin(it->first.rapbin().low(), it->first.rapbin().high(), it->first.ptbin().low(), it->first.ptbin().high(), 0,200); dy = gsyst[thebin].value; cout << "global syst: " << dy << endl; TBox *tbox = new TBox(x-dx,y-dy,x+dx,y+dy); if (thebin.rapbin() == binF((float) 0.,1.6)) tbox->SetFillColorAlpha(kRed, 0.5); else if (thebin.rapbin() == binF(1.6,2.4)) tbox->SetFillColorAlpha(kBlue, 0.5); else tbox->SetFillColorAlpha(kGreen, 0.5); tbox->Draw(); } cnt++; it_syst++; } if (xaxis=="cent") padl->cd(); tleg->Draw(); int iPos = 33; CMS_lumi( (TPad*) gPad, 105, iPos, "PbPb-PP" ); c1->cd(); c1->Update(); c1->RedrawAxis(); gSystem->mkdir(Form("Output/%s/plot/RESULT/root/", outputDir.c_str()), kTRUE); c1->SaveAs(Form("Output/%s/plot/RESULT/root/result_%s.root",outputDir.c_str(), xaxis.c_str())); gSystem->mkdir(Form("Output/%s/plot/RESULT/png/", outputDir.c_str()), kTRUE); c1->SaveAs(Form("Output/%s/plot/RESULT/png/result_%s.png",outputDir.c_str(), xaxis.c_str())); gSystem->mkdir(Form("Output/%s/plot/RESULT/pdf/", outputDir.c_str()), kTRUE); c1->SaveAs(Form("Output/%s/plot/RESULT/pdf/result_%s.pdf",outputDir.c_str(), xaxis.c_str())); delete c1; // close tex closetex(texname); cout << "Closed " << texname << endl; }