Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
Roo2DKeysPdf.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$Id$
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
17/** \class Roo2DKeysPdf
18 \ingroup Roofit
19
20Two-dimensional kernel estimation PDF.
21
22<b>This function has been superseded by the more general RooNDKeysPdf.</b>
23*/
24
25#include "Roo2DKeysPdf.h"
26#include "RooRealVar.h"
27#include "TTree.h"
28#include "TH2.h"
29#include "TFile.h"
30#include "TMath.h"
31
32using std::ostream;
33
34
35
36////////////////////////////////////////////////////////////////////////////////
37/// Constructor.
38/// \param[in] name
39/// \param[in] title
40/// \param[in] xx
41/// \param[in] yy
42/// \param[in] data
43/// \param[in] options
44/// \param[in] widthScaleFactor
45
46Roo2DKeysPdf::Roo2DKeysPdf(const char *name, const char *title,
48 RooAbsPdf(name,title),
49 x("x", "x dimension",this, xx),
50 y("y", "y dimension",this, yy)
51{
53 loadDataSet(data, options);
54}
55
56
57////////////////////////////////////////////////////////////////////////////////
58/// Copy constructor.
59/// \param[in] other
60/// \param[in] name
61
64 x("x", this, other.x),
65 y("y", this, other.y)
66{
67 if(_verbosedebug) { std::cout << "Roo2DKeysPdf::Roo2DKeysPdf copy ctor" << std::endl; }
68
69 _xMean = other._xMean;
70 _xSigma = other._xSigma;
71 _yMean = other._yMean;
72 _ySigma = other._ySigma;
73 _n = other._n;
74
75 _BandWidthType = other._BandWidthType;
76 _MirrorAtBoundary = other._MirrorAtBoundary;
77 _widthScaleFactor = other._widthScaleFactor;
78
79 _2pi = other._2pi;
80 _sqrt2pi = other._sqrt2pi;
81 _nEvents = other._nEvents;
82 _n16 = other._n16;
83 _debug = other._debug;
84 _verbosedebug = other._verbosedebug;
85 _vverbosedebug = other._vverbosedebug;
86
87 _lox = other._lox;
88 _hix = other._hix;
89 _loy = other._loy;
90 _hiy = other._hiy;
91 _xoffset = other._xoffset;
92 _yoffset = other._yoffset;
93
94 _x = new double[_nEvents];
95 _y = new double[_nEvents];
96 _hx = new double[_nEvents];
97 _hy = new double[_nEvents];
98
99 //copy the data and bandwidths
100 for(Int_t iEvt = 0; iEvt< _nEvents; iEvt++)
101 {
102 _x[iEvt] = other._x[iEvt];
103 _y[iEvt] = other._y[iEvt];
104 _hx[iEvt] = other._hx[iEvt];
105 _hy[iEvt] = other._hy[iEvt];
106 }
107}
108
109
110////////////////////////////////////////////////////////////////////////////////
111/// Destructor.
112
114 if(_verbosedebug) { std::cout << "Roo2DKeysPdf::Roo2KeysPdf dtor" << std::endl; }
115 delete[] _x;
116 delete[] _hx;
117 delete[] _y;
118 delete[] _hy;
119}
120
121
122////////////////////////////////////////////////////////////////////////////////
123/// Loads a new data set into the class instance.
124/// Returns 1 in case of error, 0 otherwise.
125/// \param[in] data
126/// \param[in] options
127
129{
130 if(_verbosedebug) { std::cout << "Roo2DKeysPdf::loadDataSet" << std::endl; }
131
132 setOptions(options);
133
134 if(_verbosedebug) { std::cout << "Roo2DKeysPdf::loadDataSet(RooDataSet& data, TString options)" << std::endl; }
135
136 _2pi = 2.0*TMath::Pi() ; //use pi from math.h
137 _sqrt2pi = sqrt(_2pi);
138 _nEvents = (Int_t)data.numEntries();
139 if(_nEvents == 0)
140 {
141 std::cout << "ERROR: Roo2DKeysPdf::loadDataSet The input data set is empty. Unable to begin generating the PDF" << std::endl;
142 return 1;
143 }
144 _n16 = std::pow(_nEvents, -1./6.); // = (4/[n(dim(R) + 2)])^1/(dim(R)+4); dim(R) = 2
145
146 _lox = x.min();
147 _hix = x.max();
148 _loy = y.min();
149 _hiy = y.max();
150
151 _x = new double[_nEvents];
152 _y = new double[_nEvents];
153 _hx = new double[_nEvents];
154 _hy = new double[_nEvents];
155
156 double x0 = 0.0;
157 double x1 = 0.0;
158 double x_2 = 0.0;
159 double y0 = 0.0;
160 double y1 = 0.0;
161 double y_2 = 0.0;
162
163 //check that the data contain the variable we are interested in
164 Int_t bad = 0;
165 const RooAbsReal & xx = x.arg();
166 const RooAbsReal & yy = y.arg();
167 if(! static_cast<RooRealVar*>((const_cast<RooArgSet *>(data.get(0)))->find( xx.GetName() )) )
168 {
169 std::cout << "Roo2DKeysPdf::Roo2DKeysPdf invalid RooAbsReal name: "<<xx.GetName()<<" not in the data set" << std::endl;
170 bad = 1;
171 }
172 if(! static_cast<RooRealVar*>((const_cast<RooArgSet *>(data.get(0)))->find( yy.GetName() )) )
173 {
174 std::cout << "Roo2DKeysPdf::Roo2DKeysPdf invalid RooAbsReal name: "<<yy.GetName()<<" not in the data set" << std::endl;
175 bad = 1;
176 }
177 if(bad)
178 {
179 std::cout << "Roo2DKeysPdf::Roo2DKeysPdf Unable to initialize object; incompatible RooDataSet doesn't contain"<< std::endl;
180 std::cout << " all of the RooAbsReal arguments"<< std::endl;
181 return 1;
182 }
183
184 //copy the data into local arrays
185 const RooArgSet * values = data.get();
186 auto X = static_cast<RooRealVar const*>(values->find(xx.GetName()));
187 auto Y = static_cast<RooRealVar const*>(values->find(yy.GetName()));
188
189 for (Int_t j=0;j<_nEvents;++j)
190 {
191 data.get(j) ;
192
193 _x[j] = X->getVal() ;
194 _y[j] = Y->getVal() ;
195
196 x0+=1; x1+=_x[j]; x_2+=_x[j]*_x[j];
197 y0+=1; y1+=_y[j]; y_2+=_y[j]*_y[j];
198 }
199
200 //==========================================//
201 //calculate the mean and sigma for the data //
202 //==========================================//
203 if(_nEvents == 0)
204 {
205 std::cout << "Roo2DKeysPdf::Roo2DKeysPdf Empty data set was used; can't generate a PDF"<< std::endl;
206 }
207
208 _xMean = x1/x0;
210
211 _yMean = y1/y0;
213
215
216 //calculate the PDF
218}
219
220
221////////////////////////////////////////////////////////////////////////////////
222
224{
225 if(_verbosedebug) { std::cout << "Roo2DKeysPdf::setOptions" << std::endl; }
226
227 options.ToLower();
228 if( options.Contains("a") ) _BandWidthType = 0;
229 else _BandWidthType = 1;
230 if( options.Contains("n") ) _BandWidthType = 1;
231 else _BandWidthType = 0;
232 if( options.Contains("m") ) _MirrorAtBoundary = 1;
233 else _MirrorAtBoundary = 0;
234 if( options.Contains("d") ) _debug = 1;
235 else _debug = 0;
236 if( options.Contains("v") ) { _debug = 1; _verbosedebug = 1; }
237 else _verbosedebug = 0;
238 if( options.Contains("vv") ) { _vverbosedebug = 1; }
239 else _vverbosedebug = 0;
240
241 if( _debug )
242 {
243 std::cout << "Roo2DKeysPdf::setOptions(TString options) options = "<< options << std::endl;
244 std::cout << "\t_BandWidthType = " << _BandWidthType << std::endl;
245 std::cout << "\t_MirrorAtBoundary = " << _MirrorAtBoundary << std::endl;
246 std::cout << "\t_debug = " << _debug << std::endl;
247 std::cout << "\t_verbosedebug = " << _verbosedebug << std::endl;
248 std::cout << "\t_vverbosedebug = " << _vverbosedebug << std::endl;
249 }
250}
251
252
253////////////////////////////////////////////////////////////////////////////////
254
256{
257 std::cout << "Roo2DKeysPdf::getOptions(void)" << std::endl;
258 std::cout << "\t_BandWidthType = " << _BandWidthType << std::endl;
259 std::cout << "\t_MirrorAtBoundary = " << _MirrorAtBoundary << std::endl;
260 std::cout << "\t_debug = " << _debug << std::endl;
261 std::cout << "\t_verbosedebug = " << _verbosedebug << std::endl;
262 std::cout << "\t_vverbosedebug = " << _vverbosedebug << std::endl;
263}
264
265
266////////////////////////////////////////////////////////////////////////////////
267/// Calculates the kernel bandwidth for x & y and the probability look up table _p[i][j]
268/// \param[in] kernel
269
271{
272 if(_verbosedebug) { std::cout << "Roo2DKeysPdf::calculateBandWidth(Int_t kernel)" << std::endl; }
273 if(kernel != -999)
274 {
276 }
277
278 double h = 0.0;
279
281 double sqrtSum = sqrt( sigSum );
282 double sigProd = _ySigma*_xSigma;
283 if(sigProd != 0.0) h = _n16*sqrt( sigSum/sigProd );
284 if(sqrtSum == 0)
285 {
286 std::cout << "Roo2DKeysPdf::calculateBandWidth The sqr(variance sum) == 0.0. " << " Your dataset represents a delta function."<< std::endl;
287 return 1;
288 }
289
290 double hXSigma = h * _xSigma;
291 double hYSigma = h * _ySigma;
292 double xhmin = hXSigma * sqrt(2.)/10; //smallest anticipated bandwidth
293 double yhmin = hYSigma * sqrt(2.)/10;
294
295 //////////////////////////////////////
296 //calculate bandwidths from the data//
297 //////////////////////////////////////
298 if(_BandWidthType == 1) //calculate a trivial bandwidth
299 {
300 std::cout << "Roo2DKeysPdf::calculateBandWidth Using a normal bandwidth (same for a given dimension) based on"<< std::endl;
301 std::cout << " h_j = n^{-1/6}*sigma_j for the j^th dimension and n events * "<<_widthScaleFactor<< std::endl;
304 for(Int_t j=0;j<_nEvents;++j)
305 {
306 _hx[j] = hxGaussian;
307 _hy[j] = hyGaussian;
308 if(_hx[j]<xhmin) _hx[j] = xhmin;
309 if(_hy[j]<yhmin) _hy[j] = yhmin;
310 }
311 }
312 else //use an adaptive bandwidth to reduce the dependence on global data distribution
313 {
314 std::cout << "Roo2DKeysPdf::calculateBandWidth Using an adaptive bandwidth (in general different for all events) [default]"<< std::endl;
315 std::cout << " scaled by a factor of "<<_widthScaleFactor<< std::endl;
316 double xnorm = h * std::pow(_xSigma/sqrtSum, 1.5) * _widthScaleFactor;
317 double ynorm = h * std::pow(_ySigma/sqrtSum, 1.5) * _widthScaleFactor;
318 for(Int_t j=0;j<_nEvents;++j)
319 {
320 double f_ti = std::pow( g(_x[j], _x, hXSigma, _y[j], _y, hYSigma), -0.25 ) ;
321 _hx[j] = xnorm * f_ti;
322 _hy[j] = ynorm * f_ti;
323 if(_hx[j]<xhmin) _hx[j] = xhmin;
324 if(_hy[j]<yhmin) _hy[j] = yhmin;
325 }
326 }
327
328 return 0;
329}
330
331
332////////////////////////////////////////////////////////////////////////////////
333/// Evaluates the kernel estimation for x,y, interpolating between the points if necessary
334///
335/// Uses the caching intrinsic in RFC to bypass the grid and remove
336/// the grid and extrapolation approximation in the kernel estimation method
337/// implementation.
338
340{
341 if(_vverbosedebug) { std::cout << "Roo2DKeysPdf::evaluate()" << std::endl; }
342 return evaluateFull(x,y);
343}
344
345
346////////////////////////////////////////////////////////////////////////////////
347/// Evaluates the sum of the product of the 2D kernels
348/// for use in calculating the fixed kernel estimate, f,
349/// given the bandwidths _hx[j] and _hy[j].
350///
351/// _n is calculated once in the constructor.
352/// \param[in] thisX
353/// \param[in] thisY
354
355double Roo2DKeysPdf::evaluateFull(double thisX, double thisY) const
356{
357 if( _vverbosedebug ) { std::cout << "Roo2DKeysPdf::evaluateFull()" << std::endl; }
358
359 double f=0.0;
360
361 double rx2;
362 double ry2;
363 double zx;
364 double zy;
366 {
367 for (Int_t j = 0; j < _nEvents; ++j)
368 {
369 rx2 = 0.0; ry2 = 0.0; zx = 0.0; zy = 0.0;
370 if(_hx[j] != 0.0) rx2 = (thisX - _x[j])/_hx[j];
371 if(_hy[j] != 0.0) ry2 = (thisY - _y[j])/_hy[j];
372
373 if(_hx[j] != 0.0) zx = exp(-0.5*rx2*rx2)/_hx[j];
374 if(_hy[j] != 0.0) zy = exp(-0.5*ry2*ry2)/_hy[j];
375
380 f += zy * zx;
381 // f += _n * zy * zx; // ooops this is a normalisation factor :(
382 }
383 }
384 else
385 {
386 for (Int_t j = 0; j < _nEvents; ++j)
387 {
388 rx2 = 0.0; ry2 = 0.0; zx = 0.0; zy = 0.0;
389 if(_hx[j] != 0.0) rx2 = (thisX - _x[j])/_hx[j];
390 if(_hy[j] != 0.0) ry2 = (thisY - _y[j])/_hy[j];
391
392 if(_hx[j] != 0.0) zx = exp(-0.5*rx2*rx2)/_hx[j];
393 if(_hy[j] != 0.0) zy = exp(-0.5*ry2*ry2)/_hy[j];
394 f += zy * zx;
395 // f += _n * zy * zx; // ooops this is a normalisation factor :(
396 }
397 }
398 return f;
399}
400
401
402////////////////////////////////////////////////////////////////////////////////
403/// Apply the mirror at boundary correction to a dimension given the space position to evaluate
404/// at (thisVar), the bandwidth at this position (thisH), the boundary (high/low) and the
405/// value of the data kernel that this correction is being applied to tVar (i.e. the _x[ix] etc.).
406/// \param[in] thisVar
407/// \param[in] thisH
408/// \param[in] high
409/// \param[in] tVar
410
411double Roo2DKeysPdf::highBoundaryCorrection(double thisVar, double thisH, double high, double tVar) const
412{
413 if(_vverbosedebug) { std::cout << "Roo2DKeysPdf::highBoundaryCorrection" << std::endl; }
414
415 if(thisH == 0.0) return 0.0;
416 double correction = (thisVar + tVar - 2.0* high )/thisH;
417 return exp(-0.5*correction*correction)/thisH;
418}
419
420
421////////////////////////////////////////////////////////////////////////////////
422
423double Roo2DKeysPdf::lowBoundaryCorrection(double thisVar, double thisH, double low, double tVar) const
424{
425 if(_vverbosedebug) { std::cout << "Roo2DKeysPdf::lowBoundaryCorrection" << std::endl; }
426
427 if(thisH == 0.0) return 0.0;
428 double correction = (thisVar + tVar - 2.0* low )/thisH;
429 return exp(-0.5*correction*correction)/thisH;
430}
431
432
433////////////////////////////////////////////////////////////////////////////////
434/// Calculates f(t_i) for the bandwidths.
435/// \f$ g = 1/(N_{evt} * \sigma_j * \sqrt{2\pi})*\sum_{all evts}{\prod d K[ \exp({-(xd - ti)/\sigma_{j}d^2}) ]}\f$
436/// \param[in] varMean1
437/// \param[in] _var1
438/// \param[in] sigma1
439/// \param[in] varMean2
440/// \param[in] _var2
441/// \param[in] sigma2
442
443double Roo2DKeysPdf::g(double varMean1, double * _var1, double sigma1, double varMean2, double * _var2, double sigma2) const
444{
445 if((_nEvents == 0.0) || (sigma1 == 0.0) || (sigma2 == 0)) return 0.0;
446
447 double c1 = -1.0/(2.0*sigma1*sigma1);
448 double c2 = -1.0/(2.0*sigma2*sigma2);
449 double d = 4.0*c1*c2 /(_sqrt2pi*_nEvents);
450 double z = 0.0;
451
452 for (Int_t i = 0; i < _nEvents; ++i)
453 {
454 double r1 = _var1[i] - varMean1;
455 double r2 = _var2[i] - varMean2;
456 z += exp( c1 * r1*r1 ) * exp( c2 * r2*r2 );
457 }
458 z = z*d;
459 return z;
460}
461
462
463////////////////////////////////////////////////////////////////////////////////
464
466{
467 if(_BandWidthType == 1) std::cout << "The Bandwidth Type selected is Trivial" << std::endl;
468 else std::cout << "The Bandwidth Type selected is Adaptive" << std::endl;
469
470 return _BandWidthType;
471}
472
473
474////////////////////////////////////////////////////////////////////////////////
475
476double Roo2DKeysPdf::getMean(const char * axis) const
477{
478 if(!strcmp(axis,x.GetName()) || !strcmp(axis,"x") || !strcmp(axis,"X")) return _xMean;
479 else if(!strcmp(axis,y.GetName()) || !strcmp(axis,"y") || !strcmp(axis,"Y")) return _yMean;
480 else
481 {
482 std::cout << "Roo2DKeysPdf::getMean unknown axis "<<axis<< std::endl;
483 }
484 return 0.0;
485}
486
487
488////////////////////////////////////////////////////////////////////////////////
489
490double Roo2DKeysPdf::getSigma(const char * axis) const
491{
492 if(!strcmp(axis,x.GetName()) || !strcmp(axis,"x") || !strcmp(axis,"X")) return _xSigma;
493 else if(!strcmp(axis,y.GetName()) || !strcmp(axis,"y") || !strcmp(axis,"Y")) return _ySigma;
494 else
495 {
496 std::cout << "Roo2DKeysPdf::getSigma unknown axis "<<axis<< std::endl;
497 }
498 return 0.0;
499}
500
501
502
503////////////////////////////////////////////////////////////////////////////////
504
505void Roo2DKeysPdf::writeToFile(char * outputFile, const char * name) const
506{
507 TString histName = name;
508 histName += "_hist";
510 nName += "_Ntuple";
511 writeHistToFile( outputFile, histName);
513}
514
515
516////////////////////////////////////////////////////////////////////////////////
517/// Plots the PDF as a histogram and saves it to a file, so that it can be loaded in
518/// as a Roo2DHist PDF in the future to save on calculation time.
519/// \param[in] outputFile Name of the file where to store the PDF
520/// \param[in] histName PDF histogram name
521
522void Roo2DKeysPdf::writeHistToFile(char * outputFile, const char * histName) const
523{
524 std::cout << "Roo2DKeysPdf::writeHistToFile This member function is temporarily disabled" << std::endl;
525 //make sure that any existing file is not over written
526 std::unique_ptr<TFile> file{TFile::Open(outputFile, "UPDATE")};
527 if (!file)
528 {
529 std::cout << "Roo2DKeysPdf::writeHistToFile unable to open file "<< outputFile << std::endl;
530 return;
531 }
532
533
534 const RooAbsReal & xx = x.arg();
535 const RooAbsReal & yy = y.arg();
536 RooArgSet values( RooArgList( xx, yy ));
537 RooRealVar * xArg = (static_cast<RooRealVar*>(values.find(xx.GetName())) ) ;
538 RooRealVar * yArg = (static_cast<RooRealVar*>(values.find(yy.GetName())) ) ;
539
540 TH2F * hist = (TH2F*)xArg->createHistogram("hist", *yArg);
541 hist = static_cast<TH2F*>(this->fillHistogram(hist, RooArgList(*xArg, *yArg) ));
542 hist->SetName(histName);
543
544 file->Write();
545 file->Close();
546}
547
548
549////////////////////////////////////////////////////////////////////////////////
550/// Saves the data and calculated bandwidths to a file,
551/// as a record of what produced the PDF and to give a reduced
552/// data set in order to facilitate re-calculation in the future.
553/// \param[in] outputFile Name of the file where to store the data
554/// \param[in] name Name of the tree which will contain the data
555
556void Roo2DKeysPdf::writeNTupleToFile(char * outputFile, const char * name) const
557{
558 TFile * file = nullptr;
559
560 //make sure that any existing file is not over written
561 file = new TFile(outputFile, "UPDATE");
562 if (!file)
563 {
564 std::cout << "Roo2DKeysPdf::writeNTupleToFile unable to open file "<< outputFile << std::endl;
565 return;
566 }
569
570 double theX;
571 double theY;
572 double hx;
573 TString label = name;
574 label += " the source data for 2D Keys PDF";
575 TTree * _theTree = new TTree(name, label);
576 if(!_theTree) { std::cout << "Unable to get a TTree for output" << std::endl; return; }
577 _theTree->SetAutoSave(1000000000); // autosave when 1 Gbyte written
578
579 //name the TBranches the same as the RooAbsReal's
580 const char * xname = xArg.GetName();
581 const char * yname = yArg.GetName();
582 if (!strcmp(xname,"")) xname = "x";
583 if (!strcmp(yname,"")) yname = "y";
584
585 _theTree->Branch(xname, &theX, " x/D");
586 _theTree->Branch(yname, &theY, " y/D");
587 _theTree->Branch("hx", &hx, " hx/D");
588 _theTree->Branch("hy", &hx, " hy/D");
589
590 for(Int_t iEvt = 0; iEvt < _nEvents; iEvt++)
591 {
592 theX = _x[iEvt];
593 theY = _y[iEvt];
594 hx = _hx[iEvt];
595 hx = _hy[iEvt];
596 _theTree->Fill();
597 }
598 file->Write();
599 file->Close();
600}
601
602
603////////////////////////////////////////////////////////////////////////////////
604/// Prints out _p[_nPoints][_nPoints] indicating the domain limits.
605/// \param[out] out Output stream where to print
606
607void Roo2DKeysPdf::PrintInfo(ostream & out) const
608{
609 out << "Roo2DKeysPDF instance domain information:"<< std::endl;
610 out << "\tX_min = " << _lox << std::endl;
611 out << "\tX_max = " << _hix << std::endl;
612 out << "\tY_min = " << _loy << std::endl;
613 out << "\tY_max = " << _hiy << std::endl;
614
615 out << "Data information:" << std::endl;
616 out << "\t<x> = " << _xMean << std::endl;
617 out << "\tsigma(x) = " << _xSigma << std::endl;
618 out << "\t<y> = " << _yMean << std::endl;
619 out << "\tsigma(y) = " << _ySigma << std::endl;
620
621 out << "END of info for Roo2DKeys pdf instance"<< std::endl;
622}
#define d(i)
Definition RSha256.hxx:102
#define f(i)
Definition RSha256.hxx:104
#define g(i)
Definition RSha256.hxx:105
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
#define X(type, name)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:110
Two-dimensional kernel estimation PDF.
RooRealProxy y
double getMean(const char *axis) const
Roo2DKeysPdf(const char *name, const char *title, RooAbsReal &xx, RooAbsReal &yy, RooDataSet &data, TString options="a", double widthScaleFactor=1.0)
Constructor.
double _widthScaleFactor
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
void writeToFile(char *outputFile, const char *name) const
Int_t _verbosedebug
double * _hy
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
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
double * _x
double * _y
double * _hx
double getSigma(const char *axis) const
~Roo2DKeysPdf() override
Destructor.
void setWidthScaleFactor(double widthScaleFactor)
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
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
TH1 * fillHistogram(TH1 *hist, const RooArgList &plotVars, double scaleFactor=1, const RooArgSet *projectedVars=nullptr, bool scaling=true, const RooArgSet *condObs=nullptr, bool setError=true) const
Fill the ROOT histogram 'hist' with values sampled from this function at the bin centers.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Container class to hold unbinned data.
Definition RooDataSet.h:32
Variable that can be changed from the outside.
Definition RooRealVar.h:37
double max(const char *rname=nullptr) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
const T & arg() const
Return reference to object held in proxy.
double min(const char *rname=nullptr) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4131
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) override
Write memory objects to this file.
Definition TFile.cxx:2477
void Close(Option_t *option="") override
Close a file.
Definition TFile.cxx:955
void SetName(const char *name) override
Change the name of this histogram.
Definition TH1.cxx:8956
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Basic string class.
Definition TString.h:139
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
A TTree represents a columnar dataset.
Definition TTree.h:79
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
return c2
Definition legend2.C:14
constexpr Double_t Pi()
Definition TMath.h:37