Functions | |
def | getOverlayMarkerAndLegend (legend, entries, options, borderSize=2.0/3, markerStyle="P") |
Global Style | |
Set the properties of the global gStyle object and create colours and colour palettes | |
def | SetTDRStyle () |
Sets the PubComm recommended style. More... | |
def | ModTDRStyle (width=600, height=600, t=0.06, b=0.12, l=0.16, r=0.04) |
Modified version of the tdrStyle. More... | |
def | SetBirdPalette () |
def | SetDeepSeaPalette () |
def | SetCorrMatrixPalette () |
def | CreateTransparentColor (color, alpha) |
def | Set (obj, **kwargs) |
TPad Layout | |
Create TPads for pre-defined layouts, for example adding a smaller lower TPad to contain ratios of objects in the main pad. | |
def | OnePad () |
def | TwoPadSplit (split_point, gap_low, gap_high) |
def | ThreePadSplit (upper_split_point, split_point, gap_low, gap_high) |
def | MultiRatioSplit (split_points, gaps_low, gaps_high) |
Create a set of TPads split vertically on the TCanvas. More... | |
def | TwoPadSplitColumns (split_point, gap_left, gap_right) |
def | MultiRatioSplitColumns (split_points, gaps_left, gaps_right) |
def | SetupTwoPadSplitAsRatio (pads, upper, lower, y_title, y_centered, y_min, y_max) |
def | StandardAxes (xaxis, yaxis, var, units, fmt='.1f') |
Axis histograms | |
By default the first TH1 or TGraph drawn on a pad takes control of the x- and y-axis settings. A better way is to create dedicated "axis" TH1s that can be drawn first, one per pad, which will then control all the axis properties. | |
def | CreateAxisHist (src, at_limits=True) |
def | CreateAxisHists (n, src, at_limits) |
def | GetAxisHist (pad) |
TFile functions | |
A collection of functions for working with TFiles. | |
def | TFileIsGood (filename) |
Performs a series of tests on a TFile to ensure that it can be opened without errors. More... | |
def | MakeTChain (files, tree) |
def | Get (file, obj) |
def | ParamFromFilename (filename, param) |
Object creation | |
These functions take existing objects (TH1s, TGraphs, TTrees, etc) and build new objects | |
def | TGraphFromTree (tree, xvar, yvar, selection) |
def | TGraph2DFromTree (tree, xvar, yvar, zvar, selection) |
def | RocCurveFrom1DHists (h_x, h_y, cut_is_greater_than) |
def | TH2FromTGraph2D (graph, method='BinEdgeAligned', force_x_width=None, force_y_width=None) |
Build an empty TH2 from the set of points in a TGraph2D. More... | |
def | MakeErrorBand (LowerGraph, UpperGraph) |
def | LimitTGraphFromJSON (js, label) |
def | LimitTGraphFromJSONFile (jsfile, label) |
def | ToyTGraphFromJSON (js, label) |
def | ToyTGraphFromJSONFile (jsfile, label) |
def | LimitBandTGraphFromJSON (js, central, lo, hi) |
def | StandardLimitsFromJSONFile (json_file, draw=['obs', 'exp0', 'exp1', 'exp2']) |
def | bestFit (tree, x, y, cut) |
def | treeToHist2D (t, x, y, name, cut, xmin, xmax, ymin, ymax, xbins, ybins) |
def | makeHist1D (name, xbins, graph, scaleXrange=1.0, absoluteXrange=None) |
def | makeHist2D (name, xbins, ybins, graph2d) |
def | makeVarBinHist2D (name, xbins, ybins) |
def | GraphDifference (graph1, graph2, relative) |
def | GraphDivide (num, den) |
def | MakeRatioHist (num, den, num_err, den_err) |
Make a new ratio TH1 from numerator and denominator TH1s with optional error propagation. More... | |
Graph manipulation | |
These functions are mostly used to modify TGraphs corresponding to likelihood scans. | |
def | RemoveGraphXDuplicates (graph) |
def | ApplyGraphYOffset (graph, y_off) |
def | RemoveGraphYAll (graph, val) |
def | RemoveSmallDelta (graph, val) |
def | RemoveGraphYAbove (graph, val) |
def | SetMinToZero (graph) |
def | ImproveMinimum (graph, func, doIt=False) |
def | FindCrossingsWithSpline (graph, func, yval) |
def | ReZeroTGraph (gr, doIt=False) |
def | FilterGraph (gr, n=3) |
def | RemoveInXRange (gr, xmin=0, xmax=1) |
def | RemoveNearMin (graph, val, spacing=None) |
def | SortGraph (Graph) |
TPad adjustments | |
These functions are mostly concerned with adjusting the axis ranges to make sure objects are not being drawn outside the range of the pad or underneath other objects, e.g. the legend. | |
def | FixTopRange (pad, fix_y, fraction) |
def | FixBothRanges (pad, fix_y_lo, frac_lo, fix_y_hi, frac_hi) |
Adjusts y-axis range such that a lower and a higher value are located a fixed fraction of the frame height away from a new minimum and maximum respectively. More... | |
def | GetPadYMaxInRange (pad, x_min, x_max, do_min=False) |
def | GetPadYMax (pad, do_min=False) |
def | GetPadYMin (pad) |
def | FixOverlay () |
def | FixBoxPadding (pad, box, frac) |
Decoration | |
Functions for drawing legends, logos, title, lines and boxes | |
def | StandardAxes (xaxis, yaxis, var, units) |
def | DrawCMSLogo (pad, cmsText, extraText, iPosX, relPosX, relPosY, relExtraDY, extraText2='', cmsTextSize=0.8) |
Blah. More... | |
def | PositionedLegend (width, height, pos, offset, horizontaloffset=None) |
def | DrawHorizontalLine (pad, line, yval) |
def | DrawVerticalLine (pad, line, xval) |
def | DrawVerticalBand (pad, box, x1, x2) |
def | DrawTitle (pad, text, align, textOffset=0.2, textSize=0.6) |
Limit plotting | |
Common limit-plotting tasks, for example setting the Brazilian colour scheme for expected limit bands and drawing the associated TGraphs in the correct order | |
def | isclose (a, b, rel_tol=1e-9, abs_tol=0.0) |
def | StyleLimitBand (graph_dict, overwrite_style_dict=None) |
def | DrawLimitBand (pad, graph_dict, draw=['exp2', 'exp1', 'exp0', 'obs'], draw_legend=None, legend=None, legend_overwrite=None) |
Contour plotting | |
Creating contour TGraphs using TH2s and TGraph2Ds | |
def | contourFromTH2 (h2in, threshold, minPoints=10, frameValue=1000.) |
def | frameTH2D (hist, threshold, frameValue=1000) |
def | fastFillTH2 (hist2d, graph, initalValue=99999, interpolateMissing=False) |
def | fillTH2 (hist2d, graph) |
def | fillInvertedTH2 (hist2d, graph) |
def | NewInterpolate (hist) |
def | rebin (hist) |
def | higgsConstraint (model, higgstype) |
Variables | |
list | COL_STORE = [] |
def python.plotting.SetTDRStyle | ( | ) |
Sets the PubComm recommended style.
Just a copy of http://ghm.web.cern.ch/ghm/plots/MacroExample/tdrstyle.C
Definition at line 26 of file plotting.py.
def python.plotting.ModTDRStyle | ( | width = 600 , |
|
height = 600 , |
|||
t = 0.06 , |
|||
b = 0.12 , |
|||
l = 0.16 , |
|||
r = 0.04 |
|||
) |
Modified version of the tdrStyle.
width | Canvas width in pixels |
height | Canvas height in pixels |
t | Pad top margin [0-1] |
b | Pad bottom margin [0-1] |
l | Pad left margin [0-1] |
r | Pad right margin [0-1] |
Definition at line 177 of file plotting.py.
def python.plotting.SetBirdPalette | ( | ) |
Definition at line 251 of file plotting.py.
def python.plotting.SetDeepSeaPalette | ( | ) |
Definition at line 264 of file plotting.py.
def python.plotting.SetCorrMatrixPalette | ( | ) |
Definition at line 277 of file plotting.py.
def python.plotting.CreateTransparentColor | ( | color, | |
alpha | |||
) |
Definition at line 286 of file plotting.py.
def python.plotting.Set | ( | obj, | |
** | kwargs | ||
) |
Definition at line 296 of file plotting.py.
def python.plotting.OnePad | ( | ) |
Definition at line 314 of file plotting.py.
def python.plotting.TwoPadSplit | ( | split_point, | |
gap_low, | |||
gap_high | |||
) |
Definition at line 322 of file plotting.py.
def python.plotting.ThreePadSplit | ( | upper_split_point, | |
split_point, | |||
gap_low, | |||
gap_high | |||
) |
Definition at line 335 of file plotting.py.
def python.plotting.MultiRatioSplit | ( | split_points, | |
gaps_low, | |||
gaps_high | |||
) |
Create a set of TPads split vertically on the TCanvas.
This is a generalisation of the two pad main/ratio split but for the case of multiple ratio pads.
split_points | Height of each ratio pad as a fraction of the canvas height. Pads will be created from the bottom of the frame upwards. The final, main pad will occupy however much space remains, therefore the size of this list should be [number of pads] - 1. |
gaps_low | Gaps between ratio pad frames created on the lower pad side at each boundary. Give a list of zeroes for no gap between pad frames. Should be the same length as split_points .1 |
gaps_high | Gaps between ratio pad frames created on the upper pad side at each boundary. Give a list of zeroes for no gap between pad frames. |
Definition at line 374 of file plotting.py.
def python.plotting.TwoPadSplitColumns | ( | split_point, | |
gap_left, | |||
gap_right | |||
) |
Definition at line 389 of file plotting.py.
def python.plotting.MultiRatioSplitColumns | ( | split_points, | |
gaps_left, | |||
gaps_right | |||
) |
Definition at line 403 of file plotting.py.
def python.plotting.SetupTwoPadSplitAsRatio | ( | pads, | |
upper, | |||
lower, | |||
y_title, | |||
y_centered, | |||
y_min, | |||
y_max | |||
) |
Definition at line 419 of file plotting.py.
def python.plotting.StandardAxes | ( | xaxis, | |
yaxis, | |||
var, | |||
units, | |||
fmt = '.1f' |
|||
) |
Definition at line 437 of file plotting.py.
def python.plotting.CreateAxisHist | ( | src, | |
at_limits = True |
|||
) |
Definition at line 460 of file plotting.py.
def python.plotting.CreateAxisHists | ( | n, | |
src, | |||
at_limits | |||
) |
Definition at line 485 of file plotting.py.
def python.plotting.GetAxisHist | ( | pad | ) |
Definition at line 493 of file plotting.py.
def python.plotting.TFileIsGood | ( | filename | ) |
Performs a series of tests on a TFile to ensure that it can be opened without errors.
filename | str The name of the TFile to check |
bool
True if the file can opened, is not a zombie, and if ROOT did not need to try and recover the contents Definition at line 527 of file plotting.py.
def python.plotting.MakeTChain | ( | files, | |
tree | |||
) |
Definition at line 545 of file plotting.py.
def python.plotting.Get | ( | file, | |
obj | |||
) |
Definition at line 552 of file plotting.py.
def python.plotting.ParamFromFilename | ( | filename, | |
param | |||
) |
Definition at line 560 of file plotting.py.
def python.plotting.TGraphFromTree | ( | tree, | |
xvar, | |||
yvar, | |||
selection | |||
) |
Definition at line 581 of file plotting.py.
def python.plotting.TGraph2DFromTree | ( | tree, | |
xvar, | |||
yvar, | |||
zvar, | |||
selection | |||
) |
Definition at line 587 of file plotting.py.
def python.plotting.RocCurveFrom1DHists | ( | h_x, | |
h_y, | |||
cut_is_greater_than | |||
) |
Definition at line 594 of file plotting.py.
def python.plotting.TH2FromTGraph2D | ( | graph, | |
method = 'BinEdgeAligned' , |
|||
force_x_width = None , |
|||
force_y_width = None |
|||
) |
Build an empty TH2 from the set of points in a TGraph2D.
There is no unique way to define a TH2 binning given an arbitrary TGraph2D, therefore this function supports multiple named methods:
BinEdgeAligned
simply takes the sets of x- and y- values in the TGraph2D and uses these as the bin edge arrays in the TH2. The implication of this is that when filling the bin contents interpolation will be required when evaluating the TGraph2D at the bin centres.BinCenterAligned
will try to have the TGraph2D points at the bin centers, but this will only work completely correctly when the input point spacing is regular. The algorithm first identifies the bin width as the smallest interval between points on each axis. The start position of the TH2 axis is then defined as the lowest value in the TGraph2D minus half this width, and the axis continues with regular bins until the graph maximum is passed.graph | Should have at least two unique x and y values, otherwise we can't define any bins |
method | The binning algorithm to use |
force_x_width | Override the derived x-axis bin width in the CenterAligned method |
force_y_width | Override the derived y-axis bin width in the CenterAligned method |
RuntimeError | If the method name is not recognised |
Definition at line 670 of file plotting.py.
def python.plotting.MakeErrorBand | ( | LowerGraph, | |
UpperGraph | |||
) |
Definition at line 712 of file plotting.py.
def python.plotting.LimitTGraphFromJSON | ( | js, | |
label | |||
) |
Definition at line 730 of file plotting.py.
def python.plotting.LimitTGraphFromJSONFile | ( | jsfile, | |
label | |||
) |
Definition at line 741 of file plotting.py.
def python.plotting.ToyTGraphFromJSON | ( | js, | |
label | |||
) |
Definition at line 746 of file plotting.py.
def python.plotting.ToyTGraphFromJSONFile | ( | jsfile, | |
label | |||
) |
Definition at line 768 of file plotting.py.
def python.plotting.LimitBandTGraphFromJSON | ( | js, | |
central, | |||
lo, | |||
hi | |||
) |
Definition at line 773 of file plotting.py.
def python.plotting.StandardLimitsFromJSONFile | ( | json_file, | |
draw = ['obs', 'exp0', 'exp1', 'exp2'] |
|||
) |
Definition at line 789 of file plotting.py.
def python.plotting.bestFit | ( | tree, | |
x, | |||
y, | |||
cut | |||
) |
Definition at line 805 of file plotting.py.
def python.plotting.treeToHist2D | ( | t, | |
x, | |||
y, | |||
name, | |||
cut, | |||
xmin, | |||
xmax, | |||
ymin, | |||
ymax, | |||
xbins, | |||
ybins | |||
) |
Definition at line 820 of file plotting.py.
def python.plotting.makeHist1D | ( | name, | |
xbins, | |||
graph, | |||
scaleXrange = 1.0 , |
|||
absoluteXrange = None |
|||
) |
Definition at line 838 of file plotting.py.
def python.plotting.makeHist2D | ( | name, | |
xbins, | |||
ybins, | |||
graph2d | |||
) |
Definition at line 849 of file plotting.py.
def python.plotting.makeVarBinHist2D | ( | name, | |
xbins, | |||
ybins | |||
) |
Definition at line 859 of file plotting.py.
def python.plotting.GraphDifference | ( | graph1, | |
graph2, | |||
relative | |||
) |
Definition at line 888 of file plotting.py.
def python.plotting.GraphDivide | ( | num, | |
den | |||
) |
Definition at line 904 of file plotting.py.
def python.plotting.MakeRatioHist | ( | num, | |
den, | |||
num_err, | |||
den_err | |||
) |
Make a new ratio TH1 from numerator and denominator TH1s with optional error propagation.
num | Numerator histogram |
den | Denominator histogram |
num_err | Propagate the error in the numerator TH1 |
den_err | Propagate the error in the denominator TH1 |
Definition at line 928 of file plotting.py.
def python.plotting.RemoveGraphXDuplicates | ( | graph | ) |
Definition at line 947 of file plotting.py.
def python.plotting.ApplyGraphYOffset | ( | graph, | |
y_off | |||
) |
Definition at line 957 of file plotting.py.
def python.plotting.RemoveGraphYAll | ( | graph, | |
val | |||
) |
Definition at line 962 of file plotting.py.
def python.plotting.RemoveSmallDelta | ( | graph, | |
val | |||
) |
Definition at line 971 of file plotting.py.
def python.plotting.RemoveGraphYAbove | ( | graph, | |
val | |||
) |
Definition at line 981 of file plotting.py.
def python.plotting.SetMinToZero | ( | graph | ) |
Definition at line 991 of file plotting.py.
def python.plotting.ImproveMinimum | ( | graph, | |
func, | |||
doIt = False |
|||
) |
Definition at line 1003 of file plotting.py.
def python.plotting.FindCrossingsWithSpline | ( | graph, | |
func, | |||
yval | |||
) |
Definition at line 1040 of file plotting.py.
def python.plotting.ReZeroTGraph | ( | gr, | |
doIt = False |
|||
) |
Definition at line 1087 of file plotting.py.
def python.plotting.FilterGraph | ( | gr, | |
n = 3 |
|||
) |
Definition at line 1112 of file plotting.py.
def python.plotting.RemoveInXRange | ( | gr, | |
xmin = 0 , |
|||
xmax = 1 |
|||
) |
Definition at line 1126 of file plotting.py.
def python.plotting.RemoveNearMin | ( | graph, | |
val, | |||
spacing = None |
|||
) |
Definition at line 1138 of file plotting.py.
def python.plotting.SortGraph | ( | Graph | ) |
Definition at line 1166 of file plotting.py.
def python.plotting.FixTopRange | ( | pad, | |
fix_y, | |||
fraction | |||
) |
Definition at line 1186 of file plotting.py.
def python.plotting.FixBothRanges | ( | pad, | |
fix_y_lo, | |||
frac_lo, | |||
fix_y_hi, | |||
frac_hi | |||
) |
Adjusts y-axis range such that a lower and a higher value are located a fixed fraction of the frame height away from a new minimum and maximum respectively.
This function is useful in conjunction with GetPadYMax which returns the maximum or minimum y value of all histograms and graphs drawn on the pad.
In the example below, the minimum and maximum values found via this function are used as the fix_y_lo
and fix_y_hi
arguments, and the spacing fractions as 0.15 and 0.30 respectively.
pad | A TPad on which histograms and graphs have already been drawn |
fix_y_lo | The y value which will end up a fraction frac_lo above the new axis minimum. |
frac_lo | A fraction of the y-axis height |
fix_y_hi | The y value which will end up a fraction frac_hi below from the new axis maximum. |
frac_hi | A fraction of the y-axis height |
Definition at line 1226 of file plotting.py.
def python.plotting.GetPadYMaxInRange | ( | pad, | |
x_min, | |||
x_max, | |||
do_min = False |
|||
) |
Definition at line 1252 of file plotting.py.
def python.plotting.GetPadYMax | ( | pad, | |
do_min = False |
|||
) |
Definition at line 1310 of file plotting.py.
def python.plotting.GetPadYMin | ( | pad | ) |
Definition at line 1319 of file plotting.py.
def python.plotting.FixOverlay | ( | ) |
Definition at line 1323 of file plotting.py.
def python.plotting.FixBoxPadding | ( | pad, | |
box, | |||
frac | |||
) |
Definition at line 1328 of file plotting.py.
def python.plotting.StandardAxes | ( | xaxis, | |
yaxis, | |||
var, | |||
units | |||
) |
Definition at line 1372 of file plotting.py.
def python.plotting.DrawCMSLogo | ( | pad, | |
cmsText, | |||
extraText, | |||
iPosX, | |||
relPosX, | |||
relPosY, | |||
relExtraDY, | |||
extraText2 = '' , |
|||
cmsTextSize = 0.8 |
|||
) |
Blah.
pad | Description |
cmsText | Description |
extraText | Description |
iPosX | Description |
relPosX | Description |
relPosY | Description |
relExtraDY | Description |
extraText2 | Description |
cmsTextSize | Description |
Definition at line 1399 of file plotting.py.
def python.plotting.PositionedLegend | ( | width, | |
height, | |||
pos, | |||
offset, | |||
horizontaloffset = None |
|||
) |
Definition at line 1492 of file plotting.py.
def python.plotting.DrawHorizontalLine | ( | pad, | |
line, | |||
yval | |||
) |
Definition at line 1519 of file plotting.py.
def python.plotting.DrawVerticalLine | ( | pad, | |
line, | |||
xval | |||
) |
Definition at line 1526 of file plotting.py.
def python.plotting.DrawVerticalBand | ( | pad, | |
box, | |||
x1, | |||
x2 | |||
) |
Definition at line 1532 of file plotting.py.
def python.plotting.DrawTitle | ( | pad, | |
text, | |||
align, | |||
textOffset = 0.2 , |
|||
textSize = 0.6 |
|||
) |
Definition at line 1539 of file plotting.py.
def python.plotting.isclose | ( | a, | |
b, | |||
rel_tol = 1e-9 , |
|||
abs_tol = 0.0 |
|||
) |
Definition at line 1583 of file plotting.py.
def python.plotting.StyleLimitBand | ( | graph_dict, | |
overwrite_style_dict = None |
|||
) |
Definition at line 1586 of file plotting.py.
def python.plotting.DrawLimitBand | ( | pad, | |
graph_dict, | |||
draw = ['exp2', 'exp1', 'exp0', 'obs'] , |
|||
draw_legend = None , |
|||
legend = None , |
|||
legend_overwrite = None |
|||
) |
Definition at line 1602 of file plotting.py.
def python.plotting.contourFromTH2 | ( | h2in, | |
threshold, | |||
minPoints = 10 , |
|||
frameValue = 1000. |
|||
) |
Definition at line 1636 of file plotting.py.
def python.plotting.frameTH2D | ( | hist, | |
threshold, | |||
frameValue = 1000 |
|||
) |
Definition at line 1675 of file plotting.py.
def python.plotting.fastFillTH2 | ( | hist2d, | |
graph, | |||
initalValue = 99999 , |
|||
interpolateMissing = False |
|||
) |
Definition at line 1742 of file plotting.py.
def python.plotting.fillTH2 | ( | hist2d, | |
graph | |||
) |
Definition at line 1761 of file plotting.py.
def python.plotting.fillInvertedTH2 | ( | hist2d, | |
graph | |||
) |
Definition at line 1769 of file plotting.py.
def python.plotting.NewInterpolate | ( | hist | ) |
Definition at line 1782 of file plotting.py.
def python.plotting.rebin | ( | hist | ) |
Definition at line 1871 of file plotting.py.
def python.plotting.higgsConstraint | ( | model, | |
higgstype | |||
) |
Definition at line 1898 of file plotting.py.
def python.plotting.getOverlayMarkerAndLegend | ( | legend, | |
entries, | |||
options, | |||
borderSize = 2.0/3 , |
|||
markerStyle = "P" |
|||
) |
Definition at line 1920 of file plotting.py.
list python.plotting.COL_STORE = [] |
Definition at line 12 of file plotting.py.