Logo ROOT  
Reference Guide
Roo2DKeysPdf.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * File: $Id: Roo2DKeysPdf.h,v 1.12 2007/05/11 09:13:07 verkerke Exp $
5 * Authors: *
6 * AB, Adrian Bevan, Liverpool University, bevan@slac.stanford.edu *
7 * *
8 * Copyright (c) 2000-2005, Regents of the University of California, *
9 * Liverpool University, *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_2DKEYS
17#define ROO_2DKEYS
18
19#include "RooAbsPdf.h"
20#include "RooRealProxy.h"
21#include "RooAbsReal.h"
22#include "RooDataSet.h"
23
24////////////////////////////////////////////////////////////////////////////////////
25class Roo2DKeysPdf : public RooAbsPdf
26{
27public:
28 Roo2DKeysPdf(const char *name, const char *title,
29 RooAbsReal& xx, RooAbsReal &yy, RooDataSet& data, TString options = "a", double widthScaleFactor = 1.0);
30 Roo2DKeysPdf(const Roo2DKeysPdf& other, const char* name=nullptr);
31 TObject* clone(const char* newname) const override { return new Roo2DKeysPdf(*this,newname); }
32
33 ~Roo2DKeysPdf() override;
34
35//load in a new dataset and re-calculate the PDF
36//return 0 if successful
38
39// The Roo2DKeys options available are:
40// a = select an adaptive bandwidth [default]
41// n = select a normal bandwidth
42// m = mirror kernel contributions at edges [fold gaussians back into the x,y plane]
43// d = print debug statements [useful for development only; default is off]
44// v = print verbose debug statements [useful for development only; default is off]
45// vv = print ludicrously verbose debug statements [useful for development only; default is off]
46 void setOptions(TString options);
47 void getOptions(void) const;
48
49// Set the value of a scale factor to modify the bandwidth by. The default value for this is unity.
50// Modification of 'normal' bandwidths is useful when the data are not 'normally distributed',
51// otherwise one expects little departure from that behavior. Note that both the normal and adaptive
52// bandwidth selections are modified by this factor. Useful for systematic studies.
53// ***********
54// *IMPORTANT* The kernel is proportional to 1/widthScaleFactor.
55// ***********
56 inline void setWidthScaleFactor(double widthScaleFactor);
57
58// choose the kernel bandwith to use. The default is 0
59// 0 = use adaptive kernel estimator (uses local population to vary with of kernels)
60// 1 = use trivial kernel estimator (uses all data and sigma to estimate uniform kernel bandwidth)
61 Int_t calculateBandWidth(Int_t kernel = -999);
62
63 Int_t getBandWidthType() const;
64 double getMean(const char * axis) const;
65 double getSigma(const char * axis) const;
66
67// print content and basic information about the data
68 void PrintInfo(std::ostream &) const;
69
70// save PDF to a file as a TH2F *, TTree * or both
71// this is so that you only need to compute the PDF once and
72// are free to use the much faster Roo2DHistPdf class in order
73// to perform fits/do toy studies etc.
74 void writeToFile(char * outputFile, const char * name) const;
75 void writeHistToFile(char * outputFile, const char * histName) const;
76 void writeNTupleToFile(char * outputFile, const char * name) const;
77
80
81 double evaluate() const override;
82
83protected:
84
85private:
86 // these are used in calculating bandwidths for x and y
87 double evaluateFull(double thisX, double thisY) const;
88 double g(double var1, double * _var1, double sigma1, double var2,
89 double * _var2, double sigma2) const;
90
91 //mirror corrections for the boundaries
92 double highBoundaryCorrection(double thisVar, double thisH, double high, double tVar) const;
93 double lowBoundaryCorrection(double thisVar, double thisH, double low, double tVar) const;
94
95 double * _x;
96 double * _hx;
97 double * _y;
98 double * _hy;
99 double _norm;
100 double _xMean; // the (x,y) mean and sigma are properties of the data, not of the PDF
101 double _xSigma;
102 double _yMean;
103 double _ySigma;
104 double _n; //coefficient of the kernel estimation sum
105 double _n16; //pow(_nEvents, -1/6)
106 double _sqrt2pi;
107 double _2pi; // = M_PI*2
108 double _lox,_hix;
109 double _loy,_hiy;
110 double _xoffset;
111 double _yoffset;
112 double _widthScaleFactor; //allow manipulation of the bandwidth by a scale factor
113
120
121 ClassDefOverride(Roo2DKeysPdf,0) // Two-dimensional kernel estimation p.d.f.
122};
123
124inline void Roo2DKeysPdf::setWidthScaleFactor(double widthScaleFactor) { _widthScaleFactor = widthScaleFactor; }
125
126#endif
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition: TGX11.cxx:110
Two-dimensional kernel estimation PDF.
Definition: Roo2DKeysPdf.h:26
RooRealProxy y
Definition: Roo2DKeysPdf.h:79
double getMean(const char *axis) const
double _yoffset
Definition: Roo2DKeysPdf.h:111
Roo2DKeysPdf(const char *name, const char *title, RooAbsReal &xx, RooAbsReal &yy, RooDataSet &data, TString options="a", double widthScaleFactor=1.0)
Constructor.
double _widthScaleFactor
Definition: Roo2DKeysPdf.h:112
void writeNTupleToFile(char *outputFile, const char *name) const
Saves the data and calculated bandwidths to a file, as a record of what produced the PDF and to give ...
Int_t _BandWidthType
Definition: Roo2DKeysPdf.h:115
void writeToFile(char *outputFile, const char *name) const
Int_t _verbosedebug
Definition: Roo2DKeysPdf.h:118
double _ySigma
Definition: Roo2DKeysPdf.h:103
double * _hy
Definition: Roo2DKeysPdf.h:98
double _sqrt2pi
Definition: Roo2DKeysPdf.h:106
double lowBoundaryCorrection(double thisVar, double thisH, double low, double tVar) const
double evaluate() const override
Evaluates the kernel estimation for x,y, interpolating between the points if necessary.
Int_t getBandWidthType() const
Int_t _MirrorAtBoundary
Definition: Roo2DKeysPdf.h:116
void PrintInfo(std::ostream &) const
Prints out _p[_nPoints][_nPoints] indicating the domain limits.
Int_t loadDataSet(RooDataSet &data, TString options)
Loads a new data set into the class instance.
double g(double var1, double *_var1, double sigma1, double var2, double *_var2, double sigma2) const
Calculates f(t_i) for the bandwidths.
Int_t _vverbosedebug
Definition: Roo2DKeysPdf.h:119
double * _x
Definition: Roo2DKeysPdf.h:95
double * _y
Definition: Roo2DKeysPdf.h:97
double _norm
Definition: Roo2DKeysPdf.h:99
double * _hx
Definition: Roo2DKeysPdf.h:96
TObject * clone(const char *newname) const override
Definition: Roo2DKeysPdf.h:31
double getSigma(const char *axis) const
double _xoffset
Definition: Roo2DKeysPdf.h:110
~Roo2DKeysPdf() override
Destructor.
void setWidthScaleFactor(double widthScaleFactor)
Definition: Roo2DKeysPdf.h:124
double _xSigma
Definition: Roo2DKeysPdf.h:101
double highBoundaryCorrection(double thisVar, double thisH, double high, double tVar) const
Apply the mirror at boundary correction to a dimension given the space position to evaluate at (thisV...
void writeHistToFile(char *outputFile, const char *histName) const
Plots the PDF as a histogram and saves it to a file, so that it can be loaded in as a Roo2DHist PDF i...
Int_t calculateBandWidth(Int_t kernel=-999)
Calculates the kernel bandwidth for x & y and the probability look up table _p[i][j].
void setOptions(TString options)
void getOptions(void) const
double evaluateFull(double thisX, double thisY) const
Evaluates the sum of the product of the 2D kernels for use in calculating the fixed kernel estimate,...
RooRealProxy x
Definition: Roo2DKeysPdf.h:78
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:62
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:55
Mother of all ROOT objects.
Definition: TObject.h:41
Basic string class.
Definition: TString.h:136