00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef ROOT_TMVA_PDF
00032 #define ROOT_TMVA_PDF
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <iosfwd>
00043
00044 #ifndef ROOT_TH1
00045 #include "TH1.h"
00046 #endif
00047 #ifndef ROOT_TMVA_KDEKernel
00048 #include "TMVA/KDEKernel.h"
00049 #endif
00050 #ifndef ROOT_TMVA_Configurable
00051 #include "TMVA/Configurable.h"
00052 #endif
00053
00054 class TSpline;
00055 class TGraph;
00056 class TF1;
00057
00058 namespace TMVA {
00059
00060 class MsgLogger;
00061
00062 class PDF;
00063 ostream& operator<< ( ostream& os, const PDF& tree );
00064 istream& operator>> ( istream& istr, PDF& tree);
00065
00066 class PDF : public Configurable {
00067
00068 friend ostream& operator<< ( ostream& os, const PDF& tree );
00069 friend istream& operator>> ( istream& istr, PDF& tree);
00070
00071 public:
00072
00073 enum EInterpolateMethod { kSpline0, kSpline1, kSpline2, kSpline3, kSpline5, kKDE };
00074
00075 explicit PDF( const TString& name, Bool_t norm=kTRUE );
00076 explicit PDF( const TString& name, const TH1* theHist, EInterpolateMethod method = kSpline2,
00077 Int_t minnsmooth = 0, Int_t maxnsmooth = 0, Bool_t checkHist = kFALSE, Bool_t norm=kTRUE );
00078 explicit PDF( const TString& name, const TH1* theHist,
00079 KDEKernel::EKernelType ktype, KDEKernel::EKernelIter kiter, KDEKernel::EKernelBorder
00080 kborder, Float_t FineFactor, Bool_t norm=kTRUE );
00081 explicit PDF( const TString& name, const TString& options, const TString& suffix = "", PDF* defaultPDF = 0, Bool_t norm=kTRUE);
00082 virtual ~PDF();
00083
00084
00085 void BuildPDF (const TH1* theHist);
00086
00087
00088 Double_t GetVal( Double_t x ) const;
00089
00090 void AddXMLTo( void* parent );
00091 void ReadXML( void* pdfnode );
00092
00093
00094 TH1* GetPDFHist() const { return fPDFHist; }
00095 TH1* GetOriginalHist() const { return fHistOriginal; }
00096 TH1* GetSmoothedHist() const { return fHist; }
00097 TH1* GetNSmoothHist() const { return fNSmoothHist; }
00098
00099
00100 Double_t GetIntegral( Double_t xmin, Double_t xmax );
00101
00102
00103 TSpline* GetSpline() const { return fSpline; }
00104 Int_t GetNBins () const { return fHist->GetNbinsX(); }
00105 Double_t GetXmin () const { return fHist->GetXaxis()->GetXmin(); }
00106 Double_t GetXmax () const { return fHist->GetXaxis()->GetXmax(); }
00107
00108
00109 void ValidatePDF( TH1* original = 0 ) const;
00110
00111
00112 Int_t GetHistNBins ( Int_t evtNum = 0 );
00113
00114 TMVA::PDF::EInterpolateMethod GetInterpolMethod() { return fInterpolMethod;}
00115
00116
00117 const char* GetName() const { return fPDFName; }
00118
00119
00120 void SetReadingVersion( UInt_t rv ) { fReadingVersion = rv; }
00121 UInt_t GetReadingVersion() const { return fReadingVersion; }
00122
00123
00124 void ProcessOptions();
00125
00126
00127 void DeclareOptions();
00128
00129 private:
00130
00131
00132
00133 void CheckHist() const;
00134 void FillSplineToHist();
00135 void BuildKDEPDF();
00136 void SmoothHistogram();
00137 void FillHistToGraph();
00138 Double_t GetIntegral() const;
00139 Double_t GetPdfHistBinWidth() const {
00140 TH1* h = GetPDFHist();
00141 return (fPDFHist) ? (h->GetXaxis()->GetXmax() - h->GetXaxis()->GetXmin())/h->GetNbinsX() : 1;
00142 }
00143
00144
00145 Bool_t UseHistogram() const { return fUseHistogram; }
00146
00147
00148 void BuildSplinePDF();
00149
00150
00151
00152
00153 Bool_t fUseHistogram;
00154
00155
00156
00157
00158
00159 static const Int_t fgNbin_PdfHist;
00160 static const Bool_t fgManualIntegration;
00161 static const Double_t fgEpsilon;
00162
00163
00164 TString fPDFName;
00165 Int_t fNsmooth;
00166 Int_t fMinNsmooth;
00167 Int_t fMaxNsmooth;
00168 TH1* fNSmoothHist;
00169
00170 TMVA::PDF::EInterpolateMethod fInterpolMethod;
00171 TSpline* fSpline;
00172 TH1* fPDFHist;
00173 TH1* fHist;
00174 TH1* fHistOriginal;
00175 TGraph* fGraph;
00176 TF1* fIGetVal;
00177
00178 Int_t fHistAvgEvtPerBin;
00179 Int_t fHistDefinedNBins;
00180
00181 TString fKDEtypeString;
00182 TString fKDEiterString;
00183 TString fBorderMethodString;
00184 TString fInterpolateString;
00185
00186 KDEKernel::EKernelType fKDEtype;
00187 KDEKernel::EKernelIter fKDEiter;
00188 KDEKernel::EKernelBorder fKDEborder;
00189 Float_t fFineFactor;
00190
00191 UInt_t fReadingVersion;
00192
00193 Bool_t fCheckHist;
00194 Bool_t fNormalize;
00195
00196 TString fSuffix;
00197 mutable MsgLogger* fLogger;
00198 MsgLogger& Log() const { return *fLogger; }
00199
00200
00201 static PDF* fgThisPDF;
00202 static PDF* ThisPDF( void );
00203
00204
00205 static Double_t IGetVal( Double_t*, Double_t* );
00206
00207 ClassDef(PDF,1)
00208 };
00209
00210 }
00211
00212 #endif