<jupyter_start><jupyter_text>Notebook for reading TGraphs from '.C' filesWith this notebook you can read TGraphs from '.C' files. As explained in the "Getting started" notebook, a `Submission` needs to exist or be created.<jupyter_code>from hepdata_lib import Submission
submission = Submission()
from hepdata_lib import Table
table = Table("MyLimit")
table.description = "Here is the description."<jupyter_output><empty_output><jupyter_text>Here we import the `CFileReader` class from `hepdata_lib` and read a '.C' file.<jupyter_code>from hepdata_lib.c_file_reader import CFileReader
c_file = "example_inputs/brazilianFlag_BulkZZ_VVnew_new_combined_13TeV.C"
reader = CFileReader(c_file)
graphs = reader.get_graphs()<jupyter_output>/Users/clange/hepdata_lib/hepdata_lib/root_utils.py:412: FutureWarning: ROOT.Double is deprecated and will disappear in a future version of ROOT. Instead, use ctypes.c_double for pass-by-ref of doubles
  graph.GetPoint(i, x_val, y_val)<jupyter_text>Once you have read the '.C' file, you can list the included graphs with the following command:<jupyter_code>list(graphs.keys())<jupyter_output><empty_output><jupyter_text>`CFileReader` lists all `TGraphs` as a dictionary. You can access the included values by opening individual dictionaries and choosing the variable you want.<jupyter_code>from hepdata_lib import Variable, Uncertainty
d = Variable("Bulk graviton mass", is_independent=True, is_binned=False, units="GeV")
d.values = graphs["Graph0"]['x'][:30]

obs = Variable("BulkZZ", is_independent=False, is_binned=False, units="pb")
obs.values = graphs["Graph2"]['y'][:30]
obs.add_qualifier("Limit", "Observed")
obs.add_qualifier("SQRT(S)", 13, "TeV")
obs.add_qualifier("LUMINOSITY", 35.9, "fb$^{-1}$")

exp = Variable("BulkZZ", is_independent=False, is_binned=False, units="pb")
exp.values = graphs["Graph3"]['y'][:30]
exp.add_qualifier("Limit", "Expected")
exp.add_qualifier("SQRT(S)", 13, "TeV")
exp.add_qualifier("LUMINOSITY", 35.9, "fb$^{-1}$")

#+/- 1 sigma
unc_1s = Uncertainty("1 s.d.", is_symmetric=False)
unc_1s.set_values_from_intervals(zip(graphs["Graph1"]['y'][:30], graphs["Graph1"]['y'][::-1][:30]), nominal=exp.values)
exp.add_uncertainty(unc_1s)

# +/- 2 sigma
unc_2s = Uncertainty("2 s.d.", is_symmetric=False)
unc_2s.set_values_from_intervals(zip(graphs["Graph0"]['y'][:30], graphs["Graph0"]['y'][::-1][:30]), nominal=exp.values)
exp.add_uncertainty(unc_2s)<jupyter_output><empty_output><jupyter_text>All that needs to be done is to add the variables to the `Table`, the `Table` to the `Submission`, and then run the command to create the output files. Again, please refer to the 'Getting started' notebook for a complete example.<jupyter_code>table.add_variable(d)
table.add_variable(obs)
table.add_variable(exp)
submission.add_table(table)
submission.create_files("example_output")
!ls example_output
!head -n 30 example_output/mylimit.yaml<jupyter_output>dependent_variables:
- header:
    name: BulkZZ
    units: pb
  qualifiers:
  - name: Limit
    value: Observed
  - name: SQRT(S)
    units: TeV
    value: 13
  - name: LUMINOSITY
    units: fb$^{-1}$
    value: 35.9
  values:
  - value: 0.033069
  - value: 0.023478
  - value: 0.017733
  - value: 0.013937
  - value: 0.01084
  - value: 0.0086169
  - value: 0.0069185
  - value: 0.0056197
  - value: 0.0046831
  - value: 0.0039838
  - value: 0.0034093
  - value: 0.0030346
  - value: 0.0027099
  - value: 0.0024539
  - value: 0.0022541
  - value: 0.0020543
{'fraction_non_alphanumeric': 0.13836477987421383, 'fraction_numerical': 0.051457975986277875, 'mean_word_length': 5.431985294117647, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '73582', 'license': 'MIT', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1255, 'n_words': 297, 'path': 'examples/read_c_file.ipynb', 'repo_name': 'emanueleusai/hepdata_lib', 'size': '3498'}