本文整理汇总了Python中tools.plotting.Histogram_properties.formats方法的典型用法代码示例。如果您正苦于以下问题:Python Histogram_properties.formats方法的具体用法?Python Histogram_properties.formats怎么用?Python Histogram_properties.formats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools.plotting.Histogram_properties
的用法示例。
在下文中一共展示了Histogram_properties.formats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: debug_last_bin
# 需要导入模块: from tools.plotting import Histogram_properties [as 别名]
# 或者: from tools.plotting.Histogram_properties import formats [as 别名]
def debug_last_bin():
'''
For debugging why the last bin in the problematic variables deviates a
lot in _one_ of the channels only.
'''
file_template = '/hdfs/TopQuarkGroup/run2/dpsData/'
file_template += 'data/normalisation/background_subtraction/13TeV/'
file_template += '{variable}/VisiblePS/central/'
file_template += 'normalised_xsection_{channel}_RooUnfoldSvd{suffix}.txt'
problematic_variables = ['HT', 'MET', 'NJets', 'lepton_pt']
for variable in problematic_variables:
results = {}
Result = namedtuple(
'Result', ['before_unfolding', 'after_unfolding', 'model'])
for channel in ['electron', 'muon', 'combined']:
input_file_data = file_template.format(
variable=variable,
channel=channel,
suffix='_with_errors',
)
input_file_model = file_template.format(
variable=variable,
channel=channel,
suffix='',
)
data = read_data_from_JSON(input_file_data)
data_model = read_data_from_JSON(input_file_model)
before_unfolding = data['TTJet_measured_withoutFakes']
after_unfolding = data['TTJet_unfolded']
model = data_model['powhegPythia8']
# only use the last bin
h_before_unfolding = value_errors_tuplelist_to_graph(
[before_unfolding[-1]], bin_edges_vis[variable][-2:])
h_after_unfolding = value_errors_tuplelist_to_graph(
[after_unfolding[-1]], bin_edges_vis[variable][-2:])
h_model = value_error_tuplelist_to_hist(
[model[-1]], bin_edges_vis[variable][-2:])
r = Result(before_unfolding, after_unfolding, model)
h = Result(h_before_unfolding, h_after_unfolding, h_model)
results[channel] = (r, h)
models = {'POWHEG+PYTHIA': results['combined'][1].model}
h_unfolded = [results[channel][1].after_unfolding for channel in [
'electron', 'muon', 'combined']]
tmp_hists = spread_x(h_unfolded, bin_edges_vis[variable][-2:])
measurements = {}
for channel, hist in zip(['electron', 'muon', 'combined'], tmp_hists):
value = results[channel][0].after_unfolding[-1][0]
error = results[channel][0].after_unfolding[-1][1]
label = '{c_label} ({value:1.2g} $\pm$ {error:1.2g})'.format(
c_label=channel,
value=value,
error=error,
)
measurements[label] = hist
properties = Histogram_properties()
properties.name = 'normalised_xsection_compare_channels_{0}_{1}_last_bin'.format(
variable, channel)
properties.title = 'Comparison of channels'
properties.path = 'plots'
properties.has_ratio = True
properties.xerr = False
properties.x_limits = (
bin_edges_vis[variable][-2], bin_edges_vis[variable][-1])
properties.x_axis_title = variables_latex[variable]
properties.y_axis_title = r'$\frac{1}{\sigma} \frac{d\sigma}{d' + \
variables_latex[variable] + '}$'
properties.legend_location = (0.95, 0.40)
if variable == 'NJets':
properties.legend_location = (0.97, 0.80)
properties.formats = ['png']
compare_measurements(models=models, measurements=measurements, show_measurement_errors=True,
histogram_properties=properties, save_folder='plots/', save_as=properties.formats)