Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sPhenixStyle.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file sPhenixStyle.C
1 //
2 // sPHENIX Style, based on a style file from BaBar, v0.1
3 //
4 
5 #include <iostream>
6 
7 #include "sPhenixStyle.h"
8 
9 #include "TROOT.h"
10 
12 {
13  static TStyle* sphenixStyle = 0;
14  std::cout << "sPhenixStyle: Applying nominal settings." << std::endl ;
15  if ( sphenixStyle==0 ) sphenixStyle = sPhenixStyle();
16  gROOT->SetStyle("sPHENIX");
17  gROOT->ForceStyle();
18 }
19 
20 TStyle* sPhenixStyle()
21 {
22  TStyle *sphenixStyle = new TStyle("sPHENIX","sPHENIX style");
23 
24  // use plain black on white colors
25  Int_t icol=0; // WHITE
26  sphenixStyle->SetFrameBorderMode(icol);
27  sphenixStyle->SetFrameFillColor(icol);
28  sphenixStyle->SetCanvasBorderMode(icol);
29  sphenixStyle->SetCanvasColor(icol);
30  sphenixStyle->SetPadBorderMode(icol);
31  sphenixStyle->SetPadColor(icol);
32  sphenixStyle->SetStatColor(icol);
33  //sphenixStyle->SetFillColor(icol); // don't use: white fill color for *all* objects
34 
35  // set the paper & margin sizes
36  sphenixStyle->SetPaperSize(20,26);
37 
38  // set margin sizes
39  sphenixStyle->SetPadTopMargin(0.05);
40  sphenixStyle->SetPadRightMargin(0.05);
41  sphenixStyle->SetPadBottomMargin(0.16);
42  sphenixStyle->SetPadLeftMargin(0.16);
43 
44  // set title offsets (for axis label)
45  sphenixStyle->SetTitleXOffset(1.4);
46  sphenixStyle->SetTitleYOffset(1.4);
47 
48  // use large fonts
49  //Int_t font=72; // Helvetica italics
50  Int_t font=42; // Helvetica
51  Double_t tsize=0.05;
52  sphenixStyle->SetTextFont(font);
53 
54  sphenixStyle->SetTextSize(tsize);
55  sphenixStyle->SetLabelFont(font,"x");
56  sphenixStyle->SetTitleFont(font,"x");
57  sphenixStyle->SetLabelFont(font,"y");
58  sphenixStyle->SetTitleFont(font,"y");
59  sphenixStyle->SetLabelFont(font,"z");
60  sphenixStyle->SetTitleFont(font,"z");
61 
62  sphenixStyle->SetLabelSize(tsize,"x");
63  sphenixStyle->SetTitleSize(tsize,"x");
64  sphenixStyle->SetLabelSize(tsize,"y");
65  sphenixStyle->SetTitleSize(tsize,"y");
66  sphenixStyle->SetLabelSize(tsize,"z");
67  sphenixStyle->SetTitleSize(tsize,"z");
68 
69  // use bold lines and markers
70  sphenixStyle->SetMarkerStyle(20);
71  sphenixStyle->SetMarkerSize(1.2);
72  sphenixStyle->SetHistLineWidth(2.);
73  sphenixStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
74 
75  // get rid of X error bars
76  //sphenixStyle->SetErrorX(0.001);
77  // get rid of error bar caps
78  sphenixStyle->SetEndErrorSize(0.);
79 
80  // do not display any of the standard histogram decorations
81  sphenixStyle->SetOptTitle(0);
82  //sphenixStyle->SetOptStat(1111);
83  sphenixStyle->SetOptStat(0);
84  //sphenixStyle->SetOptFit(1111);
85  sphenixStyle->SetOptFit(0);
86 
87  // put tick marks on top and RHS of plots
88  sphenixStyle->SetPadTickX(1);
89  sphenixStyle->SetPadTickY(1);
90 
91  // legend modificatin
92  sphenixStyle->SetLegendBorderSize(0);
93  sphenixStyle->SetLegendFillColor(0);
94  sphenixStyle->SetLegendFont(font);
95 
96 
97 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
98  std::cout << "sPhenixStyle: ROOT6 mode" << std::endl;
99  sphenixStyle->SetLegendTextSize(tsize);
100  sphenixStyle->SetPalette(kBird);
101 #else
102  std::cout << "sPhenixStyle: ROOT5 mode" << std::endl;
103  // color palette - manually define 'kBird' palette only available in ROOT 6
104  Int_t alpha = 0;
105  Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
106  Double_t red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764};
107  Double_t green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832};
108  Double_t blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539};
109  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
110 #endif
111 
112  sphenixStyle->SetNumberContours(80);
113 
114  return sphenixStyle;
115 
116 }
117