CMS 3D CMS Logo

NicePlot.cc
Go to the documentation of this file.
2 
3 #include <TROOT.h>
4 #include <TStyle.h>
5 #include <string>
6 
7 using namespace std;
8 
10  gROOT->SetStyle("Plain");
11  gStyle->SetPalette(1);
12  gStyle->SetHistMinimumZero(kTRUE);
13 
14  s1 = new Style();
15 
16  s1->SetLineWidth(2);
17  s1->SetLineColor(1);
18 
19  s2 = new Style();
20 
21  s2->SetLineWidth(2);
22  s2->SetLineColor(4);
23 
24  sg1 = new Style();
25 
26  sg1->SetMarkerColor(4);
27  sg1->SetLineColor(4);
28  sg1->SetLineWidth(2);
29  sg1->SetMarkerStyle(21);
30 
31  sback = new Style();
32  sback->SetFillStyle(1001);
33  sback->SetFillColor(5);
34 
35  spred = new Style();
36  spred->SetLineColor(2);
37  spred->SetLineWidth(2);
38  spred->SetFillStyle(1001);
39  spred->SetFillColor(kRed - 8);
40 
41  spblue = new Style();
42  spblue->SetLineColor(4);
43  spblue->SetLineWidth(2);
44 
45  sgr1 = new Style();
46  sgr1->SetLineWidth(1);
47  sgr1->SetLineColor(1);
48 
49  sgr2 = new Style();
50  sgr2->SetLineWidth(1);
51  sgr2->SetLineColor(1);
52 }
53 
54 void Styles::FormatHisto(TH1 *h, const Style *s) {
55  // h->SetStats(0);
56  h->SetTitle("CMS Preliminary");
57 
58  h->GetYaxis()->SetTitleSize(0.06);
59  h->GetYaxis()->SetTitleOffset(1.2);
60  h->GetXaxis()->SetTitleSize(0.06);
61  h->GetYaxis()->SetLabelSize(0.045);
62  h->GetXaxis()->SetLabelSize(0.045);
63 
64  h->SetLineWidth(s->GetLineWidth());
65  h->SetLineColor(s->GetLineColor());
66  h->SetFillStyle(s->GetFillStyle());
67  h->SetFillColor(s->GetFillColor());
68 }
69 
70 void Styles::FormatPad(TPad *pad, bool grid, bool logx, bool logy) {
71  pad->SetGridx(grid);
72  pad->SetGridy(grid);
73 
74  if (logx)
75  pad->SetLogx();
76  if (logy)
77  pad->SetLogy();
78 
79  pad->SetBottomMargin(0.14);
80  pad->SetLeftMargin(0.15);
81  pad->SetRightMargin(0.05);
82  pad->Modified();
83  pad->Update();
84 }
85 
86 void Styles::SavePlot(const char *name, const char *dir) {
87  string eps = dir;
88  eps += "/";
89  eps += name;
90  eps += ".eps";
91  gPad->SaveAs(eps.c_str());
92 
93  string png = dir;
94  png += "/";
95  png += name;
96  png += ".png";
97  gPad->SaveAs(png.c_str());
98 }
static void FormatHisto(TH1 *h, const Style *s)
Definition: NicePlot.cc:54
static void FormatPad(TPad *pad, bool grid=true, bool logx=false, bool logy=false)
Definition: NicePlot.cc:70
static void SavePlot(const char *name, const char *dir)
Definition: NicePlot.cc:86
Definition: Style.py:1
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Styles()
Definition: NicePlot.cc:9