Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions hist/histv7/inc/ROOT/RHist.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,11 @@ public:
template <typename... A>
void Fill(const A &...args)
{
fEngine.Fill(args...);
fStats.Fill(args...);
static_assert(sizeof...(A) >= 1, "need at least one argument to Fill");
if constexpr (sizeof...(A) >= 1) {
fEngine.Fill(args...);
fStats.Fill(args...);
}
}

/// Scale all histogram bin contents and statistics.
Expand Down
62 changes: 34 additions & 28 deletions hist/histv7/inc/ROOT/RHistEngine.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -365,21 +365,24 @@ public:
template <typename... A>
void Fill(const A &...args)
{
auto t = std::forward_as_tuple(args...);
if constexpr (std::is_same_v<typename Internal::LastType<A...>::type, RWeight>) {
static_assert(SupportsWeightedFilling, "weighted filling is not supported for integral bin content types");
static constexpr std::size_t N = sizeof...(A) - 1;
if (N != fAxes.GetNDimensions()) {
throw std::invalid_argument("invalid number of arguments to Fill");
static_assert(sizeof...(A) >= 1, "need at least one argument to Fill");
if constexpr (sizeof...(A) >= 1) {
auto t = std::forward_as_tuple(args...);
if constexpr (std::is_same_v<typename Internal::LastType<A...>::type, RWeight>) {
static_assert(SupportsWeightedFilling, "weighted filling is not supported for integral bin content types");
static constexpr std::size_t N = sizeof...(A) - 1;
if (N != fAxes.GetNDimensions()) {
throw std::invalid_argument("invalid number of arguments to Fill");
}
RWeight weight = std::get<N>(t);
RLinearizedIndex index = fAxes.ComputeGlobalIndexImpl<N>(t);
if (index.fValid) {
assert(index.fIndex < fBinContents.size());
fBinContents[index.fIndex] += weight.fValue;
}
} else {
Fill(t);
}
RWeight weight = std::get<N>(t);
RLinearizedIndex index = fAxes.ComputeGlobalIndexImpl<N>(t);
if (index.fValid) {
assert(index.fIndex < fBinContents.size());
fBinContents[index.fIndex] += weight.fValue;
}
} else {
Fill(t);
}
}

Expand Down Expand Up @@ -458,21 +461,24 @@ public:
template <typename... A>
void FillAtomic(const A &...args)
{
auto t = std::forward_as_tuple(args...);
if constexpr (std::is_same_v<typename Internal::LastType<A...>::type, RWeight>) {
static_assert(SupportsWeightedFilling, "weighted filling is not supported for integral bin content types");
static constexpr std::size_t N = sizeof...(A) - 1;
if (N != fAxes.GetNDimensions()) {
throw std::invalid_argument("invalid number of arguments to Fill");
}
RWeight weight = std::get<N>(t);
RLinearizedIndex index = fAxes.ComputeGlobalIndexImpl<N>(t);
if (index.fValid) {
assert(index.fIndex < fBinContents.size());
Internal::AtomicAdd(&fBinContents[index.fIndex], weight.fValue);
static_assert(sizeof...(A) >= 1, "need at least one argument to Fill");
if constexpr (sizeof...(A) >= 1) {
auto t = std::forward_as_tuple(args...);
if constexpr (std::is_same_v<typename Internal::LastType<A...>::type, RWeight>) {
static_assert(SupportsWeightedFilling, "weighted filling is not supported for integral bin content types");
static constexpr std::size_t N = sizeof...(A) - 1;
if (N != fAxes.GetNDimensions()) {
throw std::invalid_argument("invalid number of arguments to Fill");
}
RWeight weight = std::get<N>(t);
RLinearizedIndex index = fAxes.ComputeGlobalIndexImpl<N>(t);
if (index.fValid) {
assert(index.fIndex < fBinContents.size());
Internal::AtomicAdd(&fBinContents[index.fIndex], weight.fValue);
}
} else {
FillAtomic(t);
}
} else {
FillAtomic(t);
}
}

Expand Down
7 changes: 5 additions & 2 deletions hist/histv7/inc/ROOT/RHistFillContext.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ public:
template <typename... A>
void Fill(const A &...args)
{
fHist->fEngine.FillAtomic(args...);
fStats.Fill(args...);
static_assert(sizeof...(A) >= 1, "need at least one argument to Fill");
if constexpr (sizeof...(A) >= 1) {
fHist->fEngine.FillAtomic(args...);
fStats.Fill(args...);
}
}

/// Flush locally accumulated entries to the histogram.
Expand Down
27 changes: 15 additions & 12 deletions hist/histv7/inc/ROOT/RHistStats.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -415,19 +415,22 @@ public:
template <typename... A>
void Fill(const A &...args)
{
auto t = std::forward_as_tuple(args...);
if constexpr (std::is_same_v<typename Internal::LastType<A...>::type, RWeight>) {
static constexpr std::size_t N = sizeof...(A) - 1;
if (N != fDimensionStats.size()) {
throw std::invalid_argument("invalid number of arguments to Fill");
static_assert(sizeof...(A) >= 1, "need at least one argument to Fill");
if constexpr (sizeof...(A) >= 1) {
auto t = std::forward_as_tuple(args...);
if constexpr (std::is_same_v<typename Internal::LastType<A...>::type, RWeight>) {
static constexpr std::size_t N = sizeof...(A) - 1;
if (N != fDimensionStats.size()) {
throw std::invalid_argument("invalid number of arguments to Fill");
}
fNEntries++;
double w = std::get<N>(t).fValue;
fSumW += w;
fSumW2 += w * w;
FillImpl<0, N>(t, w);
} else {
Fill(t);
}
fNEntries++;
double w = std::get<N>(t).fValue;
fSumW += w;
fSumW2 += w * w;
FillImpl<0, N>(t, w);
} else {
Fill(t);
}
}

Expand Down
Loading