#include "StandardLabels.C" void pres_vs_p_vs_theta_discrete(const char *suffix="") { gROOT->Reset(); gStyle->SetPalette(1); TCanvas *c1 = new TCanvas("c1"); c1->SetTicks(); c1->SetGrid(); char fname[256]; sprintf(fname, "hd_res_charged%s.root", suffix); TFile *f = new TFile(fname); TH2D *dp_over_p_sigma = (TH2D*)gROOT->FindObject("dp_over_p_sigma"); // Draw empty axes TH2D *axes = new TH2D("axes", "Total momentum resolution", 100, 0.0, 9, 100, 0.0, 0.14); axes->SetStats(0); axes->SetXTitle("Polar angle #theta (degrees)"); axes->SetYTitle("Total Momentum Resolution (fraction)"); axes->Draw(); // Make legend TLegend *leg = new TLegend(0.40, 0.5, 0.60, 0.65); leg->SetFillColor(kWhite); // Loop over momenta to plot TAxis *yaxis = dp_over_p_sigma->GetYaxis(); double mom[]={0.35, 0.5, 1.0, 2.0}; int Nmom = 4; int colors[] = {kBlue, kRed, kGreen, kMagenta}; int styles[] = {20, 21, 22, 23}; for(int i=0; iFindBin(mom[i]); cout<<"Projecting for momentum="<ProjectionX("_px",ybin,ybin); dp_over_p_sigma_px = (TH1D*)gROOT->FindObject("dp_over_p_sigma_px"); char hname[256]; sprintf(hname, "h%d", i); TH1D *h = (TH1D*)dp_over_p_sigma_px->Clone(hname); h->SetLineColor(colors[i]); h->SetMarkerColor(colors[i]); h->SetMarkerStyle(styles[i]); h->Draw("sameP"); char lab[256]; sprintf(lab, "%3.3f GeV/c", mom[i]); leg->AddEntry(h, lab); } leg->Draw(); // Add standard labeling StandardLabels2D(axes, suffix); char fname[256]; sprintf(fname, "pres_vs_p_vs_theta_discrete%s.gif", suffix); c1->SaveAs(fname); sprintf(fname, "pres_vs_p_vs_theta_discrete%s.pdf", suffix); c1->SaveAs(fname); }