-
Notifications
You must be signed in to change notification settings - Fork 35
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
Optionally generate primaries without a HepMC3 input file in the demo loop #463
Conversation
Ooh fancy! Reviewing now! |
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.
Nice! Two minor comments.
int pdg; //!< Primary PDG number | ||
real_type energy; //!< [MeV] | ||
Real3 position; //!< [cm] | ||
Real3 direction; | ||
size_type num_events; | ||
size_type primaries_per_event; | ||
|
||
//! Whether the options are valid | ||
explicit operator bool() const | ||
{ | ||
return pdg != 0 && energy >= 0 && num_events > 0 | ||
&& primaries_per_event > 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.
Without initializers, these scalar types are uninitialized; in particular for the object LDemoArgs::primary_gen_options
. If you're unlucky (and on my machine, I seem to be always unlucky), this makes operator bool()
return true
and it's not possible to load HepMC3 files (unless an explicit primary_gen_options
initializes the fields to zero? not tested).
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.
Ugh, you're right: and since there's no unit test for this class it doesn't run through valgrind. I'll add a test and push a fix.
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.
Fixed by #472
The unintentional explicit constructor causes problems with nljson on clang 14. This showed up because of the IO in celeritas-project#463.
The unintentional explicit constructor causes problems with nljson on clang 14. This showed up because of the IO in #463.
This adds an optional demo loop input argument to generate primaries based on a specified quantity, particle type, energy, position, and direction rather than reading the events from a HepMC3 input file. For example, adding the following to the input JSON would generate the same primaries as in testem3.100k.hepmc3:
This should make it easier to run with a range of inputs, e.g. for #460, without needing to create a new HepMC3 input file each time.