-
Notifications
You must be signed in to change notification settings - Fork 45
Implement Celeritas-DD4hep integration plugin #1756
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
base: develop
Are you sure you want to change the base?
Implement Celeritas-DD4hep integration plugin #1756
Conversation
Test summary 5 735 files 9 221 suites 7m 2s ⏱️ Results for commit aeadd13. ♻️ This comment has been updated with latest results. |
b3e3fd5 to
ab67f02
Compare
ccc0fca to
988047d
Compare
6369a78 to
2d9531e
Compare
|
@sethrj This implementation is pretty preliminary based on streamlining the multiple test beds I was working on. I decided to use the OpenDataDetector from acts-project for validation as it should be a simpler approximation to something like the EIC ePIC geometry. Build and run instructions are inside the steeringFile.py. I can see celeritas logs but haven't validated the output yet. |
|
Running with gdb to investigate segfaults gives: |
|
Building Geant4 Building DD4hep Building celeritas Running with gdb Complete backtrace |
|
|
With changes to the hit processor (#1835), we can see some hits in the ODD ecal if we ignore saving MC truth particle info in edm4hep output. Now we need to consider the following:
|
sethrj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great! Excellent work, and I have hope that we can continue to make the integration even tighter.
| inline DDcelerRunAction(Geant4Context* ctxt, std::string const& nam); | ||
|
|
||
| // Default destructor | ||
| ~DDcelerRunAction(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think virtual is automatic if the base class is; @esseivaju has taught me using override (if it's not the first virtual base class), whichI think is the best choice here.
| workflow_call: | ||
| push: | ||
| branches: | ||
| - feature-dd4hep-integration-plugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: will update this so that we run at the end of each PR
| if (!tfile || tfile->IsZombie()) | ||
| { | ||
| std::cerr << "Error: Cannot open file " << file.Data() << std::endl; | ||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should exit with a failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now being done as part of the GHA workflow via a root invocation; is that or a direct build preferable? (I would tend toward direct build but I'm not a ROOT guy.)
example/ddceler/steeringFile.py
Outdated
| @@ -0,0 +1,59 @@ | |||
| """ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the Celeritas copyright header to this file and other relevant ones.
| CELER_VALIDATE(!overlayed_obj->magnetic_components.empty(), | ||
| << "No magnetic field components found in DD4hep field " | ||
| "description."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's OK if there's no magnetic field; we can just use a constant of zero.
| double min_step = 1e-6 * celer_mm; | ||
| double delta_chord = 0.025 * celer_mm; | ||
| double delta_intersection = 1e-5 * celer_mm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does DD4HEP define these defaults somewhere? It would be good to annotate where they should be copied from
| // Save diagnostic file to a unique name | ||
| opts.output_file = "trackingmanager-offload.out.json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a user input parameter, or be based on the dd4hep run name
| } // namespace sim | ||
| } // namespace dd4hep | ||
|
|
||
| DECLARE_GEANT4ACTION(DDcelerTMI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little annotation about what this does would be good (it doesn't start with DDG4_ or anything to indicate it's coming from that library).
src/ddceler/DDcelerTMI.hh
Outdated
| int m_maxNumTracks; | ||
| int m_initCapacity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be default initialized. Maybe use -1, and then VALIDATE that they're greater than zero when you first set up, to ensure that the user has set them to appropriate values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use unsigned here since both num tracks and capacity are inherently positive (and then init at 0 since that's what the capacity presumably is at startup).
This commit means that you must (please!) install pre-commit on your development machine and run `pre-commit install --install-hooks`. For more information, see https://celeritas-project.github.io/celeritas/user/development/style.html#formatting Autogenerated: https://pre-commit.ci
…ponents files - Set CMAKE_LIBRARY_OUTPUT_DIRECTORY to output plugin libraries to build/lib - Configure RPATH to prioritize build directory libraries over installed ones - Use BUILD_RPATH to point to build/lib during development - Use INSTALL_RPATH for installation directory - Add --disable-new-dtags linker flag to use RPATH instead of RUNPATH for correct library search priority - Add custom target to copy .components files to build/lib for DD4hep plugin discovery This ensures the plugins link against the newly built Celeritas libraries instead of any pre-existing installation (e.g., /opt/local). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
When VecGeom is enabled, add accel_final library with --no-as-needed linker flag to ensure proper symbol resolution for VecGeom geometry. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
src/ddceler/DDcelerTMI.hh
Outdated
| DDcelerTMI::DDcelerTMI(Geant4Context* ctxt, std::string const& nam) | ||
| : Geant4PhysicsList(ctxt, nam) | ||
| { | ||
| declareProperty("MaxNumTracks", m_maxNumTracks); | ||
| declareProperty("InitCapacity", m_initCapacity); | ||
| declareProperty("IgnoreProcesses", m_ignoreProcesses); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go in the .cc file (there is, after all, nowhere to inline it to!). Once we transition to an inp::FrameworkInput, we can specify even more of these (and maybe semi-automate it). Since should be set before the run initialization, we could do this setup in the TMI or RunAction.
|
|
||
| // Register Celeritas tracking manager | ||
| auto& tmi = TMI::Instance(); | ||
| physics->RegisterPhysics(new celeritas::TrackingManagerConstructor(&tmi)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this can throw, you may want to write (after including accel/ExceptionConverter.hh):
| physics->RegisterPhysics(new celeritas::TrackingManagerConstructor(&tmi)); | |
| CELER_TRY_HANDLE( | |
| physics->RegisterPhysics(new celeritas::TrackingManagerConstructor(&tmi)), | |
| ExceptionConverter{"ddceler.construct-physics"}); |
and same below with your call to SetOptions(makeOptions())
…ywhere" This reverts commit 9120784.
Removed push trigger for feature-dd4hep-integration-plugin branch.
This reverts commit 1b437a6.
Updated the workflow to run Celeritas and Geant4 simulations in parallel, capturing logs for both and checking exit codes.
Removed sourcing of /etc/profile in the CI workflow.
Added error handling and improved logging for dd4hep integration tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Rename RUNNER to runner (lowercase for module-level variable) - Rename setupPhysics to setup_physics (snake_case for functions) - Reformat docstring to be more concise - Split long comment line to stay within 79 character limit - Add function docstring - Move DDG4 imports inside function scope 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Update DDcelerTMI constructor parameter from nam to name - Update DDcelerRunAction constructor parameter from nam to name - Remove 'nam' from codespell-ignore.txt 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…m/rahmans1/celeritas into feature-dd4hep-integration-plugin
Default-initialize m_maxNumTracks and m_initCapacity to 0 and add validation in makeOptions() to ensure they are set to positive values before use. This addresses PR feedback to ensure users explicitly configure these parameters. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| DDG4_DEFINE_ACTION_CONSTRUCTORS(DDcelerTMI); | ||
|
|
||
| int m_maxNumTracks{0}; | ||
| int m_initCapacity{0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wdconinc if i try to set it to unsigned, i get the following error
PhysicsList +++ Verbosity: 1
BasicGrammar ERROR FAILED to look up non existent registry: 46C292BB247E0FFD [unsigned int]
DDSim.Helper.Physics ERROR Exception in UserFunction: <cppyy.gbl.std.runtime_error object at 0x57907f1714d0>
Traceback (most recent call last):
File "/opt/local/lib/python3.12/site-packages/DDSim/Helper/Physics.py", line 221, in setupPhysics
func(kernel)
File "/home/srahman1/celeritas-dd4hep/celeritas-orange/example/ddceler/steeringFile.py", line 51, in setup_physics
celer_phys = PhysicsList(kernel, str("DDcelerTMI"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/local/lib/python3.12/site-packages/DDG4.py", line 242, in PhysicsList
return Interface.createPhysicsList(kernel, str(nam))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cppyy.gbl.std.runtime_error: static dd4hep::sim::PhysicsListHandle dd4hep::sim::Geant4ActionCreation::createPhysicsList(dd4hep::sim::KernelHandle& kernel, const string& name_type) =>
runtime_error: BasicGrammar: FAILED to look up non existent registry: 46C292BB247E0FFD [unsigned int]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/local/bin/ddsim", line 25, in <module>
sys.exit(RUNNER.run())
^^^^^^^^^^^^
File "/opt/local/lib/python3.12/site-packages/DDSim/DD4hepSimulation.py", line 519, in run
_phys = self.physics.setupPhysics(kernel, name=self.physicsList)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/local/lib/python3.12/site-packages/DDSim/Helper/Physics.py", line 224, in setupPhysics
raise RuntimeError("Exception in UserFunction: %r" % e)
RuntimeError: Exception in UserFunction: <cppyy.gbl.std.runtime_error object at 0x57907f1714d0>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this caused by the unsigned int change? Doesn't look like that to me.

See issue #1731