|
HyperPlot
v1
Bin and visualise multidimensional datasets
|
HyperPlot, Author: Sam Harnew, sam.harnew@gmail.com , Date: Dec 2015
The base class for any histogram object (my version of a TH1)
Definition at line 30 of file HistogramBase.h.
#include <HistogramBase.h>
Public Member Functions | |
| HistogramBase (int nBins) | |
| virtual | ~HistogramBase () |
| int | checkBinNumber (int bin) const |
| void | resetBinContents (int nBins) |
| void | fillBase (int binNum, double weight) |
| void | setBinContent (int bin, double val) |
| void | setBinError (int bin, double val) |
| virtual void | merge (const HistogramBase &other) |
| double | getBinContent (int bin) const |
| double | getBinError (int bin) const |
| int | getNBins () const |
| void | divide (const HistogramBase &other) |
| void | multiply (const HistogramBase &other) |
| void | add (const HistogramBase &other) |
| void | minus (const HistogramBase &other) |
| void | pulls (const HistogramBase &other) |
| void | drawPullHistogram (const HistogramBase &other, TString name, int nBins=50, double pmLimits=3.5) const |
| double | chi2 (const HistogramBase &other) const |
| double | pvalue (const HistogramBase &other, int ndof=-1) const |
| double | integral () const |
| double | integralError () const |
| void | randomiseWithinErrors (int seed) |
| double | getMin () const |
| double | getMax () const |
| void | setMin (double min) |
| void | setMax (double max) |
| double | getMinDensity () const |
| double | getMaxDensity () const |
| void | setMinDensity (double min) |
| void | setMaxDensity (double max) |
| void | saveBase () |
| void | saveBase (TString filename) |
| void | loadBase (TString filename) |
| void | normalise (double area=1.0) |
| virtual double | getBinVolume (int bin) const |
| double | getFrequencyDensity (int bin) const |
| void | reserveCapacity (int nElements) |
| void | makeFrequencyDensity () |
| void | print () |
Protected Attributes | |
| int | _nBins |
| std::vector< double > | _binContents |
| std::vector< double > | _sumW2 |
| double | _min |
| double | _max |
| double | _minDensity |
| double | _maxDensity |
| HistogramBase::HistogramBase | ( | int | nBins | ) |
Construct a histogram base with a specified number of bins
Definition at line 8 of file HistogramBase.cpp.
|
virtual |
Destructor
Definition at line 139 of file HistogramBase.cpp.
| void HistogramBase::add | ( | const HistogramBase & | other | ) |
Add this hitogram to another. Histograms must have the same number of bins
Definition at line 277 of file HistogramBase.cpp.
| int HistogramBase::checkBinNumber | ( | int | bin | ) | const |
Check if it's a valid bin number, if not return the overflow/underflow bin
Definition at line 154 of file HistogramBase.cpp.
| double HistogramBase::chi2 | ( | const HistogramBase & | other | ) | const |
Calculate the chi2 between this histogram and another. Histograms must have the same number of bins
Definition at line 399 of file HistogramBase.cpp.
| void HistogramBase::divide | ( | const HistogramBase & | other | ) |
Divide this hitogram by another. Histograms must have the same number of bins
Definition at line 212 of file HistogramBase.cpp.
| void HistogramBase::drawPullHistogram | ( | const HistogramBase & | other, |
| TString | name, | ||
| int | nBins = 50, |
||
| double | pmLimits = 3.5 |
||
| ) | const |
Draw the distribution of pulls between two histograms. They are only drawn between +- pmLimits sigma, using nBins. The plot is saved with the name 'name'.
Definition at line 426 of file HistogramBase.cpp.
| void HistogramBase::fillBase | ( | int | binNum, |
| double | weight | ||
| ) |
Fill the specifed bin with a specifed weight. Note that the bin numbers run from 0 to nBins-1 inclusive so that nBins is overflow/underflow
Definition at line 146 of file HistogramBase.cpp.
| double HistogramBase::getBinContent | ( | int | bin | ) | const |
Get the content of a bin
Definition at line 501 of file HistogramBase.cpp.
| double HistogramBase::getBinError | ( | int | bin | ) | const |
Get the error of a bin
Definition at line 508 of file HistogramBase.cpp.
|
virtual |
Get the bin volume. This is a virual function, as the bin volume depends on the binning used (which isn't defined here).
Reimplemented in HyperHistogram.
Definition at line 516 of file HistogramBase.cpp.
| double HistogramBase::getFrequencyDensity | ( | int | bin | ) | const |
Get the frequency density in a bin - this is just the bin content divided by the bin volume
Definition at line 523 of file HistogramBase.cpp.
| double HistogramBase::getMax | ( | ) | const |
If the user hasn't specified a minimum using setMax, then loop over the bins and find the maximum
Definition at line 179 of file HistogramBase.cpp.
| double HistogramBase::getMaxDensity | ( | ) | const |
If the user hasn't specified a maximum using setMaxDensity, then loop over the bins and find the maximum density
Definition at line 201 of file HistogramBase.cpp.
| double HistogramBase::getMin | ( | ) | const |
If the user hasn't specified a minimum using setMin, then loop over the bins and find the minimum
Definition at line 168 of file HistogramBase.cpp.
| double HistogramBase::getMinDensity | ( | ) | const |
If the user hasn't specified a minimum using setMinDensity, then loop over the bins and find the minimum density
Definition at line 190 of file HistogramBase.cpp.
|
inline |
Get the number of bins in the histogram
Definition at line 62 of file HistogramBase.h.
| double HistogramBase::integral | ( | ) | const |
Calcualte the integral (sum of bin contents, excluding the undeflow/overflow)
Definition at line 453 of file HistogramBase.cpp.
| double HistogramBase::integralError | ( | ) | const |
Calcualte the error on the integral (excluding the undeflow/overflow)
Definition at line 463 of file HistogramBase.cpp.
| void HistogramBase::loadBase | ( | TString | filename | ) |
Load the contents, sumw2, and bin numbers from a TTree in the ROOT file specified (opened using READ)
Definition at line 106 of file HistogramBase.cpp.
| void HistogramBase::makeFrequencyDensity | ( | ) |
Replace all the bin contents with frequency density.
Definition at line 531 of file HistogramBase.cpp.
|
virtual |
Merge one HistogramBase with another
Reimplemented in HyperHistogram.
Definition at line 37 of file HistogramBase.cpp.
| void HistogramBase::minus | ( | const HistogramBase & | other | ) |
Subtract other histogram from this one. Histograms must have the same number of bins
Definition at line 307 of file HistogramBase.cpp.
| void HistogramBase::multiply | ( | const HistogramBase & | other | ) |
Multiply this hitogram by another. Histograms must have the same number of bins
Definition at line 245 of file HistogramBase.cpp.
| void HistogramBase::normalise | ( | double | area = 1.0 | ) |
Normalise sum of bin contents to specified area. Errors are also scaled.
Definition at line 473 of file HistogramBase.cpp.
| void HistogramBase::print | ( | ) |
Print the contents and errors of all the bins to the screen.
Definition at line 543 of file HistogramBase.cpp.
| void HistogramBase::pulls | ( | const HistogramBase & | other | ) |
Find pulls between this histogram and another. Histograms must have the same number of bins
Definition at line 337 of file HistogramBase.cpp.
| double HistogramBase::pvalue | ( | const HistogramBase & | other, |
| int | ndof = -1 |
||
| ) | const |
Calculate the chi2 between this histogram and another, and use this to find a p-value using the specified degrees of freedom. If ndof isn't specified, nBins is used. Histograms must have the same number of bins
Definition at line 388 of file HistogramBase.cpp.
| void HistogramBase::randomiseWithinErrors | ( | int | seed | ) |
Randomise the histogram within it's Gaussian errors using the given seed. If value is < 0.0 then content is set to 0.0. errors remain the same before and after randomisation.
Definition at line 368 of file HistogramBase.cpp.
| void HistogramBase::resetBinContents | ( | int | nBins | ) |
Update the number of bins and set all contents to zero
Definition at line 22 of file HistogramBase.cpp.
| void HistogramBase::saveBase | ( | ) |
Save the contents, sumw2, and bin numbers in a TTree to an open TFile
Definition at line 68 of file HistogramBase.cpp.
| void HistogramBase::saveBase | ( | TString | filename | ) |
Save the contents, sumw2, and bin numbers in a TTree into the ROOT file specified (opened using RECREATE)
Definition at line 93 of file HistogramBase.cpp.
| void HistogramBase::setBinContent | ( | int | bin, |
| double | val | ||
| ) |
Set the content of a bin (leaves error unchanged)
Definition at line 487 of file HistogramBase.cpp.
| void HistogramBase::setBinError | ( | int | bin, |
| double | val | ||
| ) |
Set the error of a bin
Definition at line 494 of file HistogramBase.cpp.
|
inline |
Set the maximum bin content for plotting
Definition at line 85 of file HistogramBase.h.
|
inline |
Set the maximum frequency density for plotting
Definition at line 90 of file HistogramBase.h.
|
inline |
Set the minimum bin content for plotting
Definition at line 84 of file HistogramBase.h.
|
inline |
Set the minimum frequency density for plotting
Definition at line 89 of file HistogramBase.h.
|
protected |
Bin contents (note that bin nBins is underflow/overflow)
Definition at line 35 of file HistogramBase.h.
|
protected |
Maximum bin content (for plotting)
Definition at line 39 of file HistogramBase.h.
|
protected |
Maximum bin density (bin content / bin volume) (for plotting)
Definition at line 41 of file HistogramBase.h.
|
protected |
Minimum bin content (for plotting)
Definition at line 38 of file HistogramBase.h.
|
protected |
Minimum bin density (bin content / bin volume) (for plotting)
Definition at line 40 of file HistogramBase.h.
|
protected |
Number of bins in the histogram
Definition at line 34 of file HistogramBase.h.
|
protected |
Sum of weights^2 for each bin (note that bin nBins is underflow/overflow)
Definition at line 36 of file HistogramBase.h.
1.8.10