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

pctpairprotons in Python #5

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

acoussat
Copy link
Contributor

Reimplementation of pctpairprotons in Python in order to remove the dependency on ROOT. The current behavior is that the script is always copied to the build folder, and the C++ version of pctpairprotons is only compiled when PCT_WITH_ROOT is on. I checked on simple cases that the C++ and the Python versions produce the same outputs at the byte level.

The Python version adds a dependency on pandas to efficiently merge the two ROOT files. I couldn't find an easy way to reproduce the same behavior in pure NumPy. I did write a pure NumPy implementation of the same script, but it uses for loops pretty much like the C++ version does. I didn't include it in this PR, but it is accessible there: https://github.com/acoussat/PCT/blob/pctpairprotons-numpy/pctpairprotons_numpy.py. I didn't extensively compare the two implementations to check which one is faster, but I would guess that pandas' optimized routine is probably faster.

Let me know what you think!

CMakeLists.txt Outdated
TARGET_LINK_LIBRARIES(pctpaircuts ${ROOT_LIBRARIES} RooFit RooFitCore Minuit)
ADD_PCT_EXECUTABLE(pctlluconverter pctlluconverter.cxx)
TARGET_LINK_LIBRARIES(pctlluconverter ${ROOT_LIBRARIES})
ADD_PCT_EXECUTABLE(pctpaircuts pctpaircuts.cxx)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to remove the root dependency but we can't entirely disable pctpaircuts. Would be nice to have a compilation define (e.g., PCT_USE_ROOT) to disable certain features in pctpaircuts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have implemented such idea atop master here: acoussat@5ae18f5. Should I open a new PR with this code or update this PR?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think it's part of the same PR.
Nothing wrong with your code but I'd consider creating a pctConfiguration.h.in similar to RTK's rtkConfiguration.h.in. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment! I have modified my code to mimic how RTK operates, and created pctConfiguration.h in commit 85074eb. Let me know what you think.

@acoussat
Copy link
Contributor Author

Following our discussion, 48fd2a5 removes the dependency on pandas and is pure NumPy. I checked on a simple example and I can reproduce the results of the previous version.

@acoussat acoussat force-pushed the pctpairprotons-python branch from 1529a94 to c8f54a8 Compare December 3, 2024 12:56
@acoussat
Copy link
Contributor Author

acoussat commented Dec 6, 2024

I just noticed that I did not re-implemented the optional sixth column with nuclear information. Should I also re-implement it or is it unnecessary at this stage?

@SimonRit
Copy link
Owner

SimonRit commented Dec 6, 2024

Yes, please reimplement it if it's not a lot of work. We can consider a reimplementation later on but it would be nice to start from just a translation of the original tool. Thanks in advance!

@acoussat acoussat force-pushed the pctpairprotons-python branch from 9a0771d to ec21a3d Compare December 12, 2024 08:58
@acoussat
Copy link
Contributor Author

Yes, please reimplement it if it's not a lot of work. We can consider a reimplementation later on but it would be nice to start from just a translation of the original tool. Thanks in advance!

Unfortunately, it's not as easy as it looks, as GATE 10 does not export branches NuclearProcess and Order. After discussing with @dsarrut, it looks to me that there is no straightforward solution, even if we modify GATE. We can discuss it more in details if you want, but @dsarrut suggests to postpone this feature or simply remove this part of the code. What do you think?

This commit introduces three changes:
- Provide the GATE simulation in GATE 10, and delete the old GATE 6 one
- Delete C++ version of pctpairprotons, which is now superseded by the Python version
- Change pctpairprotons.py to remove parameters that allowed to reorganize the GATE simulation output. pctpairprotons.py should now be easier to understand.

A single commit was made for these three changes because the changes they introduce are somewhat interleaved.
@acoussat acoussat force-pushed the pctpairprotons-python branch from 8f18b94 to 293416e Compare December 12, 2024 10:38
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

Successfully merging this pull request may close these issues.

2 participants