Accessing values and info of a particle?
Hi,
I was wondering about how to access the values of a particle's ID and other attributes (in numerical values) such as Px and Py. Are there any functions or methods I could use to get their numerical values?
Thanks!
Hello, maybe my comment https://github.com/scikit-hep/pylhe/issues/120#issuecomment-1114749613 will help you, as the example notebooks?
Hello there! I have been exploring a little, and a possible way to do it (surely not the most efficient) would be:
import pylhe
path = 'path_to_you/file.lhe'
var_of_interest = 'px' # let's say px to illustrate
data = {var_of_interest: []}
main_object = pylhe.readLHE(path)
for obj in main_object:
for particle in obj.particles:
data[var_of_interest].append(getattr(particle, var_of_interest))
print(data)
Furthermore, I have been working in some functionalities to read the data of .root files and .lhe files to a dataframe. This work is heavily based on uproot and pylhe. If you need something like that feel free to give a glimpse to https://pypi.org/project/nndm-library/.