56 x(
"x",
"x dimension",this, xx),
57 y(
"y",
"y dimension",this, yy)
71 x(
"x", this, other.
x),
74 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::Roo2DKeysPdf copy ctor" << endl; }
109 _x[iEvt] = other.
_x[iEvt];
110 _y[iEvt] = other.
_y[iEvt];
111 _hx[iEvt] = other.
_hx[iEvt];
112 _hy[iEvt] = other.
_hy[iEvt];
121 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::Roo2KeysPdf dtor" << endl; }
137 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::loadDataSet" << endl; }
141 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::loadDataSet(RooDataSet& data, TString options)" << endl; }
148 cout <<
"ERROR: Roo2DKeysPdf::loadDataSet The input data set is empty. Unable to begin generating the PDF" << endl;
176 cout <<
"Roo2DKeysPdf::Roo2DKeysPdf invalid RooAbsReal name: "<<xx.
GetName()<<
" not in the data set" <<endl;
181 cout <<
"Roo2DKeysPdf::Roo2DKeysPdf invalid RooAbsReal name: "<<yy.
GetName()<<
" not in the data set" << endl;
186 cout <<
"Roo2DKeysPdf::Roo2DKeysPdf Unable to initilize object; incompatible RooDataSet doesn't contain"<<endl;
187 cout <<
" all of the RooAbsReal arguments"<<endl;
204 y0+=1; y1+=
_y[j]; y_2+=
_y[j]*
_y[j];
212 cout <<
"Roo2DKeysPdf::Roo2DKeysPdf Empty data set was used; can't generate a PDF"<<endl;
232 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::setOptions" << endl; }
250 cout <<
"Roo2DKeysPdf::setOptions(TString options) options = "<< options << endl;
253 cout <<
"\t_debug = " <<
_debug << endl;
264 cout <<
"Roo2DKeysPdf::getOptions(void)" << endl;
267 cout <<
"\t_debug = " <<
_debug << endl;
279 if(
_verbosedebug) { cout <<
"Roo2DKeysPdf::calculateBandWidth(Int_t kernel)" << endl; }
290 if(sigProd != 0.0)
h =
_n16*
sqrt( sigSum/sigProd );
293 cout <<
"Roo2DKeysPdf::calculateBandWidth The sqr(variance sum) == 0.0. " <<
" Your dataset represents a delta function."<<endl;
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;
315 if(
_hx[j]<xhmin)
_hx[j] = xhmin;
316 if(
_hy[j]<yhmin)
_hy[j] = yhmin;
321 cout <<
"Roo2DKeysPdf::calculateBandWidth Using an adaptive bandwidth (in general different for all events) [default]"<<endl;
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;
348 if(
_vverbosedebug) { cout <<
"Roo2DKeysPdf::evaluate()" << endl; }
364 if(
_vverbosedebug ) { cout <<
"Roo2DKeysPdf::evaluateFull()" << endl; }
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];
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];
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];
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];
417 if(
_vverbosedebug) { cout <<
"Roo2DKeysPdf::highBoundaryCorrection" << endl; }
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;
429 if(
_vverbosedebug) { cout <<
"Roo2DKeysPdf::lowBoundaryCorrection" << endl; }
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;
449 if((
_nEvents == 0.0) || (sigma1 == 0.0) || (sigma2 == 0))
return 0.0;
471 if(
_BandWidthType == 1) cout <<
"The Bandwidth Type selected is Trivial" << endl;
472 else cout <<
"The Bandwidth Type selected is Adaptive" << endl;
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;
486 cout <<
"Roo2DKeysPdf::getMean unknown axis "<<axis<<endl;
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;
500 cout <<
"Roo2DKeysPdf::getSigma unknown axis "<<axis<<endl;
529 cout <<
"Roo2DKeysPdf::writeHistToFile This member function is temporarily disabled" <<endl;
534 cout <<
"Roo2DKeysPdf::writeHistToFile unable to open file "<< outputFile <<endl;
569 cout <<
"Roo2DKeysPdf::writeNTupleToFile unable to open file "<< outputFile <<endl;
577 label +=
" the source data for 2D Keys PDF";
579 if(!_theTree) { cout <<
"Unable to get a TTree for output" << endl;
return; }
583 const char * xname = xArg.
GetName();
584 const char * yname = yArg.
GetName();
585 if (!strcmp(xname,
"")) xname =
"x";
586 if (!strcmp(yname,
"")) yname =
"y";
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");
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;
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;
624 out <<
"END of info for Roo2DKeys pdf instance"<< endl;
static const double x1[5]
Two-dimensional kernel estimation PDF.
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 ...
Double_t getMean(const char *axis) const
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.
void writeToFile(char *outputFile, const char *name) const
Roo2DKeysPdf(const char *name, const char *title, RooAbsReal &xx, RooAbsReal &yy, RooDataSet &data, TString options="a", Double_t widthScaleFactor=1.0)
Constructor.
Double_t getSigma(const char *axis) const
Double_t _widthScaleFactor
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_t evaluate() const
Evaluates the kernel estimation for x,y, interpolating between the points if necessary.
virtual ~Roo2DKeysPdf()
Destructor.
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 lowBoundaryCorrection(Double_t thisVar, Double_t thisH, Double_t low, Double_t tVar) const
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)
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,...
void getOptions(void) const
void setWidthScaleFactor(Double_t widthScaleFactor)
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual Int_t numEntries() const
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...
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 'hist' with values sampled from this function at the bin centers.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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.
virtual const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
RooRealVar represents a variable that can be changed from the outside.
Double_t min(const char *rname=0) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
const T & arg() const
Return reference to object held in proxy.
Double_t max(const char *rname=0) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
virtual void SetName(const char *name)
Change the name of this histogram.
2-D histogram with a float per channel (see TH1 documentation)}
virtual const char * GetName() const
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)
This function may be called at the start of a program to change the default value for fAutoSave (and ...
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.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)