Logo ROOT   6.08/07
Reference Guide
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT > Class Template Reference

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
class ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >

Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value of type PRECISION.

STAT stores statistical data of the entries filled into the histogram (bin content, uncertainties etc).

A histogram counts occurrences of values or n-dimensional combinations thereof. Contrary to for instance a TTree, a histogram combines adjacent values. The resolution of this combination is defined by the axis binning, see e.g. http://www.wikiwand.com/en/Histogram

Definition at line 33 of file THist.hxx.

Public Types

using AxisRange_t = typename ImplBase_t::AxisIterRange_t
 Range. More...
 
using const_iterator = Detail::THistBinIter< ImplBase_t >
 
using CoordArray_t = typename ImplBase_t::CoordArray_t
 The coordinates type: a DIMENSIONS-dimensional std::array of double. More...
 
using FillFunc_t = typename ImplBase_t::FillFunc_t
 Pointer type to HistImpl_t::Fill, for faster access. More...
 
using ImplBase_t = Detail::THistImplBase< Detail::THistData< DIMENSIONS, PRECISION, Detail::THistDataDefaultStorage, STAT... > >
 The type of the Detail::THistImplBase of this histogram. More...
 
using Weight_t = PRECISION
 The type of weights. More...
 

Public Member Functions

 THist ()=default
 
 THist (THist &&)=default
 
 THist (std::array< TAxisConfig, DIMENSIONS > axes)
 Create a histogram from an array of axes (TAxisConfigs). More...
 
 THist (std::string_view histTitle, std::array< TAxisConfig, DIMENSIONS > axes)
 Constructor overload taking the histogram title. More...
 
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 1>::type>
 THist (const TAxisConfig &xaxis)
 Constructor overload that's only available for a 1-dimensional histogram. More...
 
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 1>::type>
 THist (std::string_view histTitle, const TAxisConfig &xaxis)
 Constructor overload that's only available for a 1-dimensional histogram, also passing the histogram title. More...
 
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 2>::type>
 THist (const TAxisConfig &xaxis, const TAxisConfig &yaxis)
 Constructor overload that's only available for a 2-dimensional histogram. More...
 
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 2>::type>
 THist (std::string_view histTitle, const TAxisConfig &xaxis, const TAxisConfig &yaxis)
 Constructor overload that's only available for a 2-dimensional histogram, also passing the histogram title. More...
 
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 3>::type>
 THist (const TAxisConfig &xaxis, const TAxisConfig &yaxis, const TAxisConfig &zaxis)
 Constructor overload that's only available for a 3-dimensional histogram. More...
 
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 3>::type>
 THist (std::string_view histTitle, const TAxisConfig &xaxis, const TAxisConfig &yaxis, const TAxisConfig &zaxis)
 Constructor overload that's only available for a 3-dimensional histogram, also passing the histogram title. More...
 
const_iterator begin () const
 
const_iterator end () const
 
void Fill (const CoordArray_t &x, Weight_t weight=(Weight_t) 1) noexcept
 Add weight to the bin containing coordinate x. More...
 
void FillN (const std::array_view< CoordArray_t > xN, const std::array_view< Weight_t > weightN) noexcept
 For each coordinate in xN, add weightN[i] to the bin at coordinate xN[i]. More...
 
void FillN (const std::array_view< CoordArray_t > xN) noexcept
 Convenience overload: FillN() with weight 1. More...
 
Weight_t GetBinContent (const CoordArray_t &x) const
 Get the content of the bin at x. More...
 
double GetBinUncertainty (const CoordArray_t &x) const
 Get the uncertainty on the content of the bin at x. More...
 
int64_t GetEntries () const noexcept
 Get the number of entries this histogram was filled with. More...
 
ImplBase_tGetImpl () const noexcept
 Access the ImplBase_t this THist points to. More...
 
void swap (THist< DIMENSIONS, PRECISION, STAT... > &other) noexcept
 Swap *this and other. More...
 
std::unique_ptr< ImplBase_t > && TakeImpl () noexcept
 "Steal" the ImplBase_t this THist points to. More...
 

Static Public Member Functions

static constexpr int GetNDim () noexcept
 Number of dimensions of the coordinates. More...
 

Private Attributes

FillFunc_t fFillFunc = nullptr
 ! Pinter to THistImpl::Fill() member function More...
 
std::unique_ptr< ImplBase_tfImpl
 The actual histogram implementation. More...
 

Friends

THist HistFromImpl (std::unique_ptr< ImplBase_t >)
 

#include <ROOT/THist.hxx>

Member Typedef Documentation

◆ AxisRange_t

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
using ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::AxisRange_t = typename ImplBase_t::AxisIterRange_t

Range.

Definition at line 68 of file THist.hxx.

◆ const_iterator

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
using ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::const_iterator = Detail::THistBinIter<ImplBase_t>

Definition at line 70 of file THist.hxx.

◆ CoordArray_t

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
using ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::CoordArray_t = typename ImplBase_t::CoordArray_t

The coordinates type: a DIMENSIONS-dimensional std::array of double.

Definition at line 62 of file THist.hxx.

◆ FillFunc_t

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
using ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::FillFunc_t = typename ImplBase_t::FillFunc_t

Pointer type to HistImpl_t::Fill, for faster access.

Definition at line 66 of file THist.hxx.

◆ ImplBase_t

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
using ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::ImplBase_t = Detail::THistImplBase<Detail::THistData<DIMENSIONS, PRECISION, Detail::THistDataDefaultStorage, STAT...> >

The type of the Detail::THistImplBase of this histogram.

Definition at line 60 of file THist.hxx.

◆ Weight_t

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
using ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::Weight_t = PRECISION

The type of weights.

Definition at line 64 of file THist.hxx.

Constructor & Destructor Documentation

◆ THist() [1/10]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( )
default

◆ THist() [2/10]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( THist< DIMENSIONS, PRECISION, STAT > &&  )
default

◆ THist() [3/10]

template<int DIMENSIONS, class PRECISION , template< int D_, class P_, template< class P__ > class S_ > class... STAT>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( std::array< TAxisConfig, DIMENSIONS >  axes)
explicit

Create a histogram from an array of axes (TAxisConfigs).

Example code:

Construct a 1-dimensional histogram that can be filled with floatss. The axis has 10 bins between 0. and 1. The two outermost sets of curly braces are to reach the initialization of the std::array elements; the inner one is for the initialization of a TAxisCoordinate.

THist<1,float> h1f({{ {10, 0., 1.} }});

Construct a 2-dimensional histogram, with the first axis as before, and the second axis having non-uniform ("irregular") binning, where all bin- edges are specified. As this is itself an array it must be enclosed by double curlies.

THist<2,int> h2i({{ {10, 0., 1.}, {{-1., 0., 1., 10., 100.}} }});  

Definition at line 280 of file THist.hxx.

◆ THist() [4/10]

template<int DIMENSIONS, class PRECISION , template< int D_, class P_, template< class P__ > class S_ > class... STAT>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( std::string_view  histTitle,
std::array< TAxisConfig, DIMENSIONS >  axes 
)

Constructor overload taking the histogram title.

Definition at line 270 of file THist.hxx.

◆ THist() [5/10]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 1>::type>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( const TAxisConfig xaxis)
inlineexplicit

Constructor overload that's only available for a 1-dimensional histogram.

Definition at line 101 of file THist.hxx.

◆ THist() [6/10]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 1>::type>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( std::string_view  histTitle,
const TAxisConfig xaxis 
)
inline

Constructor overload that's only available for a 1-dimensional histogram, also passing the histogram title.

Definition at line 109 of file THist.hxx.

◆ THist() [7/10]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 2>::type>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( const TAxisConfig xaxis,
const TAxisConfig yaxis 
)
inline

Constructor overload that's only available for a 2-dimensional histogram.

Definition at line 116 of file THist.hxx.

◆ THist() [8/10]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 2>::type>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( std::string_view  histTitle,
const TAxisConfig xaxis,
const TAxisConfig yaxis 
)
inline

Constructor overload that's only available for a 2-dimensional histogram, also passing the histogram title.

Definition at line 124 of file THist.hxx.

◆ THist() [9/10]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 3>::type>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( const TAxisConfig xaxis,
const TAxisConfig yaxis,
const TAxisConfig zaxis 
)
inline

Constructor overload that's only available for a 3-dimensional histogram.

Definition at line 131 of file THist.hxx.

◆ THist() [10/10]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
template<int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 3>::type>
ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::THist ( std::string_view  histTitle,
const TAxisConfig xaxis,
const TAxisConfig yaxis,
const TAxisConfig zaxis 
)
inline

Constructor overload that's only available for a 3-dimensional histogram, also passing the histogram title.

Definition at line 139 of file THist.hxx.

Member Function Documentation

◆ begin()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
const_iterator ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::begin ( ) const
inline

Definition at line 172 of file THist.hxx.

◆ end()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
const_iterator ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::end ( ) const
inline

Definition at line 174 of file THist.hxx.

◆ Fill()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
void ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::Fill ( const CoordArray_t x,
Weight_t  weight = (Weight_t) 1 
)
inlinenoexcept

Add weight to the bin containing coordinate x.

Definition at line 152 of file THist.hxx.

◆ FillN() [1/2]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
void ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::FillN ( const std::array_view< CoordArray_t xN,
const std::array_view< Weight_t weightN 
)
inlinenoexcept

For each coordinate in xN, add weightN[i] to the bin at coordinate xN[i].

The sizes of xN and weightN must be the same. This is more efficient than many separate calls to Fill().

Definition at line 157 of file THist.hxx.

◆ FillN() [2/2]

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
void ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::FillN ( const std::array_view< CoordArray_t xN)
inlinenoexcept

Convenience overload: FillN() with weight 1.

Definition at line 161 of file THist.hxx.

◆ GetBinContent()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
Weight_t ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::GetBinContent ( const CoordArray_t x) const
inline

Get the content of the bin at x.

Definition at line 167 of file THist.hxx.

◆ GetBinUncertainty()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
double ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::GetBinUncertainty ( const CoordArray_t x) const
inline

Get the uncertainty on the content of the bin at x.

Definition at line 170 of file THist.hxx.

◆ GetEntries()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
int64_t ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::GetEntries ( ) const
inlinenoexcept

Get the number of entries this histogram was filled with.

Definition at line 164 of file THist.hxx.

◆ GetImpl()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
ImplBase_t* ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::GetImpl ( ) const
inlinenoexcept

Access the ImplBase_t this THist points to.

Definition at line 146 of file THist.hxx.

◆ GetNDim()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
static constexpr int ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::GetNDim ( )
inlinestaticnoexcept

Number of dimensions of the coordinates.

Definition at line 73 of file THist.hxx.

◆ swap()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
void ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::swap ( THist< DIMENSIONS, PRECISION, STAT... > &  other)
inlinenoexcept

Swap *this and other.

Very efficient; swaps the fImpl pointers.

Definition at line 179 of file THist.hxx.

◆ TakeImpl()

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
std::unique_ptr<ImplBase_t>&& ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::TakeImpl ( )
inlinenoexcept

"Steal" the ImplBase_t this THist points to.

Definition at line 149 of file THist.hxx.

Friends And Related Function Documentation

◆ HistFromImpl

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
THist HistFromImpl ( std::unique_ptr< ImplBase_t )
friend

Member Data Documentation

◆ fFillFunc

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
FillFunc_t ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::fFillFunc = nullptr
private

! Pinter to THistImpl::Fill() member function

Definition at line 186 of file THist.hxx.

◆ fImpl

template<int DIMENSIONS, class PRECISION, template< int D_, class P_, template< class P__ > class S_ > class... STAT>
std::unique_ptr<ImplBase_t> ROOT::Experimental::THist< DIMENSIONS, PRECISION, STAT >::fImpl
private

The actual histogram implementation.

Definition at line 185 of file THist.hxx.


The documentation for this class was generated from the following file: