Skip to content

Conversation

@edish-github
Copy link
Contributor

This Pull request:

Adds a convenience action .Product() to RDataFrame to calculate the product of column values. This complements the existing reductions like .Sum(), .Mean(), .Min(), and .Max().

The implementation uses the generic Reduce action with a multiplication lambda and an identity element of 1 (cast to the column type).

Motivation:
Calculating the product of a column is a common operation in HEP analysis (e.g., calculating total event weights from multiple scale factors: w_total = w_trig * w_iso * w_pileup). Currently, users must write a verbose Reduce lambda manually. This helper simplifies the syntax and prevents common "identity element" errors (starting at 0 instead of 1).

Changes or fixes:

  • Added Product function template to tree/dataframe/inc/ROOT/RDF/RInterface.hxx.
  • Implemented using Reduce with operator* and identity 1.
  • Added Doxygen documentation and usage examples.

Checklist:

  • tested changes locally (Verified with integer and double types using a factorial test case)
  • updated the docs (if necessary) (Added Doxygen comments to the header)

This PR fixes #

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.

3 participants