Created
October 31, 2022 16:13
-
-
Save kratsg/e8bf750c8b4ccbda42b6c9bf39e0a6df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import onnx | |
import onnxruntime | |
from onnx import numpy_helper | |
import uproot | |
model="./model.onnx" | |
session = onnxruntime.InferenceSession(model, None) | |
input_name = session.get_inputs()[0].name | |
output_name = session.get_outputs()[0].name | |
print(input_name) | |
print(output_name) | |
with open("./inputs/branches_21.2.87-1.list.2") as fp: | |
branches = [line.strip() for line in fp.readlines()] | |
print(branches) | |
m_gluino = 2300 | |
m_lsp = 1200 | |
isGtt = 0 | |
for chunk in uproot.iterate("./inputs/DAOD_TRUTH3.GG_ttn1_2300_5000_1200_nominal.root:ntuple", expressions=branches, library="np", how=tuple): | |
step_size = len(chunk[0]) | |
data = np.stack([*chunk, [isGtt]*step_size, [m_gluino]*step_size, [m_lsp]*step_size]).T | |
result = session.run([output_name], {input_name: data.astype('float32')}) | |
print('result=',result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment