Logo ROOT  
Reference Guide
 
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,
47 RooAbsReal& xx, RooAbsReal & yy, RooDataSet& data, TString options, double widthScaleFactor):
48 RooAbsPdf(name,title),
49 x("x", "x dimension",this, xx),
50 y("y", "y dimension",this, yy)
51{
52 setWidthScaleFactor(widthScaleFactor);
53 loadDataSet(data, options);
54}
55
56
57////////////////////////////////////////////////////////////////////////////////
58/// Copy constructor.
59/// \param[in] other
60/// \param[in] name
61
62Roo2DKeysPdf::Roo2DKeysPdf(const Roo2DKeysPdf & other, const char* name) :
63 RooAbsPdf(other,name),
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
78
79 _2pi = other._2pi;
80 _sqrt2pi = other._sqrt2pi;
81 _nEvents = other._nEvents;
82 _n16 = other._n16;
83 _debug = other._debug;
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;
209 _xSigma = sqrt(x_2/_nEvents-_xMean*_xMean);
210
211 _yMean = y1/y0;
212 _ySigma = sqrt(y_2/_nEvents-_yMean*_yMean);
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 {
238 _verbosedebug = 0;
239 }
240 if( options.Contains("vv") ) { _vverbosedebug = 1;
241 } else {
242 _vverbosedebug = 0;
243 }
244
245 if( _debug )
246 {
247 std::cout << "Roo2DKeysPdf::setOptions(TString options) options = "<< options << std::endl;
248 std::cout << "\t_BandWidthType = " << _BandWidthType << std::endl;
249 std::cout << "\t_MirrorAtBoundary = " << _MirrorAtBoundary << std::endl;
250 std::cout << "\t_debug = " << _debug << std::endl;
251 std::cout << "\t_verbosedebug = " << _verbosedebug << std::endl;
252 std::cout << "\t_vverbosedebug = " << _vverbosedebug << std::endl;
253 }
254}
255
256
257////////////////////////////////////////////////////////////////////////////////
258
260{
261 std::cout << "Roo2DKeysPdf::getOptions(void)" << std::endl;
262 std::cout << "\t_BandWidthType = " << _BandWidthType << std::endl;
263 std::cout << "\t_MirrorAtBoundary = " << _MirrorAtBoundary << std::endl;
264 std::cout << "\t_debug = " << _debug << std::endl;
265 std::cout << "\t_verbosedebug = " << _verbosedebug << std::endl;
266 std::cout << "\t_vverbosedebug = " << _vverbosedebug << std::endl;
267}
268
269
270////////////////////////////////////////////////////////////////////////////////
271/// Calculates the kernel bandwidth for x & y and the probability look up table _p[i][j]
272/// \param[in] kernel
273
275{
276 if(_verbosedebug) { std::cout << "Roo2DKeysPdf::calculateBandWidth(Int_t kernel)" << std::endl; }
277 if(kernel != -999)
278 {
279 _BandWidthType = kernel;
280 }
281
282 double h = 0.0;
283
284 double sigSum = _xSigma*_xSigma + _ySigma*_ySigma;
285 double sqrtSum = sqrt( sigSum );
286 double sigProd = _ySigma*_xSigma;
287 if(sigProd != 0.0) h = _n16*sqrt( sigSum/sigProd );
288 if(sqrtSum == 0)
289 {
290 std::cout << "Roo2DKeysPdf::calculateBandWidth The sqr(variance sum) == 0.0. " << " Your dataset represents a delta function."<< std::endl;
291 return 1;
292 }
293
294 double hXSigma = h * _xSigma;
295 double hYSigma = h * _ySigma;
296 double xhmin = hXSigma * sqrt(2.)/10; //smallest anticipated bandwidth
297 double yhmin = hYSigma * sqrt(2.)/10;
298
299 //////////////////////////////////////
300 //calculate bandwidths from the data//
301 //////////////////////////////////////
302 if(_BandWidthType == 1) //calculate a trivial bandwidth
303 {
304 std::cout << "Roo2DKeysPdf::calculateBandWidth Using a normal bandwidth (same for a given dimension) based on"<< std::endl;
305 std::cout << " h_j = n^{-1/6}*sigma_j for the j^th dimension and n events * "<<_widthScaleFactor<< std::endl;
306 double hxGaussian = _n16 * _xSigma * _widthScaleFactor;
307 double hyGaussian = _n16 * _ySigma * _widthScaleFactor;
308 for(Int_t j=0;j<_nEvents;++j)
309 {
310 _hx[j] = hxGaussian;
311 _hy[j] = hyGaussian;
312 if(_hx[j]<xhmin) _hx[j] = xhmin;
313 if(_hy[j]<yhmin) _hy[j] = yhmin;
314 }
315 }
316 else //use an adaptive bandwidth to reduce the dependence on global data distribution
317 {
318 std::cout << "Roo2DKeysPdf::calculateBandWidth Using an adaptive bandwidth (in general different for all events) [default]"<< std::endl;
319 std::cout << " scaled by a factor of "<<_widthScaleFactor<< std::endl;
320 double xnorm = h * std::pow(_xSigma/sqrtSum, 1.5) * _widthScaleFactor;
321 double ynorm = h * std::pow(_ySigma/sqrtSum, 1.5) * _widthScaleFactor;
322 for(Int_t j=0;j<_nEvents;++j)
323 {
324 double f_ti = std::pow( g(_x[j], _x, hXSigma, _y[j], _y, hYSigma), -0.25 ) ;
325 _hx[j] = xnorm * f_ti;
326 _hy[j] = ynorm * f_ti;
327 if(_hx[j]<xhmin) _hx[j] = xhmin;
328 if(_hy[j]<yhmin) _hy[j] = yhmin;
329 }
330 }
331
332 return 0;
333}
334
335
336////////////////////////////////////////////////////////////////////////////////
337/// Evaluates the kernel estimation for x,y, interpolating between the points if necessary
338///
339/// Uses the caching intrinsic in RFC to bypass the grid and remove
340/// the grid and extrapolation approximation in the kernel estimation method
341/// implementation.
342
344{
345 if(_vverbosedebug) { std::cout << "Roo2DKeysPdf::evaluate()" << std::endl; }
346 return evaluateFull(x,y);
347}
348
349
350////////////////////////////////////////////////////////////////////////////////
351/// Evaluates the sum of the product of the 2D kernels
352/// for use in calculating the fixed kernel estimate, f,
353/// given the bandwidths _hx[j] and _hy[j].
354///
355/// _n is calculated once in the constructor.
356/// \param[in] thisX
357/// \param[in] thisY
358
359double Roo2DKeysPdf::evaluateFull(double thisX, double thisY) const
360{
361 if( _vverbosedebug ) { std::cout << "Roo2DKeysPdf::evaluateFull()" << std::endl; }
362
363 double f=0.0;
364
365 double rx2;
366 double ry2;
367 double zx;
368 double zy;
370 {
371 for (Int_t j = 0; j < _nEvents; ++j)
372 {
373 rx2 = 0.0; ry2 = 0.0; zx = 0.0; zy = 0.0;
374 if(_hx[j] != 0.0) rx2 = (thisX - _x[j])/_hx[j];
375 if(_hy[j] != 0.0) ry2 = (thisY - _y[j])/_hy[j];
376
377 if(_hx[j] != 0.0) zx = exp(-0.5*rx2*rx2)/_hx[j];
378 if(_hy[j] != 0.0) zy = exp(-0.5*ry2*ry2)/_hy[j];
379
380 zx += highBoundaryCorrection(thisX, _hx[j], x.max(), _x[j])
381 + lowBoundaryCorrection(thisX, _hx[j], x.min(), _x[j]);
382 zy += highBoundaryCorrection(thisY, _hy[j], y.max(), _y[j])
383 + lowBoundaryCorrection(thisY, _hy[j], y.min(), _y[j]);
384 f += zy * zx;
385 // f += _n * zy * zx; // ooops this is a normalisation factor :(
386 }
387 }
388 else
389 {
390 for (Int_t j = 0; j < _nEvents; ++j)
391 {
392 rx2 = 0.0; ry2 = 0.0; zx = 0.0; zy = 0.0;
393 if(_hx[j] != 0.0) rx2 = (thisX - _x[j])/_hx[j];
394 if(_hy[j] != 0.0) ry2 = (thisY - _y[j])/_hy[j];
395
396 if(_hx[j] != 0.0) zx = exp(-0.5*rx2*rx2)/_hx[j];
397 if(_hy[j] != 0.0) zy = exp(-0.5*ry2*ry2)/_hy[j];
398 f += zy * zx;
399 // f += _n * zy * zx; // ooops this is a normalisation factor :(
400 }
401 }
402 return f;
403}
404
405
406////////////////////////////////////////////////////////////////////////////////
407/// Apply the mirror at boundary correction to a dimension given the space position to evaluate
408/// at (thisVar), the bandwidth at this position (thisH), the boundary (high/low) and the
409/// value of the data kernel that this correction is being applied to tVar (i.e. the _x[ix] etc.).
410/// \param[in] thisVar
411/// \param[in] thisH
412/// \param[in] high
413/// \param[in] tVar
414
415double Roo2DKeysPdf::highBoundaryCorrection(double thisVar, double thisH, double high, double tVar) const
416{
417 if(_vverbosedebug) { std::cout << "Roo2DKeysPdf::highBoundaryCorrection" << std::endl; }
418
419 if(thisH == 0.0) return 0.0;
420 double correction = (thisVar + tVar - 2.0* high )/thisH;
421 return exp(-0.5*correction*correction)/thisH;
422}
423
424
425////////////////////////////////////////////////////////////////////////////////
426
427double Roo2DKeysPdf::lowBoundaryCorrection(double thisVar, double thisH, double low, double tVar) const
428{
429 if(_vverbosedebug) { std::cout << "Roo2DKeysPdf::lowBoundaryCorrection" << std::endl; }
430
431 if(thisH == 0.0) return 0.0;
432 double correction = (thisVar + tVar - 2.0* low )/thisH;
433 return exp(-0.5*correction*correction)/thisH;
434}
435
436
437////////////////////////////////////////////////////////////////////////////////
438/// Calculates f(t_i) for the bandwidths.
439/// \f$ g = 1/(N_{evt} * \sigma_j * \sqrt{2\pi})*\sum_{all evts}{\prod d K[ \exp({-(xd - ti)/\sigma_{j}d^2}) ]}\f$
440/// \param[in] varMean1
441/// \param[in] _var1
442/// \param[in] sigma1
443/// \param[in] varMean2
444/// \param[in] _var2
445/// \param[in] sigma2
446
447double Roo2DKeysPdf::g(double varMean1, double * _var1, double sigma1, double varMean2, double * _var2, double sigma2) const
448{
449 if((_nEvents == 0.0) || (sigma1 == 0.0) || (sigma2 == 0)) return 0.0;
450
451 double c1 = -1.0/(2.0*sigma1*sigma1);
452 double c2 = -1.0/(2.0*sigma2*sigma2);
453 double d = 4.0*c1*c2 /(_sqrt2pi*_nEvents);
454 double z = 0.0;
455
456 for (Int_t i = 0; i < _nEvents; ++i)
457 {
458 double r1 = _var1[i] - varMean1;
459 double r2 = _var2[i] - varMean2;
460 z += exp( c1 * r1*r1 ) * exp( c2 * r2*r2 );
461 }
462 z = z*d;
463 return z;
464}
465
466
467////////////////////////////////////////////////////////////////////////////////
468
470{
471 if(_BandWidthType == 1) std::cout << "The Bandwidth Type selected is Trivial" << std::endl;
472 else std::cout << "The Bandwidth Type selected is Adaptive" << std::endl;
473
474 return _BandWidthType;
475}
476
477
478////////////////////////////////////////////////////////////////////////////////
479
480double Roo2DKeysPdf::getMean(const char * axis) const
481{
482 if(!strcmp(axis,x.GetName()) || !strcmp(axis,"x") || !strcmp(axis,"X")) return _xMean;
483 else if(!strcmp(axis,y.GetName()) || !strcmp(axis,"y") || !strcmp(axis,"Y")) return _yMean;
484 else
485 {
486 std::cout << "Roo2DKeysPdf::getMean unknown axis "<<axis<< std::endl;
487 }
488 return 0.0;
489}
490
491
492////////////////////////////////////////////////////////////////////////////////
493
494double Roo2DKeysPdf::getSigma(const char * axis) const
495{
496 if(!strcmp(axis,x.GetName()) || !strcmp(axis,"x") || !strcmp(axis,"X")) return _xSigma;
497 else if(!strcmp(axis,y.GetName()) || !strcmp(axis,"y") || !strcmp(axis,"Y")) return _ySigma;
498 else
499 {
500 std::cout << "Roo2DKeysPdf::getSigma unknown axis "<<axis<< std::endl;
501 }
502 return 0.0;
503}
504
505
506
507////////////////////////////////////////////////////////////////////////////////
508
509void Roo2DKeysPdf::writeToFile(char * outputFile, const char * name) const
510{
511 TString histName = name;
512 histName += "_hist";
513 TString nName = name;
514 nName += "_Ntuple";
515 writeHistToFile( outputFile, histName);
516 writeNTupleToFile( outputFile, nName);
517}
518
519
520////////////////////////////////////////////////////////////////////////////////
521/// Plots the PDF as a histogram and saves it to a file, so that it can be loaded in
522/// as a Roo2DHist PDF in the future to save on calculation time.
523/// \param[in] outputFile Name of the file where to store the PDF
524/// \param[in] histName PDF histogram name
525
526void Roo2DKeysPdf::writeHistToFile(char * outputFile, const char * histName) const
527{
528 std::cout << "Roo2DKeysPdf::writeHistToFile This member function is temporarily disabled" << std::endl;
529 //make sure that any existing file is not over written
530 std::unique_ptr<TFile> file{TFile::Open(outputFile, "UPDATE")};
531 if (!file)
532 {
533 std::cout << "Roo2DKeysPdf::writeHistToFile unable to open file "<< outputFile << std::endl;
534 return;
535 }
536
537
538 const RooAbsReal & xx = x.arg();
539 const RooAbsReal & yy = y.arg();
540 RooArgSet values( RooArgList( xx, yy ));
541 RooRealVar * xArg = (static_cast<RooRealVar*>(values.find(xx.GetName())) ) ;
542 RooRealVar * yArg = (static_cast<RooRealVar*>(values.find(yy.GetName())) ) ;
543
544 TH2F * hist = (TH2F*)xArg->createHistogram("hist", *yArg);
545 hist = static_cast<TH2F*>(this->fillHistogram(hist, RooArgList(*xArg, *yArg) ));
546 hist->SetName(histName);
547
548 file->Write();
549 file->Close();
550}
551
552
553////////////////////////////////////////////////////////////////////////////////
554/// Saves the data and calculated bandwidths to a file,
555/// as a record of what produced the PDF and to give a reduced
556/// data set in order to facilitate re-calculation in the future.
557/// \param[in] outputFile Name of the file where to store the data
558/// \param[in] name Name of the tree which will contain the data
559
560void Roo2DKeysPdf::writeNTupleToFile(char * outputFile, const char * name) const
561{
562 TFile * file = nullptr;
563
564 //make sure that any existing file is not over written
565 file = new TFile(outputFile, "UPDATE");
566 if (!file)
567 {
568 std::cout << "Roo2DKeysPdf::writeNTupleToFile unable to open file "<< outputFile << std::endl;
569 return;
570 }
571 RooAbsReal & xArg = (RooAbsReal&)x.arg();
572 RooAbsReal & yArg = (RooAbsReal&)y.arg();
573
574 double theX;
575 double theY;
576 double hx;
577 TString label = name;
578 label += " the source data for 2D Keys PDF";
579 TTree * _theTree = new TTree(name, label);
580 if(!_theTree) { std::cout << "Unable to get a TTree for output" << std::endl; return; }
581 _theTree->SetAutoSave(1000000000); // autosave when 1 Gbyte written
582
583 //name the TBranches the same as the RooAbsReal's
584 const char * xname = xArg.GetName();
585 const char * yname = yArg.GetName();
586 if (!strcmp(xname,"")) xname = "x";
587 if (!strcmp(yname,"")) yname = "y";
588
589 _theTree->Branch(xname, &theX, " x/D");
590 _theTree->Branch(yname, &theY, " y/D");
591 _theTree->Branch("hx", &hx, " hx/D");
592 _theTree->Branch("hy", &hx, " hy/D");
593
594 for(Int_t iEvt = 0; iEvt < _nEvents; iEvt++)
595 {
596 theX = _x[iEvt];
597 theY = _y[iEvt];
598 hx = _hx[iEvt];
599 hx = _hy[iEvt];
600 _theTree->Fill();
601 }
602 file->Write();
603 file->Close();
604}
605
606
607////////////////////////////////////////////////////////////////////////////////
608/// Prints out _p[_nPoints][_nPoints] indicating the domain limits.
609/// \param[out] out Output stream where to print
610
611void Roo2DKeysPdf::PrintInfo(ostream & out) const
612{
613 out << "Roo2DKeysPDF instance domain information:"<< std::endl;
614 out << "\tX_min = " << _lox << std::endl;
615 out << "\tX_max = " << _hix << std::endl;
616 out << "\tY_min = " << _loy << std::endl;
617 out << "\tY_max = " << _hiy << std::endl;
618
619 out << "Data information:" << std::endl;
620 out << "\t<x> = " << _xMean << std::endl;
621 out << "\tsigma(x) = " << _xSigma << std::endl;
622 out << "\t<y> = " << _yMean << std::endl;
623 out << "\tsigma(y) = " << _ySigma << std::endl;
624
625 out << "END of info for Roo2DKeys pdf instance"<< std::endl;
626}
#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
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
#define X(type, name)
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:142
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 varMean1, double *_var1, double sigma1, double varMean2, 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:32
TH1 * createHistogram(const char *name, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
TH1 * fillHistogram(TH1 *hist, const RooArgList &plotVars, double scaleFactor=1, const RooArgSet *projectedVars=nullptr, bool scaleForDensity=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 file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override
Write memory objects to this file.
Definition TFile.cxx:2503
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:3802
void Close(Option_t *option="") override
Close a file.
Definition TFile.cxx:992
void SetName(const char *name) override
Change the name of this histogram.
Definition TH1.cxx:9193
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:345
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Basic string class.
Definition TString.h:137
void ToLower()
Change string to lower-case.
Definition TString.cxx:1190
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
A TTree represents a columnar dataset.
Definition TTree.h:95
virtual Int_t Fill()
Fill all branches.
Definition TTree.cxx:4676
virtual void SetAutoSave(Long64_t autos=-300000000)
In case of a program crash, it will be possible to recover the data in the tree up to the last AutoSa...
Definition TTree.cxx:8694
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
Definition TTree.h:411
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:40