60 std::ostream& operator<< ( std::ostream& os,
const PDF& tree );
61 std::istream& operator>> ( std::istream& istr, PDF& tree);
63 class PDF :
public Configurable {
65 friend std::ostream& operator<< ( std::ostream& os,
const PDF& tree );
66 friend std::istream& operator>> ( std::istream& istr, PDF& tree);
70 enum EInterpolateMethod { kSpline0, kSpline1, kSpline2, kSpline3, kSpline5, kKDE };
72 explicit PDF(
const TString& name, Bool_t norm=kTRUE );
73 explicit PDF(
const TString& name,
const TH1* theHist, EInterpolateMethod method = kSpline2,
74 Int_t minnsmooth = 0, Int_t maxnsmooth = 0, Bool_t checkHist = kFALSE, Bool_t norm=kTRUE );
75 explicit PDF(
const TString& name,
const TH1* theHist,
76 KDEKernel::EKernelType ktype, KDEKernel::EKernelIter kiter, KDEKernel::EKernelBorder
77 kborder, Float_t FineFactor, Bool_t norm=kTRUE );
78 explicit PDF(
const TString& name,
const TString& options,
const TString& suffix =
"", PDF* defaultPDF = 0, Bool_t norm=kTRUE);
82 void BuildPDF (
const TH1* theHist);
85 Double_t GetVal ( Double_t x )
const;
86 Double_t GetValInverse( Double_t y, Bool_t isMonotonouslyIncreasingFunction=kFALSE )
const;
88 void AddXMLTo(
void* parent );
89 void ReadXML(
void* pdfnode );
92 TH1* GetPDFHist()
const {
return fPDFHist; }
93 TGraph* GetGraph()
const {
return fGraph; }
94 TH1* GetOriginalHist()
const {
return fHistOriginal; }
95 TH1* GetSmoothedHist()
const {
return fHist; }
96 TH1* GetNSmoothHist()
const {
return fNSmoothHist; }
99 Double_t GetIntegral( Double_t xmin, Double_t xmax );
102 TSpline* GetSpline()
const {
return fSpline; }
103 Int_t GetNBins ()
const {
return fHist->GetNbinsX(); }
104 Double_t GetXmin ()
const {
return fHist->GetXaxis()->GetXmin(); }
105 Double_t GetXmax ()
const {
return fHist->GetXaxis()->GetXmax(); }
108 void ValidatePDF( TH1* original = 0 )
const;
111 Int_t GetHistNBins ( Int_t evtNum = 0 );
113 TMVA::PDF::EInterpolateMethod GetInterpolMethod() {
return fInterpolMethod;}
116 const char* GetName()
const {
return fPDFName; }
119 void SetReadingVersion( UInt_t rv ) { fReadingVersion = rv; }
120 UInt_t GetReadingVersion()
const {
return fReadingVersion; }
123 void ProcessOptions();
126 void DeclareOptions();
132 void CheckHist()
const;
133 void FillSplineToHist();
135 void SmoothHistogram();
136 void FillHistToGraph();
137 Double_t GetIntegral()
const;
138 Double_t GetPdfHistBinWidth()
const {
139 TH1* h = GetPDFHist();
140 return (fPDFHist) ? (h->GetXaxis()->GetXmax() - h->GetXaxis()->GetXmin())/h->GetNbinsX() : 1;
144 Bool_t UseHistogram()
const {
return fUseHistogram; }
146 void FindBinInverse(
const TH1* histogram, Int_t& lowerBin, Int_t& higherBin, Double_t& lowerBinValue, Double_t& higherBinValue,
147 Double_t y, Bool_t isMonotonouslyIncreasingFunction=kFALSE )
const;
150 void BuildSplinePDF();
155 Bool_t fUseHistogram;
161 static const Int_t fgNbin_PdfHist;
162 static const Bool_t fgManualIntegration;
163 static const Double_t fgEpsilon;
172 TMVA::PDF::EInterpolateMethod fInterpolMethod;
180 Int_t fHistAvgEvtPerBin;
181 Int_t fHistDefinedNBins;
183 TString fKDEtypeString;
184 TString fKDEiterString;
185 TString fBorderMethodString;
186 TString fInterpolateString;
188 KDEKernel::EKernelType fKDEtype;
189 KDEKernel::EKernelIter fKDEiter;
190 KDEKernel::EKernelBorder fKDEborder;
193 UInt_t fReadingVersion;
199 mutable MsgLogger* fLogger;
200 MsgLogger& Log()
const {
return *fLogger; }
205 static PDF*& GetThisPdfThreadLocal() { TTHREAD_TLS(PDF*) fgThisPDF(
nullptr); return fgThisPDF; };
206 static PDF* ThisPDF(
void );
209 static Double_t IGetVal( Double_t*, Double_t* );