Logo ROOT   6.07/09
Reference Guide
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 
20 Two-dimensional kernel estimation PDF.
21 
22 <b>This function has been superseded by the more general RooNDKeysPdf.</b>
23 */
24 
25 #include "RooFit.h"
26 
27 #include "Roo2DKeysPdf.h"
28 #include "Roo2DKeysPdf.h"
29 #include "RooRealVar.h"
30 #include "TTree.h"
31 #include "TH2.h"
32 #include "TFile.h"
33 #include "TBranch.h"
34 #include "TMath.h"
35 
36 //#include <math.h>
37 
38 using namespace std;
39 
41 
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// Constructor.
45 /// \param[in] name
46 /// \param[in] title
47 /// \param[in] xx
48 /// \param[in] yy
49 /// \param[in] data
50 /// \param[in] options
51 /// \param[in] widthScaleFactor
52 
53 Roo2DKeysPdf::Roo2DKeysPdf(const char *name, const char *title,
54  RooAbsReal& xx, RooAbsReal & yy, RooDataSet& data, TString options, Double_t widthScaleFactor):
55  RooAbsPdf(name,title),
56  x("x", "x dimension",this, xx),
57  y("y", "y dimension",this, yy)
58 {
59  setWidthScaleFactor(widthScaleFactor);
60  loadDataSet(data, options);
61 }
62 
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Copy constructor.
66 /// \param[in] other
67 /// \param[in] name
68 
69 Roo2DKeysPdf::Roo2DKeysPdf(const Roo2DKeysPdf & other, const char* name) :
70  RooAbsPdf(other,name),
71  x("x", this, other.x),
72  y("y", this, other.y)
73 {
74  if(_verbosedebug) { cout << "Roo2DKeysPdf::Roo2DKeysPdf copy ctor" << endl; }
75 
76  _xMean = other._xMean;
77  _xSigma = other._xSigma;
78  _yMean = other._yMean;
79  _ySigma = other._ySigma;
80  _n = other._n;
81 
85 
86  _2pi = other._2pi;
87  _sqrt2pi = other._sqrt2pi;
88  _nEvents = other._nEvents;
89  _n16 = other._n16;
90  _debug = other._debug;
93 
94  _lox = other._lox;
95  _hix = other._hix;
96  _loy = other._loy;
97  _hiy = other._hiy;
98  _xoffset = other._xoffset;
99  _yoffset = other._yoffset;
100 
101  _x = new Double_t[_nEvents];
102  _y = new Double_t[_nEvents];
103  _hx = new Double_t[_nEvents];
104  _hy = new Double_t[_nEvents];
105 
106  //copy the data and bandwidths
107  for(Int_t iEvt = 0; iEvt< _nEvents; iEvt++)
108  {
109  _x[iEvt] = other._x[iEvt];
110  _y[iEvt] = other._y[iEvt];
111  _hx[iEvt] = other._hx[iEvt];
112  _hy[iEvt] = other._hy[iEvt];
113  }
114 }
115 
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 /// Destructor.
119 
121  if(_verbosedebug) { cout << "Roo2DKeysPdf::Roo2KeysPdf dtor" << endl; }
122  delete[] _x;
123  delete[] _hx;
124  delete[] _y;
125  delete[] _hy;
126 }
127 
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 /// Loads a new data set into the class instance.
131 /// Returns 1 in case of error, 0 otherwise.
132 /// \param[in] data
133 /// \param[in] options
134 
136 {
137  if(_verbosedebug) { cout << "Roo2DKeysPdf::loadDataSet" << endl; }
138 
139  setOptions(options);
140 
141  if(_verbosedebug) { cout << "Roo2DKeysPdf::loadDataSet(RooDataSet& data, TString options)" << endl; }
142 
143  _2pi = 2.0*TMath::Pi() ; //use pi from math.h
144  _sqrt2pi = sqrt(_2pi);
145  _nEvents = (Int_t)data.numEntries();
146  if(_nEvents == 0)
147  {
148  cout << "ERROR: Roo2DKeysPdf::loadDataSet The input data set is empty. Unable to begin generating the PDF" << endl;
149  return 1;
150  }
151  _n16 = TMath::Power(_nEvents, -0.166666666); // = (4/[n(dim(R) + 2)])^1/(dim(R)+4); dim(R) = 2
152 
153  _lox = x.min();
154  _hix = x.max();
155  _loy = y.min();
156  _hiy = y.max();
157 
158  _x = new Double_t[_nEvents];
159  _y = new Double_t[_nEvents];
160  _hx = new Double_t[_nEvents];
161  _hy = new Double_t[_nEvents];
162 
163  Double_t x0 = 0.0;
164  Double_t x1 = 0.0;
165  Double_t x_2 = 0.0;
166  Double_t y0 = 0.0;
167  Double_t y1 = 0.0;
168  Double_t y_2 = 0.0;
169 
170  //check that the data contain the variable we are interested in
171  Int_t bad = 0;
172  const RooAbsReal & xx = x.arg();
173  const RooAbsReal & yy = y.arg();
174  if(! (RooRealVar*)( (RooArgSet*)data.get(0) )->find( xx.GetName() ) )
175  {
176  cout << "Roo2DKeysPdf::Roo2DKeysPdf invalid RooAbsReal name: "<<xx.GetName()<<" not in the data set" <<endl;
177  bad = 1;
178  }
179  if(! (RooRealVar*)( (RooArgSet*)data.get(0) )->find( yy.GetName() ) )
180  {
181  cout << "Roo2DKeysPdf::Roo2DKeysPdf invalid RooAbsReal name: "<<yy.GetName()<<" not in the data set" << endl;
182  bad = 1;
183  }
184  if(bad)
185  {
186  cout << "Roo2DKeysPdf::Roo2DKeysPdf Unable to initilize object; incompatible RooDataSet doesn't contain"<<endl;
187  cout << " all of the RooAbsReal arguments"<<endl;
188  return 1;
189  }
190 
191  //copy the data into local arrays
192  const RooArgSet * values = data.get();
193  const RooRealVar* X = ((RooRealVar*)(values->find(xx.GetName())) ) ;
194  const RooRealVar* Y = ((RooRealVar*)(values->find(yy.GetName())) ) ;
195 
196  for (Int_t j=0;j<_nEvents;++j)
197  {
198  data.get(j) ;
199 
200  _x[j] = X->getVal() ;
201  _y[j] = Y->getVal() ;
202 
203  x0+=1; x1+=_x[j]; x_2+=_x[j]*_x[j];
204  y0+=1; y1+=_y[j]; y_2+=_y[j]*_y[j];
205  }
206 
207  //==========================================//
208  //calculate the mean and sigma for the data //
209  //==========================================//
210  if(_nEvents == 0)
211  {
212  cout << "Roo2DKeysPdf::Roo2DKeysPdf Empty data set was used; can't generate a PDF"<<endl;
213  }
214 
215  _xMean = x1/x0;
216  _xSigma = sqrt(x_2/_nEvents-_xMean*_xMean);
217 
218  _yMean = y1/y0;
219  _ySigma = sqrt(y_2/_nEvents-_yMean*_yMean);
220 
221  _n = Double_t(1)/(_2pi*_nEvents*_xSigma*_ySigma);
222 
223  //calculate the PDF
225 }
226 
227 
228 ////////////////////////////////////////////////////////////////////////////////
229 
231 {
232  if(_verbosedebug) { cout << "Roo2DKeysPdf::setOptions" << endl; }
233 
234  options.ToLower();
235  if( options.Contains("a") ) _BandWidthType = 0;
236  else _BandWidthType = 1;
237  if( options.Contains("n") ) _BandWidthType = 1;
238  else _BandWidthType = 0;
239  if( options.Contains("m") ) _MirrorAtBoundary = 1;
240  else _MirrorAtBoundary = 0;
241  if( options.Contains("d") ) _debug = 1;
242  else _debug = 0;
243  if( options.Contains("v") ) { _debug = 1; _verbosedebug = 1; }
244  else _verbosedebug = 0;
245  if( options.Contains("vv") ) { _vverbosedebug = 1; }
246  else _vverbosedebug = 0;
247 
248  if( _debug )
249  {
250  cout << "Roo2DKeysPdf::setOptions(TString options) options = "<< options << endl;
251  cout << "\t_BandWidthType = " << _BandWidthType << endl;
252  cout << "\t_MirrorAtBoundary = " << _MirrorAtBoundary << endl;
253  cout << "\t_debug = " << _debug << endl;
254  cout << "\t_verbosedebug = " << _verbosedebug << endl;
255  cout << "\t_vverbosedebug = " << _vverbosedebug << endl;
256  }
257 }
258 
259 
260 ////////////////////////////////////////////////////////////////////////////////
261 
262 void Roo2DKeysPdf::getOptions(void) const
263 {
264  cout << "Roo2DKeysPdf::getOptions(void)" << endl;
265  cout << "\t_BandWidthType = " << _BandWidthType << endl;
266  cout << "\t_MirrorAtBoundary = " << _MirrorAtBoundary << endl;
267  cout << "\t_debug = " << _debug << endl;
268  cout << "\t_verbosedebug = " << _verbosedebug << endl;
269  cout << "\t_vverbosedebug = " << _vverbosedebug << endl;
270 }
271 
272 
273 ////////////////////////////////////////////////////////////////////////////////
274 /// Calculates the kernel bandwidth for x & y and the probability look up table _p[i][j]
275 /// \param[in] kernel
276 
278 {
279  if(_verbosedebug) { cout << "Roo2DKeysPdf::calculateBandWidth(Int_t kernel)" << endl; }
280  if(kernel != -999)
281  {
282  _BandWidthType = kernel;
283  }
284 
285  Double_t h = 0.0;
286 
288  Double_t sqrtSum = sqrt( sigSum );
289  Double_t sigProd = _ySigma*_xSigma;
290  if(sigProd != 0.0) h = _n16*sqrt( sigSum/sigProd );
291  if(sqrtSum == 0)
292  {
293  cout << "Roo2DKeysPdf::calculateBandWidth The sqr(variance sum) == 0.0. " << " Your dataset represents a delta function."<<endl;
294  return 1;
295  }
296 
297  Double_t hXSigma = h * _xSigma;
298  Double_t hYSigma = h * _ySigma;
299  Double_t xhmin = hXSigma * sqrt(2.)/10; //smallest anticipated bandwidth
300  Double_t yhmin = hYSigma * sqrt(2.)/10;
301 
302  //////////////////////////////////////
303  //calculate bandwidths from the data//
304  //////////////////////////////////////
305  if(_BandWidthType == 1) //calculate a trivial bandwidth
306  {
307  cout << "Roo2DKeysPdf::calculateBandWidth Using a normal bandwidth (same for a given dimension) based on"<<endl;
308  cout << " h_j = n^{-1/6}*sigma_j for the j^th dimension and n events * "<<_widthScaleFactor<<endl;
309  Double_t hxGaussian = _n16 * _xSigma * _widthScaleFactor;
310  Double_t hyGaussian = _n16 * _ySigma * _widthScaleFactor;
311  for(Int_t j=0;j<_nEvents;++j)
312  {
313  _hx[j] = hxGaussian;
314  _hy[j] = hyGaussian;
315  if(_hx[j]<xhmin) _hx[j] = xhmin;
316  if(_hy[j]<yhmin) _hy[j] = yhmin;
317  }
318  }
319  else //use an adaptive bandwidth to reduce the dependence on global data distribution
320  {
321  cout << "Roo2DKeysPdf::calculateBandWidth Using an adaptive bandwidth (in general different for all events) [default]"<<endl;
322  cout << " scaled by a factor of "<<_widthScaleFactor<<endl;
323  Double_t xnorm = h * TMath::Power(_xSigma/sqrtSum, 1.5) * _widthScaleFactor;
324  Double_t ynorm = h * TMath::Power(_ySigma/sqrtSum, 1.5) * _widthScaleFactor;
325  for(Int_t j=0;j<_nEvents;++j)
326  {
327  Double_t f_ti = TMath::Power( g(_x[j], _x, hXSigma, _y[j], _y, hYSigma), -0.25 ) ;
328  _hx[j] = xnorm * f_ti;
329  _hy[j] = ynorm * f_ti;
330  if(_hx[j]<xhmin) _hx[j] = xhmin;
331  if(_hy[j]<yhmin) _hy[j] = yhmin;
332  }
333  }
334 
335  return 0;
336 }
337 
338 
339 ////////////////////////////////////////////////////////////////////////////////
340 /// Evaluates the kernel estimation for x,y, interpolating between the points if necessary
341 ///
342 /// Uses the caching intrinsic in RFC to bypass the grid and remove
343 /// the grid and extrapolation approximation in the kernel estimation method
344 /// implementation.
345 
347 {
348  if(_vverbosedebug) { cout << "Roo2DKeysPdf::evaluate()" << endl; }
349  return evaluateFull(x,y);
350 }
351 
352 
353 ////////////////////////////////////////////////////////////////////////////////
354 /// Evaluates the sum of the product of the 2D kernels
355 /// for use in calculating the fixed kernel estimate, f,
356 /// given the bandwidths _hx[j] and _hy[j].
357 ///
358 /// _n is calculated once in the constructor.
359 /// \param[in] thisX
360 /// \param[in] thisY
361 
363 {
364  if( _vverbosedebug ) { cout << "Roo2DKeysPdf::evaluateFull()" << endl; }
365 
366  Double_t f=0.0;
367 
368  Double_t rx2, ry2, zx, zy;
369  if( _MirrorAtBoundary )
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 
416 {
417  if(_vverbosedebug) { cout << "Roo2DKeysPdf::highBoundaryCorrection" << endl; }
418 
419  if(thisH == 0.0) return 0.0;
420  Double_t correction = (thisVar + tVar - 2.0* high )/thisH;
421  return exp(-0.5*correction*correction)/thisH;
422 }
423 
424 
425 ////////////////////////////////////////////////////////////////////////////////
426 
428 {
429  if(_vverbosedebug) { cout << "Roo2DKeysPdf::lowBoundaryCorrection" << endl; }
430 
431  if(thisH == 0.0) return 0.0;
432  Double_t 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 
447 Double_t Roo2DKeysPdf::g(Double_t varMean1, Double_t * _var1, Double_t sigma1, Double_t varMean2, Double_t * _var2, Double_t sigma2) const
448 {
449  if((_nEvents == 0.0) || (sigma1 == 0.0) || (sigma2 == 0)) return 0.0;
450 
451  Double_t c1 = -1.0/(2.0*sigma1*sigma1);
452  Double_t c2 = -1.0/(2.0*sigma2*sigma2);
453  Double_t d = 4.0*c1*c2 /(_sqrt2pi*_nEvents);
454  Double_t z = 0.0;
455 
456  for (Int_t i = 0; i < _nEvents; ++i)
457  {
458  Double_t r1 = _var1[i] - varMean1;
459  Double_t 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) cout << "The Bandwidth Type selected is Trivial" << endl;
472  else cout << "The Bandwidth Type selected is Adaptive" << endl;
473 
474  return _BandWidthType;
475 }
476 
477 
478 ////////////////////////////////////////////////////////////////////////////////
479 
480 Double_t 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  cout << "Roo2DKeysPdf::getMean unknown axis "<<axis<<endl;
487  }
488  return 0.0;
489 }
490 
491 
492 ////////////////////////////////////////////////////////////////////////////////
493 
494 Double_t 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  cout << "Roo2DKeysPdf::getSigma unknown axis "<<axis<<endl;
501  }
502  return 0.0;
503 }
504 
505 
506 
507 ////////////////////////////////////////////////////////////////////////////////
508 
509 void 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 
526 void Roo2DKeysPdf::writeHistToFile(char * outputFile, const char * histName) const
527 {
528  TFile * file = 0;
529  cout << "Roo2DKeysPdf::writeHistToFile This member function is temporarily disabled" <<endl;
530  //make sure that any existing file is not over written
531  file = new TFile(outputFile, "UPDATE");
532  if (!file)
533  {
534  cout << "Roo2DKeysPdf::writeHistToFile unable to open file "<< outputFile <<endl;
535  return;
536  }
537 
538 
539  const RooAbsReal & xx = x.arg();
540  const RooAbsReal & yy = y.arg();
541  RooArgSet values( RooArgList( xx, yy ));
542  RooRealVar * xArg = ((RooRealVar*)(values.find(xx.GetName())) ) ;
543  RooRealVar * yArg = ((RooRealVar*)(values.find(yy.GetName())) ) ;
544 
545  TH2F * hist = (TH2F*)xArg->createHistogram("hist", *yArg);
546  hist = (TH2F*)this->fillHistogram(hist, RooArgList(*xArg, *yArg) );
547  hist->SetName(histName);
548 
549  file->Write();
550  file->Close();
551 }
552 
553 
554 ////////////////////////////////////////////////////////////////////////////////
555 /// Saves the data and calculated bandwidths to a file,
556 /// as a record of what produced the PDF and to give a reduced
557 /// data set in order to facilitate re-calculation in the future.
558 /// \param[in] outputFile Name of the file where to store the data
559 /// \param[in] name Name of the tree which will contain the data
560 
561 void Roo2DKeysPdf::writeNTupleToFile(char * outputFile, const char * name) const
562 {
563  TFile * file = 0;
564 
565  //make sure that any existing file is not over written
566  file = new TFile(outputFile, "UPDATE");
567  if (!file)
568  {
569  cout << "Roo2DKeysPdf::writeNTupleToFile unable to open file "<< outputFile <<endl;
570  return;
571  }
572  RooAbsReal & xArg = (RooAbsReal&)x.arg();
573  RooAbsReal & yArg = (RooAbsReal&)y.arg();
574 
575  Double_t theX, theY, hx/*, hy*/;
576  TString label = name;
577  label += " the source data for 2D Keys PDF";
578  TTree * _theTree = new TTree(name, label);
579  if(!_theTree) { cout << "Unable to get a TTree for output" << endl; return; }
580  _theTree->SetAutoSave(1000000000); // autosave when 1 Gbyte written
581 
582  //name the TBranches the same as the RooAbsReal's
583  const char * xname = xArg.GetName();
584  const char * yname = yArg.GetName();
585  if (!strcmp(xname,"")) xname = "x";
586  if (!strcmp(yname,"")) yname = "y";
587 
588  _theTree->Branch(xname, &theX, " x/D");
589  _theTree->Branch(yname, &theY, " y/D");
590  _theTree->Branch("hx", &hx, " hx/D");
591  _theTree->Branch("hy", &hx, " hy/D");
592 
593  for(Int_t iEvt = 0; iEvt < _nEvents; iEvt++)
594  {
595  theX = _x[iEvt];
596  theY = _y[iEvt];
597  hx = _hx[iEvt];
598  hx = _hy[iEvt];
599  _theTree->Fill();
600  }
601  file->Write();
602  file->Close();
603 }
604 
605 
606 ////////////////////////////////////////////////////////////////////////////////
607 /// Prints out _p[_nPoints][_nPoints] indicating the domain limits.
608 /// \param[out] out Output stream where to print
609 
610 void Roo2DKeysPdf::PrintInfo(ostream & out) const
611 {
612  out << "Roo2DKeysPDF instance domain information:"<<endl;
613  out << "\tX_min = " << _lox <<endl;
614  out << "\tX_max = " << _hix <<endl;
615  out << "\tY_min = " << _loy <<endl;
616  out << "\tY_max = " << _hiy <<endl;
617 
618  out << "Data information:" << endl;
619  out << "\t<x> = " << _xMean <<endl;
620  out << "\tsigma(x) = " << _xSigma <<endl;
621  out << "\t<y> = " << _yMean <<endl;
622  out << "\tsigma(y) = " << _ySigma <<endl;
623 
624  out << "END of info for Roo2DKeys pdf instance"<< endl;
625 }
626 
627 
Double_t _ySigma
Definition: Roo2DKeysPdf.h:103
Double_t getSigma(const char *axis) const
RooRealProxy y
Definition: Roo2DKeysPdf.h:79
Int_t _vverbosedebug
Definition: Roo2DKeysPdf.h:119
Roo2DKeysPdf(const char *name, const char *title, RooAbsReal &xx, RooAbsReal &yy, RooDataSet &data, TString options="a", Double_t widthScaleFactor=1.0)
Constructor.
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 loadDataSet(RooDataSet &data, TString options)
Loads a new data set into the class instance.
Double_t * _y
Definition: Roo2DKeysPdf.h:97
Double_t _hiy
Definition: Roo2DKeysPdf.h:109
void setOptions(TString options)
return c1
Definition: legend1.C:41
Double_t _widthScaleFactor
Definition: Roo2DKeysPdf.h:112
virtual Int_t Fill()
Fill all branches.
Definition: TTree.cxx:4374
TH1 * h
Definition: legend2.C:5
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
Double_t * _x
Definition: Roo2DKeysPdf.h:95
Double_t _yMean
Definition: Roo2DKeysPdf.h:102
virtual ~Roo2DKeysPdf()
Destructor.
Double_t * _hy
Definition: Roo2DKeysPdf.h:98
virtual void SetAutoSave(Long64_t autos=-300000000)
This function may be called at the start of a program to change the default value for fAutoSave (and ...
Definition: TTree.cxx:7676
Basic string class.
Definition: TString.h:137
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1089
int Int_t
Definition: RtypesCore.h:41
STL namespace.
const RooAbsReal & arg() const
Definition: RooRealProxy.h:43
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:501
Double_t _hix
Definition: Roo2DKeysPdf.h:108
double sqrt(double)
Double_t x[n]
Definition: legend1.C:17
Int_t getBandWidthType() const
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
Double_t _n16
Definition: Roo2DKeysPdf.h:105
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 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...
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
Double_t _xSigma
Definition: Roo2DKeysPdf.h:101
Double_t _xoffset
Definition: Roo2DKeysPdf.h:110
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0)
Write memory objects to this file.
Definition: TFile.cxx:2268
tomato 2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:255
Double_t lowBoundaryCorrection(Double_t thisVar, Double_t thisH, Double_t low, Double_t tVar) const
unsigned int r1[N_CITIES]
Definition: simanTSP.cxx:321
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:269
void writeToFile(char *outputFile, const char *name) const
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
Int_t _BandWidthType
Definition: Roo2DKeysPdf.h:115
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
Double_t getMean(const char *axis) const
TH1 * fillHistogram(TH1 *hist, const RooArgList &plotVars, Double_t scaleFactor=1, const RooArgSet *projectedVars=0, Bool_t scaling=kTRUE, const RooArgSet *condObs=0, Bool_t setError=kTRUE) const
Fill the ROOT histogram &#39;hist&#39; with values sampled from this function at the bin centers.
Double_t Pi()
Definition: TMath.h:44
virtual void SetName(const char *name)
Change the name of this histogram.
Definition: TH1.cxx:8028
Double_t _lox
Definition: Roo2DKeysPdf.h:108
Double_t * _hx
Definition: Roo2DKeysPdf.h:96
Double_t _loy
Definition: Roo2DKeysPdf.h:109
Two-dimensional kernel estimation PDF.
Definition: Roo2DKeysPdf.h:25
return c2
Definition: legend2.C:14
static const double x1[5]
#define ClassImp(name)
Definition: Rtypes.h:279
double f(double x)
double Double_t
Definition: RtypesCore.h:55
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...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
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 y[n]
Definition: legend1.C:17
void PrintInfo(std::ostream &) const
Prints out _p[_nPoints][_nPoints] indicating the domain limits.
Double_t evaluate() const
Evaluates the kernel estimation for x,y, interpolating between the points if necessary.
TH1 * createHistogram(const char *name, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
Definition: TTree.cxx:1651
Int_t _verbosedebug
Definition: Roo2DKeysPdf.h:118
Double_t _sqrt2pi
Definition: Roo2DKeysPdf.h:106
Double_t _xMean
Definition: Roo2DKeysPdf.h:100
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
Double_t min(const char *rname=0) const
Definition: RooRealProxy.h:56
Definition: file.py:1
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
RooRealProxy x
Definition: Roo2DKeysPdf.h:78
A TTree object has a header with a name and a title.
Definition: TTree.h:98
Int_t _MirrorAtBoundary
Definition: Roo2DKeysPdf.h:116
double exp(double)
Double_t _n
Definition: Roo2DKeysPdf.h:104
Double_t _yoffset
Definition: Roo2DKeysPdf.h:111
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event &#39;index&#39;.
Double_t _2pi
Definition: Roo2DKeysPdf.h:107
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 max(const char *rname=0) const
Definition: RooRealProxy.h:57
unsigned int r2[N_CITIES]
Definition: simanTSP.cxx:322
char name[80]
Definition: TGX11.cxx:109
void getOptions(void) const
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:904