#include "StandardLabels.C" void Ncdchits_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 *Ncdchits_on_track = (TH2D*)gROOT->FindObject("Ncdchits_on_track"); // Draw empty axes TH2D *axes = new TH2D("axes", "CDC wires on track", 100, 0.0, 9, 100, 0.0, 50.0); axes->SetStats(0); axes->SetXTitle("Polar angle #theta (degrees)"); axes->SetYTitle("Number of CDC wires on track"); axes->Draw(); // Make legend TLegend *leg = new TLegend(0.567, 0.223, 0.768, 0.3745); leg->SetFillColor(kWhite); // Loop over momenta to plot TAxis *yaxis = Ncdchits_on_track->GetYaxis(); double mom[]={0.350, 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); Ncdchits_on_track_px = (TH1D*)gROOT->FindObject("Ncdchits_on_track_px"); char hname[256]; sprintf(hname, "h%d", i); TH1D *h = (TH1D*)Ncdchits_on_track_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, "Ncdchits_vs_p_vs_theta_discrete%s.gif", suffix); c1->SaveAs(fname); sprintf(fname, "Ncdchits_vs_p_vs_theta_discrete%s.pdf", suffix); c1->SaveAs(fname); }