-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMSGraphics.py
87 lines (67 loc) · 2.63 KB
/
CMSGraphics.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
import os, sys, imp
import ROOT
from array import array
import CMS_lumi
def makeCMSCanvas(name="canvas",title="canvas",width=800,height=600):
canvas = ROOT.TCanvas(name,name,50,50,width,height)
canvas.SetFillColor(0)
canvas.SetBorderMode(0)
canvas.SetFrameFillStyle(0)
canvas.SetFrameBorderMode(0)
T = 0.08*600
B = 0.12*600
L = 0.12*800
R = 0.04*800
canvas.SetLeftMargin( L/width )
canvas.SetRightMargin( R/width )
canvas.SetTopMargin( T/height )
canvas.SetBottomMargin( B/height )
canvas.SetTickx(0)
canvas.SetTicky(0)
if width == 800: ROOT.gStyle.SetTitleYOffset(1)
return canvas
def makeLegend(nentries=1):
height = nentries*0.06
leg = ROOT.TLegend(0.56,(0.88 - height),0.92,0.88)
leg.SetMargin(0.)
leg.SetFillColor(ROOT.kWhite)
leg.SetBorderSize(0)
leg.SetTextSize(0.04)
leg.SetTextFont(20)
return leg
def printLumiPrelLeft(canvas, lumitext="13 TeV"):
#change the CMS_lumi variables (see CMS_lumi.py)
CMS_lumi.writeExtraText = 1
CMS_lumi.extraText = "Preliminary"
CMS_lumi.lumi_sqrtS = lumitext # used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string)
iPos = 11 # inside frame left, default
if ( iPos==0 ): CMS_lumi.relPosX = 0.12
iPeriod = 4
CMS_lumi.CMS_lumi(canvas, iPeriod, iPos)
def printLumiPrelOut(canvas, lumitext="13 TeV"):
#change the CMS_lumi variables (see CMS_lumi.py)
CMS_lumi.writeExtraText = 1
CMS_lumi.extraText = "Preliminary"
CMS_lumi.lumi_sqrtS = lumitext # used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string)
iPos = 0 # outside frame left
if ( iPos==0 ): CMS_lumi.relPosX = 0.12
iPeriod = 4
CMS_lumi.CMS_lumi(canvas, iPeriod, iPos)
def printLumiLeft(canvas, lumitext="13 TeV"):
#change the CMS_lumi variables (see CMS_lumi.py)
CMS_lumi.writeExtraText = 0
CMS_lumi.extraText = ""
CMS_lumi.lumi_sqrtS = lumitext # used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string)
iPos = 11 # inside frame left, default
if ( iPos==0 ): CMS_lumi.relPosX = 0.12
iPeriod = 4
CMS_lumi.CMS_lumi(canvas, iPeriod, iPos)
def printLumiOut(canvas, lumitext="13 TeV"):
#change the CMS_lumi variables (see CMS_lumi.py)
CMS_lumi.writeExtraText = 0
CMS_lumi.extraText = ""
CMS_lumi.lumi_sqrtS = lumitext # used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string)
iPos = 0 # outside frame left
if ( iPos==0 ): CMS_lumi.relPosX = 0.12
iPeriod = 4
CMS_lumi.CMS_lumi(canvas, iPeriod, iPos)