Roo2DKeysPdf.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitModels                                                     *
00004  *    File: $Id: Roo2DKeysPdf.h,v 1.12 2007/05/11 09:13:07 verkerke Exp $
00005  * Authors:                                                                  *
00006  *   AB, Adrian Bevan, Liverpool University, bevan@slac.stanford.edu         *
00007  *                                                                           *
00008  * Copyright (c) 2000-2005, Regents of the University of California,         *
00009  *                          Liverpool University,                            *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_2DKEYS
00017 #define ROO_2DKEYS
00018 
00019 #include "RooAbsPdf.h"
00020 #include "RooRealProxy.h"
00021 #include "RooAbsReal.h"
00022 #include "RooDataSet.h"
00023 
00024 ////////////////////////////////////////////////////////////////////////////////////
00025 class Roo2DKeysPdf : public RooAbsPdf 
00026 {
00027 public:
00028   Roo2DKeysPdf(const char *name, const char *title,
00029              RooAbsReal& xx, RooAbsReal &yy, RooDataSet& data, TString options = "a", Double_t widthScaleFactor = 1.0);
00030   Roo2DKeysPdf(const Roo2DKeysPdf& other, const char* name=0);
00031   virtual TObject* clone(const char* newname) const { return new Roo2DKeysPdf(*this,newname); }
00032 
00033   virtual ~Roo2DKeysPdf();
00034 
00035 //load in a new dataset and re-calculate the PDF
00036 //return 0 if sucessful
00037   Int_t    loadDataSet(RooDataSet& data, TString options);
00038 
00039 // The Roo2DKeys options available are:
00040 //      a = select an adaptove bandwidth [default]
00041 //      n = select a normal bandwidth
00042 //      m = mirror kernal contributions at edges [fold gaussians back into the x,y plane]
00043 //      d = print debug statements [useful for development only; default is off]
00044 //      v  = print verbose debug statements [useful for development only; default is off]
00045 //      vv = print ludicrously verbose debug statements [useful for development only; default is off]
00046   void     setOptions(TString options);
00047   void     getOptions(void) const;
00048 
00049 // Set the value of a scale factor to modify the bandwidth by. The default value for this is unity.
00050 // Modification of 'normal' bandwidths is useful when the data are not 'normally distributed', 
00051 // otherwise one expects little departure from that behavior.  Note that both the normal and adaptive
00052 // bandwidth selections are modified by this factor.  Useful for systematic studies.
00053 //           ***********
00054 //           *IMPORTANT* The kernel is proportional to 1/widthScaleFactor.
00055 //           ***********
00056   inline void     setWidthScaleFactor(Double_t widthScaleFactor);
00057 
00058 // choose the kernel bandwith to use.  The default is 0                                               
00059 //    0 = use adaptive kernel estimator (uses local population to vary with of kernels)               
00060 //    1 = use trivial kernel estimator (uses all data and sigma to estimate uniform kernel bandwidth)
00061   Int_t    calculateBandWidth(Int_t kernel = -999);
00062 
00063   Int_t    getBandWidthType() const;
00064   Double_t getMean(const char * axis) const;
00065   Double_t getSigma(const char * axis) const;
00066 
00067 // print content and basic information about the data
00068   void     PrintInfo(ostream &) const;
00069 
00070 // save PDF to a file as a TH2F *, TTree * or both
00071 // this is so that you only need to compute the PDF once and 
00072 // are free to use the much faster Roo2DHistPdf class in order 
00073 // to perform fits/do toy studies etc.  
00074   void     writeToFile(char * outputFile, const char * name) const;
00075   void     writeHistToFile(char * outputFile, const char * histName) const;
00076   void     writeNTupleToFile(char * outputFile, const char * name) const;
00077 
00078   RooRealProxy x;
00079   RooRealProxy y;
00080 
00081   Double_t evaluate() const;
00082 
00083 protected:
00084 
00085 private:
00086   // these are used in calculating bandwidths for x and y
00087   Double_t evaluateFull(Double_t thisX, Double_t thisY) const;
00088   Double_t g(Double_t var1, Double_t * _var1, Double_t sigma1, Double_t var2, 
00089              Double_t * _var2, Double_t sigma2) const; 
00090 
00091   //mirror corrections for the boundaries
00092   Double_t highBoundaryCorrection(Double_t thisVar, Double_t thisH, Double_t high, Double_t tVar) const;
00093   Double_t lowBoundaryCorrection(Double_t thisVar, Double_t thisH, Double_t low, Double_t tVar) const;
00094 
00095   Double_t * _x;
00096   Double_t * _hx;
00097   Double_t * _y;
00098   Double_t * _hy;
00099   Double_t   _norm;
00100   Double_t   _xMean;    // the (x,y) mean and sigma are properties of the data, not of the PDF
00101   Double_t   _xSigma;
00102   Double_t   _yMean;
00103   Double_t   _ySigma;
00104   Double_t   _n;         //coefficient of the kernel estimation sum
00105   Double_t   _n16;       //pow(_nEvents, -1/6)
00106   Double_t   _sqrt2pi;
00107   Double_t   _2pi;       // = M_PI*2
00108   Double_t   _lox,_hix;
00109   Double_t   _loy,_hiy;
00110   Double_t   _xoffset;
00111   Double_t   _yoffset;
00112   Double_t   _widthScaleFactor; //allow manipulation of the bandwidth by a scale factor
00113 
00114   Int_t      _nEvents;
00115   Int_t      _BandWidthType;
00116   Int_t      _MirrorAtBoundary;
00117   Int_t      _debug;
00118   Int_t      _verbosedebug;
00119   Int_t      _vverbosedebug;
00120 
00121   ClassDef(Roo2DKeysPdf,0) // Two-dimensional kernel estimation p.d.f.
00122 };
00123 
00124 inline void  Roo2DKeysPdf::setWidthScaleFactor(Double_t widthScaleFactor) { _widthScaleFactor = widthScaleFactor; }
00125 
00126 #endif
00127 
00128 
00129 

Generated on Tue Jul 5 14:25:55 2011 for ROOT_528-00b_version by  doxygen 1.5.1