pylhe icon indicating copy to clipboard operation
pylhe copied to clipboard

Accessing values and info of a particle?

Open tshelley200 opened this issue 3 years ago • 2 comments

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!

tshelley200 avatar Apr 29 '22 08:04 tshelley200

Hello, maybe my comment https://github.com/scikit-hep/pylhe/issues/120#issuecomment-1114749613 will help you, as the example notebooks?

eduardo-rodrigues avatar May 03 '22 16:05 eduardo-rodrigues

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/.

Andresfgomez970 avatar May 17 '22 06:05 Andresfgomez970