ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Style/src/MitStyle.cc
Revision: 1.2
Committed: Sun Oct 3 03:51:15 2010 UTC (14 years, 7 months ago) by paus
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
Log Message:
Error in cvs use.

File Contents

# Content
1 #include <TCanvas.h>
2 #include <TPad.h>
3 #include <TH1.h>
4 #include <TStyle.h>
5 #include "MitPlots/Style/interface/MitStyle.h"
6
7 using namespace mithep;
8
9 void MitStyle::Init()
10 {
11 // Initialization with proper defaults is the start
12
13 const char* author = "$Author: paus $$";
14 const char* modified = "$Modified: Mon Aug 23 23:18:54 2010 by paus $$";
15 printf(" MIT root style (%s,%s).\n",author,modified);
16 printf("\n");
17 printf(" Use: MitStyle::MakeCanvas(name,title)\n");
18 printf(" MitStyle::InitSubPad(pad,nPad)\n");
19 printf(" MitStyle::InitHist(hist,xTitle,yTitle,color)\n");
20 printf("\n");
21 SetStyle();
22 }
23
24 TCanvas* MitStyle::MakeCanvas(const char* name, const char *title)
25 {
26 // Make a canvas with good initial settings
27
28 TCanvas *canvas = new TCanvas(name,title);
29
30 // the default should be taken from MitStyle::Init()
31
32 //// General overall stuff
33 //canvas->SetFillColor (0);
34 //canvas->SetBorderMode (0);
35 //canvas->SetBorderSize (10);
36 //// Set margins to reasonable defaults
37 //canvas->SetLeftMargin (0.20);
38 //canvas->SetRightMargin (0.05);
39 //canvas->SetTopMargin (0.08);
40 //canvas->SetBottomMargin (0.15);
41 //// Setup a frame which makes sense
42 //canvas->SetFrameFillStyle (0);
43 //canvas->SetFrameLineStyle (0);
44 //canvas->SetFrameBorderMode(0);
45 //canvas->SetFrameBorderSize(10);
46 //canvas->SetFrameFillStyle (0);
47 //canvas->SetFrameLineStyle (0);
48 //canvas->SetFrameBorderMode(0);
49 //canvas->SetFrameBorderSize(10);
50
51 return canvas;
52 }
53
54 void MitStyle::InitSubPad(TPad* pad, int i)
55 {
56 // Initializing a sub pad
57
58 pad->cd(i);
59 TPad *tmpPad = (TPad*) pad->GetPad(i);
60 tmpPad->SetLeftMargin (0.20);
61 tmpPad->SetTopMargin (0.05);
62 tmpPad->SetRightMargin (0.07);
63 tmpPad->SetBottomMargin(0.15);
64 return;
65 }
66
67 void MitStyle::InitHist(TH1 *hist, const char *xtit, const char *ytit, EColor color)
68 {
69 // Initializing a histogram
70
71 hist->SetTitle ("");
72 hist->SetXTitle (xtit);
73 hist->SetYTitle (ytit);
74
75 hist->SetLineColor (color);
76 hist->SetLineWidth (2.0);
77
78 hist->SetMarkerStyle(20);
79 hist->SetMarkerColor(color);
80 hist->SetMarkerSize (0.6);
81
82 hist->SetTitleFont (42 ,"X");
83 hist->SetTitleSize (0.055,"X");
84 hist->SetTitleOffset(1.100,"X");
85 hist->SetLabelOffset(0.010,"X");
86 hist->SetLabelSize (0.050,"X");
87 hist->SetLabelFont (42 ,"X");
88 hist->SetTickLength (-0.01,"X");
89
90 hist->SetTitleFont (42 ,"Y");
91 hist->SetTitleSize (0.055,"Y");
92 hist->SetTitleOffset(1.700,"Y");
93 hist->SetLabelOffset(0.010,"Y");
94 hist->SetLabelSize (0.050,"Y");
95 hist->SetLabelFont (42 ,"Y");
96 hist->SetTickLength (-0.01,"Y");
97
98 return;
99 }
100
101 void MitStyle::SetStyle()
102 {
103 // Setting style parameters
104
105 TStyle *MitStyle = gStyle;// new TStyle("MIT-Style","The Perfect Style for Plots ;-)");
106 //gStyle = MitStyle;
107
108 // Canvas
109 MitStyle->SetCanvasColor (0);
110 MitStyle->SetCanvasBorderSize(10);
111 MitStyle->SetCanvasBorderMode(0);
112 MitStyle->SetCanvasDefH (700);
113 MitStyle->SetCanvasDefW (700);
114 MitStyle->SetCanvasDefX (100);
115 MitStyle->SetCanvasDefY (100);
116
117 // Pads
118 MitStyle->SetPadColor (0);
119 MitStyle->SetPadBorderSize (10);
120 MitStyle->SetPadBorderMode (0);
121 MitStyle->SetPadBottomMargin(0.13);
122 MitStyle->SetPadTopMargin (0.04);
123 MitStyle->SetPadLeftMargin (0.18);
124 MitStyle->SetPadRightMargin (0.04);
125 MitStyle->SetPadGridX (0);
126 MitStyle->SetPadGridY (0);
127 MitStyle->SetPadTickX (0);
128 MitStyle->SetPadTickY (0);
129
130 // Frames
131 MitStyle->SetFrameFillStyle ( 0);
132 MitStyle->SetFrameFillColor ( 0);
133 MitStyle->SetFrameLineColor ( 1);
134 MitStyle->SetFrameLineStyle ( 0);
135 MitStyle->SetFrameLineWidth ( 1);
136 MitStyle->SetFrameBorderSize(10);
137 MitStyle->SetFrameBorderMode( 0);
138
139 // Histograms
140 MitStyle->SetHistFillColor(2);
141 MitStyle->SetHistFillStyle(0);
142 MitStyle->SetHistLineColor(1);
143 MitStyle->SetHistLineStyle(0);
144 MitStyle->SetHistLineWidth(2);
145 MitStyle->SetNdivisions(505);
146
147 // Functions
148 MitStyle->SetFuncColor(1);
149 MitStyle->SetFuncStyle(0);
150 MitStyle->SetFuncWidth(2);
151
152 // Various
153 MitStyle->SetMarkerStyle(20);
154 MitStyle->SetMarkerColor(kBlack);
155 MitStyle->SetMarkerSize (1.2);
156
157 MitStyle->SetTitleSize (0.055,"X");
158 MitStyle->SetTitleOffset(1.200,"X");
159 MitStyle->SetLabelOffset(0.005,"X");
160 MitStyle->SetLabelSize (0.050,"X");
161 MitStyle->SetLabelFont (42 ,"X");
162 MitStyle->SetTickLength (-0.03,"X");
163
164 MitStyle->SetStripDecimals(kFALSE);
165
166 MitStyle->SetTitleSize (0.055,"Y");
167 MitStyle->SetTitleOffset(1.800,"Y");
168 MitStyle->SetLabelOffset(0.010,"Y");
169 MitStyle->SetLabelSize (0.050,"Y");
170 MitStyle->SetLabelFont (42 ,"Y");
171 MitStyle->SetTickLength (-0.03,"Y");
172
173 MitStyle->SetTextSize (0.055);
174 MitStyle->SetTextFont (42);
175
176 MitStyle->SetStatFont (42);
177 MitStyle->SetTitleFont (42);
178 MitStyle->SetTitleFont (42,"X");
179 MitStyle->SetTitleFont (42,"Y");
180
181 MitStyle->SetOptStat (0);
182 return;
183 }