Meerkat is hosted by Hepforge, IPPP Durham
Meerkat  v1r3
Multidimensional kernel density estimation package

#include <BinnedKernelDensity.hh>

Inheritance diagram for BinnedKernelDensity:
AbsDensity

Public Member Functions

 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, UInt_t bins1, Double_t width1, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 1-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *weight, UInt_t bins1, Double_t width1, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 1-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *vars2, UInt_t bins1, UInt_t bins2, Double_t width1, Double_t width2, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 2-dimensional kernel PDF with binned interpolation from the sample of points in an NTUple. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *vars2, const char *weight, UInt_t bins1, UInt_t bins2, Double_t width1, Double_t width2, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 2-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *vars2, const char *vars3, UInt_t bins1, UInt_t bins2, UInt_t bins3, Double_t width1, Double_t width2, Double_t width3, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 3-dimensional kernel PDF with binned interpolation from the sample of points in an NTUple. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *vars2, const char *vars3, const char *weight, UInt_t bins1, UInt_t bins2, UInt_t bins3, Double_t width1, Double_t width2, Double_t width3, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 3-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *vars2, const char *vars3, const char *vars4, UInt_t bins1, UInt_t bins2, UInt_t bins3, UInt_t bins4, Double_t width1, Double_t width2, Double_t width3, Double_t width4, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 4-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *vars2, const char *vars3, const char *vars4, const char *weight, UInt_t bins1, UInt_t bins2, UInt_t bins3, UInt_t bins4, Double_t width1, Double_t width2, Double_t width3, Double_t width4, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 4-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *vars2, const char *vars3, const char *vars4, const char *vars5, UInt_t bins1, UInt_t bins2, UInt_t bins3, UInt_t bins4, UInt_t bins5, Double_t width1, Double_t width2, Double_t width3, Double_t width4, Double_t width5, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 5-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *vars2, const char *vars3, const char *vars4, const char *vars5, const char *weight, UInt_t bins1, UInt_t bins2, UInt_t bins3, UInt_t bins4, UInt_t bins5, Double_t width1, Double_t width2, Double_t width3, Double_t width4, Double_t width5, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 5-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight. More...
 
 BinnedKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, std::vector< TString > &vars, std::vector< UInt_t > &binning, std::vector< Double_t > &width, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for kernel PDF with binned interpolation of arbitrary dimensionality from the sample of points in an NTuple. More...
 
virtual ~BinnedKernelDensity ()
 Destructor. More...
 
void writeToFile (const char *fileName)
 Write density map to a file, ROOT or text depending on extension. More...
 
void writeToTextFile (const char *fileName)
 Write the binned PDF to a text file. More...
 
void writeToRootFile (const char *fileName)
 Write the binned density into a ROOT file. More...
 
Double_t density (std::vector< Double_t > &x)
 Calculate PDF density at the point. Multilinear binned interpolation is used which is calculated in the constructor, so this call is fast. More...
 
AbsPhaseSpacephaseSpace ()
 Return the phase space. More...
 
void setFractionalMode (Bool_t mode=true)
 Set fractional mode of operation. More...
 
void normalise (void)
 Normalise the PDF such that the average PDF value over the allowed phase space equals to 1. More...
 
- Public Member Functions inherited from AbsDensity
 AbsDensity (const char *pdfName)
 Constructor. More...
 
virtual ~AbsDensity ()
 Destructor. More...
 
void slice (std::vector< Double_t > &x, UInt_t num, TH1F *hist)
 Calculate 1D slice of the PDF. More...
 
void slice (std::vector< Double_t > &x, UInt_t numx, UInt_t numy, TH2F *hist, Bool_t inPhaseSpace=true)
 Calculate 2D slice of the PDF. More...
 
double transform (TH1F *hist1, TH1F *hist2, double x)
 
void project (TH1F *hist)
 Calculate projection of the 1D PDF. More...
 
void project (TH2F *hist, Bool_t inPhaseSpace=true)
 Calculate projection of the 2D PDF. More...
 
void setMajorant (Double_t majorant)
 Set majorant for accept-reject method. More...
 
void setMaxTries (UInt_t maxTries)
 Set maximum number of tries for accept-reject method. More...
 
Double_t generate (std::vector< Double_t > &x)
 Generate a single point within the phase space according to the PDF using accept-reject method. More...
 
void generate (TNtuple *tree, UInt_t numEvents)
 Generate a sample of points within the phase space according to the PDF using accept-reject method. More...
 
const char * name (void)
 Return the name of the PDF. More...
 
void setSeed (UInt_t seed=0)
 Set random seed. More...
 

Private Member Functions

void init (AbsPhaseSpace *thePhaseSpace, TTree *tree, std::vector< TString > &vars, std::vector< UInt_t > &binning, std::vector< Double_t > &width, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Common initialise method used by all constructors. More...
 
UInt_t iterToIndex (std::vector< UInt_t > &iter)
 Convert an N-dimensional iterator vector into a linear bin index in the bin map. More...
 
void addToMap (std::vector< Double_t > &map, std::vector< Double_t > &point, Double_t weight=1.)
 Add a kernel density of a single data point to the binned map. More...
 
void fillMapFromTree (TTree *tree, std::vector< TString > &vars, UInt_t maxEvents=0, UInt_t skipEvents=0)
 
void fillMapFromDensity (AbsDensity *density, UInt_t toyEvents=0)
 
Double_t mapDensity (std::vector< Double_t > &map, std::vector< Double_t > &x)
 Calculate the raw density using the binned map (estimated or approximation) at a given point. More...
 

Private Attributes

std::vector< Double_t > m_map
 Bin map of estimated PDF. More...
 
std::vector< Double_t > m_approxMap
 Bin map of approximation PDF convolved with the kernel. More...
 
std::vector< UInt_t > m_binning
 Vector of bin numbers in each variable. More...
 
AbsPhaseSpacem_phaseSpace
 Reference to phase space. More...
 
AbsDensitym_approxDensity
 Reference to approximation PDF. More...
 
std::vector< Double_t > m_width
 Vector of kernel widths. More...
 
UInt_t m_dim
 Cached dimensionality of the phase space. More...
 
Bool_t m_fractionalMode
 Fractional mode flag. More...
 

Additional Inherited Members

- Protected Attributes inherited from AbsDensity
char m_name [256]
 PDF name. More...
 
Double_t m_majorant
 PDF majorant (maximum PDF value needed for accept-reject). More...
 
UInt_t m_maxTries
 Maximum number of tries for accept-reject method. More...
 
TRandom3 m_rnd
 Random number generator. More...
 

Detailed Description

Definition at line 10 of file BinnedKernelDensity.hh.

Constructor & Destructor Documentation

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
UInt_t  bins1,
Double_t  width1,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 1-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars1variable name
[in]bins1number of bins for the binned interpolation
[in]width1kernel width
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 31 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
const char *  weight,
UInt_t  bins1,
Double_t  width1,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 1-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars1variable name
[in]weightweight variable name
[in]bins1number of bins for the binned interpolation
[in]width1kernel width
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 54 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
const char *  vars2,
UInt_t  bins1,
UInt_t  bins2,
Double_t  width1,
Double_t  width2,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 2-dimensional kernel PDF with binned interpolation from the sample of points in an NTUple.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars11st variable name
[in]vars22nd variable name
[in]bins1number of bins for the 1st variable for the binned interpolation
[in]bins2number of bins for the 2nd variable for the binned interpolation
[in]width1kernel width for the 1st variable
[in]width2kernel width for the 2nd variable
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 79 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
const char *  vars2,
const char *  weight,
UInt_t  bins1,
UInt_t  bins2,
Double_t  width1,
Double_t  width2,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 2-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars11st variable name
[in]vars22nd variable name
[in]weightweight variable name
[in]bins1number of bins for the 1st variable for the binned interpolation
[in]bins2number of bins for the 2nd variable for the binned interpolation
[in]width1kernel width for the 1st variable
[in]width2kernel width for the 2nd variable
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 105 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
const char *  vars2,
const char *  vars3,
UInt_t  bins1,
UInt_t  bins2,
UInt_t  bins3,
Double_t  width1,
Double_t  width2,
Double_t  width3,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 3-dimensional kernel PDF with binned interpolation from the sample of points in an NTUple.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars11st variable name
[in]vars22nd variable name
[in]vars33rd variable name
[in]bins1number of bins for the 1st variable for the binned interpolation
[in]bins2number of bins for the 2nd variable for the binned interpolation
[in]bins3number of bins for the 3rd variable for the binned interpolation
[in]width1kernel width for the 1st variable
[in]width2kernel width for the 2nd variable
[in]width3kernel width for the 3rd variable
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 133 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
const char *  vars2,
const char *  vars3,
const char *  weight,
UInt_t  bins1,
UInt_t  bins2,
UInt_t  bins3,
Double_t  width1,
Double_t  width2,
Double_t  width3,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 3-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars11st variable name
[in]vars22nd variable name
[in]vars33rd variable name
[in]weightweight variable name
[in]bins1number of bins for the 1st variable for the binned interpolation
[in]bins2number of bins for the 2nd variable for the binned interpolation
[in]bins3number of bins for the 3rd variable for the binned interpolation
[in]width1kernel width for the 1st variable
[in]width2kernel width for the 2nd variable
[in]width3kernel width for the 3rd variable
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 162 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
const char *  vars2,
const char *  vars3,
const char *  vars4,
UInt_t  bins1,
UInt_t  bins2,
UInt_t  bins3,
UInt_t  bins4,
Double_t  width1,
Double_t  width2,
Double_t  width3,
Double_t  width4,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 4-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars11st variable name
[in]vars22nd variable name
[in]vars33rd variable name
[in]vars44th variable name
[in]bins1number of bins for the 1st variable for the binned interpolation
[in]bins2number of bins for the 2nd variable for the binned interpolation
[in]bins3number of bins for the 3rd variable for the binned interpolation
[in]bins4number of bins for the 4th variable for the binned interpolation
[in]width1kernel width for the 1st variable
[in]width2kernel width for the 2nd variable
[in]width3kernel width for the 3rd variable
[in]width4kernel width for the 4th variable
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 193 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
const char *  vars2,
const char *  vars3,
const char *  vars4,
const char *  weight,
UInt_t  bins1,
UInt_t  bins2,
UInt_t  bins3,
UInt_t  bins4,
Double_t  width1,
Double_t  width2,
Double_t  width3,
Double_t  width4,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 4-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars11st variable name
[in]vars22nd variable name
[in]vars33rd variable name
[in]vars44th variable name
[in]weightweight variable name
[in]bins1number of bins for the 1st variable for the binned interpolation
[in]bins2number of bins for the 2nd variable for the binned interpolation
[in]bins3number of bins for the 3rd variable for the binned interpolation
[in]bins4number of bins for the 4th variable for the binned interpolation
[in]width1kernel width for the 1st variable
[in]width2kernel width for the 2nd variable
[in]width3kernel width for the 3rd variable
[in]width4kernel width for the 4th variable
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 225 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
const char *  vars2,
const char *  vars3,
const char *  vars4,
const char *  vars5,
UInt_t  bins1,
UInt_t  bins2,
UInt_t  bins3,
UInt_t  bins4,
UInt_t  bins5,
Double_t  width1,
Double_t  width2,
Double_t  width3,
Double_t  width4,
Double_t  width5,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 5-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars11st variable name
[in]vars22nd variable name
[in]vars33rd variable name
[in]vars44th variable name
[in]vars55th variable name
[in]bins1number of bins for the 1st variable for the binned interpolation
[in]bins2number of bins for the 2nd variable for the binned interpolation
[in]bins3number of bins for the 3rd variable for the binned interpolation
[in]bins4number of bins for the 4th variable for the binned interpolation
[in]bins5number of bins for the 5th variable for the binned interpolation
[in]width1kernel width for the 1st variable
[in]width2kernel width for the 2nd variable
[in]width3kernel width for the 3rd variable
[in]width4kernel width for the 4th variable
[in]width5kernel width for the 5th variable
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 259 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
const char *  vars1,
const char *  vars2,
const char *  vars3,
const char *  vars4,
const char *  vars5,
const char *  weight,
UInt_t  bins1,
UInt_t  bins2,
UInt_t  bins3,
UInt_t  bins4,
UInt_t  bins5,
Double_t  width1,
Double_t  width2,
Double_t  width3,
Double_t  width4,
Double_t  width5,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 5-dimensional kernel PDF with binned interpolation from the sample of points in an NTuple with weight.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]vars11st variable name
[in]vars22nd variable name
[in]vars33rd variable name
[in]vars44th variable name
[in]vars55th variable name
[in]weightweight
[in]bins1number of bins for the 1st variable for the binned interpolation
[in]bins2number of bins for the 2nd variable for the binned interpolation
[in]bins3number of bins for the 3rd variable for the binned interpolation
[in]bins4number of bins for the 4th variable for the binned interpolation
[in]bins5number of bins for the 5th variable for the binned interpolation
[in]width1kernel width for the 1st variable
[in]width2kernel width for the 2nd variable
[in]width3kernel width for the 3rd variable
[in]width4kernel width for the 4th variable
[in]width5kernel width for the 5th variable
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 294 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::BinnedKernelDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
TTree *  tree,
std::vector< TString > &  vars,
std::vector< UInt_t > &  binning,
std::vector< Double_t > &  width,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for kernel PDF with binned interpolation of arbitrary dimensionality from the sample of points in an NTuple.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]varsvector of variable names. The size of vector should match the dimensionality of phase space or be larger by one.
[in]binningvector of numbers of bins for the binned interpolation. The size of vector should match the dimensionality of phase space.
[in]widthvector of kernel widths. The size of vector should match the dimensionality of phase space.
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 17 of file BinnedKernelDensity.cpp.

BinnedKernelDensity::~BinnedKernelDensity ( )
virtual

Destructor.

Definition at line 331 of file BinnedKernelDensity.cpp.

Member Function Documentation

void BinnedKernelDensity::addToMap ( std::vector< Double_t > &  map,
std::vector< Double_t > &  point,
Double_t  weight = 1. 
)
private

Add a kernel density of a single data point to the binned map.

Parameters
[in]mappointer to the binned map
[in]pointdata point coordinates
[in]weightpoint weight

Definition at line 405 of file BinnedKernelDensity.cpp.

Double_t BinnedKernelDensity::density ( std::vector< Double_t > &  x)
virtual

Calculate PDF density at the point. Multilinear binned interpolation is used which is calculated in the constructor, so this call is fast.

Parameters
[in]xpoint
Returns
PDF value

Implements AbsDensity.

Definition at line 996 of file BinnedKernelDensity.cpp.

void BinnedKernelDensity::fillMapFromDensity ( AbsDensity density,
UInt_t  toyEvents = 0 
)
private

Definition at line 566 of file BinnedKernelDensity.cpp.

void BinnedKernelDensity::fillMapFromTree ( TTree *  tree,
std::vector< TString > &  vars,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)
private

Definition at line 488 of file BinnedKernelDensity.cpp.

void BinnedKernelDensity::init ( AbsPhaseSpace thePhaseSpace,
TTree *  tree,
std::vector< TString > &  vars,
std::vector< UInt_t > &  binning,
std::vector< Double_t > &  width,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)
private

Common initialise method used by all constructors.

Initialise method used by all constructors.

Parameters
[in]thePhaseSpacephase space
[in]treeROOT NTuple
[in]varsvector of variable names. The size of vector should match the dimensionality of phase space.
[in]binningvector of numbers of bins for the binned interpolation. The size of vector should match the dimensionality of phase space.
[in]widthvector of kernel widths. The size of vector should match the dimensionality of phase space.
[in]approxapproximation PDF. Uniform approximation is used for approx=0
[in]toyEventsnumber of toy events for MC convolution of the approximation PDF. Use binned convolution if toyEvents=0
[in]maxEventsmaximum number of events to read from NTuple. Read all events if maxEvents=0
[in]skipEventsnumber of NTuple events to skip from the beginning

Definition at line 336 of file BinnedKernelDensity.cpp.

UInt_t BinnedKernelDensity::iterToIndex ( std::vector< UInt_t > &  iter)
private

Convert an N-dimensional iterator vector into a linear bin index in the bin map.

Calculate map index for a given iterator vector.

Parameters
[in]iteriterator vector
Returns
bin index in the map

Definition at line 392 of file BinnedKernelDensity.cpp.

Double_t BinnedKernelDensity::mapDensity ( std::vector< Double_t > &  map,
std::vector< Double_t > &  x 
)
private

Calculate the raw density using the binned map (estimated or approximation) at a given point.

Parameters
[in]mapreference to the bin map
[in]xpoint

Definition at line 895 of file BinnedKernelDensity.cpp.

void BinnedKernelDensity::normalise ( void  )

Normalise the PDF such that the average PDF value over the allowed phase space equals to 1.

Normalise density to have the average PDF value over the allowed phase space equal to 1.

Definition at line 827 of file BinnedKernelDensity.cpp.

AbsPhaseSpace* BinnedKernelDensity::phaseSpace ( )
inlinevirtual

Return the phase space.

Returns
phase space

Implements AbsDensity.

Definition at line 394 of file BinnedKernelDensity.hh.

void BinnedKernelDensity::setFractionalMode ( Bool_t  mode = true)
inline

Set fractional mode of operation.

Parameters
modeIf mode==true, the density returned will be the ratio of the kernel and approximation density

Definition at line 400 of file BinnedKernelDensity.hh.

void BinnedKernelDensity::writeToFile ( const char *  fileName)

Write density map to a file, ROOT or text depending on extension.

Write the binned PDF to a file. Can be used later by BinnedDensity. Format of the file (text or ROOT) is decided based on the extension of the file name.

Parameters
[in]fileNamefile name

Definition at line 673 of file BinnedKernelDensity.cpp.

void BinnedKernelDensity::writeToRootFile ( const char *  fileName)

Write the binned density into a ROOT file.

Write density map to a ROOT file.

Parameters
[in]fileNameoutput ROOT file name

Definition at line 744 of file BinnedKernelDensity.cpp.

void BinnedKernelDensity::writeToTextFile ( const char *  fileName)

Write the binned PDF to a text file.

Write density map to a text file.

Parameters
[in]fileNamefile name

Definition at line 682 of file BinnedKernelDensity.cpp.

Member Data Documentation

AbsDensity* BinnedKernelDensity::m_approxDensity
private

Reference to approximation PDF.

Definition at line 469 of file BinnedKernelDensity.hh.

std::vector<Double_t> BinnedKernelDensity::m_approxMap
private

Bin map of approximation PDF convolved with the kernel.

Definition at line 460 of file BinnedKernelDensity.hh.

std::vector<UInt_t> BinnedKernelDensity::m_binning
private

Vector of bin numbers in each variable.

Definition at line 463 of file BinnedKernelDensity.hh.

UInt_t BinnedKernelDensity::m_dim
private

Cached dimensionality of the phase space.

Definition at line 475 of file BinnedKernelDensity.hh.

Bool_t BinnedKernelDensity::m_fractionalMode
private

Fractional mode flag.

Definition at line 478 of file BinnedKernelDensity.hh.

std::vector<Double_t> BinnedKernelDensity::m_map
private

Bin map of estimated PDF.

Definition at line 457 of file BinnedKernelDensity.hh.

AbsPhaseSpace* BinnedKernelDensity::m_phaseSpace
private

Reference to phase space.

Definition at line 466 of file BinnedKernelDensity.hh.

std::vector<Double_t> BinnedKernelDensity::m_width
private

Vector of kernel widths.

Definition at line 472 of file BinnedKernelDensity.hh.


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