Skip to content
Open
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
141 changes: 81 additions & 60 deletions hist/histv7/inc/ROOT/RHist.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public:

~RHist() = default;

/// \name Accessors
/// \{

const RHistEngine<BinContentType> &GetEngine() const { return fEngine; }
const RHistStats &GetStats() const { return fStats; }

Expand All @@ -154,13 +157,22 @@ public:
std::uint64_t GetTotalNBins() const { return fEngine.GetTotalNBins(); }

std::uint64_t GetNEntries() const { return fStats.GetNEntries(); }

/// \}
/// \name Computations
/// \{

/// \copydoc RHistStats::ComputeNEffectiveEntries()
double ComputeNEffectiveEntries() const { return fStats.ComputeNEffectiveEntries(); }
/// \copydoc RHistStats::ComputeMean()
double ComputeMean(std::size_t dim = 0) const { return fStats.ComputeMean(dim); }
/// \copydoc RHistStats::ComputeStdDev()
double ComputeStdDev(std::size_t dim = 0) const { return fStats.ComputeStdDev(dim); }

/// \}
/// \name Accessors
/// \{

/// Get the content of a single bin.
///
/// \code
Expand Down Expand Up @@ -258,8 +270,7 @@ public:
/// \param[in] indices the array of indices for each axis
/// \param[in] value the new value of the bin content
/// \par See also
/// the \ref SetBinContent(const A &... args) const "variadic function template overload" accepting arguments
/// directly
/// the \ref SetBinContent(const A &... args) "variadic function template overload" accepting arguments directly
template <std::size_t N, typename V>
void SetBinContent(const std::array<RBinIndex, N> &indices, const V &value)
{
Expand Down Expand Up @@ -287,71 +298,18 @@ public:
///
/// \param[in] args the arguments for each axis and the new value of the bin content
/// \par See also
/// the \ref SetBinContent(const std::array<RBinIndex, N> &indices, const V &value) const "function overload"
/// accepting `std::array`
/// the \ref SetBinContent(const std::array<RBinIndex, N> &indices, const V &value) "function overload" accepting
/// `std::array`
template <typename... A>
void SetBinContent(const A &...args)
{
fEngine.SetBinContent(args...);
fStats.Taint();
}

/// Add all bin contents and statistics of another histogram.
///
/// Throws an exception if the axes configurations are not identical.
///
/// \param[in] other another histogram
void Add(const RHist &other)
{
fEngine.Add(other.fEngine);
fStats.Add(other.fStats);
}

/// Add all bin contents and statistics of another histogram using atomic instructions.
///
/// Throws an exception if the axes configurations are not identical.
///
/// \param[in] other another histogram that must not be modified during the operation
void AddAtomic(const RHist &other)
{
fEngine.AddAtomic(other.fEngine);
fStats.AddAtomic(other.fStats);
}

/// Clear all bin contents and statistics.
void Clear()
{
fEngine.Clear();
fStats.Clear();
}

/// Clone this histogram.
///
/// Copying all bin contents can be an expensive operation, depending on the number of bins.
///
/// \return the cloned object
RHist Clone() const
{
RHist h(fEngine.Clone());
h.fStats = fStats;
return h;
}

/// Convert this histogram to a different bin content type.
///
/// There is no bounds checking to make sure that the converted values can be represented. Note that it is not
/// possible to convert to RBinWithError since the information about individual weights has been lost since filling.
///
/// Converting all bin contents can be an expensive operation, depending on the number of bins.
///
/// \return the converted object
template <typename U>
RHist<U> Convert() const
{
RHist<U> h(fEngine.template Convert<U>());
h.fStats = fStats;
return h;
}
/// \}
/// \name Filling
/// \{

/// Fill an entry into the histogram.
///
Expand Down Expand Up @@ -440,6 +398,67 @@ public:
}
}

/// \}
/// \name Operations
/// \{

/// Add all bin contents and statistics of another histogram.
///
/// Throws an exception if the axes configurations are not identical.
///
/// \param[in] other another histogram
void Add(const RHist &other)
{
fEngine.Add(other.fEngine);
fStats.Add(other.fStats);
}

/// Add all bin contents and statistics of another histogram using atomic instructions.
///
/// Throws an exception if the axes configurations are not identical.
///
/// \param[in] other another histogram that must not be modified during the operation
void AddAtomic(const RHist &other)
{
fEngine.AddAtomic(other.fEngine);
fStats.AddAtomic(other.fStats);
}

/// Clear all bin contents and statistics.
void Clear()
{
fEngine.Clear();
fStats.Clear();
}

/// Clone this histogram.
///
/// Copying all bin contents can be an expensive operation, depending on the number of bins.
///
/// \return the cloned object
RHist Clone() const
{
RHist h(fEngine.Clone());
h.fStats = fStats;
return h;
}

/// Convert this histogram to a different bin content type.
///
/// There is no bounds checking to make sure that the converted values can be represented. Note that it is not
/// possible to convert to RBinWithError since the information about individual weights has been lost since filling.
///
/// Converting all bin contents can be an expensive operation, depending on the number of bins.
///
/// \return the converted object
template <typename U>
RHist<U> Convert() const
{
RHist<U> h(fEngine.template Convert<U>());
h.fStats = fStats;
return h;
}

/// Scale all histogram bin contents and statistics.
///
/// This method is not available for integral bin content types.
Expand Down Expand Up @@ -560,6 +579,8 @@ public:
return Slice(sliceSpecs);
}

/// \}

/// %ROOT Streamer function to throw when trying to store an object of this class.
void Streamer(TBuffer &) { throw std::runtime_error("unable to store RHist"); }
};
Expand Down
Loading
Loading