void Eres_vs_p_vs_theta(const char *suffix="") { gROOT->Reset(); gStyle->SetPalette(1); gStyle->SetPadRightMargin(0.15); TCanvas *c1 = new TCanvas("c1"); c1->SetTicks(); TFile *f = new TFile("hd_res_photon.root"); TH2D *h = (TH2D*)gROOT->FindObject("dE_over_E_vs_p_vs_theta"); h->SetTitle("Reconstructed #gamma energy resolution (relative) vs. p_{tot} and #theta"); h->GetXaxis()->SetRangeUser(0.0, 130.0); h->SetZTitle("#sigma(#deltaE/E)"); h->Draw("colz"); AddStandardLabels(h); char fname[256]; sprintf(fname, "Eres_vs_p_vs_theta%s.gif", suffix); c1->SaveAs(fname); sprintf(fname, "Eres_vs_p_vs_theta%s.pdf", suffix); c1->SaveAs(fname); } //---------------- // AddStandardLabels //---------------- void AddStandardLabels(TH2D *axes=NULL) { // This will draw a label or two on the // current plot using the NDC coordinates. // It is put here to make sure all plots have // a consistent labeling. // Date, Author TLatex *lab = new TLatex(0.4, 0.7, "Feb. 15, 2009 DL"); ConvertFromNDC(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(33); lab->Draw(); // SVN Revision lab = new TLatex(0.4, 0.645, "svn revision: 4865"); ConvertFromNDC(lab, axes); lab->SetTextSize(0.02); lab->SetTextAlign(31); lab->Draw(); // Event type lab = new TLatex(0.275, 0.6, "Single #gamma"); ConvertFromNDC(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(31); lab->Draw(); } //---------------- // ConvertFromNDC //---------------- void ConvertFromNDC(TLatex *obj, TH2D *h=NULL) { // Bugs in ROOT make it hard to plot labels consistently. // For 1D plots, the histogram axes define the coordinate // system. For 2D plots, we seem to be forced to use the // NDC. There does not seem to be an obvious way to tell // which we're using so we pass the information in in the // form of the "axes" histogram. If it is not NULL, then // we use it to define the limits. Otherwise, we do nothing. if(h==NULL)return; TAxis *xaxis = h->GetXaxis(); int Nbinsx = xaxis->GetNbins(); double xmin = xaxis->GetBinLowEdge(1); double xmax = xmin + xaxis->GetBinLowEdge(Nbinsx); TAxis *yaxis = h->GetYaxis(); int Nbinsy = yaxis->GetNbins(); double ymin = yaxis->GetBinLowEdge(1); double ymax = ymin + yaxis->GetBinLowEdge(Nbinsy); double x = obj->GetX(); double y = obj->GetY(); cout<<" in: x="<