BCH2D Class Reference

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

#include <BCH2D.h>

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

Public Types

Enumerators
enum  BCH2DBandType { kNoBands = -1, kSmallestInterval = 0 }
 Enum for type of bands to draw on plot. More...
 
enum  BCH2DProfileType { kProfileMean = 0, kProfileMedian = 1, kProfileMode = 2 }
 Enum for type of profile. More...
 
enum  BCH2DProfileAxis { kProfileX = 0, kProfileY = 1 }
 Enum for axis to profile. 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

Constructor and destructors
 BCH2D (const TH2 *const h=0)
 The complete constructor. More...
 
 BCH2D (const BCH2D &other)
 Copy constuctor. More...
 
virtual ~BCH2D ()
 The default destructor. More...
 
Member functions (get)
TH2 * GetHistogram ()
 Return the TH2 histogram. More...
 
BCH2DBandType GetBandType ()
 
bool GetLogz ()
 
bool GetDrawProfileX ()
 
BCH2DProfileType GetProfileXType ()
 
int GetProfileXLineColor ()
 
int GetProfileXLineStyle ()
 
bool GetDrawProfileY ()
 
BCH2DProfileType GetProfileYType ()
 
int GetProfileYLineColor ()
 
int GetProfileYLineStyle ()
 
Member functions (set)
void CopyOptions (const BCH2D &other)
 copy options from
 
void SetGlobalMode (double x, double y)
 Set global mode. More...
 
void SetLocalMode (double x, double y)
 Set local mode. More...
 
void SetBandType (BCH2DBandType bt)
 Set band type. More...
 
void SetLogz (bool flag=true)
 Sets drawing of z axis in log. More...
 
void SetDrawProfileX (bool flag=true)
 Set drawing of x profile. More...
 
void SetProfileXType (BCH2DProfileType pt)
 Set profile type of x profile. More...
 
void SetProfileXLineColor (int c)
 Set line color of x profile. More...
 
void SetProfileXLineStyle (int s)
 Set line style of x profile. More...
 
void SetDrawProfileY (bool flag=true)
 Set drawing of y profile. More...
 
void SetProfileYType (BCH2DProfileType pt)
 Set profile type of y profile. More...
 
void SetProfileYLineColor (int c)
 Set line color of y profile. More...
 
void SetProfileYLineStyle (int s)
 Set line style of y profile. 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 band type. More...
 
virtual std::vector< double > DefaultIntervals (int nbands=-1)
 Return default intervals. More...
 
virtual void DrawBands (const std::string &options="same")
 Draw band, or if band type set to no bands, histogram. More...
 
virtual void DrawMarkers ()
 Draw Markers: global mode, local mode, etc. More...
 
TGraph * CalculateProfileGraph (BCH2DProfileAxis axis, BCH2DProfileType pt=kProfileMean)
 Return a graph of the profile along x or y. More...
 
void DrawProfileGraphs ()
 Draw the profiles along x and y.
 
- 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...
 
virtual void SetColorScheme (BCHColorScheme scheme)
 Sets the color scheme. 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

BCH2DBandType fBandType
 band type. More...
 
bool fDrawProfileX
 flag for drawing x profile. More...
 
bool fDrawProfileY
 flag for drawing y profile. More...
 
bool fLogz
 flag for drawing log z. More...
 
int fProfileXLineColor
 color of x profile. More...
 
int fProfileXLineStyle
 line style of x profile. More...
 
BCH2DProfileType fProfileXType
 profile type of x profile. More...
 
int fProfileYLineColor
 color of y profile. More...
 
int fProfileYLineStyle
 line style of y profile. More...
 
BCH2DProfileType fProfileYType
 profile type of y profile. 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 2D distributions.

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

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

Definition at line 37 of file BCH2D.h.

Member Enumeration Documentation

Enum for type of bands to draw on plot.

Enumerator
kNoBands 

no bands

kSmallestInterval 

smallest intervals containing probability mass

Definition at line 47 of file BCH2D.h.

Enum for axis to profile.

Definition at line 70 of file BCH2D.h.

Enum for type of profile.

Definition at line 62 of file BCH2D.h.

Constructor & Destructor Documentation

BCH2D::BCH2D ( const TH2 *const  h = 0)

The complete constructor.

Definition at line 28 of file BCH2D.cxx.

BCH2D::BCH2D ( const BCH2D other)

Copy constuctor.

Definition at line 45 of file BCH2D.cxx.

virtual BCH2D::~BCH2D ( )
inlinevirtual

The default destructor.

Definition at line 90 of file BCH2D.h.

Member Function Documentation

TGraph * BCH2D::CalculateProfileGraph ( BCH2DProfileAxis  axis,
BCH2DProfileType  pt = kProfileMean 
)

Return a graph of the profile along x or y.

The profile is calculated by scanning through the one axis, e.g., y, and finding the mode, mean, median, etc. with respect to the other axis, e.g. x.

Parameters
axisx-axis (0) or y-axis (1)
ptType of profile to construct.

Definition at line 182 of file BCH2D.cxx.

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

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

Definition at line 67 of file BCH2D.cxx.

std::vector< double > BCH2D::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 74 of file BCH2D.cxx.

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

Draw band, or if band type set to no bands, histogram.

Reimplemented from BCHistogramBase.

Definition at line 91 of file BCH2D.cxx.

void BCH2D::DrawMarkers ( )
virtual

Draw Markers: global mode, local mode, etc.

Reimplemented from BCHistogramBase.

Definition at line 175 of file BCH2D.cxx.

BCH2DBandType BCH2D::GetBandType ( )
inline
Returns
Band type.

Definition at line 105 of file BCH2D.h.

bool BCH2D::GetDrawProfileX ( )
inline
Returns
flag for drawing x profile.

Definition at line 115 of file BCH2D.h.

bool BCH2D::GetDrawProfileY ( )
inline
Returns
flag for drawing y profile.

Definition at line 135 of file BCH2D.h.

TH2* BCH2D::GetHistogram ( )
inline

Return the TH2 histogram.

Returns
The TH2 histogram.

Definition at line 100 of file BCH2D.h.

bool BCH2D::GetLogz ( )
inline
Returns
flag for plotting log on z axis.

Definition at line 110 of file BCH2D.h.

int BCH2D::GetProfileXLineColor ( )
inline
Returns
line color for x profile.

Definition at line 125 of file BCH2D.h.

int BCH2D::GetProfileXLineStyle ( )
inline
Returns
line style for x profile.

Definition at line 130 of file BCH2D.h.

BCH2DProfileType BCH2D::GetProfileXType ( )
inline
Returns
profile type for x profile.

Definition at line 120 of file BCH2D.h.

int BCH2D::GetProfileYLineColor ( )
inline
Returns
line color for y profile.

Definition at line 145 of file BCH2D.h.

int BCH2D::GetProfileYLineStyle ( )
inline
Returns
line style for y profile.

Definition at line 150 of file BCH2D.h.

BCH2DProfileType BCH2D::GetProfileYType ( )
inline
Returns
profile type for y profile.

Definition at line 140 of file BCH2D.h.

void BCH2D::SetBandType ( BCH2DBandType  bt)
inline

Set band type.

Definition at line 184 of file BCH2D.h.

void BCH2D::SetDrawProfileX ( bool  flag = true)
inline

Set drawing of x profile.

Definition at line 194 of file BCH2D.h.

void BCH2D::SetDrawProfileY ( bool  flag = true)
inline

Set drawing of y profile.

Definition at line 214 of file BCH2D.h.

void BCH2D::SetGlobalMode ( double  x,
double  y 
)
inline

Set global mode.

Parameters
xGlobal mode in x.
yGlobal mode in y.

Definition at line 171 of file BCH2D.h.

void BCH2D::SetLocalMode ( double  x,
double  y 
)
inline

Set local mode.

Parameters
xGlobal mode in x.
yGlobal mode in y.

Definition at line 180 of file BCH2D.h.

void BCH2D::SetLogz ( bool  flag = true)
inline

Sets drawing of z axis in log.

Definition at line 189 of file BCH2D.h.

void BCH2D::SetProfileXLineColor ( int  c)
inline

Set line color of x profile.

Definition at line 204 of file BCH2D.h.

void BCH2D::SetProfileXLineStyle ( int  s)
inline

Set line style of x profile.

Definition at line 209 of file BCH2D.h.

void BCH2D::SetProfileXType ( BCH2DProfileType  pt)
inline

Set profile type of x profile.

Definition at line 199 of file BCH2D.h.

void BCH2D::SetProfileYLineColor ( int  c)
inline

Set line color of y profile.

Definition at line 224 of file BCH2D.h.

void BCH2D::SetProfileYLineStyle ( int  s)
inline

Set line style of y profile.

Definition at line 229 of file BCH2D.h.

void BCH2D::SetProfileYType ( BCH2DProfileType  pt)
inline

Set profile type of y profile.

Definition at line 219 of file BCH2D.h.

Member Data Documentation

BCH2DBandType BCH2D::fBandType
protected

band type.

Definition at line 278 of file BCH2D.h.

bool BCH2D::fDrawProfileX
protected

flag for drawing x profile.

Definition at line 286 of file BCH2D.h.

bool BCH2D::fDrawProfileY
protected

flag for drawing y profile.

Definition at line 302 of file BCH2D.h.

bool BCH2D::fLogz
protected

flag for drawing log z.

Definition at line 282 of file BCH2D.h.

int BCH2D::fProfileXLineColor
protected

color of x profile.

Definition at line 294 of file BCH2D.h.

int BCH2D::fProfileXLineStyle
protected

line style of x profile.

Definition at line 298 of file BCH2D.h.

BCH2DProfileType BCH2D::fProfileXType
protected

profile type of x profile.

Definition at line 290 of file BCH2D.h.

int BCH2D::fProfileYLineColor
protected

color of y profile.

Definition at line 310 of file BCH2D.h.

int BCH2D::fProfileYLineStyle
protected

line style of y profile.

Definition at line 314 of file BCH2D.h.

BCH2DProfileType BCH2D::fProfileYType
protected

profile type of y profile.

Definition at line 306 of file BCH2D.h.


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