/usr/include/root/TMVA/PDF.h is in libroot-tmva-dev 5.34.30-0ubuntu8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | // @(#)root/tmva $Id$
// Author: Asen Christov, Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss , Jan Therhaag
/**********************************************************************************
* Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
* Package: TMVA *
* Class : PDF *
* Web : http://tmva.sourceforge.net *
* *
* Description: *
* PDF wrapper for histograms; uses user-defined spline interpolation *
* and kernel density estimation *
* *
* Authors (alphabetical): *
* Asen Christov <christov@physik.uni-freiburg.de> - Freiburg U., Germany *
* Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
* Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
* Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
* Jan Therhaag <Jan.Therhaag@cern.ch> - U of Bonn, Germany *
* *
* Copyright (c) 2005-2011: *
* CERN, Switzerland *
* U. of Victoria, Canada *
* MPI-K Heidelberg, Germany *
* Freiburg U., Germany *
* U. of Bonn, Germany *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted according to the terms listed in LICENSE *
* (http://tmva.sourceforge.net/LICENSE) *
**********************************************************************************/
#ifndef ROOT_TMVA_PDF
#define ROOT_TMVA_PDF
//////////////////////////////////////////////////////////////////////////
// //
// PDF //
// //
// PDF wrapper for histograms; uses user-defined spline interpolation //
// //
//////////////////////////////////////////////////////////////////////////
#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;
std::ostream& operator<< ( std::ostream& os, const PDF& tree );
std::istream& operator>> ( std::istream& istr, PDF& tree);
class PDF : public Configurable {
friend std::ostream& operator<< ( std::ostream& os, const PDF& tree );
friend std::istream& operator>> ( std::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();
//creates the pdf after the definitions have been stored in
void BuildPDF (const TH1* theHist);
// returns probability density at given abscissa
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 );
// histogram underlying the PDF
TH1* GetPDFHist() const { return fPDFHist; }
TGraph* GetGraph() const { return fGraph; }
TH1* GetOriginalHist() const { return fHistOriginal; }
TH1* GetSmoothedHist() const { return fHist; }
TH1* GetNSmoothHist() const { return fNSmoothHist; }
// integral of PDF within given range
Double_t GetIntegral( Double_t xmin, Double_t xmax );
// accessors
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(); }
// perform series of validation tests
void ValidatePDF( TH1* original = 0 ) const;
//gives the number of needed bins in the source histogram
Int_t GetHistNBins ( Int_t evtNum = 0 );
TMVA::PDF::EInterpolateMethod GetInterpolMethod() { return fInterpolMethod;}
// modified name (remove TMVA::)
const char* GetName() const { return fPDFName; }
// TMVA version control (for weight files)
void SetReadingVersion( UInt_t rv ) { fReadingVersion = rv; }
UInt_t GetReadingVersion() const { return fReadingVersion; }
//void WriteOptionsToStream ( std::ostream& o, const TString& prefix ) const;
void ProcessOptions();
// reads from and option string the definitions for pdf returns it
void DeclareOptions();
private:
// sanity check of PDF quality (after smoothing): comparison with
// original histogram
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;
}
// do we use the original histogram as reference ?
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();
// flag that indicates that no splines are produced and no smoothing
// is applied, i.e., the original histogram is used as reference
// this is useful for discrete variables
Bool_t fUseHistogram; // spline0 uses histogram as reference
// static configuration variables ----------------------------
// to increase computation speed, the final PDF is filled in
// a high-binned histogram; "GetValue" then returns the histogram
// entry, linearized between adjacent bins
static const Int_t fgNbin_PdfHist; // number of bins in high-binned reference histogram
static const Bool_t fgManualIntegration; // manual integration (sum over bins) or DGAUSS
static const Double_t fgEpsilon; // minimum PDF return
// -----------------------------------------------------------
TString fPDFName; // for output
Int_t fNsmooth; // Min number of smoothing iterations
Int_t fMinNsmooth; // Min number of smoothing iterations
Int_t fMaxNsmooth; // Max number of smoothing iterations
TH1* fNSmoothHist; // number of smooth for each bin
TMVA::PDF::EInterpolateMethod fInterpolMethod; // interpolation method
TSpline* fSpline; //! the used spline type
TH1* fPDFHist; // the high-binned histogram corresponding to the PDF
TH1* fHist; // copy of input histogram
TH1* fHistOriginal; // the input histogram
TGraph* fGraph; //! needed to create PDF from histogram
TF1* fIGetVal; // integration interface
Int_t fHistAvgEvtPerBin; // avg event per source hist bin
Int_t fHistDefinedNBins; // source hist bin num set by user
TString fKDEtypeString; // strings used to read definitions
TString fKDEiterString;
TString fBorderMethodString;
TString fInterpolateString;
KDEKernel::EKernelType fKDEtype; // Kernel type to use for KDE
KDEKernel::EKernelIter fKDEiter; // Number of iterations (adaptive or not)
KDEKernel::EKernelBorder fKDEborder; // The method to take care about "border" effects (string)
Float_t fFineFactor; // fine tuning factor for Adaptive KDE
UInt_t fReadingVersion; // the TMVA version of the weight file
Bool_t fCheckHist; // check of source histogram
Bool_t fNormalize; // normalize histogram (false for cumulative distribution used in GaussTranform)
TString fSuffix; //! the suffix for options
mutable MsgLogger* fLogger; //! message logger
MsgLogger& Log() const { return *fLogger; }
// static pointer to this object
static PDF* fgThisPDF; // this PDF pointer
static PDF* ThisPDF( void );
// external auxiliary functions
static Double_t IGetVal( Double_t*, Double_t* );
ClassDef(PDF,1) // PDF wrapper for histograms
};
} // namespace TMVA
#endif
|