Tomographer  v1.0a
Tomographer C++ Framework Documentation
Tomographer::AveragedHistogram< HistogramType_, RealAvgType > Struct Template Reference

Combines several histograms (with same parameters) into an averaged histogram. More...

#include <tomographer/histogram.h>

+ Inheritance diagram for Tomographer::AveragedHistogram< HistogramType_, RealAvgType >:
+ Collaboration diagram for Tomographer::AveragedHistogram< HistogramType_, RealAvgType >:

Public Types

typedef HistogramType_ HistogramType
 Type of the individual histograms we are averaging. More...
 
typedef UniformBinsHistogramWithErrorBars< typename HistogramType_::Scalar, RealAvgType > Base_
 Shortcut for our base class' type.
 
typedef Base_::Params Params
 The histogram parameters' type. See UniformBinsHistogramWithErrorBars::Params.
 
typedef Base_::Scalar Scalar
 The histogram's X-axis scalar type. See UniformBinsHistogramWithErrorBars::Scalar.
 
typedef Base_::CountType CountType
 The histogram' count type. This is exactly the same as RealAvgType.
 
- Public Types inherited from Tomographer::UniformBinsHistogramWithErrorBars< HistogramType_::Scalar, RealAvgType >
typedef HistogramType_::Scalar Scalar
 The Scalar (X-axis) Type. See UniformBinsHistogram<Scalar_,CountType_>::Scalar.
 
typedef RealAvgType CountType
 The Type used to keep track of counts. See UniformBinsHistogram<Scalar_,CountType_>::CountType.
 
typedef UniformBinsHistogram< HistogramType_::Scalar, RealAvgType > Base_
 Shortcut for our base class type.
 
typedef Base_::Params Params
 Shortcut for our base class' histogram parameters. See UniformBinsHistogram<typename Scalar_, typename CountType_>::Params.
 
- Public Types inherited from Tomographer::UniformBinsHistogram< HistogramType_::Scalar, RealAvgType >
typedef HistogramType_::Scalar Scalar
 The scalar type of the "X"-axis of the histogram (usually double)
 
typedef RealAvgType CountType
 The type that serves to count how many hits in each bin.
 

Public Member Functions

 AveragedHistogram (const Params &params=Params())
 Constructs an AveragedHistogram with the given histogram parameters. More...
 
void reset (const Params &params_)
 Resets the data and sets new params. More...
 
void reset ()
 Resets the data keeping the exisiting params. More...
 
template<bool dummy = true, typename std::enable_if< dummy &&(!HistogramType::HasErrorBars), bool >::type dummy2 = true>
void add_histogram (const HistogramType &histogram)
 
template<bool dummy = true, typename std::enable_if< dummy &&(!HistogramType::HasErrorBars), bool >::type dummy2 = true>
void finalize ()
 
template<bool dummy = true, typename std::enable_if< dummy &&(HistogramType::HasErrorBars), bool >::type dummy2 = true>
void add_histogram (const HistogramType &histogram)
 
template<bool dummy = true, typename std::enable_if< dummy &&(HistogramType::HasErrorBars), bool >::type dummy2 = true>
void finalize ()
 
- Public Member Functions inherited from Tomographer::UniformBinsHistogramWithErrorBars< HistogramType_::Scalar, RealAvgType >
 UniformBinsHistogramWithErrorBars (Params params=Params())
 Constructor, with given histogram parameters. More...
 
 UniformBinsHistogramWithErrorBars (Scalar min, Scalar max, std::size_t num_bins)
 Constructor, with given histogram parameters. More...
 
void reset ()
 Resets the histogram to zero counts everywhere, and zero error bars. More...
 
CountType errorbar (std::size_t i) const
 For the Histogram Interface. Get error bar for bin number i. More...
 
std::string pretty_print (int max_width=0) const
 Print the histogram in human readable form. More...
 
- Public Member Functions inherited from Tomographer::UniformBinsHistogram< HistogramType_::Scalar, RealAvgType >
 UniformBinsHistogram (Params p=Params())
 Constructor: stores the parameters and initializes the histogram to zero counts everywhere.
 
 UniformBinsHistogram (Scalar min_, Scalar max_, std::size_t num_bins)
 Constructor: stores the parameters and initializes the histogram to zero counts everywhere.
 
 UniformBinsHistogram (const HistogramType &other)
 Constructor: copy another histogram type.
 
void reset ()
 Resets the histogram to zero counts everywhere.
 
void load (const Eigen::DenseBase< EigenType > &x, CountType off_chart_=0)
 Load data for the histogram. Uses current histogram parameters, just sets the bin counts. More...
 
void add (const Eigen::ArrayBase< EigenType > &x, CountType off_chart_=0)
 Add data to the histogram. More...
 
void add (const UniformBinsHistogram< OtherScalar, OtherCountType > &x)
 Add data to the histogram. More...
 
std::size_t num_bins () const
 Shorthand for params.num_bins
 
CountType count (std::size_t i) const
 Shorthand for bins(i)
 
bool is_within_bounds (Scalar value) const
 Shorthand for params.is_within_bounds(value)
 
std::size_t bin_index (Scalar value) const
 Shorthand for params.bin_index(value)
 
Scalar bin_lower_value (int index) const
 Shorthand for params.bin_lower_value(index)
 
Scalar bin_center_value (std::size_t index) const
 Shorthand for params.bin_center_value(index)
 
Scalar bin_upper_value (std::size_t index) const
 Shorthand for params.bin_upper_value(index)
 
Scalar bin_resolution () const
 Shorthand for params.bin_resolution()
 
std::size_t record (Scalar value)
 Record a new value in the histogram. More...
 
std::size_t record (Scalar value, CountType weight)
 Record a new value in the histogram, with a certain weight. More...
 
std::string pretty_print (int max_width=0) const
 Pretty-print the histogram and return it as a string with horizontal bars. More...
 

Public Attributes

int num_histograms
 The number of histograms averaged. More...
 
- Public Attributes inherited from Tomographer::UniformBinsHistogramWithErrorBars< HistogramType_::Scalar, RealAvgType >
Eigen::Array< CountType, Eigen::Dynamic, 1 > delta
 The error bars associated with each histogram bin.
 
- Public Attributes inherited from Tomographer::UniformBinsHistogram< HistogramType_::Scalar, RealAvgType >
Params params
 Parameters of this histogram (range and # of bins)
 
Eigen::Array< CountType, Eigen::Dynamic, 1 > bins
 The counts for each bin.
 
CountType off_chart
 The number of points that fell outside of the given range.
 

Static Public Attributes

static constexpr bool HasErrorBars = true
 For the Histogram Interface. This histogram type does provide error bars.
 
- Static Public Attributes inherited from Tomographer::UniformBinsHistogramWithErrorBars< HistogramType_::Scalar, RealAvgType >
static constexpr bool HasErrorBars
 For the Histogram Interface. This type of histogram does provide error bars.
 
- Static Public Attributes inherited from Tomographer::UniformBinsHistogram< HistogramType_::Scalar, RealAvgType >
static constexpr bool HasErrorBars
 This histogram type does not provide error bars (see Histogram Interface)
 

Detailed Description

template<typename HistogramType_, typename RealAvgType = double>
struct Tomographer::AveragedHistogram< HistogramType_, RealAvgType >

Combines several histograms (with same parameters) into an averaged histogram.

What this class does exactly is explained on the page Averaged Histogram.

The HistogramType is expected to be a Histogram Interface -compliant type. It may, or may not, come with its own error bars. If this is the case, then the error bars are properly combined.

You should add histograms to average with repeated calls to add_histogram(). Then, you should call finalize(). Then this object, which inherits UniformBinsHistogramWithErrorBars, will be properly initialized with average counts and error bars.

Warning
All the histograms added with add_histogram() MUST have the same params, i.e. bin ranges and number of bins! The bin values are added up regardless of any parameters, simply because the Histogram Interface does not expose any API for querying the params for a general histogram.

This class itself complies with the Histogram Interface.

Warning
Don't forget to call finalize()! The bin counts bins, off-chart count off_chart and error bars delta have UNDEFINED VALUES before calling finalize().
Template Parameters
HistgoramType_the type of the individual histograms that we are averaging. This must comply with the Histogram Interface
RealAvgTypethe real scalar type used for averaging. You'll most likely want to choose double here. This can be different from the underlying HistogramType's CountType, because that may be an integer type and not suitable for holding an average.

Definition at line 506 of file histogram.h.

Member Typedef Documentation

template<typename HistogramType_ , typename RealAvgType = double>
typedef HistogramType_ Tomographer::AveragedHistogram< HistogramType_, RealAvgType >::HistogramType

Type of the individual histograms we are averaging.

This is the argument given as template parameter, and is expected to compily with the Histogram Interface.

Definition at line 514 of file histogram.h.

Constructor & Destructor Documentation

template<typename HistogramType_ , typename RealAvgType = double>
Tomographer::AveragedHistogram< HistogramType_, RealAvgType >::AveragedHistogram ( const Params params = Params())
inline

Constructs an AveragedHistogram with the given histogram parameters.

The params are the histogram parameters (see UniformBinsHistogram::Params) of the individual histograms which will be averaged. Note that all those histograms must have the same params.

Definition at line 542 of file histogram.h.

Member Function Documentation

template<typename HistogramType_ , typename RealAvgType = double>
void Tomographer::AveragedHistogram< HistogramType_, RealAvgType >::reset ( const Params params_)
inline

Resets the data and sets new params.

Warning
the corresponding base class has NO virtual methods. So don't see this class inheritance as object polymorphism. If you need to reset a uniform bins histogram with error bars, you need to know its type.

Definition at line 553 of file histogram.h.

template<typename HistogramType_ , typename RealAvgType = double>
void Tomographer::AveragedHistogram< HistogramType_, RealAvgType >::reset ( )
inline

Resets the data keeping the exisiting params.

Warning
the corresponding base class has NO virtual methods. So don't see this class inheritance as object polymorphism. If you need to reset a uniform bins histogram with error bars, you need to know its type.

Definition at line 566 of file histogram.h.

Member Data Documentation

template<typename HistogramType_ , typename RealAvgType = double>
int Tomographer::AveragedHistogram< HistogramType_, RealAvgType >::num_histograms

The number of histograms averaged.

This member records how many histograms have been added using add_histogram() since the object was created or was last reset().

Definition at line 533 of file histogram.h.


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