meerkat is hosted by Hepforge, IPPP Durham
Meerkat  v1r3
Multidimensional kernel density estimation package
BinnedDensity.hh
Go to the documentation of this file.
1 #ifndef BINNED_DENSITY
2 #define BINNED_DENSITY
3 
4 #include "AbsDensity.hh"
5 
6 #include "TMath.h"
7 
8 #include <vector>
9 
12 
13 class BinnedDensity : public AbsDensity {
14 
15  public:
16 
18 
28  BinnedDensity(const char* pdfName,
29  AbsPhaseSpace* thePhaseSpace,
30  AbsDensity* d,
31  UInt_t bins1,
32  UInt_t bins2 = 0,
33  UInt_t bins3 = 0,
34  UInt_t bins4 = 0,
35  UInt_t bins5 = 0);
36 
38 
44  BinnedDensity(const char* pdfName,
45  AbsPhaseSpace* thePhaseSpace,
46  std::vector<UInt_t> &binning,
47  AbsDensity* d);
48 
50 
56  BinnedDensity(const char* pdfName,
57  AbsPhaseSpace* thePhaseSpace,
58  const char* fileName,
59  const Double_t cutoff = 1.e50);
60 
62  virtual ~BinnedDensity();
63 
65 
68  void setCutoff(Double_t cutoff) { m_cutoff = cutoff; }
69 
71 
74  void readFromFile(const char* fileName);
75 
77 
80  void readFromTextFile(const char* fileName);
81 
83 
86  void readFromRootFile(const char* fileName);
87 
89 
92  void writeToFile(const char* fileName);
93 
95 
98  void writeToTextFile(const char* fileName);
99 
101 
104  void writeToRootFile(const char* fileName);
105 
107 
111  Double_t density(std::vector<Double_t> &x);
112 
114 
118 
119  private:
120 
122 
127  void init(AbsPhaseSpace* thePhaseSpace,
128  std::vector<UInt_t> &binning,
129  AbsDensity* d);
130 
132  std::vector<Double_t> m_map;
133 
135  std::vector<UInt_t> m_binning;
136 
139 
142 
144  Double_t m_cutoff;
145 
146 };
147 
148 #endif
std::vector< Double_t > m_map
Map of PDF values in bins.
void setCutoff(Double_t cutoff)
Set cutoff value. Values in bins greater than cutoff will be made equal to cutoff.
Abstract class which defines probability density interface.
Definition: AbsDensity.hh:16
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...
void readFromTextFile(const char *fileName)
Read the binned density from a text file. The dimensionality of the density stored in the file should...
Double_t m_cutoff
Cutoff value (values in bins greater than cutoff will be make equal to cutoff).
void writeToFile(const char *fileName)
Write the binned density into a file (ROOT or text format depending on the extension) ...
Abstract class which defines phase space interface.
AbsDensity * m_density
Reference to the input density.
void writeToRootFile(const char *fileName)
Write the binned density into a ROOT file.
void init(AbsPhaseSpace *thePhaseSpace, std::vector< UInt_t > &binning, AbsDensity *d)
Common initalisation function used by both constructors from an AbsDensity.
virtual ~BinnedDensity()
Destructor.
void readFromFile(const char *fileName)
Read the binned density from a file, ROOT or text depending on the extension. The dimensionality of t...
std::vector< UInt_t > m_binning
Vector of bin numbers for each variable.
AbsPhaseSpace * phaseSpace()
Return the phase space.
void readFromRootFile(const char *fileName)
Read the binned density from a ROOT file. The dimensionality of the density stored in the file should...
AbsPhaseSpace * m_phaseSpace
Reference to the phase space definition.
void writeToTextFile(const char *fileName)
Write the binned density into a file.
Double_t density(std::vector< Double_t > &x)
Return the value of the PDF in a point.