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

#include <AdaptiveKernelDensity.hh>

Inheritance diagram for AdaptiveKernelDensity:
AbsDensity

Public Member Functions

 AdaptiveKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, UInt_t bins1, Double_t width1, AbsDensity *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 1-dimensional adaptive kernel PDF from the sample of points in an NTuple. More...
 
 AdaptiveKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, const char *vars1, const char *weight, UInt_t bins1, Double_t width1, AbsDensity *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 1-dimensional adaptive kernel PDF from the sample of points in an NTuple with weight. More...
 
 AdaptiveKernelDensity (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 *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 2-dimensional adaptive kernel PDF from the sample of points in an NTUple. More...
 
 AdaptiveKernelDensity (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 *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 2-dimensional adaptive kernel PDF from the sample of points in an NTuple with weight. More...
 
 AdaptiveKernelDensity (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 *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 3-dimensional adaptive kernel PDF from the sample of points in an NTuple. More...
 
 AdaptiveKernelDensity (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 *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 3-dimensional adaptive kernel PDF from the sample of points in an NTuple with weight. More...
 
 AdaptiveKernelDensity (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 *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 4-dimensional adaptive kernel PDF from the sample of points in an NTuple. More...
 
 AdaptiveKernelDensity (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 *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 4-dimensional adaptive kernel PDF from the sample of points in an NTuple with weight. More...
 
 AdaptiveKernelDensity (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 *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 5-dimensional adaptive kernel PDF from the sample of points in an NTuple. More...
 
 AdaptiveKernelDensity (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 *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for 5-dimensional adaptive kernel PDF from the sample of points in an NTuple with weight. More...
 
 AdaptiveKernelDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, TTree *tree, std::vector< TString > &vars, std::vector< UInt_t > &binning, std::vector< Double_t > &width, AbsDensity *widthScale, AbsDensity *approx=0, UInt_t toyEvents=0, UInt_t maxEvents=0, UInt_t skipEvents=0)
 Constructor for adaptive kernel PDF of arbitrary dimensionality from the sample of points in an NTUple. More...
 
virtual ~AdaptiveKernelDensity ()
 Destructor. More...
 
void writeToFile (const char *fileName)
 Write density map to file 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 *widthScale, 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 widthScale=1., 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 *theDensity, 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...
 
AbsDensitym_widthScaleDensity
 Reference to PDF used for kernel width scaling. 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...
 
Double_t m_minValue
 Minimum value of the width scale PDF to be used for scaling. More...
 
Double_t m_maxValue
 Maximum value of the width scale PDF to be used for scaling. More...
 
Double_t m_minScale
 Minimum width scale factor. More...
 
Double_t m_maxScale
 Maximum width scale factor. 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

A class to calculate the binned multidimensional density using adaptive kernel estimation technique with approximation PDF.

Definition at line 14 of file AdaptiveKernelDensity.hh.

Constructor & Destructor Documentation

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

Constructor for 1-dimensional adaptive kernel PDF 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]width1average kernel width
[in]widthScalePDF for width scaling
[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 35 of file AdaptiveKernelDensity.cpp.

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

Constructor for 1-dimensional adaptive kernel PDF 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]width1average kernel width
[in]widthScalePDF for width scaling
[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 59 of file AdaptiveKernelDensity.cpp.

AdaptiveKernelDensity::AdaptiveKernelDensity ( 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 widthScale,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 2-dimensional adaptive kernel PDF 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]width1average kernel width for the 1st variable
[in]width2average kernel width for the 2nd variable
[in]widthScalePDF for width scaling
[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 85 of file AdaptiveKernelDensity.cpp.

AdaptiveKernelDensity::AdaptiveKernelDensity ( 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 widthScale,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 2-dimensional adaptive kernel PDF 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]width1average kernel width for the 1st variable
[in]width2average kernel width for the 2nd variable
[in]widthScalePDF for width scaling
[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 112 of file AdaptiveKernelDensity.cpp.

AdaptiveKernelDensity::AdaptiveKernelDensity ( 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 widthScale,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 3-dimensional adaptive kernel PDF 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]width1average kernel width for the 1st variable
[in]width2average kernel width for the 2nd variable
[in]width3average kernel width for the 3rd variable
[in]widthScalePDF for width scaling
[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 141 of file AdaptiveKernelDensity.cpp.

AdaptiveKernelDensity::AdaptiveKernelDensity ( 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 widthScale,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 3-dimensional adaptive kernel PDF 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]width1average kernel width for the 1st variable
[in]width2average kernel width for the 2nd variable
[in]width3average kernel width for the 3rd variable
[in]widthScalePDF for width scaling
[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 171 of file AdaptiveKernelDensity.cpp.

AdaptiveKernelDensity::AdaptiveKernelDensity ( 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 widthScale,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 4-dimensional adaptive kernel PDF 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]width1average kernel width for the 1st variable
[in]width2average kernel width for the 2nd variable
[in]width3average kernel width for the 3rd variable
[in]width4average kernel width for the 4th variable
[in]widthScalePDF for width scaling
[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 203 of file AdaptiveKernelDensity.cpp.

AdaptiveKernelDensity::AdaptiveKernelDensity ( 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 widthScale,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 4-dimensional adaptive kernel PDF 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]width1average kernel width for the 1st variable
[in]width2average kernel width for the 2nd variable
[in]width3average kernel width for the 3rd variable
[in]width4average kernel width for the 4th variable
[in]widthScalePDF for width scaling
[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 236 of file AdaptiveKernelDensity.cpp.

AdaptiveKernelDensity::AdaptiveKernelDensity ( 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 widthScale,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 5-dimensional adaptive kernel PDF 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]width1average kernel width for the 1st variable
[in]width2average kernel width for the 2nd variable
[in]width3average kernel width for the 3rd variable
[in]width4average kernel width for the 4th variable
[in]width5average kernel width for the 5th variable
[in]widthScalePDF for width scaling
[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 271 of file AdaptiveKernelDensity.cpp.

AdaptiveKernelDensity::AdaptiveKernelDensity ( 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 widthScale,
AbsDensity approx = 0,
UInt_t  toyEvents = 0,
UInt_t  maxEvents = 0,
UInt_t  skipEvents = 0 
)

Constructor for 5-dimensional adaptive kernel PDF 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 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]width1average kernel width for the 1st variable
[in]width2average kernel width for the 2nd variable
[in]width3average kernel width for the 3rd variable
[in]width4average kernel width for the 4th variable
[in]width5average kernel width for the 5th variable
[in]widthScalePDF for width scaling
[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 307 of file AdaptiveKernelDensity.cpp.

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

Constructor for adaptive kernel PDF 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 one larger.
[in]binningvector of numbers of bins for the binned interpolation. The size of vector should match the dimensionality of phase space.
[in]widthvector of average kernel widths. The size of vector should match the dimensionality of phase space.
[in]widthScalePDF for width scaling
[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 20 of file AdaptiveKernelDensity.cpp.

AdaptiveKernelDensity::~AdaptiveKernelDensity ( )
virtual

Destructor.

Definition at line 346 of file AdaptiveKernelDensity.cpp.

Member Function Documentation

void AdaptiveKernelDensity::addToMap ( std::vector< Double_t > &  map,
std::vector< Double_t > &  point,
Double_t  widthScale = 1.,
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]widthScalekernel width scale factor
[in]weightpoint weight

Definition at line 429 of file AdaptiveKernelDensity.cpp.

Double_t AdaptiveKernelDensity::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 1072 of file AdaptiveKernelDensity.cpp.

void AdaptiveKernelDensity::fillMapFromDensity ( AbsDensity theDensity,
UInt_t  toyEvents = 0 
)
private

Definition at line 615 of file AdaptiveKernelDensity.cpp.

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

Definition at line 528 of file AdaptiveKernelDensity.cpp.

void AdaptiveKernelDensity::init ( AbsPhaseSpace thePhaseSpace,
TTree *  tree,
std::vector< TString > &  vars,
std::vector< UInt_t > &  binning,
std::vector< Double_t > &  width,
AbsDensity widthScale,
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 average kernel widths. The size of vector should match the dimensionality of phase space.
[in]widthScalePDF for width scaling
[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 352 of file AdaptiveKernelDensity.cpp.

UInt_t AdaptiveKernelDensity::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 416 of file AdaptiveKernelDensity.cpp.

Double_t AdaptiveKernelDensity::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 971 of file AdaptiveKernelDensity.cpp.

void AdaptiveKernelDensity::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 In addition, determine the maximum value of the PDF to be use as a majorant for toy MC generation.

Definition at line 898 of file AdaptiveKernelDensity.cpp.

AbsPhaseSpace* AdaptiveKernelDensity::phaseSpace ( )
inlinevirtual

Return the phase space.

Returns
phase space

Implements AbsDensity.

Definition at line 418 of file AdaptiveKernelDensity.hh.

void AdaptiveKernelDensity::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 424 of file AdaptiveKernelDensity.hh.

void AdaptiveKernelDensity::writeToFile ( const char *  fileName)

Write density map to file 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 739 of file AdaptiveKernelDensity.cpp.

void AdaptiveKernelDensity::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 814 of file AdaptiveKernelDensity.cpp.

void AdaptiveKernelDensity::writeToTextFile ( const char *  fileName)

Write the binned PDF to a text file.

Write density map to file.

Parameters
[in]fileNamefile name

Definition at line 751 of file AdaptiveKernelDensity.cpp.

Member Data Documentation

AbsDensity* AdaptiveKernelDensity::m_approxDensity
private

Reference to approximation PDF.

Definition at line 498 of file AdaptiveKernelDensity.hh.

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

Bin map of approximation PDF convolved with the kernel.

Definition at line 489 of file AdaptiveKernelDensity.hh.

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

Vector of bin numbers in each variable.

Definition at line 492 of file AdaptiveKernelDensity.hh.

UInt_t AdaptiveKernelDensity::m_dim
private

Cached dimensionality of the phase space.

Definition at line 507 of file AdaptiveKernelDensity.hh.

Bool_t AdaptiveKernelDensity::m_fractionalMode
private

Fractional mode flag.

Definition at line 510 of file AdaptiveKernelDensity.hh.

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

Bin map of estimated PDF.

Definition at line 486 of file AdaptiveKernelDensity.hh.

Double_t AdaptiveKernelDensity::m_maxScale
private

Maximum width scale factor.

Definition at line 522 of file AdaptiveKernelDensity.hh.

Double_t AdaptiveKernelDensity::m_maxValue
private

Maximum value of the width scale PDF to be used for scaling.

Definition at line 516 of file AdaptiveKernelDensity.hh.

Double_t AdaptiveKernelDensity::m_minScale
private

Minimum width scale factor.

Definition at line 519 of file AdaptiveKernelDensity.hh.

Double_t AdaptiveKernelDensity::m_minValue
private

Minimum value of the width scale PDF to be used for scaling.

Definition at line 513 of file AdaptiveKernelDensity.hh.

AbsPhaseSpace* AdaptiveKernelDensity::m_phaseSpace
private

Reference to phase space.

Definition at line 495 of file AdaptiveKernelDensity.hh.

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

Vector of kernel widths.

Definition at line 504 of file AdaptiveKernelDensity.hh.

AbsDensity* AdaptiveKernelDensity::m_widthScaleDensity
private

Reference to PDF used for kernel width scaling.

Definition at line 501 of file AdaptiveKernelDensity.hh.


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