{ /* zmumu_1.C Example macro to illustrate the D0 recommended style for plots Usage: in a root session type ".x zmumu_1.C;" Created: January 2003, Avto Kharchilava Updated: January 2004, --"-- Comment added: February 2005, --"-- Comment: In a ROOT session screen, as well as in a file saved as .gif, the "\349" symbol (used for D\O\ collaboration name) shows up as "é". However, the .eps file has it right. Use unix "convert" command to have, e.g., a .jpg version of the plot: "convert czmass.eps czmass.jpg" */ gROOT->Reset(); gROOT->SetStyle("Plain"); gROOT->LoadMacro("d02004style.C"); global_style(); // ... // Set this to 1 for colored version of the plot, otherwise keep it 0 int color_plot=1; // 1/0 for color/black&white plots // ... // Change colors for canvas (D=29), frame (10) and legend (29) here // int canvas_color=29; int frame_color=10; int legend_color=canvas_color; int canvas_color=19; int frame_color=10; int legend_color=10; // ... // Define canvas and its layout here TCanvas *czmass = new TCanvas("czmass"," ",10,10,400,500); // See "d02004style.C" macro for the list of "canvas_style" arguments/defaults canvas_style(czmass,.12,.04,.04,.11,0,0); // B&W if(color_plot) canvas_style(czmass,.12,.04,.04,.11,canvas_color,frame_color); // canvas_style(czmass); // Use defaults // ... // Histogram(s)/graph(s) usually will be read from a root file // This is just an example of data histogram TH1 *zmass = new TH1F("zmass","",50,0,300); zmass->SetEntries(170); zmass->SetBinContent(2,1); zmass->SetBinContent(3,1); zmass->SetBinContent(6,3); zmass->SetBinContent(7,4); zmass->SetBinContent(8,4); zmass->SetBinContent(9,3); zmass->SetBinContent(10,3); zmass->SetBinContent(11,5); zmass->SetBinContent(12,7); zmass->SetBinContent(13,15); zmass->SetBinContent(14,18); zmass->SetBinContent(15,28); zmass->SetBinContent(16,23); zmass->SetBinContent(17,16); zmass->SetBinContent(18,13); zmass->SetBinContent(19,5); zmass->SetBinContent(20,7); zmass->SetBinContent(21,3); zmass->SetBinContent(23,2); zmass->SetBinContent(24,2); zmass->SetBinContent(26,1); zmass->SetBinContent(27,2); zmass->SetBinContent(34,1); zmass->SetBinContent(38,1); zmass->SetBinContent(40,1); zmass->SetBinContent(49,1); // ... // Pass on the histogram attributes // See "d02004style.C" macro for the list of "h1_style" arguments/defaults h1_style(zmass,3,1,1, 0,0, 0.01,45., 505,505, 8,1,1.2, 0); if(color_plot) h1_style(zmass,3,4,1, 0,0, 0.01,45., 505,505, 8,4,1.2, 0); // h1_style(zmass); // Use defaults // ... Drawing style, axis title, etc. zmass->Draw("PE"); // "PE" // ... Following 3 lines ensure "unbroken" error bars; LMK of better way TH1F *zmass_t=(TH1F*)zmass->Clone(); zmass_t->SetMarkerSize(0.); zmass_t->Draw("SAMEE"); zmass->GetXaxis()->SetTitle("M_{#mu+#mu-} (GeV)"); zmass->GetYaxis()->SetTitle("Events / 6 GeV"); // ... // Example of MC histogram; again, can read in from a root file TH1 *zmass_mc = new TH1F("zmass_mc","",50,0,300); zmass_mc->SetBinContent(10,0.3); zmass_mc->SetBinContent(11,1); zmass_mc->SetBinContent(12,2); zmass_mc->SetBinContent(13,4); zmass_mc->SetBinContent(14,12); zmass_mc->SetBinContent(15,38); zmass_mc->SetBinContent(16,25); zmass_mc->SetBinContent(17,10); zmass_mc->SetBinContent(18,3); zmass_mc->SetBinContent(19,1); zmass_mc->SetBinContent(20,0.5); zmass_mc->SetBinContent(21,0.1); //... // Pass on different attributes for MC histogram // See "d02004style.C" macro for the list of "h1_style" arguments/defaults h1_style(zmass_mc,5,1,1, 0,0, 0.,45., 505,505, 21,1,1.0, 0); if(color_plot) h1_style(zmass_mc,5,2,1, 0,0, 0.,45., 505,505, 21,2,1.0, 0); // h1_style(zmass_mc); // defaults zmass_mc->Draw("SAME"); // ... // Now legend for hisograms TLegend *leg = new TLegend(0.70,0.70,0.90,0.80,NULL,"brNDC"); leg->SetTextSize(0.06); leg->SetFillStyle(0); leg->SetFillColor(0); if(color_plot) { leg->SetFillStyle(1001); leg->SetFillColor(legend_color); } //... other fancy attributes for legend leg->SetBorderSize(0); // 0; 2 // leg->SetLineColor(1); // leg->SetLineStyle(1); // leg->SetLineWidth(1); entry=leg->AddEntry(zmass,"Data","P"); entry->SetTextFont(52); entry->SetTextAlign(32); // entry->SetTextColor(1); // 3 entry=leg->AddEntry(zmass_mc,"MC","l"); entry->SetTextFont(52); entry->SetTextAlign(32); // entry->SetTextColor(1); // 2 leg->Draw(); // ... // Some more comments on the plot // Need only for outside world TText *t1 = new TText(); t1->SetTextFont(62); t1->SetTextColor(1); // 4 t1->SetTextAlign(12); t1->SetTextSize(0.06); t1->DrawTextNDC(0.38,0.92,"D\349 Run II Preliminary"); /* TLatex causes wrong symbol under MS // ... // Some more comments on the plot // Need only for outside world TLatex *tex1 = new TLatex(85.,42.,"Dé Run II Preliminary"); // TLatex *tex1 = new TLatex(85.,42.,"D#oslash Run II Preliminary"); // TLatex *tex1 = new TLatex(120.,42.,"D#oslash II Preliminary"); tex1->SetTextSize(0.06); tex1->SetTextColor(1); tex1->Draw(); // Comment this line if result is final */ TLatex *tex2 = new TLatex(180.,27.,"p_{T}^{#mu} > 15 GeV"); tex2->SetTextSize(0.055); tex2->SetTextColor(1); tex2->Draw(); TLatex *tex3 = new TLatex(180.,23.,"|#eta^{#mu}| < 2"); tex3->SetTextSize(0.055); tex3->SetTextColor(1); tex3->Draw(); // ... // Print out the plot czmass->Modified(); czmass->Print("czmass.eps"); }