DESY Hbb Analysis Framework
HttStylesNew.h
Go to the documentation of this file.
1 #ifndef Analysis_Tools_HttStylesNew_h
2 #define Analysis_Tools_HttStylesNew_h 1
3 
4 #include <TH1.h>
5 #include <TPad.h>
6 #include <TStyle.h>
7 #include <TCanvas.h>
8 #include <TLegend.h>
9 #include <TPaveText.h>
10 #include "TLatex.h"
11 #include "TH1.h"
12 
14 void SetStyle();
16 TCanvas* MakeCanvas(const char* name, const char* title, int dX=600, int dY=600);
18 void InitSubPad(TPad* pad, int i);
20 void InitHist(TH1* hist, const char* xtit, const char* ytit="Number of Entries", int color=kBlack, int style=0);
22 void InitData(TH1* hist);
24 void InitSignal(TH1* hist);
26 void SetLegendStyle(TLegend* leg);
28 void CMSPrelim(const char* dataset, double lowX=0.4, double lowY=0.74);
29 void plotchannel(TString channel);
30 
31 
32 
33 /*
34  Implementation
35 */
36 
37 
38 void SetStyle()
39 {
40  TStyle *HttStyle = new TStyle("Htt-Style","The Perfect Style for Plots ;-)");
41  gStyle = HttStyle;
42 
43  // Canvas
44  HttStyle->SetCanvasColor (0);
45  HttStyle->SetCanvasBorderSize(10);
46  HttStyle->SetCanvasBorderMode(0);
47  HttStyle->SetCanvasDefH (700);
48  HttStyle->SetCanvasDefW (700);
49  HttStyle->SetCanvasDefX (100);
50  HttStyle->SetCanvasDefY (100);
51 
52  // color palette for 2D temperature plots
53  HttStyle->SetPalette(1,0);
54 
55  // Pads
56  HttStyle->SetPadColor (0);
57  HttStyle->SetPadBorderSize (10);
58  HttStyle->SetPadBorderMode (0);
59  HttStyle->SetPadBottomMargin(0.13);
60  HttStyle->SetPadTopMargin (0.08);
61  HttStyle->SetPadLeftMargin (0.15);
62  HttStyle->SetPadRightMargin (0.05);
63  HttStyle->SetPadGridX (0);
64  HttStyle->SetPadGridY (0);
65  HttStyle->SetPadTickX (1);
66  HttStyle->SetPadTickY (1);
67 
68  // Frames
69  HttStyle->SetLineWidth(3);
70  HttStyle->SetFrameFillStyle ( 0);
71  HttStyle->SetFrameFillColor ( 0);
72  HttStyle->SetFrameLineColor ( 1);
73  HttStyle->SetFrameLineStyle ( 0);
74  HttStyle->SetFrameLineWidth ( 2);
75  HttStyle->SetFrameBorderSize(10);
76  HttStyle->SetFrameBorderMode( 0);
77 
78  // Histograms
79  HttStyle->SetHistFillColor(2);
80  HttStyle->SetHistFillStyle(0);
81  HttStyle->SetHistLineColor(1);
82  HttStyle->SetHistLineStyle(0);
83  HttStyle->SetHistLineWidth(3);
84  HttStyle->SetNdivisions(505);
85 
86  // Functions
87  HttStyle->SetFuncColor(1);
88  HttStyle->SetFuncStyle(0);
89  HttStyle->SetFuncWidth(2);
90 
91  // Various
92  HttStyle->SetMarkerStyle(20);
93  HttStyle->SetMarkerColor(kBlack);
94  HttStyle->SetMarkerSize (1.4);
95 
96  HttStyle->SetTitleBorderSize(0);
97  HttStyle->SetTitleFillColor (0);
98  HttStyle->SetTitleX (0.2);
99 
100  HttStyle->SetTitleSize (0.055,"X");
101  HttStyle->SetTitleOffset(1.200,"X");
102  HttStyle->SetLabelOffset(0.005,"X");
103  HttStyle->SetLabelSize (0.050,"X");
104  HttStyle->SetLabelFont (42 ,"X");
105 
106  HttStyle->SetStripDecimals(kFALSE);
107  HttStyle->SetLineStyleString(11,"20 10");
108 
109  HttStyle->SetTitleSize (0.055,"Y");
110  HttStyle->SetTitleOffset(1.600,"Y");
111  HttStyle->SetLabelOffset(0.010,"Y");
112  HttStyle->SetLabelSize (0.050,"Y");
113  HttStyle->SetLabelFont (42 ,"Y");
114 
115  HttStyle->SetTextSize (0.055);
116  HttStyle->SetTextFont (42);
117 
118  HttStyle->SetStatFont (42);
119  HttStyle->SetTitleFont (42);
120  HttStyle->SetTitleFont (42,"X");
121  HttStyle->SetTitleFont (42,"Y");
122 
123  HttStyle->SetOptStat (0);
124  return;
125 }
126 
127 TCanvas* MakeCanvas(const char* name, const char *title, int dX, int dY)
128 {
129  // Start with a canvas
130  TCanvas *canvas = new TCanvas(name,title,0,0,dX,dY);
131  // General overall stuff
132  canvas->SetFillColor (0);
133  canvas->SetBorderMode (0);
134  canvas->SetBorderSize (10);
135  // Set margins to reasonable defaults
136  canvas->SetLeftMargin (0.18);
137  canvas->SetRightMargin (0.05);
138  canvas->SetTopMargin (0.08);
139  canvas->SetBottomMargin (0.15);
140  // Setup a frame which makes sense
141  canvas->SetFrameFillStyle (0);
142  canvas->SetFrameLineStyle (0);
143  canvas->SetFrameBorderMode(0);
144  canvas->SetFrameBorderSize(10);
145  canvas->SetFrameFillStyle (0);
146  canvas->SetFrameLineStyle (0);
147  canvas->SetFrameBorderMode(0);
148  canvas->SetFrameBorderSize(10);
149 
150  return canvas;
151 }
152 
153 void InitSubPad(TPad* pad, int i)
154 {
155  pad->cd(i);
156  TPad *tmpPad = (TPad*) pad->GetPad(i);
157  tmpPad->SetLeftMargin (0.18);
158  tmpPad->SetTopMargin (0.05);
159  tmpPad->SetRightMargin (0.07);
160  tmpPad->SetBottomMargin(0.15);
161  return;
162 }
163 
164 void InitSignal(TH1 *hist)
165 {
166  hist->SetFillStyle(0.);
167  hist->SetLineStyle(11);
168  hist->SetLineWidth(2.);
169  hist->SetLineColor(kBlue+3);
170 }
171 
172 void InitHist(TH1 *hist, const char *xtit, const char *ytit, int color, int style)
173 {
174  hist->SetXTitle(xtit);
175  hist->SetYTitle(ytit);
176  hist->SetLineColor(kBlack);
177  hist->SetLineWidth( 2.);
178  hist->SetFillColor(color );
179  hist->SetFillStyle(style );
180  hist->SetTitleSize (0.055,"Y");
181  hist->SetTitleOffset(1.600,"Y");
182  hist->SetLabelOffset(0.014,"Y");
183  hist->SetLabelSize (0.040,"Y");
184  hist->SetLabelFont (42 ,"Y");
185  hist->SetTitleSize (0.055,"X");
186  hist->SetTitleOffset(1.300,"X");
187  hist->SetLabelOffset(0.014,"X");
188  hist->SetLabelSize (0.050,"X");
189  hist->SetLabelFont (42 ,"X");
190  hist->SetMarkerStyle(20);
191  hist->SetMarkerColor(color);
192  hist->SetMarkerSize (0.6);
193  hist->GetYaxis()->SetTitleFont(42);
194  hist->GetXaxis()->SetTitleFont(42);
195  hist->SetTitle("");
196  return;
197 }
198 
199 void InitData(TH1* hist)
200 {
201  hist->SetMarkerStyle(20.);
202  hist->SetMarkerSize (1.3);
203  hist->SetLineWidth ( 2.);
204 }
205 
206 void SetLegendStyle(TLegend* leg)
207 {
208  leg->SetFillStyle (0);
209  leg->SetFillColor (0);
210  leg->SetBorderSize(0);
211 }
212 
213 void CMSPrelim(const char* dataset, double lowX, double lowY)
214 {
215  TPaveText* cmsprel = new TPaveText(lowX, lowY+0.06, lowX+0.30, lowY+0.16, "NDC");
216  cmsprel->SetBorderSize( 0 );
217  cmsprel->SetFillStyle( 0 );
218  cmsprel->SetTextAlign( 12 );
219  cmsprel->SetTextSize ( 0.05 );
220  cmsprel->SetTextColor( 1 );
221  cmsprel->SetTextFont ( 62 );
222  cmsprel->AddText("CMS");
223  cmsprel->Draw();
224 
225  TPaveText* lumi = new TPaveText(lowX+0.08, lowY+0.061, lowX+0.45, lowY+0.161, "NDC");
226  lumi->SetBorderSize( 0 );
227  lumi->SetFillStyle( 0 );
228  lumi->SetTextAlign( 12 );
229  lumi->SetTextSize ( 0.05 );
230  lumi->SetTextColor( 1 );
231  lumi->SetTextFont ( 62 );
232  lumi->AddText(dataset);
233  lumi->Draw();
234 
235 }
236 void plotchannel(TString channel) {
237 
238  TLatex * tex = new TLatex(0.2,0.94,channel);
239  tex->SetNDC();
240  tex->SetTextSize(0.06);
241  tex->SetLineWidth(2);
242  tex->Draw();
243 
244 }
245 
246 #endif
void plotchannel(TString channel)
Definition: HttStylesNew.h:236
void SetLegendStyle(TLegend *leg)
define common legend style
Definition: HttStylesNew.h:206
void InitSignal(TH1 *hist)
define line style, width and color for signal sample
Definition: HttStylesNew.h:164
void InitData(TH1 *hist)
define poly markers and line width for data
Definition: HttStylesNew.h:199
std::string leg[10]
Definition: PlotsCompare.cc:29
void InitSubPad(TPad *pad, int i)
define common style of pads
Definition: HttStylesNew.h:153
TCanvas * MakeCanvas(const char *name, const char *title, int dX=600, int dY=600)
create a canveas in common style (default is square)
Definition: HttStylesNew.h:127
void InitHist(TH1 *hist, const char *xtit, const char *ytit="Number of Entries", int color=kBlack, int style=0)
define a histogram file (not yet including poly markers, which are used fro data) ...
Definition: HttStylesNew.h:172
void SetStyle()
define common styles
Definition: HttStylesNew.h:38
void CMSPrelim(const char *dataset, double lowX=0.4, double lowY=0.74)
add CMSPreliminary logo, lumi and channel
Definition: HttStylesNew.h:213