1 |
dhidas |
1.1 |
from tdrStyle import *
|
2 |
|
|
from ROOT import *
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
def setStyle():
|
6 |
|
|
tdrStyle = setTDRStyle();
|
7 |
|
|
|
8 |
|
|
#slight adaptation
|
9 |
|
|
tdrStyle.SetPadRightMargin( 0.05 ); #originally was 0.02, too narrow!
|
10 |
|
|
tdrStyle.SetStatH( 0.2 );
|
11 |
|
|
#tdrStyle.SetOptStat(1110);//off title
|
12 |
|
|
tdrStyle.SetOptStat( 0 );#off title
|
13 |
|
|
tdrStyle.SetOptFit( 0 );#off title
|
14 |
|
|
tdrStyle.cd();
|
15 |
|
|
gROOT.ForceStyle();
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
def rebin( hists, nbins, histname ):
|
19 |
|
|
for sample in hists.keys():
|
20 |
|
|
if len( hists[sample].keys() ) == 0:
|
21 |
|
|
continue
|
22 |
|
|
if '*' in histname:
|
23 |
|
|
nameToken = histname.replace('*', '')
|
24 |
|
|
histlist = hists[sample]
|
25 |
|
|
for name in histlist.keys():
|
26 |
|
|
if nameToken in name:
|
27 |
|
|
hists[sample][name].Rebin( nbins )
|
28 |
|
|
elif hists[sample].has_key( histname ):
|
29 |
|
|
hists[sample][histname].Rebin( nbins )
|
30 |
|
|
return hists
|
31 |
|
|
|
32 |
|
|
def setXRange( hists, limits = ( 0, 5000 ), histname = '' ):
|
33 |
|
|
for sample in hists.keys():
|
34 |
|
|
if len( hists[sample].keys() ) == 0:
|
35 |
|
|
continue
|
36 |
|
|
if '*' in histname:
|
37 |
|
|
nameToken = histname.replace('*', '')
|
38 |
|
|
histlist = hists[sample]
|
39 |
|
|
for name in histlist.keys():
|
40 |
|
|
if nameToken in name:
|
41 |
|
|
hists[sample][name].GetXaxis().SetRangeUser( limits[0], limits[1] )
|
42 |
|
|
elif hists[sample].has_key( histname ):
|
43 |
|
|
hists[sample][histname].GetXaxis().SetRangeUser( limits[0], limits[1] );
|
44 |
|
|
return hists
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
def setXTitle( hists, title, histname = '' ):
|
48 |
|
|
for sample in hists.keys():
|
49 |
|
|
if len( hists[sample].keys() ) == 0:
|
50 |
|
|
continue
|
51 |
|
|
if '*' in histname:
|
52 |
|
|
nameToken = histname.replace('*', '')
|
53 |
|
|
histlist = hists[sample]
|
54 |
|
|
for name in histlist.keys():
|
55 |
|
|
if nameToken in name:
|
56 |
|
|
hists[sample][name].SetXTitle( title )
|
57 |
|
|
elif hists[sample].has_key( histname ):
|
58 |
|
|
hists[sample][histname].SetXTitle( title );
|
59 |
|
|
return hists
|
60 |
|
|
|
61 |
|
|
def setYTitle( hists, title, histname = '' ):
|
62 |
|
|
for sample in hists.keys():
|
63 |
|
|
if len( hists[sample].keys() ) == 0:
|
64 |
|
|
continue
|
65 |
|
|
if '*' in histname:
|
66 |
|
|
nameToken = histname.replace('*', '')
|
67 |
|
|
histlist = hists[sample]
|
68 |
|
|
for name in histlist.keys():
|
69 |
|
|
if nameToken in name:
|
70 |
|
|
hists[sample][name].SetYTitle( title )
|
71 |
|
|
elif hists[sample].has_key( histname ):
|
72 |
|
|
hists[sample][histname].SetYTitle( title );
|
73 |
|
|
return hists
|
74 |
|
|
|
75 |
|
|
# for sample in hists.keys():
|
76 |
|
|
# if len( hists[sample].keys() ) == 0 or not hists[sample].has_key( histname ) or not len( limits ) == 2:
|
77 |
|
|
# continue
|
78 |
|
|
# hists[sample][histname].GetXaxis().SetRangeUser( limits[0], limits[1] );
|
79 |
|
|
# return hists
|
80 |
|
|
|
81 |
|
|
def applyDefaultStylesAndColors( hists ):
|
82 |
|
|
defaultColors = {'data':0,
|
83 |
|
|
'ttbar' : kRed + 1,
|
84 |
|
|
'wjets' : kGreen - 3,
|
85 |
|
|
'zjets' : kAzure - 2,
|
86 |
|
|
'bce1' : kRed-7,
|
87 |
|
|
'bce2' : kRed-8,
|
88 |
|
|
'bce3' : kRed-9,
|
89 |
|
|
'enri1' : kBlue-7,
|
90 |
|
|
'enri2' : kBlue-8,
|
91 |
|
|
'enri3' : kBlue-9,
|
92 |
|
|
'pj1' : kYellow-7,
|
93 |
|
|
'pj2' : kYellow-8,
|
94 |
|
|
'pj3' : kYellow-9,
|
95 |
|
|
'qcd': kYellow,
|
96 |
|
|
'singleTop': kMagenta,
|
97 |
|
|
'Zprime500': kTeal - 9,
|
98 |
|
|
'Zprime750': kBlue - 6,
|
99 |
|
|
'Zprime1000': 28,
|
100 |
|
|
'Zprime1250': kCyan - 5,
|
101 |
|
|
'Zprime1500': kOrange + 1, }
|
102 |
|
|
|
103 |
|
|
for sample, histlist in hists.iteritems():
|
104 |
|
|
if not sample in defaultColors.keys():
|
105 |
|
|
continue
|
106 |
|
|
for histname, hist in histlist.iteritems():
|
107 |
|
|
hists[sample][histname].SetFillColor( defaultColors[sample] )
|
108 |
|
|
if histname == 'data':
|
109 |
|
|
hists[sample][histname].SetMarkerStyle( 8 )
|
110 |
|
|
elif 'Zprime' in histname:
|
111 |
|
|
hists[sample][histname].SetFillStyle( 0 )
|
112 |
|
|
hists[sample][histname].SetLineColor( defaultColors[sample] )
|
113 |
|
|
else:
|
114 |
|
|
hists[sample][histname].SetFillStyle( 1001 );
|
115 |
|
|
|
116 |
|
|
return hists
|
117 |
|
|
|