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