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

test: geant4 python example #1334

Merged
merged 24 commits into from
Aug 2, 2022
Merged

Conversation

andiwand
Copy link
Contributor

@andiwand andiwand commented Jul 21, 2022

similar to fatras.py I tried to add a Geant4 utility function to add it to the chain instead of fatras

@andiwand andiwand added the 🚧 WIP Work-in-progress label Jul 21, 2022
@andiwand
Copy link
Contributor Author

andiwand commented Jul 21, 2022

any thoughts on this @paulgessinger @timadye ?

we could also run this in the CI or use it to run Geant4 in the CI

@codecov
Copy link

codecov bot commented Jul 21, 2022

Codecov Report

Merging #1334 (997245a) into main (6fe9ca2) will not change coverage.
The diff coverage is n/a.

❗ Current head 997245a differs from pull request most recent head a78a045. Consider uploading reports for the commit a78a045 to get more accurate results

@@           Coverage Diff           @@
##             main    #1334   +/-   ##
=======================================
  Coverage   47.46%   47.46%           
=======================================
  Files         375      375           
  Lines       19827    19827           
  Branches     9297     9297           
=======================================
  Hits         9410     9410           
  Misses       4033     4033           
  Partials     6384     6384           

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@andiwand andiwand changed the title example python geant4 testexample python geant4 Jul 21, 2022
@andiwand andiwand changed the title testexample python geant4 test: example python geant4 Jul 21, 2022
@paulgessinger
Copy link
Member

This is a very good idea, thanks!

@andiwand andiwand added this to the next milestone Jul 22, 2022
@andiwand andiwand removed the 🚧 WIP Work-in-progress label Jul 22, 2022
@andiwand andiwand changed the title test: example python geant4 test: geant4 python example Jul 22, 2022
@timadye
Copy link
Contributor

timadye commented Jul 22, 2022

Looks good. Just a couple of suggestions:

  • Can this be coordinated with refactor: Move add* functions to python modules #1309? Probably simplest is to make a similar move as done there, moving addGeant4 to the new Examples/Python/python/acts/examples/simulation.py, but keep runGeant4 where it is.
  • Comparing with addFatras, I notice that addGeant4 doesn't have any output writers. I guess they would work the same as for Fatras (since both output to particles_final etc), so the same code could be copied. That's potentially a lot of duplicated code, so maybe could be done with an internal routine (addFratrasWriters?) called by both addGeant4 and addFatras in acts.examples.simulation.

What do you think?

@andiwand
Copy link
Contributor Author

those are very good suggestions @timadye thank you! I am going to implement this next week

@andiwand andiwand requested a review from timadye July 25, 2022 07:26
@andiwand
Copy link
Contributor Author

I implemented your suggestions @timadye . do you know when #1309 will be ready? I guess we can merge #1309 or #1334 first either way and deal with the conflicts in the remaining PR. happy to do it in #1309 too

@timadye
Copy link
Contributor

timadye commented Jul 25, 2022

do you know when #1309 will be ready? I guess we can merge #1309 or #1334 first either way and deal with the conflicts in the remaining PR. happy to do it in #1309 too

Hopefully @tboldagh and @paulgessinger can comment on the best way/order to do this.

@tboldagh
Copy link
Contributor

do you know when #1309 will be ready?
I actively look into is now. Struggling a bit with ACTS complex build system though. But earlier today I was able to reproduce the issue seen online. So far so good.

@tboldagh
Copy link
Contributor

tboldagh commented Jul 25, 2022

Need an advice one one thing here. The getOpenDataDetecotrDirectory discovery mechanism for the ODD files path relied on the fact the the __file__ was pointing in fact to the sources directory. However, now when above function is installed the __file__ points to the build dir. I though that the way to go is to use DD4hep_DIR env variable. But I am struggling with it actually. @timadye @paulgessinger

@paulgessinger
Copy link
Member

That's a good point. I think these functions can't really work in the installed case, since they assume they know where ODD is located.
I don't think we can assume this in the installed case.

Do we need to support this autoconfig ODD mode if ACTS is installed?

@andiwand
Copy link
Contributor Author

in this case we might want to install the ODD as well as part of Acts. but we might overshoot the original goal

@timadye
Copy link
Contributor

timadye commented Jul 25, 2022

Alternatively, could we treat the ODD like we treat the ITk and let the user specify the base directory? For the ITk, we need to do that because it's in a separate repo, but we could use a similar mechanism for the ODD.

@paulgessinger
Copy link
Member

We use the ODD all over the place in the python based tests and it's our performance baseline. I think it's reasonable to have ODD work "out-of-the-box" in the most common scenario.

@tboldagh
Copy link
Contributor

Maybe odd.py could only contain the getOpenDataDetector whereas the getOpenDataDetectorDirectory could go back to the sources dir and thus allow the discovery. Archeologists will wonder though.

@timadye
Copy link
Contributor

timadye commented Jul 25, 2022

Maybe odd.py could only contain the getOpenDataDetector whereas the getOpenDataDetectorDirectory could go back to the sources dir and thus allow the discovery. Archeologists will wonder though.

How do we refer to the source directory in the import? If we kept the current layout, it would mean ODD scripts would only work if run from the source directory, which was one of the things this change was supposed to fix.

andiwand and others added 2 commits July 28, 2022 15:09
Co-authored-by: Paul Gessinger <hello@paulgessinger.com>
@andiwand
Copy link
Contributor Author

Should we actually run this from pytest @andiwand? Might have to go through subprocess again because G4.

good idea will do

@andiwand
Copy link
Contributor Author

this should be ready now

Copy link
Member

@paulgessinger paulgessinger left a comment

Choose a reason for hiding this comment

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

Sorry for more comments. 😅

Examples/Python/python/acts/examples/simulation.py Outdated Show resolved Hide resolved
Examples/Python/tests/test_examples.py Outdated Show resolved Hide resolved
Examples/Python/tests/test_examples.py Show resolved Hide resolved
andiwand and others added 4 commits August 1, 2022 15:58
Co-authored-by: Paul Gessinger <hello@paulgessinger.com>
Co-authored-by: Paul Gessinger <hello@paulgessinger.com>
@andiwand
Copy link
Contributor Author

andiwand commented Aug 2, 2022

I think I addressed all your comments @paulgessinger

@kodiakhq kodiakhq bot merged commit 8f07289 into acts-project:main Aug 2, 2022
@andiwand andiwand deleted the example-python-geant4 branch August 2, 2022 11:08
@paulgessinger paulgessinger modified the milestones: next, v19.6.0 Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants