SND@LHC Software
Loading...
Searching...
No Matches
ShipStyle.py
Go to the documentation of this file.
1from __future__ import print_function
2# Global scope variables
3from ROOT import *
4from ROOT import Double
5lhcbstyle = TStyle() # general lhcb style
6lhcbName = TPaveText() # standard lhcb text for plot
7lhcbLabel = TText # style for Ttext
8lhcbLatex = TLatex #style for TLatex
9
10# define names for colours
11black=1
12red=2
13green=3
14blue=4
15yellow=5
16magenta=6
17cyan=7
18purple=9
19
22
62
63 lhcbstyle=TStyle("lhcbstyle","Standard LHCb plots style")
64
65# use helvetica-bold-r-normal, precision 2 (rotatable)
66 lhcbFont = 62
67# line thickness
68 lhcbWidth = int(3.00)
69
70# use plain black on white colors
71 lhcbstyle.SetFrameBorderMode(0)
72 lhcbstyle.SetCanvasBorderMode(0)
73 lhcbstyle.SetPadBorderMode(0)
74 lhcbstyle.SetPadColor(0)
75 lhcbstyle.SetCanvasColor(0)
76 lhcbstyle.SetStatColor(0)
77 lhcbstyle.SetPalette(1)
78
79# set the paper & margin sizes
80 lhcbstyle.SetPaperSize(20,26)
81 lhcbstyle.SetPadTopMargin(0.05)
82 lhcbstyle.SetPadRightMargin(0.05) # increase for colz plots
83 lhcbstyle.SetPadBottomMargin(0.16)
84 lhcbstyle.SetPadLeftMargin(0.14)
85
86# use large fonts
87 lhcbstyle.SetTextFont(lhcbFont)
88 lhcbstyle.SetTextSize(0.08)
89 lhcbstyle.SetLabelFont(lhcbFont,"x")
90 lhcbstyle.SetLabelFont(lhcbFont,"y")
91 lhcbstyle.SetLabelFont(lhcbFont,"z")
92 lhcbstyle.SetLabelSize(0.04,"x")
93 lhcbstyle.SetLabelSize(0.04,"y")
94 lhcbstyle.SetLabelSize(0.04,"z")
95 lhcbstyle.SetTitleFont(lhcbFont)
96 lhcbstyle.SetTitleSize(0.05,"x")
97 lhcbstyle.SetTitleSize(0.05,"y")
98 lhcbstyle.SetTitleSize(0.05,"z")
99
100# use bold lines and markers
101 lhcbstyle.SetLineWidth(lhcbWidth)
102 lhcbstyle.SetFrameLineWidth(lhcbWidth)
103 lhcbstyle.SetHistLineWidth(lhcbWidth)
104 lhcbstyle.SetFuncWidth(lhcbWidth)
105 lhcbstyle.SetGridWidth(lhcbWidth)
106 lhcbstyle.SetLineStyleString(2,"[12 12]") # postscript dashes
107 lhcbstyle.SetMarkerStyle(20)
108 lhcbstyle.SetMarkerSize(1.5)
109
110# label offsets
111 lhcbstyle.SetLabelOffset(0.015)
112
113# by default, do not display histogram decorations:
114 lhcbstyle.SetOptStat(0)
115 lhcbstyle.SetOptStat("emr") # show only nent -e , mean - m , rms -r
116# full opts at http:#root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat
117 lhcbstyle.SetStatFormat("6.3g") # specified as c printf options
118 lhcbstyle.SetOptTitle(0)
119 lhcbstyle.SetOptFit(0)
120#lhcbstyle.SetOptFit(1011) # order is probability, Chi2, errors, parameters
121
122# look of the statistics box:
123 lhcbstyle.SetStatBorderSize(0)
124 lhcbstyle.SetStatFont(lhcbFont)
125 lhcbstyle.SetStatFontSize(0.05)
126 lhcbstyle.SetStatX(0.9)
127 lhcbstyle.SetStatY(0.9)
128 lhcbstyle.SetStatW(0.25)
129 lhcbstyle.SetStatH(0.15)
130# put tick marks on top and RHS of plots
131 lhcbstyle.SetPadTickX(1)
132 lhcbstyle.SetPadTickY(1)
133
134# histogram divisions: only 5 in x to avoid label overlaps
135 lhcbstyle.SetNdivisions(505,"x")
136 lhcbstyle.SetNdivisions(510,"y")
137
138
139#define style for text
140 lhcbLabel = TText()
141 lhcbLabel.SetTextFont(lhcbFont)
142 lhcbLabel.SetTextColor(1)
143 lhcbLabel.SetTextSize(0.04)
144 lhcbLabel.SetTextAlign(12)
145
146# define style of latex text
147 lhcbLatex = TLatex()
148 lhcbLatex.SetTextFont(lhcbFont)
149 lhcbLatex.SetTextColor(1)
150 lhcbLatex.SetTextSize(0.04)
151 lhcbLatex.SetTextAlign(12)
152
153# set this style
154 gROOT.SetStyle("lhcbstyle")
155 gROOT.ForceStyle()
156
157
158def printLHCb(optLR="L", optPrelim="Final", optText=""):
159
165 if optLR=="R" :
166 lhcbName = TPaveText(0.70 - lhcbstyle.GetPadRightMargin(),
167 0.75 - lhcbstyle.SetPadTopMargin(0.05),
168 0.95 - lhcbstyle.GetPadRightMargin(),
169 0.85 - lhcbstyle.SetPadTopMargin(0.05),
170 "BRNDC")
171 elif optLR=="L":
172 lhcbName = TPaveText(lhcbstyle.GetPadLeftMargin() + 0.05,
173 0.87 - lhcbstyle.GetPadTopMargin(),
174 lhcbstyle.GetPadLeftMargin() + 0.30,
175 0.95 - lhcbstyle.GetPadTopMargin(),
176 "BRNDC")
177 else :
178 print("printLHCb: option unknown" , optLR)
179 if optPrelim=="Final":
180 lhcbName.AddText("LHCb")
181 elif optPrelim=="Prelim":
182 lhcbName.AddText("#splitline{LHCb}{#scale[1.0]{Preliminary}}")
183 elif optPrelim=="Other":
184 lhcbName.AddText(optText)
185 else :
186 print("printLHCb: option unknown " , optPrelim)
187 lhcbName.SetFillColor(0)
188 lhcbName.SetTextAlign(12)
189 lhcbName.SetBorderSize(0)
190 lhcbName.Draw()
lhcbstyleSetup()
Definition ShipStyle.py:20
printLHCb(optLR="L", optPrelim="Final", optText="")
Definition ShipStyle.py:158