53 x(
"x",
"x dimension",this, xx),
54 y(
"y",
"y dimension",this, yy)
68 x(
"x", this, other.
x),
71 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::Roo2DKeysPdf copy ctor" << endl; }
106 _x[iEvt] = other.
_x[iEvt];
107 _y[iEvt] = other.
_y[iEvt];
108 _hx[iEvt] = other.
_hx[iEvt];
109 _hy[iEvt] = other.
_hy[iEvt];
118 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::Roo2KeysPdf dtor" << endl; }
134 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::loadDataSet" << endl; }
138 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::loadDataSet(RooDataSet& data, TString options)" << endl; }
145 cout <<
"ERROR: Roo2DKeysPdf::loadDataSet The input data set is empty. Unable to begin generating the PDF" << endl;
173 cout <<
"Roo2DKeysPdf::Roo2DKeysPdf invalid RooAbsReal name: "<<xx.
GetName()<<
" not in the data set" <<endl;
178 cout <<
"Roo2DKeysPdf::Roo2DKeysPdf invalid RooAbsReal name: "<<yy.
GetName()<<
" not in the data set" << endl;
183 cout <<
"Roo2DKeysPdf::Roo2DKeysPdf Unable to initialize object; incompatible RooDataSet doesn't contain"<<endl;
184 cout <<
" all of the RooAbsReal arguments"<<endl;
209 cout <<
"Roo2DKeysPdf::Roo2DKeysPdf Empty data set was used; can't generate a PDF"<<endl;
229 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::setOptions" << endl; }
247 cout <<
"Roo2DKeysPdf::setOptions(TString options) options = "<< options << endl;
250 cout <<
"\t_debug = " <<
_debug << endl;
261 cout <<
"Roo2DKeysPdf::getOptions(void)" << endl;
264 cout <<
"\t_debug = " <<
_debug << endl;
276 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::calculateBandWidth(Int_t kernel)" << endl; }
285 double sqrtSum =
sqrt( sigSum );
287 if(sigProd != 0.0)
h =
_n16*
sqrt( sigSum/sigProd );
290 cout <<
"Roo2DKeysPdf::calculateBandWidth The sqr(variance sum) == 0.0. " <<
" Your dataset represents a delta function."<<endl;
296 double xhmin = hXSigma *
sqrt(2.)/10;
297 double yhmin = hYSigma *
sqrt(2.)/10;
304 cout <<
"Roo2DKeysPdf::calculateBandWidth Using a normal bandwidth (same for a given dimension) based on"<<endl;
305 cout <<
" h_j = n^{-1/6}*sigma_j for the j^th dimension and n events * "<<
_widthScaleFactor<<endl;
312 if(
_hx[j]<xhmin)
_hx[j] = xhmin;
313 if(
_hy[j]<yhmin)
_hy[j] = yhmin;
318 cout <<
"Roo2DKeysPdf::calculateBandWidth Using an adaptive bandwidth (in general different for all events) [default]"<<endl;
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;
345 if(
_vverbosedebug) { cout <<
"Roo2DKeysPdf::evaluate()" << endl; }
361 if(
_vverbosedebug ) { cout <<
"Roo2DKeysPdf::evaluateFull()" << endl; }
365 double rx2, ry2, zx, zy;
370 rx2 = 0.0; ry2 = 0.0; zx = 0.0; zy = 0.0;
371 if(
_hx[j] != 0.0) rx2 = (thisX -
_x[j])/
_hx[j];
372 if(
_hy[j] != 0.0) ry2 = (thisY -
_y[j])/
_hy[j];
374 if(
_hx[j] != 0.0) zx =
exp(-0.5*rx2*rx2)/
_hx[j];
375 if(
_hy[j] != 0.0) zy =
exp(-0.5*ry2*ry2)/
_hy[j];
389 rx2 = 0.0; ry2 = 0.0; zx = 0.0; zy = 0.0;
390 if(
_hx[j] != 0.0) rx2 = (thisX -
_x[j])/
_hx[j];
391 if(
_hy[j] != 0.0) ry2 = (thisY -
_y[j])/
_hy[j];
393 if(
_hx[j] != 0.0) zx =
exp(-0.5*rx2*rx2)/
_hx[j];
394 if(
_hy[j] != 0.0) zy =
exp(-0.5*ry2*ry2)/
_hy[j];
414 if(
_vverbosedebug) { cout <<
"Roo2DKeysPdf::highBoundaryCorrection" << endl; }
416 if(thisH == 0.0)
return 0.0;
417 double correction = (thisVar + tVar - 2.0* high )/thisH;
418 return exp(-0.5*correction*correction)/thisH;
426 if(
_vverbosedebug) { cout <<
"Roo2DKeysPdf::lowBoundaryCorrection" << endl; }
428 if(thisH == 0.0)
return 0.0;
429 double correction = (thisVar + tVar - 2.0* low )/thisH;
430 return exp(-0.5*correction*correction)/thisH;
444double Roo2DKeysPdf::g(
double varMean1,
double * _var1,
double sigma1,
double varMean2,
double * _var2,
double sigma2)
const
446 if((
_nEvents == 0.0) || (sigma1 == 0.0) || (sigma2 == 0))
return 0.0;
448 double c1 = -1.0/(2.0*sigma1*sigma1);
449 double c2 = -1.0/(2.0*sigma2*sigma2);
455 double r1 = _var1[i] - varMean1;
456 double r2 = _var2[i] - varMean2;
468 if(
_BandWidthType == 1) cout <<
"The Bandwidth Type selected is Trivial" << endl;
469 else cout <<
"The Bandwidth Type selected is Adaptive" << endl;
479 if(!strcmp(axis,
x.
GetName()) || !strcmp(axis,
"x") || !strcmp(axis,
"X"))
return _xMean;
480 else if(!strcmp(axis,
y.
GetName()) || !strcmp(axis,
"y") || !strcmp(axis,
"Y"))
return _yMean;
483 cout <<
"Roo2DKeysPdf::getMean unknown axis "<<axis<<endl;
493 if(!strcmp(axis,
x.
GetName()) || !strcmp(axis,
"x") || !strcmp(axis,
"X"))
return _xSigma;
494 else if(!strcmp(axis,
y.
GetName()) || !strcmp(axis,
"y") || !strcmp(axis,
"Y"))
return _ySigma;
497 cout <<
"Roo2DKeysPdf::getSigma unknown axis "<<axis<<endl;
526 cout <<
"Roo2DKeysPdf::writeHistToFile This member function is temporarily disabled" <<endl;
531 cout <<
"Roo2DKeysPdf::writeHistToFile unable to open file "<< outputFile <<endl;
566 cout <<
"Roo2DKeysPdf::writeNTupleToFile unable to open file "<< outputFile <<endl;
572 double theX, theY, hx;
574 label +=
" the source data for 2D Keys PDF";
576 if(!_theTree) { cout <<
"Unable to get a TTree for output" << endl;
return; }
580 const char * xname = xArg.
GetName();
581 const char * yname = yArg.
GetName();
582 if (!strcmp(xname,
"")) xname =
"x";
583 if (!strcmp(yname,
"")) yname =
"y";
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");
609 out <<
"Roo2DKeysPDF instance domain information:"<<endl;
610 out <<
"\tX_min = " <<
_lox <<endl;
611 out <<
"\tX_max = " <<
_hix <<endl;
612 out <<
"\tY_min = " <<
_loy <<endl;
613 out <<
"\tY_max = " <<
_hiy <<endl;
615 out <<
"Data information:" << endl;
616 out <<
"\t<x> = " <<
_xMean <<endl;
617 out <<
"\tsigma(x) = " <<
_xSigma <<endl;
618 out <<
"\t<y> = " <<
_yMean <<endl;
619 out <<
"\tsigma(y) = " <<
_ySigma <<endl;
621 out <<
"END of info for Roo2DKeys pdf instance"<< endl;
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
Two-dimensional kernel estimation PDF.
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.
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 ...
void writeToFile(char *outputFile, const char *name) const
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
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.
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,...
RooAbsArg * find(const char *name) const
Find object with given name in list.
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
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
TH1 * fillHistogram(TH1 *hist, const RooArgList &plotVars, double scaleFactor=1, const RooArgSet *projectedVars=0, bool scaling=true, const RooArgSet *condObs=0, 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.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooDataSet is a container class to hold unbinned data.
RooRealVar represents a variable that can be changed from the outside.
double min(const char *rname=0) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
double max(const char *rname=0) 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.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
void SetName(const char *name) override
Change the name of this histogram.
2-D histogram with a float per channel (see TH1 documentation)}
const char * GetName() const override
Returns name of object.
void ToLower()
Change string to lower-case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
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...
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.
RVec< PromoteType< T > > exp(const RVec< T > &v)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.