{ //..General setup to get nice looking plots. Based on workdir/RooLogon.C //..Set the style to BABAR, then force pre-existing histograms to // adopt this style gROOT->Reset(); gROOT->SetStyle("BABAR"); gROOT->ForceStyle(); TCanvas MyC("MyC"); //-------------------------------------------------------------------- //..Specialize the following for the specific histogram // Note that the name of drawing macro cannot be the same as the // histogram name, or else the f.Get gets confused. //..Read in the histogram. Note that to manipulate histograms in a macro, // you first need to explicitly create a pointer. TFile f("histAnalysis-final.root"); TH1* hmassJpsi_sig = (TH1*) f.Get("hmassJpsi_sig"); //..I like filled circles as the marker, but the default size is a bit big. // For a different symbol, try hmassJpsi_sig->SetMarkerStyle(n); hmassJpsi_sig->SetMarkerSize(0.8); //..Define the histogram maximum to be a nice round number Float_t ymax(70.); hmassJpsi_sig->SetMaximum(ymax); //..Plot markers (P) and force a marker even if zero entries (0) // Then plot again with error bars on the same canvas. // In principle, could be done in a single command but it doesn't work. hmassJpsi_sig->Draw("P0"); hmassJpsi_sig->Draw("Esame"); //..Add lines marking a selected Jpsi mass range TLine *l1 = new TLine(); l1->SetLineWidth(2); l1->SetLineStyle(2); l1->SetLineColor(2); l1->DrawLine(3.05, 0, 3.05, ymax); l1->DrawLine(3.14, 0, 3.14, ymax); //..The vertical title has a superscript, so move it a bit closer to // axis so that it does not run off the page. Text is basically // Latex math mode, but with a # instead of \ to get symbols. hmassJpsi_sig->GetYaxis()->SetTitleOffset(0.9); hmassJpsi_sig->SetXTitle("J/#psi Candidate Mass (GeV/c^{2})"); hmassJpsi_sig->SetYTitle("Entries per 7 MeV/c^{2}"); //..For publication, you should generally use fewer axis tick marks. // On the y axis, for example, this gives approximately 4 major and 2 // minor divisions. -204 would give exactly 4 and 2. hmassJpsi_sig->GetXaxis()->SetNdivisions(505); hmassJpsi_sig->GetYaxis()->SetNdivisions(204); //..The 0 and 2.9 axis labels collide, so move the X labels a bit hmassJpsi_sig->GetXaxis()->SetLabelOffset(0.015); //..Put BaBar preliminary label BABARSmartLabel(-1,-1,-1,"~1",-1,-1); //..Print out a eps version. Or .ps or .gif if you prefer. MyC->Print("JpsiMass.eps"); }