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

#include <BinnedDensity.hh>

Inheritance diagram for BinnedDensity:
AbsDensity

Public Member Functions

 BinnedDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, AbsDensity *d, UInt_t bins1, UInt_t bins2=0, UInt_t bins3=0, UInt_t bins4=0, UInt_t bins5=0)
 Constructor that creates the binned density from any AbsDensity of the dimensionality up to five. More...
 
 BinnedDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, std::vector< UInt_t > &binning, AbsDensity *d)
 Constructor that creates the binned density from any AbsDensity of arbitrary dimensionality. More...
 
 BinnedDensity (const char *pdfName, AbsPhaseSpace *thePhaseSpace, const char *fileName, const Double_t cutoff=1.e50)
 Constructor that reads the binned density from a file. The dimensionality of the density stored in the file should match the dimensionality of the phase space. More...
 
virtual ~BinnedDensity ()
 Destructor. More...
 
void setCutoff (Double_t cutoff)
 Set cutoff value. Values in bins greater than cutoff will be made equal to cutoff. More...
 
void readFromFile (const char *fileName)
 Read the binned density from a file, ROOT or text depending on the extension. The dimensionality of the density stored in the file should match the dimensionality of the phase space. More...
 
void readFromTextFile (const char *fileName)
 Read the binned density from a text file. The dimensionality of the density stored in the file should match the dimensionality of the phase space. More...
 
void readFromRootFile (const char *fileName)
 Read the binned density from a ROOT file. The dimensionality of the density stored in the file should match the dimensionality of the phase space. More...
 
void writeToFile (const char *fileName)
 Write the binned density into a file (ROOT or text format depending on the extension) More...
 
void writeToTextFile (const char *fileName)
 Write the binned density into a file. More...
 
void writeToRootFile (const char *fileName)
 Write the binned density into a ROOT file. More...
 
Double_t density (std::vector< Double_t > &x)
 Return the value of the PDF in a point. More...
 
AbsPhaseSpacephaseSpace ()
 Return the phase space. 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, std::vector< UInt_t > &binning, AbsDensity *d)
 Common initalisation function used by both constructors from an AbsDensity. More...
 

Private Attributes

std::vector< Double_t > m_map
 Map of PDF values in bins. More...
 
std::vector< UInt_t > m_binning
 Vector of bin numbers for each variable. More...
 
AbsPhaseSpacem_phaseSpace
 Reference to the phase space definition. More...
 
AbsDensitym_density
 Reference to the input density. More...
 
Double_t m_cutoff
 Cutoff value (values in bins greater than cutoff will be make equal to cutoff). 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 that describes the PDF which is a multilinear interpolation on the binned grid.

Definition at line 13 of file BinnedDensity.hh.

Constructor & Destructor Documentation

BinnedDensity::BinnedDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
AbsDensity d,
UInt_t  bins1,
UInt_t  bins2 = 0,
UInt_t  bins3 = 0,
UInt_t  bins4 = 0,
UInt_t  bins5 = 0 
)

Constructor that creates the binned density from any AbsDensity of the dimensionality up to five.

Constructor that fills bins from AbsDensity.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]dinput density
[in]bins1number of bins in 1st variable
[in]bins2number of bins in 2nd variable
[in]bins3number of bins in 3rd variable
[in]bins4number of bins in 4th variable
[in]bins5number of bins in 5th variable

Definition at line 21 of file BinnedDensity.cpp.

BinnedDensity::BinnedDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
std::vector< UInt_t > &  binning,
AbsDensity d 
)

Constructor that creates the binned density from any AbsDensity of arbitrary dimensionality.

Constructor that fills bins from AbsDensity.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]binningvector of bin numbers for each variable. Vector size should match the dimensionality of the phase space.
[in]dinput density

Definition at line 40 of file BinnedDensity.cpp.

BinnedDensity::BinnedDensity ( const char *  pdfName,
AbsPhaseSpace thePhaseSpace,
const char *  fileName,
const Double_t  cutoff = 1.e50 
)

Constructor that reads the binned density from a file. The dimensionality of the density stored in the file should match the dimensionality of the phase space.

Constructor that reads from file.

Parameters
[in]pdfNamePDF name
[in]thePhaseSpacephase space
[in]fileNameinput file name
[in]cutoffcutoff value

Definition at line 145 of file BinnedDensity.cpp.

BinnedDensity::~BinnedDensity ( )
virtual

Destructor.

Definition at line 394 of file BinnedDensity.cpp.

Member Function Documentation

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

Return the value of the PDF in a point.

Parameters
[in]xpoint
Returns
PDF value

Implements AbsDensity.

Definition at line 550 of file BinnedDensity.cpp.

void BinnedDensity::init ( AbsPhaseSpace thePhaseSpace,
std::vector< UInt_t > &  binning,
AbsDensity d 
)
private

Common initalisation function used by both constructors from an AbsDensity.

Initialise method used by both constructors.

Parameters
[in]thePhaseSpacephase space
[in]binningvector of bin numbers for each variable. Vector size should match the dimensionality of the phase space.
[in]dinput density

Definition at line 48 of file BinnedDensity.cpp.

AbsPhaseSpace* BinnedDensity::phaseSpace ( )
inlinevirtual

Return the phase space.

Returns
phase space

Implements AbsDensity.

Definition at line 117 of file BinnedDensity.hh.

void BinnedDensity::readFromFile ( const char *  fileName)

Read the binned density from a file, ROOT or text depending on the extension. The dimensionality of the density stored in the file should match the dimensionality of the phase space.

Parameters
[in]fileNameinput file name

Definition at line 153 of file BinnedDensity.cpp.

void BinnedDensity::readFromRootFile ( const char *  fileName)

Read the binned density from a ROOT file. The dimensionality of the density stored in the file should match the dimensionality of the phase space.

Read from ROOT file.

Parameters
[in]fileNameinput file name

Definition at line 270 of file BinnedDensity.cpp.

void BinnedDensity::readFromTextFile ( const char *  fileName)

Read the binned density from a text file. The dimensionality of the density stored in the file should match the dimensionality of the phase space.

Read from text file.

Parameters
[in]fileNameinput file name

Definition at line 162 of file BinnedDensity.cpp.

void BinnedDensity::setCutoff ( Double_t  cutoff)
inline

Set cutoff value. Values in bins greater than cutoff will be made equal to cutoff.

Parameters
[in]cutoffcutoff value

Definition at line 68 of file BinnedDensity.hh.

void BinnedDensity::writeToFile ( const char *  fileName)

Write the binned density into a file (ROOT or text format depending on the extension)

Parameters
[in]fileNameoutput file name

Definition at line 398 of file BinnedDensity.cpp.

void BinnedDensity::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 471 of file BinnedDensity.cpp.

void BinnedDensity::writeToTextFile ( const char *  fileName)

Write the binned density into a file.

Write density map to file.

Parameters
[in]fileNameoutput file name

Definition at line 407 of file BinnedDensity.cpp.

Member Data Documentation

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

Vector of bin numbers for each variable.

Definition at line 135 of file BinnedDensity.hh.

Double_t BinnedDensity::m_cutoff
private

Cutoff value (values in bins greater than cutoff will be make equal to cutoff).

Definition at line 144 of file BinnedDensity.hh.

AbsDensity* BinnedDensity::m_density
private

Reference to the input density.

Definition at line 141 of file BinnedDensity.hh.

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

Map of PDF values in bins.

Definition at line 132 of file BinnedDensity.hh.

AbsPhaseSpace* BinnedDensity::m_phaseSpace
private

Reference to the phase space definition.

Definition at line 138 of file BinnedDensity.hh.


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