#ifndef ROOT_TMVA_PDF
#define ROOT_TMVA_PDF
#include <iosfwd>
#ifndef ROOT_TH1
#include "TH1.h"
#endif
#ifndef ROOT_TMVA_KDEKernel
#include "TMVA/KDEKernel.h"
#endif
#ifndef ROOT_TMVA_Configurable
#include "TMVA/Configurable.h"
#endif
class TSpline;
class TGraph;
class TF1;
namespace TMVA {
class MsgLogger;
class PDF;
ostream& operator<< ( ostream& os, const PDF& tree );
istream& operator>> ( istream& istr, PDF& tree);
class PDF : public Configurable {
friend ostream& operator<< ( ostream& os, const PDF& tree );
friend istream& operator>> ( istream& istr, PDF& tree);
public:
enum EInterpolateMethod { kSpline0, kSpline1, kSpline2, kSpline3, kSpline5, kKDE };
explicit PDF( const TString& name, Bool_t norm=kTRUE );
explicit PDF( const TString& name, const TH1* theHist, EInterpolateMethod method = kSpline2,
Int_t minnsmooth = 0, Int_t maxnsmooth = 0, Bool_t checkHist = kFALSE, Bool_t norm=kTRUE );
explicit PDF( const TString& name, const TH1* theHist,
KDEKernel::EKernelType ktype, KDEKernel::EKernelIter kiter, KDEKernel::EKernelBorder
kborder, Float_t FineFactor, Bool_t norm=kTRUE );
explicit PDF( const TString& name, const TString& options, const TString& suffix = "", PDF* defaultPDF = 0, Bool_t norm=kTRUE);
virtual ~PDF();
void BuildPDF (const TH1* theHist);
Double_t GetVal ( Double_t x ) const;
Double_t GetValInverse( Double_t y, Bool_t isMonotonouslyIncreasingFunction=kFALSE ) const;
void AddXMLTo( void* parent );
void ReadXML( void* pdfnode );
TH1* GetPDFHist() const { return fPDFHist; }
TH1* GetOriginalHist() const { return fHistOriginal; }
TH1* GetSmoothedHist() const { return fHist; }
TH1* GetNSmoothHist() const { return fNSmoothHist; }
Double_t GetIntegral( Double_t xmin, Double_t xmax );
TSpline* GetSpline() const { return fSpline; }
Int_t GetNBins () const { return fHist->GetNbinsX(); }
Double_t GetXmin () const { return fHist->GetXaxis()->GetXmin(); }
Double_t GetXmax () const { return fHist->GetXaxis()->GetXmax(); }
void ValidatePDF( TH1* original = 0 ) const;
Int_t GetHistNBins ( Int_t evtNum = 0 );
TMVA::PDF::EInterpolateMethod GetInterpolMethod() { return fInterpolMethod;}
const char* GetName() const { return fPDFName; }
void SetReadingVersion( UInt_t rv ) { fReadingVersion = rv; }
UInt_t GetReadingVersion() const { return fReadingVersion; }
void ProcessOptions();
void DeclareOptions();
private:
void CheckHist() const;
void FillSplineToHist();
void BuildKDEPDF();
void SmoothHistogram();
void FillHistToGraph();
Double_t GetIntegral() const;
Double_t GetPdfHistBinWidth() const {
TH1* h = GetPDFHist();
return (fPDFHist) ? (h->GetXaxis()->GetXmax() - h->GetXaxis()->GetXmin())/h->GetNbinsX() : 1;
}
Bool_t UseHistogram() const { return fUseHistogram; }
void FindBinInverse( const TH1* histogram, Int_t& lowerBin, Int_t& higherBin, Double_t& lowerBinValue, Double_t& higherBinValue,
Double_t y, Bool_t isMonotonouslyIncreasingFunction=kFALSE ) const;
void BuildSplinePDF();
Bool_t fUseHistogram;
static const Int_t fgNbin_PdfHist;
static const Bool_t fgManualIntegration;
static const Double_t fgEpsilon;
TString fPDFName;
Int_t fNsmooth;
Int_t fMinNsmooth;
Int_t fMaxNsmooth;
TH1* fNSmoothHist;
TMVA::PDF::EInterpolateMethod fInterpolMethod;
TSpline* fSpline;
TH1* fPDFHist;
TH1* fHist;
TH1* fHistOriginal;
TGraph* fGraph;
TF1* fIGetVal;
Int_t fHistAvgEvtPerBin;
Int_t fHistDefinedNBins;
TString fKDEtypeString;
TString fKDEiterString;
TString fBorderMethodString;
TString fInterpolateString;
KDEKernel::EKernelType fKDEtype;
KDEKernel::EKernelIter fKDEiter;
KDEKernel::EKernelBorder fKDEborder;
Float_t fFineFactor;
UInt_t fReadingVersion;
Bool_t fCheckHist;
Bool_t fNormalize;
TString fSuffix;
mutable MsgLogger* fLogger;
MsgLogger& Log() const { return *fLogger; }
static PDF* fgThisPDF;
static PDF* ThisPDF( void );
static Double_t IGetVal( Double_t*, Double_t* );
ClassDef(PDF,1)
};
}
#endif