Skip to content

N_gen set to sum weights - #145

Merged
mashephe merged 2 commits into
masterfrom
total_genmc_sumweight
Sep 3, 2026
Merged

N_gen set to sum weights#145
mashephe merged 2 commits into
masterfrom
total_genmc_sumweight

Conversation

@mashephe

@mashephe mashephe commented Sep 3, 2026

Copy link
Copy Markdown
Owner

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.

…rated MC sample as the total number of generated events rather than the integer number of actual generated events
Copilot AI lite review requested due to automatic review settings September 3, 2026 16:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 NormIntInterfaceMPI to exchange generated weight sums via MPI_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 thread AmpTools/IUAmpTools/NormIntInterface.cc Outdated
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 thread AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc
Comment thread AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc
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 );
@mashephe
mashephe merged commit 91b4ec7 into master Sep 3, 2026
8 checks passed
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