ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RootMacros/style-CMSTDR.C
Revision: 1.3
Committed: Fri Nov 20 21:12:40 2009 UTC (15 years, 5 months ago) by anderson
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +5 -7 lines
Log Message:
Updated and added comments

File Contents

# User Rev Content
1 anderson 1.2 /***********************
2     To use this, type
3     in root:
4    
5     root[0] .L tdrstyle.C
6     root[1] setTDRStyle()
7     ***********************/
8     #include "TStyle.h"
9    
10     // tdrGrid: Turns the grid lines on (true) or off (false)
11    
12     void tdrGrid(bool gridOn) {
13     tdrStyle->SetPadGridX(gridOn);
14     tdrStyle->SetPadGridY(gridOn);
15     }
16    
17     // fixOverlay: Redraws the axis
18    
19     void fixOverlay() {
20     gPad->RedrawAxis();
21     }
22    
23     void setTDRStyle() {
24     TStyle *tdrStyle = new TStyle("tdrStyle","Style for P-TDR");
25 jhegeman 1.1
26     // For the canvas:
27     tdrStyle->SetCanvasBorderMode(0);
28     tdrStyle->SetCanvasColor(kWhite);
29     tdrStyle->SetCanvasDefH(600); //Height of canvas
30     tdrStyle->SetCanvasDefW(600); //Width of canvas
31     tdrStyle->SetCanvasDefX(0); //POsition on screen
32     tdrStyle->SetCanvasDefY(0);
33    
34     // For the Pad:
35     tdrStyle->SetPadBorderMode(0);
36     // tdrStyle->SetPadBorderSize(Width_t size = 1);
37     tdrStyle->SetPadColor(kWhite);
38     tdrStyle->SetPadGridX(false);
39     tdrStyle->SetPadGridY(false);
40     tdrStyle->SetGridColor(0);
41     tdrStyle->SetGridStyle(3);
42     tdrStyle->SetGridWidth(1);
43    
44     // For the frame:
45     tdrStyle->SetFrameBorderMode(0);
46     tdrStyle->SetFrameBorderSize(1);
47     tdrStyle->SetFrameFillColor(0);
48     tdrStyle->SetFrameFillStyle(0);
49     tdrStyle->SetFrameLineColor(1);
50     tdrStyle->SetFrameLineStyle(1);
51     tdrStyle->SetFrameLineWidth(1);
52    
53     // For the histo:
54     // tdrStyle->SetHistFillColor(1);
55     // tdrStyle->SetHistFillStyle(0);
56     tdrStyle->SetHistLineColor(1);
57     tdrStyle->SetHistLineStyle(0);
58     tdrStyle->SetHistLineWidth(1);
59     // tdrStyle->SetLegoInnerR(Float_t rad = 0.5);
60     // tdrStyle->SetNumberContours(Int_t number = 20);
61    
62     tdrStyle->SetEndErrorSize(2);
63 anderson 1.3 //tdrStyle->SetErrorMarker(20); // Seems to give an error
64 jhegeman 1.1 tdrStyle->SetErrorX(0.);
65 anderson 1.2
66 jhegeman 1.1 tdrStyle->SetMarkerStyle(20);
67    
68     //For the fit/function:
69     tdrStyle->SetOptFit(1);
70     tdrStyle->SetFitFormat("5.4g");
71     tdrStyle->SetFuncColor(2);
72     tdrStyle->SetFuncStyle(1);
73     tdrStyle->SetFuncWidth(1);
74    
75     //For the date:
76     tdrStyle->SetOptDate(0);
77     // tdrStyle->SetDateX(Float_t x = 0.01);
78     // tdrStyle->SetDateY(Float_t y = 0.01);
79    
80     // For the statistics box:
81     tdrStyle->SetOptFile(0);
82     tdrStyle->SetOptStat(0); // To display the mean and RMS: SetOptStat("mr");
83     tdrStyle->SetStatColor(kWhite);
84     tdrStyle->SetStatFont(42);
85     tdrStyle->SetStatFontSize(0.025);
86     tdrStyle->SetStatTextColor(1);
87     tdrStyle->SetStatFormat("6.4g");
88     tdrStyle->SetStatBorderSize(1);
89     tdrStyle->SetStatH(0.1);
90     tdrStyle->SetStatW(0.15);
91     // tdrStyle->SetStatStyle(Style_t style = 1001);
92     // tdrStyle->SetStatX(Float_t x = 0);
93     // tdrStyle->SetStatY(Float_t y = 0);
94    
95     // Margins:
96 anderson 1.2 tdrStyle->SetPadTopMargin(0.05);
97 jhegeman 1.1 tdrStyle->SetPadBottomMargin(0.13);
98 anderson 1.2 tdrStyle->SetPadLeftMargin(0.16);
99     tdrStyle->SetPadRightMargin(0.02);
100 jhegeman 1.1
101     // For the Global title:
102 anderson 1.3 tdrStyle->SetOptTitle(1); // 0=No Title
103 jhegeman 1.1 tdrStyle->SetTitleFont(42);
104     tdrStyle->SetTitleColor(1);
105     tdrStyle->SetTitleTextColor(1);
106     tdrStyle->SetTitleFillColor(10);
107     tdrStyle->SetTitleFontSize(0.05);
108     // tdrStyle->SetTitleH(0); // Set the height of the title box
109     // tdrStyle->SetTitleW(0); // Set the width of the title box
110     // tdrStyle->SetTitleX(0); // Set the position of the title box
111     // tdrStyle->SetTitleY(0.985); // Set the position of the title box
112     // tdrStyle->SetTitleStyle(Style_t style = 1001);
113     // tdrStyle->SetTitleBorderSize(2);
114    
115     // For the axis titles:
116     tdrStyle->SetTitleColor(1, "XYZ");
117     tdrStyle->SetTitleFont(42, "XYZ");
118     tdrStyle->SetTitleSize(0.06, "XYZ");
119     // tdrStyle->SetTitleXSize(Float_t size = 0.02); // Another way to set the size?
120     // tdrStyle->SetTitleYSize(Float_t size = 0.02);
121 anderson 1.2 tdrStyle->SetTitleXOffset(0.9);
122     tdrStyle->SetTitleYOffset(1.25);
123     // tdrStyle->SetTitleOffset(1.1, "Y"); // Another way to set the Offset
124 jhegeman 1.1
125     // For the axis labels:
126     tdrStyle->SetLabelColor(1, "XYZ");
127     tdrStyle->SetLabelFont(42, "XYZ");
128     tdrStyle->SetLabelOffset(0.007, "XYZ");
129     tdrStyle->SetLabelSize(0.05, "XYZ");
130    
131     // For the axis:
132     tdrStyle->SetAxisColor(1, "XYZ");
133     tdrStyle->SetStripDecimals(kTRUE);
134     tdrStyle->SetTickLength(0.03, "XYZ");
135     tdrStyle->SetNdivisions(510, "XYZ");
136 anderson 1.3 tdrStyle->SetPadTickX(0); // 0=Text labels (and tics) only on bottom, 1=Text labels on top and bottom
137 jhegeman 1.1 tdrStyle->SetPadTickY(1);
138    
139     // Change for log plots:
140     tdrStyle->SetOptLogx(0);
141     tdrStyle->SetOptLogy(0);
142     tdrStyle->SetOptLogz(0);
143    
144     // Postscript options:
145 anderson 1.2 tdrStyle->SetPaperSize(20.,20.);
146 jhegeman 1.1 // tdrStyle->SetLineScalePS(Float_t scale = 3);
147     // tdrStyle->SetLineStyleString(Int_t i, const char* text);
148     // tdrStyle->SetHeaderPS(const char* header);
149     // tdrStyle->SetTitlePS(const char* pstitle);
150    
151     // tdrStyle->SetBarOffset(Float_t baroff = 0.5);
152     // tdrStyle->SetBarWidth(Float_t barwidth = 0.5);
153     // tdrStyle->SetPaintTextFormat(const char* format = "g");
154     // tdrStyle->SetPalette(Int_t ncolors = 0, Int_t* colors = 0);
155     // tdrStyle->SetTimeOffset(Double_t toffset);
156     // tdrStyle->SetHistMinimumZero(kTRUE);
157    
158 anderson 1.3 //gROOT->ForceStyle(); // Try this if stuff doesn't work right
159    
160 jhegeman 1.1 tdrStyle->cd();
161    
162     }