![]() |
|
|||
File indexing completed on 2025-09-18 09:32:48
0001 /***************************************************************************** 0002 * Project: RooFit * 0003 * Package: RooFitModels * 0004 * File: $Id: Roo2DKeysPdf.h,v 1.12 2007/05/11 09:13:07 verkerke Exp $ 0005 * Authors: * 0006 * AB, Adrian Bevan, Liverpool University, bevan@slac.stanford.edu * 0007 * * 0008 * Copyright (c) 2000-2005, Regents of the University of California, * 0009 * Liverpool University, * 0010 * and Stanford University. All rights reserved. * 0011 * * 0012 * Redistribution and use in source and binary forms, * 0013 * with or without modification, are permitted according to the terms * 0014 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) * 0015 *****************************************************************************/ 0016 #ifndef ROO_2DKEYS 0017 #define ROO_2DKEYS 0018 0019 #include "RooAbsPdf.h" 0020 #include "RooRealProxy.h" 0021 #include "RooAbsReal.h" 0022 #include "RooDataSet.h" 0023 0024 //////////////////////////////////////////////////////////////////////////////////// 0025 class Roo2DKeysPdf : public RooAbsPdf 0026 { 0027 public: 0028 Roo2DKeysPdf(const char *name, const char *title, 0029 RooAbsReal& xx, RooAbsReal &yy, RooDataSet& data, TString options = "a", double widthScaleFactor = 1.0); 0030 Roo2DKeysPdf(const Roo2DKeysPdf& other, const char* name=nullptr); 0031 TObject* clone(const char* newname=nullptr) const override { return new Roo2DKeysPdf(*this,newname); } 0032 0033 ~Roo2DKeysPdf() override; 0034 0035 //load in a new dataset and re-calculate the PDF 0036 //return 0 if successful 0037 Int_t loadDataSet(RooDataSet& data, TString options); 0038 0039 // The Roo2DKeys options available are: 0040 // a = select an adaptive bandwidth [default] 0041 // n = select a normal bandwidth 0042 // m = mirror kernel contributions at edges [fold gaussians back into the x,y plane] 0043 // d = print debug statements [useful for development only; default is off] 0044 // v = print verbose debug statements [useful for development only; default is off] 0045 // vv = print ludicrously verbose debug statements [useful for development only; default is off] 0046 void setOptions(TString options); 0047 void getOptions(void) const; 0048 0049 // Set the value of a scale factor to modify the bandwidth by. The default value for this is unity. 0050 // Modification of 'normal' bandwidths is useful when the data are not 'normally distributed', 0051 // otherwise one expects little departure from that behavior. Note that both the normal and adaptive 0052 // bandwidth selections are modified by this factor. Useful for systematic studies. 0053 // *********** 0054 // *IMPORTANT* The kernel is proportional to 1/widthScaleFactor. 0055 // *********** 0056 inline void setWidthScaleFactor(double widthScaleFactor); 0057 0058 // choose the kernel bandwidth to use. The default is 0 0059 // 0 = use adaptive kernel estimator (uses local population to vary with of kernels) 0060 // 1 = use trivial kernel estimator (uses all data and sigma to estimate uniform kernel bandwidth) 0061 Int_t calculateBandWidth(Int_t kernel = -999); 0062 0063 Int_t getBandWidthType() const; 0064 double getMean(const char * axis) const; 0065 double getSigma(const char * axis) const; 0066 0067 // print content and basic information about the data 0068 void PrintInfo(std::ostream &) const; 0069 0070 // save PDF to a file as a TH2F *, TTree * or both 0071 // this is so that you only need to compute the PDF once and 0072 // are free to use the much faster Roo2DHistPdf class in order 0073 // to perform fits/do toy studies etc. 0074 void writeToFile(char * outputFile, const char * name) const; 0075 void writeHistToFile(char * outputFile, const char * histName) const; 0076 void writeNTupleToFile(char * outputFile, const char * name) const; 0077 0078 RooRealProxy x; 0079 RooRealProxy y; 0080 0081 double evaluate() const override; 0082 0083 protected: 0084 0085 private: 0086 // these are used in calculating bandwidths for x and y 0087 double evaluateFull(double thisX, double thisY) const; 0088 double g(double var1, double * _var1, double sigma1, double var2, 0089 double * _var2, double sigma2) const; 0090 0091 //mirror corrections for the boundaries 0092 double highBoundaryCorrection(double thisVar, double thisH, double high, double tVar) const; 0093 double lowBoundaryCorrection(double thisVar, double thisH, double low, double tVar) const; 0094 0095 double * _x; 0096 double * _hx; 0097 double * _y; 0098 double * _hy; 0099 double _norm; 0100 double _xMean; // the (x,y) mean and sigma are properties of the data, not of the PDF 0101 double _xSigma; 0102 double _yMean; 0103 double _ySigma; 0104 double _n; //coefficient of the kernel estimation sum 0105 double _n16; //pow(_nEvents, -1/6) 0106 double _sqrt2pi; 0107 double _2pi; // = M_PI*2 0108 double _lox,_hix; 0109 double _loy,_hiy; 0110 double _xoffset; 0111 double _yoffset; 0112 double _widthScaleFactor; //allow manipulation of the bandwidth by a scale factor 0113 0114 Int_t _nEvents; 0115 Int_t _BandWidthType; 0116 Int_t _MirrorAtBoundary; 0117 Int_t _debug; 0118 Int_t _verbosedebug; 0119 Int_t _vverbosedebug; 0120 0121 ClassDefOverride(Roo2DKeysPdf,0) // Two-dimensional kernel estimation p.d.f. 0122 }; 0123 0124 inline void Roo2DKeysPdf::setWidthScaleFactor(double widthScaleFactor) { _widthScaleFactor = widthScaleFactor; } 0125 0126 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |