File indexing completed on 2025-08-03 08:22:09
0001
0002
0003
0004
0005
0006
0007 from hepdata_lib import Submission, Table, Variable, Uncertainty, RootFileReader
0008
0009
0010 reader = RootFileReader("spectrum_output.root")
0011
0012
0013 submission = Submission()
0014
0015
0016
0017 table1 = Table("Exponential Spectrum")
0018 table1.description = "Dummy cross-section with statistical uncertainties and asymmetric systematic uncertainties."
0019 table1.location = "Data from Figure 1, located on page 3."
0020
0021 table1.keywords["observables"] = ["D2SIG/DPT/DETARAP"]
0022 table1.keywords["cmenergies"] = ["200"]
0023 table1.keywords["reactions"] = ["P P --> D0 X", "P P --> DBAR0 X"]
0024 table1.keywords["phrases"] = ["Cross Section", "Single Differential Cross Section","Proton-Proton Scattering","Transverse Momentum Dependence"]
0025
0026 table1.add_image("spectrum.png")
0027
0028
0029 hist = reader.read_hist_1d("hist_stat")
0030 graph = reader.read_graph("graph_asym")
0031
0032
0033
0034
0035
0036
0037 histogram_x = Variable("$p_{T}$", is_independent=True, is_binned=False, units="GeV")
0038 histogram_x.values = hist["x"]
0039
0040 histogram_y = Variable("Cross-section", is_independent=False, is_binned=False, units="mb")
0041 histogram_y.values = hist["y"]
0042
0043
0044 stat_unc = Uncertainty("stat", is_symmetric=True)
0045 stat_unc.values = hist["dy"]
0046
0047 sys_unc = Uncertainty("sys", is_symmetric=False)
0048 sys_unc.values = graph["dy"]
0049
0050
0051
0052
0053
0054
0055 histogram_y.add_uncertainty(stat_unc)
0056 histogram_y.add_uncertainty(sys_unc)
0057
0058
0059 table1.add_variable(histogram_x)
0060 table1.add_variable(histogram_y)
0061
0062
0063 hist_halved = reader.read_hist_1d("hist_halved")
0064 histogram_y_halved = Variable("Cross-section halved", is_independent=False, is_binned=False, units="mb")
0065 histogram_y_halved.values = hist_halved["y"]
0066 table1.add_variable(histogram_y_halved)
0067
0068
0069
0070 table2 = Table("Bin-to-bin Correlation Matrix")
0071 table2.description = "Random symmetric bin-to-bin correlation matrix used for uncertainty modeling."
0072 table2.add_image("corr_matrix.png")
0073 corr_matrix = reader.read_hist_2d("corr_matrix")
0074
0075
0076 x = Variable("First Axis", is_independent=True, is_binned=True)
0077 x.values = corr_matrix["x_edges"]
0078 y = Variable("Second Axis", is_independent=True, is_binned=True)
0079 y.values = corr_matrix["y_edges"]
0080 correlation = Variable("Correlation coefficient", is_independent=False, is_binned=False)
0081 correlation.values = corr_matrix["z"]
0082
0083
0084 for var in [x,y,correlation]:
0085 table2.add_variable(var)
0086
0087
0088 submission.add_table(table1)
0089 submission.add_table(table2)
0090
0091
0092 submission.create_files("submission_hepdata",remove_old=True)
0093
0094
0095
0096
0097
0098
0099
0100