Details
BTVNanoCommissioning.utils.correction
BTVNanoCommissioning.utils.selection
BTVNanoCommissioning.utils.AK4_parameters
BTVNanoCommissioning.utils.array_writer
BTVNanoCommissioning.utils.histogrammer
BTVNanoCommissioning.utils.sample
BTVNanoCommissioning.utils.plot_utils
- BTVNanoCommissioning.utils.plot_utils.MCerrorband(hmc, ax=None, flow=None, label='Stat. unc.', fill_opts=None, ext_error=None, clear=False)[source]
Create a ratio plot, dividing two compatible histograms Parameters ———-
- hmcHist
A single-axis histogram
- axmatplotlib.axes.Axes, optional
Axes object (if None, one is created)
- flowstr, optional {None, “show”, “sum”}
Whether plot the under/overflow bin. If “show”, add additional under/overflow bin. If “sum”, add the under/overflow bin content to first/last bin.
- fill_optsdict, optional
A dictionary of options to pass to the matplotlib ax.fill_between call internal to this function, filling the denominator uncertainty band. Leave blank for defaults.
- labelstr, optional
Associate a label to this entry (note: y axis label set by
num.label)- ext_error: list of np.array[error_up,error_down], optional
External MC errors not stored in the original histogram
- clearbool, optional
Whether to clear Axes before drawing (if passed); if False, this function will skip drawing the legend
Returns
- axmatplotlib.axes.Axes
A matplotlib Axes object
- BTVNanoCommissioning.utils.plot_utils.clopper_pearson_interval(num, denom, coverage=0.6826894921370859)[source]
Compute Clopper-Pearson coverage interval for a binomial distribution Parameters ———-
- numnumpy.ndarray
Numerator, or number of successes, vectorized
- denomnumpy.ndarray
Denominator or number of trials, vectorized
- coveragefloat, optional
Central coverage interval, defaults to 68%
c.f. http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval
- BTVNanoCommissioning.utils.plot_utils.compatible(self, other)[source]
Checks if this histogram is compatible with another, i.e. they have identical binning
- BTVNanoCommissioning.utils.plot_utils.normal_interval(pw, tw, pw2, tw2, coverage=0.6826894921370859)[source]
Compute errors based on the expansion of pass/(pass + fail), possibly weighted Parameters ———-
- pwnp.ndarray
Numerator, or number of (weighted) successes, vectorized
- twnp.ndarray
Denominator or number of (weighted) trials, vectorized
- pw2np.ndarray
Numerator sum of weights squared, vectorized
- tw2np.ndarray
Denominator sum of weights squared, vectorized
- coveragefloat, optional
Central coverage interval, defaults to 68%
c.f. https://root.cern.ch/doc/master/TEfficiency_8cxx_source.html#l02515
- BTVNanoCommissioning.utils.plot_utils.plotratio(num, denom, ax=None, clear=True, flow=None, xerr=False, error_opts={}, denom_fill_opts={}, guide_opts={}, unc='num', label=None, ext_denom_error=None)[source]
Create a ratio plot, dividing two compatible histograms Parameters ———-
- numHist
Numerator, a single-axis histogram
- denomHist
Denominator, a single-axis histogram
- axmatplotlib.axes.Axes, optional
Axes object (if None, one is created)
- clearbool, optional
Whether to clear Axes before drawing (if passed); if False, this function will skip drawing the legend
- flowstr, optional {None, “show”, “sum”}
Whether plot the under/overflow bin. If “show”, add additional under/overflow bin. If “sum”, add the under/overflow bin content to first/last bin.
- xerr: bool, optional
If true, then error bars are drawn for x-axis to indicate the size of the bin.
- error_optsdict, optional
A dictionary of options to pass to the matplotlib ax.errorbar call internal to this function. Leave blank for defaults. Some special options are interpreted by this function and not passed to matplotlib: ‘emarker’ (default: ‘’) specifies the marker type to place at cap of the errorbar.
- denom_fill_optsdict, optional
A dictionary of options to pass to the matplotlib ax.fill_between call internal to this function, filling the denominator uncertainty band. Leave blank for defaults.
- guide_optsdict, optional
A dictionary of options to pass to the matplotlib ax.axhline call internal to this function, to plot a horizontal guide line at ratio of 1. Leave blank for defaults.
- uncstr, optional
Uncertainty calculation option: ‘clopper-pearson’ interval for efficiencies; ‘poisson-ratio’ interval for ratio of poisson distributions; ‘num’ poisson interval of numerator scaled by denominator value (common for data/mc, for better or worse).
- labelstr, optional
Associate a label to this entry (note: y axis label set by
num.label)- ext_denom_error: list of np.array[error_up,error_down], optional
External MC errors not stored in the original histogram
Returns
- axmatplotlib.axes.Axes
A matplotlib Axes object
- BTVNanoCommissioning.utils.plot_utils.poisson_interval(sumw, sumw2, coverage=0.6826894921370859)[source]
Frequentist coverage interval for Poisson-distributed observations Parameters ———-
- sumwnumpy.ndarray
Sum of weights vector
- sumw2numpy.ndarray
Sum weights squared vector
- coveragefloat, optional
Central coverage interval, defaults to 68%
Calculates the so-called ‘Garwood’ interval, c.f. https://www.ine.pt/revstat/pdf/rs120203.pdf or http://ms.mcmaster.ca/peter/s743/poissonalpha.html For weighted data, this approximates the observed count by
sumw**2/sumw2, which effectively scales the unweighted poisson interval by the average weight. This may not be the optimal solution: see https://arxiv.org/pdf/1309.1287.pdf for a proper treatment. When a bin is zero, the scale of the nearest nonzero bin is substituted to scale the nominal upper bound. If all bins zero, a warning is generated and interval is set tosumw.
BTVNanoCommissioning.helpers.update_branch
BTVNanoCommissioning.helpers.func
BTVNanoCommissioning.helpers.BTA_helper
BTVNanoCommissioning.helpers.xs_scaler
BTVNanoCommissioning.helpers.xsection
This module provides functions to handle cross section information used to normalize data and MC when making plots.
Cross section information is crucial for normalizing data and Monte Carlo (MC) simulations to ensure accurate comparisons and analyses.
To add a new dictionary to the cross section list, you can obtain the necessary information from the [XSDB](https://cms-gen-dev.cern.ch/xsdb/).
Example of a cross section dictionary:
“id”: “61641f28294617432cff1379”, “process_name”: “QCD_Pt-30to50_EMEnriched_TuneCP5_13TeV_pythia8”, “cross_section”: “6447000.0”, “total_uncertainty”: “19870.0”, “equivalent_lumi”: “0.0001551”, “matrix_generator”: “none”, “energy”: “13”,
}
scripts.