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_t widthScaleFactor = 1.0);
30 Roo2DKeysPdf(const Roo2DKeysPdf& other, const char* name=0);
31 virtual TObject* clone(const char* newname) const { return new Roo2DKeysPdf(*this,newname); }
32
33 virtual ~Roo2DKeysPdf();
34
35//load in a new dataset and re-calculate the PDF
36//return 0 if successful
37 Int_t loadDataSet(RooDataSet& data, TString options);
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_t 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_t getMean(const char * axis) const;
65 Double_t 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_t evaluate() const;
82
83protected:
84
85private:
86 // these are used in calculating bandwidths for x and y
87 Double_t evaluateFull(Double_t thisX, Double_t thisY) const;
88 Double_t g(Double_t var1, Double_t * _var1, Double_t sigma1, Double_t var2,
89 Double_t * _var2, Double_t sigma2) const;
90
91 //mirror corrections for the boundaries
92 Double_t highBoundaryCorrection(Double_t thisVar, Double_t thisH, Double_t high, Double_t tVar) const;
93 Double_t lowBoundaryCorrection(Double_t thisVar, Double_t thisH, Double_t low, Double_t tVar) const;
94
100 Double_t _xMean; // the (x,y) mean and sigma are properties of the data, not of the PDF
104 Double_t _n; //coefficient of the kernel estimation sum
105 Double_t _n16; //pow(_nEvents, -1/6)
107 Double_t _2pi; // = M_PI*2
112 Double_t _widthScaleFactor; //allow manipulation of the bandwidth by a scale factor
113
120
121 ClassDef(Roo2DKeysPdf,0) // Two-dimensional kernel estimation p.d.f.
122};
123
124inline void Roo2DKeysPdf::setWidthScaleFactor(Double_t widthScaleFactor) { _widthScaleFactor = widthScaleFactor; }
125
126#endif
int Int_t
Definition: RtypesCore.h:41
double Double_t
Definition: RtypesCore.h:55
#define ClassDef(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
Two-dimensional kernel estimation PDF.
Definition: Roo2DKeysPdf.h:26
RooRealProxy y
Definition: Roo2DKeysPdf.h:79
Double_t _lox
Definition: Roo2DKeysPdf.h:108
Double_t _loy
Definition: Roo2DKeysPdf.h:109
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
Double_t getMean(const char *axis) const
Double_t g(Double_t var1, Double_t *_var1, Double_t sigma1, Double_t var2, Double_t *_var2, Double_t sigma2) const
Calculates f(t_i) for the bandwidths.
Double_t _hix
Definition: Roo2DKeysPdf.h:108
void writeToFile(char *outputFile, const char *name) const
Int_t _verbosedebug
Definition: Roo2DKeysPdf.h:118
Double_t _ySigma
Definition: Roo2DKeysPdf.h:103
Double_t * _x
Definition: Roo2DKeysPdf.h:95
Double_t _n
Definition: Roo2DKeysPdf.h:104
Roo2DKeysPdf(const char *name, const char *title, RooAbsReal &xx, RooAbsReal &yy, RooDataSet &data, TString options="a", Double_t widthScaleFactor=1.0)
Constructor.
Double_t _norm
Definition: Roo2DKeysPdf.h:99
Double_t _n16
Definition: Roo2DKeysPdf.h:105
Double_t getSigma(const char *axis) const
Double_t _hiy
Definition: Roo2DKeysPdf.h:109
Double_t _widthScaleFactor
Definition: Roo2DKeysPdf.h:112
Double_t * _hy
Definition: Roo2DKeysPdf.h:98
Double_t _yoffset
Definition: Roo2DKeysPdf.h:111
Int_t getBandWidthType() const
Double_t _xSigma
Definition: Roo2DKeysPdf.h:101
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_t * _y
Definition: Roo2DKeysPdf.h:97
Int_t _vverbosedebug
Definition: Roo2DKeysPdf.h:119
Double_t * _hx
Definition: Roo2DKeysPdf.h:96
Double_t evaluate() const
Evaluates the kernel estimation for x,y, interpolating between the points if necessary.
virtual ~Roo2DKeysPdf()
Destructor.
virtual TObject * clone(const char *newname) const
Definition: Roo2DKeysPdf.h:31
Double_t highBoundaryCorrection(Double_t thisVar, Double_t thisH, Double_t high, Double_t tVar) const
Apply the mirror at boundary correction to a dimension given the space position to evaluate at (thisV...
Double_t _xoffset
Definition: Roo2DKeysPdf.h:110
Double_t _xMean
Definition: Roo2DKeysPdf.h:100
Double_t lowBoundaryCorrection(Double_t thisVar, Double_t thisH, Double_t low, Double_t tVar) const
Double_t _yMean
Definition: Roo2DKeysPdf.h:102
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].
Double_t _sqrt2pi
Definition: Roo2DKeysPdf.h:106
void setOptions(TString options)
Double_t evaluateFull(Double_t thisX, Double_t thisY) const
Evaluates the sum of the product of the 2D kernels for use in calculating the fixed kernel estimate,...
void getOptions(void) const
void setWidthScaleFactor(Double_t widthScaleFactor)
Definition: Roo2DKeysPdf.h:124
Double_t _2pi
Definition: Roo2DKeysPdf.h:107
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:59
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131