def setUp(self): f = File('test.root', 'recreate') tree = create_test_tree() h = create_test_hist() h.write() tree.write() f.write() f.Close()
def main(options, args): config = XSectionConfig(options.CoM) variables = ['MET', 'HT', 'ST', 'WPT'] channels = ['electron', 'muon', 'combined'] m_file = 'normalised_xsection_patType1CorrectedPFMet.txt' m_with_errors_file = 'normalised_xsection_patType1CorrectedPFMet_with_errors.txt' path_template = args[0] output_file = 'measurement_{0}TeV.root'.format(options.CoM) f = File(output_file, 'recreate') for channel in channels: d = f.mkdir(channel) d.cd() for variable in variables: dv = d.mkdir(variable) dv.cd() if channel == 'combined': path = path_template.format(variable=variable, channel=channel, centre_of_mass_energy=options.CoM) else: kv = channel + \ '/kv{0}/'.format(config.k_values[channel][variable]) path = path_template.format(variable=variable, channel=kv, centre_of_mass_energy=options.CoM) m = read_data_from_JSON(path + '/' + m_file) m_with_errors = read_data_from_JSON( path + '/' + m_with_errors_file) for name, result in m.items(): h = make_histogram(result, bin_edges_full[variable]) h.SetName(name) h.write() for name, result in m_with_errors.items(): if not 'TTJet' in name: continue h = make_histogram(result, bin_edges_full[variable]) h.SetName(name + '_with_syst') h.write() dv.write() d.cd() d.write() f.write() f.close()
def main(options, args): config = XSectionConfig(options.CoM) variables = ['MET', 'HT', 'ST', 'WPT'] channels = ['electron', 'muon', 'combined'] m_file = 'normalised_xsection_patType1CorrectedPFMet.txt' m_with_errors_file = 'normalised_xsection_patType1CorrectedPFMet_with_errors.txt' path_template = args[0] output_file = 'measurement_{0}TeV.root'.format(options.CoM) f = File(output_file, 'recreate') for channel in channels: d = f.mkdir(channel) d.cd() for variable in variables: dv = d.mkdir(variable) dv.cd() if channel == 'combined': path = path_template.format(variable=variable, channel=channel, centre_of_mass_energy=options.CoM) else: kv = channel + \ '/kv{0}/'.format(config.k_values[channel][variable]) path = path_template.format(variable=variable, channel=kv, centre_of_mass_energy=options.CoM) m = read_data_from_JSON(path + '/' + m_file) m_with_errors = read_data_from_JSON(path + '/' + m_with_errors_file) for name, result in m.items(): h = make_histogram(result, bin_edges[variable]) h.SetName(name) h.write() for name, result in m_with_errors.items(): if not 'TTJet' in name: continue h = make_histogram(result, bin_edges[variable]) h.SetName(name + '_with_syst') h.write() dv.write() d.cd() d.write() f.write() f.close()