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