87 _varItr = _varList.createIterator() ;
89 TIterator* varItr = varList.createIterator() ;
92 if (!dynamic_cast<RooAbsReal*>(var)) {
94 <<
" is not of type RooAbsReal" << endl ;
98 _varName.push_back(var->
GetName());
112 _varList(
"varList",
"List of variables",this),
117 _weights(&_weights0),
125 if (!dynamic_cast<RooAbsReal*>(var)) {
127 <<
" is not of type RooAbsReal" << endl ;
137 coutE(
InputArguments) <<
"ERROR: RhhNDKeysPdf::RhhNDKeysPdf() : The vector-size of rho is different from that of varList." 138 <<
"Unable to create the PDF." << endl;
160 _varList(
"varList",
"List of variables",this),
175 coutW(
InputArguments) <<
"RooNDKeysPdf::RooNDKeysPdf() : Warning : asymmetric mirror(s) no longer supported." << endl;
191 _varList(
"varList",
"List of variables",this),
375 <<
"\n\tbandWidthType = " <<
_options.Contains(
"a")
377 <<
"\n\tdebug = " <<
_debug 383 <<
"Calculated normalization could be too large." 407 coutE(
InputArguments) <<
"ERROR: RooNDKeysPdf::initialize() : The observable list is empty. " 408 <<
"Unable to begin generating the PDF." << endl;
413 coutE(
InputArguments) <<
"ERROR: RooNDKeysPdf::initialize() : The input data set is empty. " 414 <<
"Unable to begin generating the PDF." << endl;
489 vector<RooRealVar*> dVars(
_nDim);
500 vector<Double_t>& point =
_dataPts[i];
509 mat(j,k) += dVars[j]->getVal() * dVars[k]->getVal() * myweight;
513 point[j] = pointV[j] = dVars[j]->getVal();
515 _x0[j] += 1. * myweight;
516 _x1[j] += point[j] * myweight ;
517 _x2[j] += point[j] * point[j] * myweight ;
518 if (
_x2[j]!=
_x2[j]) exit(3);
541 covMatRho(j,k) = (mat(j,k)/
_x0[j] - _mean[j]*_mean[k]) *
_rho[j] *
_rho[k];
583 for (
Int_t j=0; j<
_nDim; j++) { sigmaRraw[j] =
sqrt(sigmaRraw[j]); }
596 coutI(
Contents) <<
"RooNDKeysPdf::loadDataSet(" <<
this <<
")" 597 <<
"\n Number of events in dataset: " << _nEvents
598 <<
"\n Weighted number of events in dataset: " <<
_nEventsW 622 vector<Double_t>
dummy(_nDim,0.);
629 vector<vector<Double_t> > mpoints(size,dummy);
630 vector<vector<Int_t> > mjdcs(size);
635 vector<Int_t>& mjdxK = mjdcs[0];
636 vector<Double_t>& mpointK = mpoints[0];
640 mpointK[j] = 2.*
_xDatLo[j]-x[j];
643 mpointK[j] = 2.*
_xDatHi[j]-x[j];
648 vector<Int_t>& mjdx0 = mjdcs[0];
650 if (size==1 && mjdx0.size()==0)
continue;
654 vector<Int_t>& mjdx = mjdcs[0];
655 vector<Double_t>& mpoint = mpoints[0];
658 Int_t eMir = 1 << mjdx.size();
659 vector<vector<Double_t> > epoints(eMir,x);
666 epoints[
l] = epoints[
l-size1];
668 vector<Double_t>& epoint = epoints[
l];
669 epoint[mjdx[
Int_t(mjdx.size()-1)-
m]] = mpoint[mjdx[
Int_t(mjdx.size()-1)-
m]];
675 epoints.erase(epoints.begin());
684 for (
Int_t j=0; j<
_nDim; j++) { pointR[j] = (epoints[
m])[j]; }
713 coutI(
Contents) <<
"RooNDKeysPdf::loadWeightSet(" <<
this <<
") : Number of weighted events : " <<
_wMap.size() << endl;
741 map<Int_t,Double_t>::iterator wMapItr =
_wMap.begin();
744 for (; wMapItr!=
_wMap.end(); ++wMapItr) {
745 Int_t i = (*wMapItr).first;
754 inVarRange = inVarRange &&
kTRUE;
755 }
else { inVarRange = inVarRange &&
kFALSE; }
758 inVarRangePlusShell = inVarRangePlusShell &&
kTRUE;
759 }
else { inVarRangePlusShell = inVarRangePlusShell &&
kFALSE; }
764 bi->
bIdcs.push_back(i);
768 if (inVarRangePlusShell) {
778 if (inShell) bi->
sIdcs.push_back(i);
786 <<
"\n Events in shell " << bi->
sIdcs.size()
787 <<
"\n Events in box " << bi->
bIdcs.size()
788 <<
"\n Events in box and shell " << bi->
bpsIdcs.size()
808 cxcoutD(
Eval) <<
"RooNDKeysPdf::calculatePreNorm() : " 822 vector<TVectorD>::iterator dpRItr =
_dataPtsR.begin();
827 itrVecR.push_back(
itPair(i,dpRItr));
828 }
else itrVecR.push_back(
itPair(i,dpRItr));
838 cxcoutD(
Eval) <<
"RooNDKeysPdf::sortDataIndices() : Number of sorted events : " <<
_sortTVIdcs[j].size() << endl;
848 cxcoutD(
Eval) <<
"RooNDKeysPdf::calculateBandWidth()" << endl;
854 cxcoutD(
Eval) <<
"RooNDKeysPdf::calculateBandWidth() Using static bandwidth." << endl;
860 weight[j] =
_rho[j] *
_n * (*_sigmaR)[j] ;
868 cxcoutD(
Eval) <<
"RooNDKeysPdf::calculateBandWidth() Using adaptive bandwidth." << endl;
870 double sqrt12=
sqrt(12.);
885 weight[j] = norm * f / sqrt12 ;
902 map<Int_t,Bool_t> ibMap;
908 map<Int_t,Bool_t>::iterator ibMapItr = ibMap.begin();
910 for (; ibMapItr!=ibMap.end(); ++ibMapItr) {
911 Int_t i = (*ibMapItr).first;
917 const vector<Double_t>& point =
_dataPts[i];
918 const vector<Double_t>& weight = weights[
_idx[i]];
921 (*_dx)[j] = x[j]-point[j];
930 Double_t c = 1./(2.*weight[j]*weight[j]);
935 z += (g*
_wMap[_idx[i]]);
950 for (
Int_t j=0; j<
_nDim; j++) { xRm[j] = xRp[j] = x[j]; }
961 vector<TVectorD> xvecRm(1,xRm);
962 vector<TVectorD> xvecRp(1,xRp);
964 map<Int_t,Bool_t> ibMapRT;
972 itVec::iterator it=lo;
974 if (_nDim==1) {
for (it=lo; it!=
hi; ++it) ibMap[(*it).first] =
kTRUE; }
975 else {
for (it=lo; it!=
hi; ++it) ibMapRT[(*it).first] =
kTRUE; }
979 for (it=lo; it!=
hi; ++it)
980 if (ibMapRT.find((*it).first)!=ibMapRT.end()) { ibMap[(*it).first] =
kTRUE; }
983 if (j!=_nDim-1) { ibMapRT = ibMap; }
1054 if (rangeName)
return 0 ;
1069 cxcoutD(
Eval) <<
"Calling RooNDKeysPdf::analyticalIntegral(" <<
GetName() <<
") with code " << code
1070 <<
" and rangeName " << (rangeName?rangeName:
"<none>") << endl;
1082 string rangeNameStr(rangeName) ;
1104 cxcoutD(
Eval) <<
"RooNDKeysPdf::analyticalIntegral() : Found new boundaries ... " << (rangeName?rangeName:
"<none>") << endl;
1109 if (!bi->
filled || newBounds) {
1122 cxcoutD(
Eval) <<
"RooNDKeysPdf::analyticalIntegral() : Using mirrored normalization : " << bi->
nEventsBW << endl;
1129 if (norm<0.) norm=0.;
1134 const vector<Double_t>& weight = (*_weights)[
_idx[bi->
sIdcs[i]]];
1136 vector<Double_t> chi(
_nDim,100.);
1139 if(!doInt[j])
continue;
1142 chi[j] = (x[j]-bi->
xVarLo[j])/weight[j];
1144 chi[j] = (bi->
xVarHi[j]-x[j])/weight[j];
1155 cxcoutD(
Eval) <<
"RooNDKeysPdf::analyticalIntegral() : Final normalization : " << norm <<
" " << bi->
nEventsBW << endl;
virtual Double_t getMin(const char *name=0) const
virtual const char * GetName() const
Returns name of object.
std::string GetName(const std::string &scope_name)
std::vector< itPair > itVec
TIterator * createIterator(Bool_t dir=kIterForward) const
void setOptions() const
set the configuration
std::vector< Double_t > xVarHi
std::vector< Double_t > _xVarLo
void loopRange(std::vector< Double_t > &x, std::map< Int_t, Bool_t > &ibMap) const
determine closest points to x, to loop over in evaluate()
virtual Double_t getMax(const char *name=0) const
void calculateBandWidth() const
void boxInfoInit(BoxInfo *bi, const char *rangeName, Int_t code) const
virtual TMatrixTBase< Element > & Zero()
Set matrix elements to zero.
void loadDataSet(Bool_t firstCall) const
copy the dataset and calculate some useful variables
std::vector< std::string > _varName
Bool_t matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
std::vector< Int_t > bIdcs
Double_t getVal(const RooArgSet *set=0) const
void mirrorDataSet() const
determine mirror dataset.
std::vector< Int_t > _bIdcs
std::vector< Double_t > _xDatLo
TMatrixT< Element > & T()
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
void Print(Option_t *option="") const
Print the vector as a list of elements.
std::vector< Double_t > _x1
Iterator abstract base class.
Double_t gauss(std::vector< Double_t > &x, std::vector< std::vector< Double_t > > &weights) const
loop over all closest point to x, as determined by loopRange()
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
std::vector< Double_t > _xDatHi
std::vector< Double_t > _xVarLoM3s
std::vector< std::vector< Double_t > > _weights1
std::vector< Double_t > _xVarHiM3s
void initialize() const
initialization
std::map< Int_t, Double_t > _wMap
std::map< std::pair< std::string, int >, BoxInfo * > _rangeBoxInfo
std::vector< Double_t > _xDatLo3s
virtual Double_t weight() const
Return event weight of current event.
TVectorT< Double_t > TVectorD
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
std::vector< std::vector< Double_t > > * _weights
const RooArgSet * nset() const
RooRealVar represents a fundamental (non-derived) real valued object.
TMatrixT< Double_t > TMatrixD
std::vector< Double_t > xVarHiP3s
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
std::vector< Double_t > _x
std::vector< itVec > _sortTVIdcs
Double_t Erf(Double_t x)
Computation of the error function erf(x).
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported...
Double_t evaluate() const
do not persist
TVectorT< Element > & Zero()
Set vector elements to zero.
std::vector< Double_t > xVarHiM3s
void calculatePreNorm(BoxInfo *bi) const
bi->nEventsBMSW=0.
RooNDKeysPdf(const char *name, const char *title, const RooArgList &varList, RooDataSet &data, TString options="a", Double_t rho=1, Double_t nSigma=3, Bool_t rotate=kTRUE)
Construct N-dimensional kernel estimation p.d.f.
RooDataSet is a container class to hold unbinned data.
std::vector< Double_t > _x0
const TMatrixD & GetEigenVectors() const
Generic N-dimensional implementation of a kernel estimation p.d.f.
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event 'index'.
void createPdf(Bool_t firstCall=kTRUE) const
evaluation order of constructor.
void calculateShell(BoxInfo *bi) const
determine points in +/- nSigma shell around the box determined by the variable ranges.
std::vector< Double_t > _mean
void loadWeightSet() const
std::vector< Double_t > _xVarHiP3s
const TVectorD & GetEigenValues() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
std::map< Int_t, Bool_t > _bpsIdcs
std::vector< Int_t > sIdcs
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral. ...
TMatrixTSym< Double_t > TMatrixDSym
static RooMathCoreReg dummy
std::vector< Double_t > xVarLoP3s
std::vector< Double_t > _xVarHi
std::vector< Int_t > _idx
std::pair< Int_t, VecTVecDouble::iterator > itPair
std::vector< Double_t > _xDatHi3s
std::vector< Int_t > _sIdcs
void Print(Option_t *name="") const
Print the matrix as a table of elements.
you should not use this method at all Int_t Int_t z
std::map< Int_t, Bool_t > bpsIdcs
std::vector< Int_t > bmsIdcs
std::vector< Double_t > _rho
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
virtual TObject * Next()=0
std::vector< TVectorD > _dataPtsR
std::vector< std::vector< Double_t > > _dataPts
std::vector< std::vector< Double_t > > _weights0
float type_of_call hi(const int &, const int &)
void sortDataIndices(BoxInfo *bi=0) const
sort entries, as needed for loopRange()
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
std::vector< Double_t > _xVarLoP3s
double norm(double *x, double *p)
std::vector< Double_t > _sigma
std::vector< Double_t > xVarLo
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
std::vector< Int_t > _bmsIdcs
virtual Int_t numEntries() const
std::vector< Double_t > xVarLoM3s
std::vector< Double_t > _x2