Skip to content

Conversation

@hahnjo
Copy link
Member

@hahnjo hahnjo commented Dec 8, 2025

As the classes are experimental, using the method will print a warning to inform the user.

Note that this is only a first version, there are a couple of advanced functionalities and better error handling that will come in future PRs.

As the classes are experimental, using the method will print a warning
to inform the user.
This needs one indirection to construct the std::tuple and separate
the weight argument.
Comment on lines +2407 to +2414
/// ### Example usage:
/// ~~~{.cpp}
/// auto h = std::make_shared<ROOT::Experimental::RHist<double>>(10, {5.0, 15.0});
/// auto myHist = myDf.Hist(h, {"col0"});
/// ~~~
template <typename ColumnType = RDFDetail::RInferredType, typename... ColumnTypes, typename BinContentType>
RResultPtr<ROOT::Experimental::RHist<BinContentType>>
Hist(std::shared_ptr<ROOT::Experimental::RHist<BinContentType>> h, const ColumnNames_t &columnList)
Copy link
Member Author

Choose a reason for hiding this comment

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

I believe we should market this overload as "bring your own histogram" 😅

Jokes aside, this will enable some nice use cases, for example filling a shared histogram from multiple computation graphs, as demonstrated by the RDFHist.PtrRunGraphs unit test.

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Test Results

    21 files      21 suites   3d 18h 43m 15s ⏱️
 3 787 tests  3 787 ✅ 0 💤 0 ❌
77 582 runs  77 582 ✅ 0 💤 0 ❌

Results for commit 46f531b.

Copy link
Member Author

@hahnjo hahnjo left a comment

Choose a reason for hiding this comment

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

Things to discuss during review (after the break)

{
std::shared_ptr h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(std::move(axes));
if (h->GetNDimensions() != columnList.size()) {
throw std::runtime_error("Wrong number of columns for the specified number of histogram axes.");
Copy link
Member Author

Choose a reason for hiding this comment

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

In histv7, we are consistently throwing std::invalid_argument while RDF prefers std::runtime_error. I think we have to decide which "consistency" to follow...

/// ROOT::Experimental::RRegularAxis axis(10, {5.0, 15.0});
/// auto myHist = myDf.Hist({axis}, {"col0"});
/// ~~~
template <typename BinContentType = double, typename ColumnType = RDFDetail::RInferredType, typename... ColumnTypes>
Copy link
Member Author

Choose a reason for hiding this comment

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

One could also argue for BinContentType = int or long as default since it's unweighted filling. However, then a number of "post-processing steps" require conversion, for example scaling...

Comment on lines 2227 to 2228
/// A list containing the names of the columns that will be passed when calling `Fill`.
/// (N columns for unweighted filling, or N+1 columns for weighted filling)
Copy link
Member Author

Choose a reason for hiding this comment

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

Reminder to ourselves that we want to change this, and backport to 6.38 a warning message

struct HistoND{};
struct HistoNSparseD{};
struct Hist{};
struct HistWithWeight{};
Copy link
Member Author

Choose a reason for hiding this comment

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

Having a second tag felt like the easiest solution, together with just a template argument bool WithWeight = false for RHistFillHelper. Other approaches are certainly possible...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant