N_gen set to sum weights - #145
Merged
Merged
Conversation
…rated MC sample as the total number of generated events rather than the integer number of actual generated events
There was a problem hiding this comment.
🟡 Changes recommended
There are correctness issues around uninitialized MPI send buffers, potential divide-by-zero with weight sums, and cache export truncating generated weight sums to an int.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This pull request updates the normalization-integral workflow so that the generated-sample normalization (N_gen) is treated consistently with accepted MC by using the sum of generated event weights rather than a raw generated event count.
Changes:
- Switch generated-event normalization from integer event counts to double-precision weight sums (
numGenEvents()/setGenEvents()semantics updated). - Update MPI communication in
NormIntInterfaceMPIto exchange generated weight sums viaMPI_DOUBLE. - Update cache I/O and internal bookkeeping to store/use generated weight sums throughout integral calculation.
File summaries
| File | Description |
|---|---|
| AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc | Updates MPI reduction/broadcast paths to use generated weight sums (double) instead of integer counts. |
| AmpTools/IUAmpTools/NormIntInterface.h | Changes the public API for generated normalization from size_t count to double sum of weights. |
| AmpTools/IUAmpTools/NormIntInterface.cc | Propagates generated weight-sum normalization through cache load/export and integral computations. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+454
to
+458
| // the static cast produces an output file that is backwards compatible | ||
| // with older versions that used integer number of generated events | ||
| // rather than the sum of the weights -- this should not make any | ||
| // signficant difference in a result | ||
| out << static_cast<int>(m_sumGenWeights) << "\t" << m_sumAccWeights << endl; |
Comment on lines
120
to
122
| // send acknowledgment | ||
| MPI_Send( &thisEvents, 1, MPI_LONG, i, MPITag::kAcknowledge, | ||
| MPI_Send( &thisWeights, 1, MPI_DOUBLE, i, MPITag::kAcknowledge, | ||
| MPI_COMM_WORLD ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This modifies the Normalization Integral Interface to set the number of generated events equal to the sum of the weights in the generated MC sample. This introduces consistency between how the accepted and generated MC samples are treated.