MINT2
Functions
lhcbStyle.h File Reference
#include "TLatex.h"
#include "TStyle.h"
#include "TText.h"
#include "TPaveText.h"
#include "TColor.h"
#include "TROOT.h"

Go to the source code of this file.

Functions

void SetLHCbStyle ()
 
TStyle * LHCbStyle ()
 

Function Documentation

◆ LHCbStyle()

TStyle* LHCbStyle ( )

Definition at line 231 of file lhcbStyle.h.

232 {
233 
234 // // define names for colours
235 // Int_t black = 1;
236 // Int_t red = 2;
237 // Int_t green = 3;
238 // Int_t blue = 4;
239 // Int_t yellow = 5;
240 // Int_t magenta= 6;
241 // Int_t cyan = 7;
242 // Int_t purple = 9;
243 
244 
245 
246 
248  // PURPOSE:
249  //
250  // This macro defines a standard style for (black-and-white)
251  // "publication quality" LHCb ROOT plots.
252  //
253  // USAGE:
254  //
255  // Include the lines
256  // gROOT->ProcessLine(".L lhcbstyle.C");
257  // lhcbStyle();
258  // at the beginning of your root macro.
259  //
260  // Example usage is given in myPlot.C
261  //
262  // COMMENTS:
263  //
264  // Font:
265  //
266  // The font is chosen to be 132, this is Times New Roman (like the text of
267  // your document) with precision 2.
268  //
269  // "Landscape histograms":
270  //
271  // The style here is designed for more or less square plots.
272  // For longer histograms, or canvas with many pads, adjustements are needed.
273  // For instance, for a canvas with 1x5 histograms:
274  // TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800);
275  // c1->Divide(1,5);
276  // Adaptions like the following will be needed:
277  // gStyle->SetTickLength(0.05,"x");
278  // gStyle->SetTickLength(0.01,"y");
279  // gStyle->SetLabelSize(0.15,"x");
280  // gStyle->SetLabelSize(0.1,"y");
281  // gStyle->SetStatW(0.15);
282  // gStyle->SetStatH(0.5);
283  //
284  // Authors: Thomas Schietinger, Andrew Powell, Chris Parkes, Niels Tuning
285  // Maintained by Editorial board member (currently Niels)
287 
288  // Use times new roman, precision 2
289  Int_t lhcbFont = 132; // Old LHCb style: 62;
290  // Line thickness
291  Double_t lhcbWidth = 2.00; // Old LHCb style: 3.00;
292  // Text size
293  Double_t lhcbTSize = 0.06;
294 
295  // use plain black on white colors
296  gROOT->SetStyle("Plain");
297  TStyle *lhcbStyle= new TStyle("lhcbStyle","LHCb plots style");
298 
299  //lhcbStyle->SetErrorX(0); // don't suppress the error bar along X
300 
301  lhcbStyle->SetFillColor(1);
302  lhcbStyle->SetFillStyle(1001); // solid
303  lhcbStyle->SetFrameFillColor(0);
304  lhcbStyle->SetFrameBorderMode(0);
305  lhcbStyle->SetPadBorderMode(0);
306  lhcbStyle->SetPadColor(0);
307  lhcbStyle->SetCanvasBorderMode(0);
308  lhcbStyle->SetCanvasColor(0);
309  lhcbStyle->SetStatColor(0);
310  lhcbStyle->SetLegendBorderSize(0);
311 
312  // If you want the usual gradient palette (blue -> red)
313  lhcbStyle->SetPalette(1);
314  // If you want colors that correspond to gray scale in black and white:
315  int colors[8] = {0,5,7,3,6,2,4,1};
316  lhcbStyle->SetPalette(8,colors);
317 
318  const Int_t NRGBs = 5;
319  const Int_t NCont = 255;
320 
321  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
322  Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
323  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
324  Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
325  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
326  lhcbStyle->SetNumberContours(NCont);
327 
328  // set the paper & margin sizes
329  lhcbStyle->SetPaperSize(20,26);
330  lhcbStyle->SetPadTopMargin(0.05);
331  lhcbStyle->SetPadRightMargin(0.10); // increase for colz plots
332  lhcbStyle->SetPadBottomMargin(0.16);
333  lhcbStyle->SetPadLeftMargin(0.14);
334 
335  // use large fonts
336  lhcbStyle->SetTextFont(lhcbFont);
337  lhcbStyle->SetTextSize(lhcbTSize);
338  lhcbStyle->SetLabelFont(lhcbFont,"x");
339  lhcbStyle->SetLabelFont(lhcbFont,"y");
340  lhcbStyle->SetLabelFont(lhcbFont,"z");
341  lhcbStyle->SetLabelSize(lhcbTSize,"x");
342  lhcbStyle->SetLabelSize(lhcbTSize,"y");
343  lhcbStyle->SetLabelSize(lhcbTSize,"z");
344  lhcbStyle->SetTitleFont(lhcbFont);
345  lhcbStyle->SetTitleFont(lhcbFont,"x");
346  lhcbStyle->SetTitleFont(lhcbFont,"y");
347  lhcbStyle->SetTitleFont(lhcbFont,"z");
348  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"x");
349  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"y");
350  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"z");
351 
352  // use medium bold lines and thick markers
353  lhcbStyle->SetLineWidth(lhcbWidth);
354  lhcbStyle->SetFrameLineWidth(lhcbWidth);
355  lhcbStyle->SetHistLineWidth(lhcbWidth);
356  lhcbStyle->SetFuncWidth(lhcbWidth);
357  lhcbStyle->SetGridWidth(lhcbWidth);
358  lhcbStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
359  lhcbStyle->SetMarkerStyle(20);
360  lhcbStyle->SetMarkerSize(1.0);
361 
362  // label offsets
363  lhcbStyle->SetLabelOffset(0.010,"X");
364  lhcbStyle->SetLabelOffset(0.010,"Y");
365 
366  // by default, do not display histogram decorations:
367  lhcbStyle->SetOptStat(0);
368  //lhcbStyle->SetOptStat("emr"); // show only nent -e , mean - m , rms -r
369  // full opts at http://root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat
370  lhcbStyle->SetStatFormat("6.3g"); // specified as c printf options
371  lhcbStyle->SetOptTitle(0);
372  lhcbStyle->SetOptFit(0);
373  //lhcbStyle->SetOptFit(1011); // order is probability, Chi2, errors, parameters
374  //titles
375  lhcbStyle->SetTitleOffset(0.95,"X");
376  lhcbStyle->SetTitleOffset(0.95,"Y");
377  lhcbStyle->SetTitleOffset(1.2,"Z");
378  lhcbStyle->SetTitleFillColor(0);
379  lhcbStyle->SetTitleStyle(0);
380  lhcbStyle->SetTitleBorderSize(0);
381  lhcbStyle->SetTitleFont(lhcbFont,"title");
382  lhcbStyle->SetTitleX(0.0);
383  lhcbStyle->SetTitleY(1.0);
384  lhcbStyle->SetTitleW(1.0);
385  lhcbStyle->SetTitleH(0.05);
386 
387  // look of the statistics box:
388  lhcbStyle->SetStatBorderSize(0);
389  lhcbStyle->SetStatFont(lhcbFont);
390  lhcbStyle->SetStatFontSize(0.05);
391  lhcbStyle->SetStatX(0.9);
392  lhcbStyle->SetStatY(0.9);
393  lhcbStyle->SetStatW(0.25);
394  lhcbStyle->SetStatH(0.15);
395 
396  // put tick marks on top and RHS of plots
397  lhcbStyle->SetPadTickX(1);
398  lhcbStyle->SetPadTickY(1);
399 
400  // histogram divisions: only 5 in x to avoid label overlaps
401  lhcbStyle->SetNdivisions(505,"x");
402  lhcbStyle->SetNdivisions(510,"y");
403 
404 // gROOT->SetStyle("lhcbStyle");
405 // gROOT->ForceStyle();
406 
407  // add LHCb label
408  TPaveText* lhcbName = new TPaveText(gStyle->GetPadLeftMargin() + 0.05,
409  0.87 - gStyle->GetPadTopMargin(),
410  gStyle->GetPadLeftMargin() + 0.20,
411  0.95 - gStyle->GetPadTopMargin(),
412  "BRNDC");
413  lhcbName->AddText("LHCb");
414  lhcbName->SetFillColor(0);
415  lhcbName->SetTextAlign(12);
416  lhcbName->SetBorderSize(0);
417 
418  TPaveText* PrelimName = new TPaveText(gStyle->GetPadLeftMargin() + 0.05,
419  0.78 - gStyle->GetPadTopMargin(),
420  gStyle->GetPadLeftMargin() + 0.20,
421  0.87 - gStyle->GetPadTopMargin(),
422  "BRNDC");
423  PrelimName->AddText("Preliminary");
424  PrelimName->SetFillColor(0);
425  PrelimName->SetTextAlign(12);
426  PrelimName->SetBorderSize(0);
427 
428  TText *lhcbLabel = new TText();
429  lhcbLabel->SetTextFont(lhcbFont);
430  lhcbLabel->SetTextColor(1);
431  lhcbLabel->SetTextSize(lhcbTSize);
432  lhcbLabel->SetTextAlign(12);
433 
434  TLatex *lhcbLatex = new TLatex();
435  lhcbLatex->SetTextFont(lhcbFont);
436  lhcbLatex->SetTextColor(1);
437  lhcbLatex->SetTextSize(lhcbTSize);
438  lhcbLatex->SetTextAlign(12);
439 
440  return lhcbStyle;
441 // cout << "-------------------------" << endl;
442 // cout << "Set LHCb Style - Feb 2012" << endl;
443 // cout << "-------------------------" << endl;
444 
445 }

◆ SetLHCbStyle()

void SetLHCbStyle ( )

Definition at line 15 of file lhcbStyle.h.

16 {
17 
18 // // define names for colours
19 // Int_t black = 1;
20 // Int_t red = 2;
21 // Int_t green = 3;
22 // Int_t blue = 4;
23 // Int_t yellow = 5;
24 // Int_t magenta= 6;
25 // Int_t cyan = 7;
26 // Int_t purple = 9;
27 
28 
29 
30 
32  // PURPOSE:
33  //
34  // This macro defines a standard style for (black-and-white)
35  // "publication quality" LHCb ROOT plots.
36  //
37  // USAGE:
38  //
39  // Include the lines
40  // gROOT->ProcessLine(".L lhcbstyle.C");
41  // lhcbStyle();
42  // at the beginning of your root macro.
43  //
44  // Example usage is given in myPlot.C
45  //
46  // COMMENTS:
47  //
48  // Font:
49  //
50  // The font is chosen to be 132, this is Times New Roman (like the text of
51  // your document) with precision 2.
52  //
53  // "Landscape histograms":
54  //
55  // The style here is designed for more or less square plots.
56  // For longer histograms, or canvas with many pads, adjustements are needed.
57  // For instance, for a canvas with 1x5 histograms:
58  // TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800);
59  // c1->Divide(1,5);
60  // Adaptions like the following will be needed:
61  // gStyle->SetTickLength(0.05,"x");
62  // gStyle->SetTickLength(0.01,"y");
63  // gStyle->SetLabelSize(0.15,"x");
64  // gStyle->SetLabelSize(0.1,"y");
65  // gStyle->SetStatW(0.15);
66  // gStyle->SetStatH(0.5);
67  //
68  // Authors: Thomas Schietinger, Andrew Powell, Chris Parkes, Niels Tuning
69  // Maintained by Editorial board member (currently Niels)
71 
72  // Use times new roman, precision 2
73  Int_t lhcbFont = 132; // Old LHCb style: 62;
74  // Line thickness
75  Double_t lhcbWidth = 2.00; // Old LHCb style: 3.00;
76  // Text size
77  Double_t lhcbTSize = 0.06;
78 
79  // use plain black on white colors
80  gROOT->SetStyle("Plain");
81  TStyle *lhcbStyle= new TStyle("lhcbStyle","LHCb plots style");
82 
83  //lhcbStyle->SetErrorX(0); // don't suppress the error bar along X
84 
85  lhcbStyle->SetFillColor(1);
86  lhcbStyle->SetFillStyle(1001); // solid
87  lhcbStyle->SetFrameFillColor(0);
88  lhcbStyle->SetFrameBorderMode(0);
89  lhcbStyle->SetPadBorderMode(0);
90  lhcbStyle->SetPadColor(0);
91  lhcbStyle->SetCanvasBorderMode(0);
92  lhcbStyle->SetCanvasColor(0);
93  lhcbStyle->SetStatColor(0);
94  lhcbStyle->SetLegendBorderSize(0);
95 
96  // If you want the usual gradient palette (blue -> red)
97  lhcbStyle->SetPalette(1);
98  // If you want colors that correspond to gray scale in black and white:
99  int colors[8] = {0,5,7,3,6,2,4,1};
100  lhcbStyle->SetPalette(8,colors);
101 
102  const Int_t NRGBs = 5;
103  const Int_t NCont = 255;
104 
105  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
106  Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
107  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
108  Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
109  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
110  lhcbStyle->SetNumberContours(NCont);
111 
112  // set the paper & margin sizes
113  lhcbStyle->SetPaperSize(20,26);
114  lhcbStyle->SetPadTopMargin(0.05);
115  lhcbStyle->SetPadRightMargin(0.10); // increase for colz plots
116  lhcbStyle->SetPadBottomMargin(0.16);
117  lhcbStyle->SetPadLeftMargin(0.14);
118 
119  // use large fonts
120  lhcbStyle->SetTextFont(lhcbFont);
121  lhcbStyle->SetTextSize(lhcbTSize);
122  lhcbStyle->SetLabelFont(lhcbFont,"x");
123  lhcbStyle->SetLabelFont(lhcbFont,"y");
124  lhcbStyle->SetLabelFont(lhcbFont,"z");
125  lhcbStyle->SetLabelSize(lhcbTSize,"x");
126  lhcbStyle->SetLabelSize(lhcbTSize,"y");
127  lhcbStyle->SetLabelSize(lhcbTSize,"z");
128  lhcbStyle->SetTitleFont(lhcbFont);
129  lhcbStyle->SetTitleFont(lhcbFont,"x");
130  lhcbStyle->SetTitleFont(lhcbFont,"y");
131  lhcbStyle->SetTitleFont(lhcbFont,"z");
132  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"x");
133  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"y");
134  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"z");
135 
136  // use medium bold lines and thick markers
137  lhcbStyle->SetLineWidth(lhcbWidth);
138  lhcbStyle->SetFrameLineWidth(lhcbWidth);
139  lhcbStyle->SetHistLineWidth(lhcbWidth);
140  lhcbStyle->SetFuncWidth(lhcbWidth);
141  lhcbStyle->SetGridWidth(lhcbWidth);
142  lhcbStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
143  lhcbStyle->SetMarkerStyle(20);
144  lhcbStyle->SetMarkerSize(1.0);
145 
146  // label offsets
147  lhcbStyle->SetLabelOffset(0.010,"X");
148  lhcbStyle->SetLabelOffset(0.010,"Y");
149 
150  // by default, do not display histogram decorations:
151  lhcbStyle->SetOptStat(0);
152  //lhcbStyle->SetOptStat("emr"); // show only nent -e , mean - m , rms -r
153  // full opts at http://root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat
154  lhcbStyle->SetStatFormat("6.3g"); // specified as c printf options
155  lhcbStyle->SetOptTitle(0);
156  lhcbStyle->SetOptFit(0);
157  //lhcbStyle->SetOptFit(1011); // order is probability, Chi2, errors, parameters
158  //titles
159  lhcbStyle->SetTitleOffset(0.95,"X");
160  lhcbStyle->SetTitleOffset(0.95,"Y");
161  lhcbStyle->SetTitleOffset(1.2,"Z");
162  lhcbStyle->SetTitleFillColor(0);
163  lhcbStyle->SetTitleStyle(0);
164  lhcbStyle->SetTitleBorderSize(0);
165  lhcbStyle->SetTitleFont(lhcbFont,"title");
166  lhcbStyle->SetTitleX(0.0);
167  lhcbStyle->SetTitleY(1.0);
168  lhcbStyle->SetTitleW(1.0);
169  lhcbStyle->SetTitleH(0.05);
170 
171  // look of the statistics box:
172  lhcbStyle->SetStatBorderSize(0);
173  lhcbStyle->SetStatFont(lhcbFont);
174  lhcbStyle->SetStatFontSize(0.05);
175  lhcbStyle->SetStatX(0.9);
176  lhcbStyle->SetStatY(0.9);
177  lhcbStyle->SetStatW(0.25);
178  lhcbStyle->SetStatH(0.15);
179 
180  // put tick marks on top and RHS of plots
181  lhcbStyle->SetPadTickX(1);
182  lhcbStyle->SetPadTickY(1);
183 
184  // histogram divisions: only 5 in x to avoid label overlaps
185  lhcbStyle->SetNdivisions(505,"x");
186  lhcbStyle->SetNdivisions(510,"y");
187 
188  gROOT->SetStyle("lhcbStyle");
189  gROOT->ForceStyle();
190 
191  // add LHCb label
192  TPaveText* lhcbName = new TPaveText(gStyle->GetPadLeftMargin() + 0.05,
193  0.87 - gStyle->GetPadTopMargin(),
194  gStyle->GetPadLeftMargin() + 0.20,
195  0.95 - gStyle->GetPadTopMargin(),
196  "BRNDC");
197  lhcbName->AddText("LHCb");
198  lhcbName->SetFillColor(0);
199  lhcbName->SetTextAlign(12);
200  lhcbName->SetBorderSize(0);
201 
202  TPaveText* PrelimName = new TPaveText(gStyle->GetPadLeftMargin() + 0.05,
203  0.78 - gStyle->GetPadTopMargin(),
204  gStyle->GetPadLeftMargin() + 0.20,
205  0.87 - gStyle->GetPadTopMargin(),
206  "BRNDC");
207  PrelimName->AddText("Preliminary");
208  PrelimName->SetFillColor(0);
209  PrelimName->SetTextAlign(12);
210  PrelimName->SetBorderSize(0);
211 
212  TText *lhcbLabel = new TText();
213  lhcbLabel->SetTextFont(lhcbFont);
214  lhcbLabel->SetTextColor(1);
215  lhcbLabel->SetTextSize(lhcbTSize);
216  lhcbLabel->SetTextAlign(12);
217 
218  TLatex *lhcbLatex = new TLatex();
219  lhcbLatex->SetTextFont(lhcbFont);
220  lhcbLatex->SetTextColor(1);
221  lhcbLatex->SetTextSize(lhcbTSize);
222  lhcbLatex->SetTextAlign(12);
223 
224 // cout << "-------------------------" << endl;
225 // cout << "Set LHCb Style - Feb 2012" << endl;
226 // cout << "-------------------------" << endl;
227 
228 }