A class for handling 1D distributions. More...

#include <BCH1D.h>

Inheritance diagram for BCH1D:
[legend]
Collaboration diagram for BCH1D:
[legend]

Classes

struct  BCH1DInterval
 Contains information about an interval. More...
 
struct  BCH1DSmallestInterval
 Vector of intervals with information about total mass. More...
 

Public Types

Enumerators
enum  BCH1DBandType {
  kNoBands = -1, kCentralInterval = 0, kSmallestInterval = 1, kUpperLimit = 2,
  kLowerLimit = 3, kUserSpecified = 4
}
 Enum for type of bands to be drawn on plot. More...
 
- Public Types inherited from BCHistogramBase
enum  BCHColorScheme { kBlackWhite = 0, kGreenYellowRed = 1, kBlueOrange = 2, kRedGreen = 3 }
 An enumerator for the color schemes. More...
 

Public Member Functions

Constructors and destructors
 BCH1D (const TH1 *const hist=0)
 The default constructor. More...
 
 BCH1D (const BCH1D &other)
 Copy constructor. More...
 
virtual ~BCH1D ()
 The default destructor. More...
 
Member functions (get)
double GetLocalMode ()
 
double GetBestFitParameters ()
 
double GetMedian ()
 
double GetQuantile (double probability)
 Returns the quantile of the distribution. More...
 
double GetLimit (double probability)
 Return the quantile of the distribution. More...
 
BCH1DBandType GetBandType ()
 
unsigned GetNQuantiles ()
 
int GetQuantileLineColor ()
 
bool GetDrawMedian ()
 
bool GetDrawCentral68 ()
 
Member functions (set)
void CopyOptions (const BCH1D &other)
 Copy options from other. More...
 
void SetColorScheme (BCHColorScheme scheme)
 Sets the color scheme. More...
 
void SetGlobalMode (double mode)
 Set global mode.
 
void SetLocalMode (double mode)
 Set local mode.
 
void SetBandType (BCH1DBandType bt)
 Set band type. More...
 
void SetDrawQuantiles (unsigned n)
 Set draw quantiles. More...
 
void SetQuantileLineColor (int c)
 Set quantile line color. More...
 
void SetDrawMedian (bool flag=true, bool central68=true)
 Set drawing of median. More...
 
Member functions (miscellaneous methods)
virtual void CheckIntervals (std::vector< double > &intervals)
 Check intervals: remove values below 0 or above 1, and sort to proper order for band type. More...
 
virtual std::vector< double > DefaultIntervals (int nbands=-1)
 Return default intervals. More...
 
virtual void DrawBands (const std::string &options="same")
 Draw bands. More...
 
virtual void DrawMarkers ()
 Draw markers: global mode, local mode, mean, quantiles, median. More...
 
virtual void DrawQuantiles (unsigned n)
 Draw quantiles. More...
 
virtual void DrawMedian ()
 Draw median & central 68% interval. More...
 
void PrintSummary (const std::string &prefix="", unsigned prec=6, std::vector< double > intervals=std::vector< double >(0))
 Print information to log. More...
 
std::vector< BCH1D::BCH1DSmallestIntervalGetSmallestIntervals (std::vector< double > masses)
 
BCH1D::BCH1DSmallestInterval GetSmallestIntervals (double mass)
 
TH1 * GetSubHistogram (double min, double max, const std::string &name="", bool preserve_range=false)
 Get histogram with bins outside min, max band being zero. More...
 
- Public Member Functions inherited from BCHistogramBase
 BCHistogramBase (const TH1 *const hist=0, int dimension=0)
 The default constructor. More...
 
 BCHistogramBase (const BCHistogramBase &other)
 Copy constructor. More...
 
virtual ~BCHistogramBase ()
 The default destructor. More...
 
TH1 * GetHistogram ()
 
unsigned GetDimension () const
 
TLegend & GetLegend ()
 
unsigned GetNLegendColumns () const
 
std::vector< double > & GetBestFitParameters ()
 
const std::vector< double > & GetBestFitParameters () const
 
double GetBestFitParameters (unsigned i) const
 
std::vector< double > & GetLocalMode ()
 
const std::vector< double > & GetLocalMode () const
 
double GetLocalMode (unsigned i)
 
int GetBandColor (int index) const
 Returns a band color of the current color scheme. More...
 
bool GetBandOvercoverage () const
 
int GetLineColor () const
 
int GetLineStyle () const
 
int GetLineWidth () const
 
int GetMarkerColor () const
 Returns the marker colors (used for mean, median, and mode. More...
 
double GetMarkerScale () const
 
short GetBandFillStyle () const
 
unsigned GetNBands () const
 
unsigned GetNSmooth () const
 
bool GetDrawGlobalMode () const
 
bool GetDrawGlobalModeArrows () const
 
int GetBestFitParametersMarkerStyle () const
 
bool GetDrawLocalMode () const
 
bool GetDrawLocalModeArrows () const
 
int GetLocalModeMarkerStyle () const
 
bool GetDrawMean () const
 
int GetMeanMarkerStyle () const
 
bool GetDrawStandardDeviation () const
 
bool GetLogx () const
 
bool GetLogy () const
 
bool GetLogz () const
 
bool GetGridx () const
 
bool GetGridy () const
 
std::vector< double > & GetIntervals ()
 
const std::vector< double > & GetIntervals () const
 
std::string & GetROOToptions ()
 
const std::string & GetROOToptions () const
 
virtual void CopyOptions (const BCHistogramBase &other)
 Copy options from. More...
 
void SetGlobalMode (std::vector< double > gm)
 Set global mode. More...
 
void UnsetGlobalMode ()
 Unset global mode. More...
 
void SetGlobalMode (unsigned i, double lm)
 Set global mode element. More...
 
void SetLocalMode (std::vector< double > lm)
 Set local mode. More...
 
void UnsetLocalMode ()
 Unset local mode. More...
 
void SetLocalMode (unsigned i, double lm)
 Set local mode element. More...
 
void AddBandColor (int c)
 Add band color. More...
 
void SetBandColor (unsigned i, int c)
 Set band color. More...
 
void SetBandOvercoverage (bool flag=true)
 Set band coverage to be overcoverage (true) or undercoverage (false). More...
 
void SetLineColor (int c)
 Set histogram line color. More...
 
void SetLineStyle (int s)
 Set histogram line style. More...
 
void SetLineWidth (int w)
 Set histogram line width. More...
 
void SetMarkerColor (int c)
 Set marker color (used for mean, median, and mode). More...
 
void SetMarkerScale (double s)
 Set marker size scale. More...
 
void SetBandFillStyle (short f)
 Set band fill style. More...
 
virtual void SetHistogram (const TH1 *const hist)
 Sets the histogram. More...
 
void SetLogx (bool flag=true)
 Sets drawing of x axis in log. More...
 
void SetLogy (bool flag=true)
 Sets drawing of y axis in log. More...
 
void SetLogz (bool flag=true)
 Sets drawing of z axis in log. More...
 
void SetGridx (bool flag=true)
 Sets drawing of grid on x axis. More...
 
void SetGridy (bool flag=true)
 Sets drawing of grid on y axis. More...
 
void SetNBands (unsigned n)
 Sets number of credibility interval bands to draw. More...
 
void SetNSmooth (unsigned n)
 Sets number of times to smooth the histogram using ROOT's smoothing function. More...
 
void SetDrawGlobalMode (bool flag=true, bool arrows=true)
 Set drawing of global mode. More...
 
void SetGlobalModeMarkerStyle (int s)
 Set global mode marker style. More...
 
void SetDrawLocalMode (bool flag=true, bool arrows=true)
 Set drawing of global mode. More...
 
void SetLocalModeMarkerStyle (int s)
 Set Local mode marker style. More...
 
void SetDrawMean (bool flag=true, bool stddev=true)
 Set drawing of mean. More...
 
void SetMeanMarkerStyle (int s)
 Set mean marker style. More...
 
void SetDrawLegend (bool flag=true)
 Set drawing of legend. More...
 
void SetNLegendColumns (unsigned n)
 Set number of columns in legend. More...
 
void SetStats (bool flag=true)
 Set drawing of ROOT histogram stats box. More...
 
void SetIntervals (std::vector< double > intervals)
 Set intervals to be drawn. More...
 
void SetInterval (double interval)
 Set intervals to one single value. More...
 
void AddInterval (double interval)
 Add interval value. More...
 
void SetROOToptions (const std::string &options)
 Set ROOT drawing options. More...
 
virtual bool Valid () const
 Whether histogram has been set and filled. More...
 
void ClearBandColors ()
 
void ClearIntervals ()
 
void Smooth (int n=-1)
 Applying ROOT smoothing to histogram, and renormalize. More...
 
virtual void Draw ()
 Draw distribution into the active pad.
 
virtual void DrawGlobalMode ()
 Draw global mode. More...
 
virtual void DrawLocalMode ()
 Draw global mode. More...
 
virtual void DrawMean ()
 Draw mean and standard deviation. More...
 
virtual double ResizeLegend ()
 Resize legend and set it for placement at the top of the pad. More...
 
virtual void DrawLegend ()
 Resize histogram and draw legend. More...
 
void GetNonzeroBinDensityMassVector (std::vector< std::pair< double, double > > &bin_dens_mass, int sort=-1)
 Fill vector with values and integrals of nonzero bins sorted by value. More...
 
std::vector< std::pair< double, double > > GetSmallestIntervalBounds (std::vector< double > masses, bool overcoverage=true)
 Get probability density levels bounding from below the smallest-interval levels with probability mass near that provided in the argument. More...
 
virtual std::vector< double > GetSmallestIntervalSize (std::vector< double > masses, bool overcoverage=true)
 Get smallest interval sizes in dimensions of histogram: length (1D), area (2D), volume (3D). More...
 
virtual double GetSmallestIntervalSize (double mass, bool overcoverage=true)
 Get smallest interval size in dimensions of histogram: length (1D), area (2D), volume (3D). More...
 
virtual void CheckIntervals (std::vector< double > &intervals, int sort)
 Check intervals: remove values below 0 or above 1. More...
 
TLegendEntry * AddLegendEntry (TObject *obj, const std::string &label, const std::string &options)
 Add legend entry, checking first for unused extra entries. More...
 
TLegendEntry * AddBandLegendEntry (TObject *obj, const std::string &label, const std::string &options)
 Add band legend entry, creating unused extra entries if necessary. More...
 
BCHistogramBaseoperator= (BCHistogramBase other)
 Assignment operator. More...
 
BCHistogramBaseoperator= (const TH1 *const hist)
 Assign TH1 histogram with operator. More...
 
BCHistogramBaseoperator= (const TH1 &hist)
 Assign TH1 histogram with operator. More...
 

Protected Attributes

BCH1DBandType fBandType
 Band type.
 
bool fDrawCentral68
 flag for darwing central 68% interval arrows. More...
 
bool fDrawMedian
 flag for drawing median. More...
 
unsigned fNQuantiles
 Number of quantiles to draw. More...
 
int fQuantileLineColor
 Quantile line color. More...
 
- Protected Attributes inherited from BCHistogramBase
std::vector< int > fBandColors
 The colors of the color scheme. More...
 
short fBandFillStyle
 The fill style for the bands. More...
 
bool fBandOvercoverage
 flag for whether bands should overcover. More...
 
int fDimension
 Dimension of histogram. More...
 
bool fDrawGlobalMode
 Flag for drawing global mode. More...
 
bool fDrawGlobalModeArrows
 Flag for drawing global mode arrows. More...
 
bool fDrawLegend
 Flag for drawing legend. More...
 
bool fDrawLocalMode
 Flag for drawing local mode. More...
 
bool fDrawLocalModeArrows
 Flag for drawing local mode arrows. More...
 
bool fDrawMean
 Flag for drawing mean. More...
 
bool fDrawStandardDeviation
 Flag for drawing standard deviation. More...
 
bool fDrawStats
 Flag for drawing stats box. More...
 
std::vector< TLegendEntry * > fExtraLegendEntries
 Storage for unused legend entries (for use with multicolumn legends). More...
 
std::vector< double > fGlobalMode
 Global mode.
 
int fGlobalModeMarkerStyle
 Holds option for global-mode marker style. More...
 
bool fGridx
 Flag for drawing of grid on x axis. More...
 
bool fGridy
 Flag for drawing of grid on y axis. More...
 
TH1 * fHistogram
 The histogram.
 
std::vector< double > fIntervals
 intervals to draw. More...
 
TLegend fLegend
 Legend. More...
 
int fLineColor
 histogram line color. More...
 
int fLineStyle
 histogram line style. More...
 
int fLineWidth
 histogram line width. More...
 
std::vector< double > fLocalMode
 Local mode.
 
int fLocalModeMarkerStyle
 Holds option for local-mode marker style. More...
 
bool fLogx
 Flag for controlling log plotting of x axis. More...
 
bool fLogy
 Flag for controlling log plotting of y axis. More...
 
bool fLogz
 Flag for controlling log plotting of z axis. More...
 
int fMarkerColor
 Marker color. More...
 
double fMarkerScale
 Marker size scale. More...
 
int fMeanMarkerStyle
 Holds option for mean marker style. More...
 
unsigned fNBands
 Number of credibility interval bands to draw. More...
 
unsigned fNLegendColumns
 number of columns to be set for legend. More...
 
unsigned fNSmooth
 Number of times to smooth histogram using ROOT's smooth function. More...
 
std::vector< TObject * > fROOTObjects
 Storage for plot objects. More...
 
std::string fROOToptions
 ROOT drawing options. More...
 

Detailed Description

A class for handling 1D distributions.

Author
Daniel Kollar
Kevin Kröninger
Daniel Greenwald
Version
1.0
Date
08.2008

This class contains a TH1 histogram and some additional functions. It is used for marginalized distributions.

Definition at line 34 of file BCH1D.h.

Member Enumeration Documentation

Enum for type of bands to be drawn on plot.

Definition at line 44 of file BCH1D.h.

Constructor & Destructor Documentation

BCH1D::BCH1D ( const TH1 *const  hist = 0)

The default constructor.

Definition at line 32 of file BCH1D.cxx.

BCH1D::BCH1D ( const BCH1D other)

Copy constructor.

Definition at line 43 of file BCH1D.cxx.

virtual BCH1D::~BCH1D ( )
inlinevirtual

The default destructor.

Definition at line 68 of file BCH1D.h.

Member Function Documentation

void BCH1D::CheckIntervals ( std::vector< double > &  intervals)
virtual

Check intervals: remove values below 0 or above 1, and sort to proper order for band type.

Definition at line 83 of file BCH1D.cxx.

void BCH1D::CopyOptions ( const BCH1D other)

Copy options from other.

Definition at line 50 of file BCH1D.cxx.

std::vector< double > BCH1D::DefaultIntervals ( int  nbands = -1)
virtual

Return default intervals.

Parameters
nbandsnbands to give defaults for; if negative, use fNBands.
Returns
vector of default values for band intervals.

Reimplemented from BCHistogramBase.

Definition at line 97 of file BCH1D.cxx.

void BCH1D::DrawBands ( const std::string &  options = "same")
virtual

Draw bands.

Reimplemented from BCHistogramBase.

Definition at line 135 of file BCH1D.cxx.

void BCH1D::DrawMarkers ( )
virtual

Draw markers: global mode, local mode, mean, quantiles, median.

Reimplemented from BCHistogramBase.

Definition at line 230 of file BCH1D.cxx.

void BCH1D::DrawMedian ( )
virtual

Draw median & central 68% interval.

Definition at line 311 of file BCH1D.cxx.

void BCH1D::DrawQuantiles ( unsigned  n)
virtual

Draw quantiles.

Definition at line 239 of file BCH1D.cxx.

BCH1DBandType BCH1D::GetBandType ( )
inline
Returns
Band type.

Definition at line 109 of file BCH1D.h.

double BCH1D::GetBestFitParameters ( )
inline
Returns
global mode.

Definition at line 84 of file BCH1D.h.

bool BCH1D::GetDrawCentral68 ( )
inline
Returns
whether to draw central 68% interval.

Definition at line 129 of file BCH1D.h.

bool BCH1D::GetDrawMedian ( )
inline
Returns
whether to draw median.

Definition at line 124 of file BCH1D.h.

double BCH1D::GetLimit ( double  probability)
inline

Return the quantile of the distribution.

Parameters
probabilityThe probability.
Returns
The quantile of the distribution for the probability.
See also
GetQuantile(double probablity)

Definition at line 104 of file BCH1D.h.

double BCH1D::GetLocalMode ( )
inline
Returns
local mode.

Definition at line 78 of file BCH1D.h.

double BCH1D::GetMedian ( )
inline
Returns
The median of the distribution.

Definition at line 89 of file BCH1D.h.

unsigned BCH1D::GetNQuantiles ( )
inline
Returns
Number of quantiles to draw.

Definition at line 114 of file BCH1D.h.

double BCH1D::GetQuantile ( double  probability)

Returns the quantile of the distribution.

Parameters
probabilityThe probability.
Returns
The quantile of the distribution for the probability.
See also
GetLimit(double probability)

Definition at line 68 of file BCH1D.cxx.

int BCH1D::GetQuantileLineColor ( )
inline
Returns
Quantile line color.

Definition at line 119 of file BCH1D.h.

std::vector< BCH1D::BCH1DSmallestInterval > BCH1D::GetSmallestIntervals ( std::vector< double >  masses)
Parameters
massesMasses to return smallest intervals of.
Returns
vector of BCH1DSmallestInterval's.

Definition at line 452 of file BCH1D.cxx.

BCH1D::BCH1DSmallestInterval BCH1D::GetSmallestIntervals ( double  mass)
inline
Parameters
massProbability mass to return smallest intervals of.
Returns
BCH1DSmallestInterval for probability mass.

Definition at line 272 of file BCH1D.h.

TH1 * BCH1D::GetSubHistogram ( double  min,
double  max,
const std::string &  name = "",
bool  preserve_range = false 
)

Get histogram with bins outside min, max band being zero.

The new histogram can have 2 more bins than the original one as the bins where min and max fall into will be split in two (except for the case when min and/or max are equal to some of the original bin boundaries).

Note
The caller is responsible for deletion of the returned object.
Parameters
minlower boundary of the non-zero interval
maxupper boundary of the non-zero interval
nameName for new histogram; empty string (default) appends "subhist" to histogram name.
preserve_rangeIf true, preserves original histograms range, setting bins outside subhistogram range to zero.
Returns
new histogram which is nonzero only between min and max

Definition at line 352 of file BCH1D.cxx.

void BCH1D::PrintSummary ( const std::string &  prefix = "",
unsigned  prec = 6,
std::vector< double >  intervals = std::vector<double>(0) 
)

Print information to log.

Parameters
prefixString to be prepended to every line.
intervalsVector of intervals to print.
precPrecision of doubles to output.

Definition at line 408 of file BCH1D.cxx.

void BCH1D::SetBandType ( BCH1DBandType  bt)
inline

Set band type.

Definition at line 163 of file BCH1D.h.

void BCH1D::SetColorScheme ( BCHColorScheme  scheme)
virtual

Sets the color scheme.

Reimplemented from BCHistogramBase.

Definition at line 61 of file BCH1D.cxx.

void BCH1D::SetDrawMedian ( bool  flag = true,
bool  central68 = true 
)
inline

Set drawing of median.

Parameters
flagToggles drawing of median.
central68Toggles drawing of arrows for central 68% interval. (Automatically suppressed if median is suppressed.)

Definition at line 182 of file BCH1D.h.

void BCH1D::SetDrawQuantiles ( unsigned  n)
inline

Set draw quantiles.

Parameters
nN divisions of quantiles to draw, set to zero or one to disable drawing of quantiles.

Definition at line 169 of file BCH1D.h.

void BCH1D::SetQuantileLineColor ( int  c)
inline

Set quantile line color.

Parameters
cQuantile line color.

Definition at line 175 of file BCH1D.h.

Member Data Documentation

bool BCH1D::fDrawCentral68
protected

flag for darwing central 68% interval arrows.

Definition at line 313 of file BCH1D.h.

bool BCH1D::fDrawMedian
protected

flag for drawing median.

Definition at line 309 of file BCH1D.h.

unsigned BCH1D::fNQuantiles
protected

Number of quantiles to draw.

Definition at line 301 of file BCH1D.h.

int BCH1D::fQuantileLineColor
protected

Quantile line color.

Definition at line 305 of file BCH1D.h.


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