forked from padeken/k-Factor_calulations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.py
204 lines (168 loc) · 6.36 KB
/
helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env python
from ROOT import gROOT , TCanvas, TPad, gStyle,TFile, gPad, TLegend, TMath, TH1F, TStyle,TColor
import ROOT as ro
from array import array
#from env import *
from math import sqrt, fabs
tdrStyle = TStyle("tdrStyle","Style for P-TDR");
tdrStyle2 = TStyle("tdrStyle2","Style for P-TDR");
def xfrange(start, stop, step):
while start < stop:
yield start
start += step
def setTDRStyle(logy):
global tdrStyle
#ro.gROOT.Macro( "setTDRStyle.C")
# For the canvas:
tdrStyle.SetCanvasBorderMode(0);
tdrStyle.SetCanvasColor(ro.kWhite);
tdrStyle.SetCanvasDefH(600); #Height of canvas
tdrStyle.SetCanvasDefW(600); #Width of canvas
tdrStyle.SetCanvasDefX(0); #POsition on screen
tdrStyle.SetCanvasDefY(0);
# For the Pad:
tdrStyle.SetPadBorderMode(0);
# tdrStyle.SetPadBorderSize(Width_t size = 1);
tdrStyle.SetPadColor(ro.kWhite);
tdrStyle.SetPadGridX(False);
tdrStyle.SetPadGridY(False);
tdrStyle.SetGridColor(0);
tdrStyle.SetGridStyle(3);
tdrStyle.SetGridWidth(1);
# For the frame:
tdrStyle.SetFrameBorderMode(0);
tdrStyle.SetFrameBorderSize(1);
tdrStyle.SetFrameFillColor(0);
tdrStyle.SetFrameFillStyle(0);
tdrStyle.SetFrameLineColor(1);
tdrStyle.SetFrameLineStyle(1);
tdrStyle.SetFrameLineWidth(1);
# For the histo:
# tdrStyle.SetHistFillColor(1);
# tdrStyle.SetHistFillStyle(0);
tdrStyle.SetHistLineColor(1);
tdrStyle.SetHistLineStyle(0);
tdrStyle.SetHistLineWidth(2);
# tdrStyle.SetLegoInnerR(Float_t rad = 0.5);
# tdrStyle.SetNumberContours(Int_t number = 20);
tdrStyle.SetEndErrorSize(2);
# tdrStyle.SetErrorMarker(20);
#tdrStyle.SetErrorX(0.);
#tdrStyle.SetMarkerStyle(20);
#For the fit/function:
tdrStyle.SetOptFit(0);
tdrStyle.SetFitFormat("5.4g");
tdrStyle.SetFuncColor(2);
tdrStyle.SetFuncStyle(1);
tdrStyle.SetFuncWidth(1);
#For the date:
tdrStyle.SetOptDate(0);
# tdrStyle.SetDateX(Float_t x = 0.01);
# tdrStyle.SetDateY(Float_t y = 0.01);
# For the statistics box:
tdrStyle.SetOptFile(0);
tdrStyle.SetOptStat("emr"); # To display the mean and RMS: SetOptStat("mr");
tdrStyle.SetStatColor(ro.kWhite);
tdrStyle.SetStatFont(42);
tdrStyle.SetStatFontSize(0.025);
tdrStyle.SetStatTextColor(1);
tdrStyle.SetStatFormat("6.4g");
tdrStyle.SetStatBorderSize(1);
tdrStyle.SetStatH(0.1);
tdrStyle.SetStatW(0.15);
# tdrStyle.SetStatStyle(Style_t style = 1001);
# tdrStyle.SetStatX(Float_t x = 0);
# tdrStyle.SetStatY(Float_t y = 0);
# Margins:
tdrStyle.SetPadTopMargin(0.05);
tdrStyle.SetPadBottomMargin(0.13);
tdrStyle.SetPadLeftMargin(0.16);
tdrStyle.SetPadRightMargin(0.05);
# For the Global title:
tdrStyle.SetOptTitle(0);
tdrStyle.SetTitleFont(42);
tdrStyle.SetTitleColor(1);
tdrStyle.SetTitleTextColor(1);
tdrStyle.SetTitleFillColor(10);
tdrStyle.SetTitleFontSize(0.05);
# tdrStyle.SetTitleH(0); # Set the height of the title box
# tdrStyle.SetTitleW(0); # Set the width of the title box
# tdrStyle.SetTitleX(0); # Set the position of the title box
# tdrStyle.SetTitleY(0.985); # Set the position of the title box
# tdrStyle.SetTitleStyle(Style_t style = 1001);
# tdrStyle.SetTitleBorderSize(2);
# For the axis titles:
tdrStyle.SetTitleColor(1, "XYZ");
tdrStyle.SetTitleFont(42, "XYZ");
tdrStyle.SetTitleSize(0.06, "XYZ");
# tdrStyle.SetTitleXSize(Float_t size = 0.02); # Another way to set the size?
# tdrStyle.SetTitleYSize(Float_t size = 0.02);
tdrStyle.SetTitleXOffset(0.9);
tdrStyle.SetTitleYOffset(1.25);
# tdrStyle.SetTitleOffset(1.1, "Y"); # Another way to set the Offset
# For the axis labels:
tdrStyle.SetLabelColor(1, "XYZ");
tdrStyle.SetLabelFont(42, "XYZ");
tdrStyle.SetLabelOffset(0.007, "XYZ");
#~ tdrStyle.SetLabelSize(0.03, "XYZ");
tdrStyle.SetLabelSize(0.05, "XYZ");
# For the axis:
tdrStyle.SetAxisColor(1, "XYZ");
tdrStyle.SetStripDecimals(ro.kTRUE);
tdrStyle.SetTickLength(0.03, "XYZ");
tdrStyle.SetNdivisions(510, "XYZ");
tdrStyle.SetPadTickX(1); # To get tick marks on the opposite side of the frame
tdrStyle.SetPadTickY(1);
# For the Legend:
tdrStyle.SetLegendFont(42)
tdrStyle.SetLegendFillColor(ro.kWhite)
tdrStyle.SetLegendBorderSize(0)
# Change for log plots:
tdrStyle.SetOptLogx(0);
tdrStyle.SetOptLogy(logy);
tdrStyle.SetOptLogz(0);
# Postscript options:
tdrStyle.SetPaperSize(20.,20.);
tdrStyle.SetPalette(1);
#tdrStyle.SetHatchesLineWidth(5);
#tdrStyle.SetHatchesSpacing(0.05);
NRGBs = 5;
NCont = 255;
stops = [ 0.00, 0.34, 0.61, 0.84, 1.00 ]
red = [ 0.00, 0.00, 0.87, 1.00, 0.51 ]
green = [ 0.00, 0.81, 1.00, 0.20, 0.00 ]
blue = [ 0.51, 1.00, 0.12, 0.00, 0.00 ]
TColor.CreateGradientColorTable(NRGBs, array("d",stops), array("d", red), array("d",green ), array("d", blue), NCont);
#TColor.CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
#TColor.CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
tdrStyle.SetNumberContours(NCont);
#gROOT.ForceStyle();
tdrStyle.cd();
colors = [1, 2, 3, 4, 6, 7, 8, 9, 11]
markers = [20, 21, 22, 23, 24, 25, 26, 27, 28]
styles = [1, 2, 3, 4, 5, 6, 7, 8, 9]
#this function is not used at the moment but you never know if you want to make a nice color plot
def set_palette(name, ncontours=999):
"""Set a color palette from a given RGB list
stops, red, green and blue should all be lists of the same length
see set_decent_colors for an example"""
if name == "gray" or name == "grayscale":
stops = [0.00, 0.34, 0.61, 0.84, 1.00]
red = [1.00, 0.84, 0.61, 0.34, 0.00]
green = [1.00, 0.84, 0.61, 0.34, 0.00]
blue = [1.00, 0.84, 0.61, 0.34, 0.00]
# elif name == "whatever":
# (define more palettes)
else:
# default palette, looks cool
stops = [0.00, 0.34, 0.61, 0.84, 1.00]
red = [0.00, 0.00, 0.87, 1.00, 0.51]
green = [0.00, 0.81, 1.00, 0.20, 0.00]
blue = [0.51, 1.00, 0.12, 0.00, 0.00]
s = array('d', stops)
r = array('d', red)
g = array('d', green)
b = array('d', blue)
npoints = len(s)
ro.TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
ro.gStyle.SetNumberContours(ncontours)