ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/auterman/SusyScan/PlotScript/StyleSettings.h
Revision: 1.1
Committed: Wed Mar 2 13:42:47 2011 UTC (14 years, 2 months ago) by auterman
Content type: text/plain
Branch: MAIN
CVS Tags: JHEP2010, HEAD
Log Message:
add script

File Contents

# User Rev Content
1 auterman 1.1 // $Id: StyleSettings.h,v 1.12 2010/12/19 22:41:03 mschrode Exp $
2    
3     #ifndef STYLE_SETTINGS_H
4     #define STYLE_SETTINGS_H
5    
6     #include <iostream>
7    
8     #include "TString.h"
9     #include "TStyle.h"
10    
11    
12    
13     namespace util {
14    
15     //! Encapsulates different pad and histogram styles
16     //!
17     //! \author Matthias Schroeder (www.desy.de/~matsch)
18     //! \date 2010/03/09
19     //! $Id: StyleSettings.h,v 1.12 2010/12/19 22:41:03 mschrode Exp $
20     // -------------------------------------------------------------------------------------
21     class StyleSettings {
22     public:
23     enum Style { Screen, Presentation, Paper };
24    
25     static Style style() {
26     Style st = Screen;
27     TString mode = gStyle->GetTitle();
28     if( mode == "Presentation" ) st = Presentation;
29     else if( mode == "Paper" ) st = Paper;
30     return st;
31     }
32     static void screen() { setStyle("Screen",true); }
33     static void screenNoTitle() { setStyle("Screen",false); }
34     static void paper() { setStyle("Paper",true); }
35     static void paperNoTitle() { setStyle("Paper",false); }
36     static void presentation() { setStyle("Presentation",true); }
37     static void presentationNoTitle() { setStyle("Presentation",false); }
38     static void cms() { setStyle("CMS",false); }
39     static int color(int i) {
40     int col[5] = { 1, 2, 4, 7, 8 };
41     return (i>=0 && i<5) ? col[i] : 1;
42     }
43     static int lineWidth() {
44     int width = 1;
45     TString mode = "Presentation";
46     if( mode.CompareTo(gStyle->GetTitle()) == 0 ) {
47     width = 2;
48     }
49     return width;
50     }
51    
52     private:
53     static void setStyle(const TString &mode, bool spaceForTitle) {
54     // Set title of current style object
55     gStyle->SetTitle(mode);
56    
57     // Zero horizontal error bars
58     gStyle->SetErrorX(0);
59    
60     // For 'colz' TH2
61     gStyle->SetPalette(1);
62    
63     // For the canvas
64     gStyle->SetCanvasBorderMode(0);
65     gStyle->SetCanvasColor(kWhite);
66     gStyle->SetCanvasDefH(800); //Height of canvas
67     gStyle->SetCanvasDefW(800); //Width of canvas
68     gStyle->SetCanvasDefX(0); //Position on screen
69     gStyle->SetCanvasDefY(0);
70    
71     // For the frame
72     gStyle->SetFrameBorderMode(0);
73     gStyle->SetFrameBorderSize(1);
74     gStyle->SetFrameFillColor(kBlack);
75     gStyle->SetFrameFillStyle(0);
76     gStyle->SetFrameLineColor(kBlack);
77     gStyle->SetFrameLineStyle(0);
78     gStyle->SetFrameLineWidth(1);
79    
80     // For the Pad
81     gStyle->SetPadBorderMode(0);
82     gStyle->SetPadColor(kWhite);
83     gStyle->SetPadGridX(false);
84     gStyle->SetPadGridY(false);
85     gStyle->SetGridColor(0);
86     gStyle->SetGridStyle(3);
87     gStyle->SetGridWidth(1);
88    
89     // Margins
90     if( mode == "Presentation" ) {
91     if( spaceForTitle ) {
92     gStyle->SetPadTopMargin(0.11);
93     gStyle->SetPadBottomMargin(0.18);
94     gStyle->SetPadLeftMargin(0.25);
95     gStyle->SetPadRightMargin(0.04);
96     } else {
97     gStyle->SetPadTopMargin(0.05);
98     gStyle->SetPadBottomMargin(0.18);
99     gStyle->SetPadLeftMargin(0.19);
100     gStyle->SetPadRightMargin(0.04);
101     }
102     } else if( mode == "Paper" || mode == "CMS" ) {
103     if( spaceForTitle ) {
104     gStyle->SetPadTopMargin(0.06);
105     gStyle->SetPadBottomMargin(0.18);
106     gStyle->SetPadLeftMargin(0.2);
107     gStyle->SetPadRightMargin(0.04);
108     } else {
109     gStyle->SetPadTopMargin(0.05);
110     gStyle->SetPadBottomMargin(0.17);
111     gStyle->SetPadLeftMargin(0.18);
112     gStyle->SetPadRightMargin(0.04);
113     }
114     } else {
115     if( spaceForTitle ) {
116     gStyle->SetPadTopMargin(0.10);
117     gStyle->SetPadBottomMargin(0.14);
118     gStyle->SetPadLeftMargin(0.18);
119     gStyle->SetPadRightMargin(0.04);
120     } else {
121     gStyle->SetPadTopMargin(0.08);
122     gStyle->SetPadBottomMargin(0.14);
123     gStyle->SetPadLeftMargin(0.18);
124     gStyle->SetPadRightMargin(0.04);
125     }
126     }
127    
128     // For the histo:
129     gStyle->SetHistLineColor(kBlack);
130     gStyle->SetHistLineStyle(0);
131     gStyle->SetHistLineWidth(1);
132    
133     // For the statistics box:
134     if( mode == "Screen" ) {
135     gStyle->SetOptStat("eMR");
136     gStyle->SetStatColor(kWhite);
137     gStyle->SetStatFont(42);
138     gStyle->SetStatFontSize(0.03);
139     gStyle->SetStatTextColor(1);
140     gStyle->SetStatFormat("6.4g");
141     gStyle->SetStatBorderSize(1);
142     gStyle->SetStatX(0.94);
143     gStyle->SetStatY(0.86);
144     gStyle->SetStatH(0.16);
145     gStyle->SetStatW(0.22);
146     } else {
147     gStyle->SetOptStat(0);
148     }
149    
150     // For the Global title:
151     gStyle->SetOptTitle(1);
152     gStyle->SetTitleFont(42,"");
153     gStyle->SetTitleColor(1);
154     gStyle->SetTitleTextColor(1);
155     gStyle->SetTitleFillColor(0);
156     gStyle->SetTitleFontSize(0.1);
157     gStyle->SetTitleAlign(23);
158     gStyle->SetTitleX(0.6);
159     gStyle->SetTitleH(0.05);
160     gStyle->SetTitleBorderSize(0);
161    
162     // For the axis
163     gStyle->SetAxisColor(1,"XYZ");
164     gStyle->SetTickLength(0.03,"XYZ");
165     gStyle->SetNdivisions(510,"XYZ");
166     if( mode == "CMS" ) {
167     gStyle->SetPadTickX(0);
168     gStyle->SetPadTickY(0);
169     } else {
170     gStyle->SetPadTickX(1);
171     gStyle->SetPadTickY(1);
172     }
173     gStyle->SetStripDecimals(kFALSE);
174    
175     // For the axis labels and titles
176     gStyle->SetTitleColor(1,"XYZ");
177     gStyle->SetLabelColor(1,"XYZ");
178     if( mode == "Presentation" ) {
179     // For the axis labels:
180     gStyle->SetLabelFont(42,"XYZ");
181     gStyle->SetLabelOffset(0.007,"XYZ");
182     gStyle->SetLabelSize(0.045,"XYZ");
183    
184     // For the axis titles:
185     gStyle->SetTitleFont(42,"XYZ");
186     gStyle->SetTitleSize(0.06,"XYZ");
187     gStyle->SetTitleXOffset(1.2);
188     if( spaceForTitle ) gStyle->SetTitleYOffset(2.0);
189     else gStyle->SetTitleYOffset(1.5);
190     } else if ( mode == "Paper" || mode == "CMS" ) {
191     // For the axis labels:
192     gStyle->SetLabelFont(42,"XYZ");
193     gStyle->SetLabelOffset(0.007,"XYZ");
194     gStyle->SetLabelSize(0.04,"XYZ");
195    
196     // For the axis titles:
197     gStyle->SetTitleFont(42,"XYZ");
198     gStyle->SetTitleSize(0.045,"XYZ");
199     gStyle->SetTitleXOffset(1.5);
200     if( spaceForTitle ) gStyle->SetTitleYOffset(2.1);
201     else gStyle->SetTitleYOffset(1.8);
202     } else {
203     // For the axis labels:
204     gStyle->SetLabelFont(42,"XYZ");
205     gStyle->SetLabelOffset(0.007,"XYZ");
206     gStyle->SetLabelSize(0.035,"XYZ");
207    
208     // For the axis titles:
209     gStyle->SetTitleFont(42,"XYZ");
210     gStyle->SetTitleSize(0.04,"XYZ");
211     gStyle->SetTitleXOffset(1.5);
212     if( spaceForTitle ) gStyle->SetTitleYOffset(2.1);
213     else gStyle->SetTitleYOffset(1.8);
214     }
215    
216    
217     // For the legend
218     gStyle->SetLegendBorderSize(0);
219    
220     // For the statistics box
221     if( mode == "Presentation" ) {
222     if( spaceForTitle ) {
223     gStyle->SetStatFontSize(0.04);
224     gStyle->SetStatX(0.92);
225     gStyle->SetStatY(0.86);
226     gStyle->SetStatH(0.2);
227     gStyle->SetStatW(0.3);
228     } else {
229     gStyle->SetStatFontSize(0.04);
230     gStyle->SetStatX(0.92);
231     gStyle->SetStatY(0.92);
232     gStyle->SetStatH(0.2);
233     gStyle->SetStatW(0.3);
234     }
235     } else {
236     if( spaceForTitle ) {
237     gStyle->SetStatFontSize(0.03);
238     gStyle->SetStatX(0.92);
239     gStyle->SetStatY(0.86);
240     gStyle->SetStatH(0.16);
241     gStyle->SetStatW(0.22);
242     } else {
243     gStyle->SetStatFontSize(0.03);
244     gStyle->SetStatX(0.92);
245     gStyle->SetStatY(0.92);
246     gStyle->SetStatH(0.16);
247     gStyle->SetStatW(0.22);
248     }
249     }
250    
251     std::cout << "Adjusted gStyle for " << std::flush;
252     if( mode == "Screen" ) std::cout << "screen viewing" << std::flush;
253     else if( mode == "Paper" ) std::cout << "papers" << std::flush;
254     else if( mode == "CMS" ) std::cout << "CMS PAS" << std::flush;
255     else std::cout << "presentations" << std::flush;
256     std::cout << " and " << std::flush;
257     if( spaceForTitle ) std::cout << "histograms with title." << std::endl;
258     else std::cout << "histograms without title." << std::endl;
259     }
260     };
261     }
262     #endif
263    
264