Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing values and info of a particle? #121

Open
tshelley200 opened this issue Apr 29, 2022 · 2 comments
Open

Accessing values and info of a particle? #121

tshelley200 opened this issue Apr 29, 2022 · 2 comments

Comments

@tshelley200
Copy link

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!

@eduardo-rodrigues
Copy link
Member

Hello, maybe my comment #120 (comment) will help you, as the example notebooks?

@Andresfgomez970
Copy link

Andresfgomez970 commented May 17, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants