75 _varList("varList","List of
variables",this),
84 _varItr = _varList.createIterator() ;
86 TIterator* varItr = varList.createIterator() ;
89 if (!dynamic_cast<RooAbsReal*>(var)) {
91 <<
" is not of type RooAbsReal" << endl ;
95 _varName.push_back(var->
GetName());
109 _varList(
"varList",
"List of variables",this),
114 _weights(&_weights0),
122 if (!dynamic_cast<RooAbsReal*>(var)) {
124 <<
" is not of type RooAbsReal" << endl ;
134 coutE(
InputArguments) <<
"ERROR: RhhNDKeysPdf::RhhNDKeysPdf() : The vector-size of rho is different from that of varList." 135 <<
"Unable to create the PDF." << endl;
156 _varList(
"varList",
"List of variables",this),
171 coutW(
InputArguments) <<
"RooNDKeysPdf::RooNDKeysPdf() : Warning : asymmetric mirror(s) no longer supported." << endl;
185 _varList(
"varList",
"List of variables",this),
359 <<
"\n\tbandWidthType = " <<
_options.Contains(
"a")
361 <<
"\n\tdebug = " <<
_debug 367 <<
"Calculated normalization could be too large." 388 coutE(
InputArguments) <<
"ERROR: RooNDKeysPdf::initialize() : The observable list is empty. " 389 <<
"Unable to begin generating the PDF." << endl;
394 coutE(
InputArguments) <<
"ERROR: RooNDKeysPdf::initialize() : The input data set is empty. " 395 <<
"Unable to begin generating the PDF." << endl;
467 vector<RooRealVar*> dVars(
_nDim);
478 vector<Double_t>& point =
_dataPts[i];
487 mat(j,k) += dVars[j]->getVal() * dVars[k]->getVal() * myweight;
491 point[j] = pointV[j] = dVars[j]->getVal();
493 _x0[j] += 1. * myweight;
494 _x1[j] += point[j] * myweight ;
495 _x2[j] += point[j] * point[j] * myweight ;
496 if (
_x2[j]!=
_x2[j]) exit(3);
519 covMatRho(j,k) = (mat(j,k)/
_x0[j] - _mean[j]*_mean[k]) *
_rho[j] *
_rho[k];
561 for (
Int_t j=0; j<
_nDim; j++) { sigmaRraw[j] =
sqrt(sigmaRraw[j]); }
574 coutI(
Contents) <<
"RooNDKeysPdf::loadDataSet(" <<
this <<
")" 575 <<
"\n Number of events in dataset: " << _nEvents
576 <<
"\n Weighted number of events in dataset: " <<
_nEventsW 597 vector<Double_t>
dummy(_nDim,0.);
604 vector<vector<Double_t> > mpoints(size,dummy);
605 vector<vector<Int_t> > mjdcs(size);
610 vector<Int_t>& mjdxK = mjdcs[0];
611 vector<Double_t>& mpointK = mpoints[0];
615 mpointK[j] = 2.*
_xDatLo[j]-x[j];
618 mpointK[j] = 2.*
_xDatHi[j]-x[j];
623 vector<Int_t>& mjdx0 = mjdcs[0];
625 if (size==1 && mjdx0.size()==0)
continue;
629 vector<Int_t>& mjdx = mjdcs[0];
630 vector<Double_t>& mpoint = mpoints[0];
633 Int_t eMir = 1 << mjdx.size();
634 vector<vector<Double_t> > epoints(eMir,x);
641 epoints[
l] = epoints[
l-size1];
643 vector<Double_t>& epoint = epoints[
l];
644 epoint[mjdx[
Int_t(mjdx.size()-1)-
m]] = mpoint[mjdx[
Int_t(mjdx.size()-1)-
m]];
650 epoints.erase(epoints.begin());
659 for (
Int_t j=0; j<
_nDim; j++) { pointR[j] = (epoints[
m])[j]; }
686 coutI(
Contents) <<
"RooNDKeysPdf::loadWeightSet(" <<
this <<
") : Number of weighted events : " <<
_wMap.size() << endl;
712 map<Int_t,Double_t>::iterator wMapItr =
_wMap.begin();
715 for (; wMapItr!=
_wMap.end(); ++wMapItr) {
716 Int_t i = (*wMapItr).first;
725 inVarRange = inVarRange &&
kTRUE;
726 }
else { inVarRange = inVarRange &&
kFALSE; }
729 inVarRangePlusShell = inVarRangePlusShell &&
kTRUE;
730 }
else { inVarRangePlusShell = inVarRangePlusShell &&
kFALSE; }
735 bi->
bIdcs.push_back(i);
739 if (inVarRangePlusShell) {
749 if (inShell) bi->
sIdcs.push_back(i);
757 <<
"\n Events in shell " << bi->
sIdcs.size()
758 <<
"\n Events in box " << bi->
bIdcs.size()
759 <<
"\n Events in box and shell " << bi->
bpsIdcs.size()
777 cxcoutD(
Eval) <<
"RooNDKeysPdf::calculatePreNorm() : " 789 vector<TVectorD>::iterator dpRItr =
_dataPtsR.begin();
794 itrVecR.push_back(
itPair(i,dpRItr));
795 }
else itrVecR.push_back(
itPair(i,dpRItr));
805 cxcoutD(
Eval) <<
"RooNDKeysPdf::sortDataIndices() : Number of sorted events : " <<
_sortTVIdcs[j].size() << endl;
813 cxcoutD(
Eval) <<
"RooNDKeysPdf::calculateBandWidth()" << endl;
819 cxcoutD(
Eval) <<
"RooNDKeysPdf::calculateBandWidth() Using static bandwidth." << endl;
825 weight[j] =
_rho[j] *
_n * (*_sigmaR)[j] ;
833 cxcoutD(
Eval) <<
"RooNDKeysPdf::calculateBandWidth() Using adaptive bandwidth." << endl;
835 double sqrt12=
sqrt(12.);
850 weight[j] = norm * f / sqrt12 ;
865 map<Int_t,Bool_t> ibMap;
871 map<Int_t,Bool_t>::iterator ibMapItr = ibMap.begin();
873 for (; ibMapItr!=ibMap.end(); ++ibMapItr) {
874 Int_t i = (*ibMapItr).first;
880 const vector<Double_t>& point =
_dataPts[i];
881 const vector<Double_t>& weight = weights[
_idx[i]];
884 (*_dx)[j] = x[j]-point[j];
893 Double_t c = 1./(2.*weight[j]*weight[j]);
898 z += (g*
_wMap[_idx[i]]);
911 for (
Int_t j=0; j<
_nDim; j++) { xRm[j] = xRp[j] = x[j]; }
922 vector<TVectorD> xvecRm(1,xRm);
923 vector<TVectorD> xvecRp(1,xRp);
925 map<Int_t,Bool_t> ibMapRT;
933 itVec::iterator it=lo;
935 if (_nDim==1) {
for (it=lo; it!=
hi; ++it) ibMap[(*it).first] =
kTRUE; }
936 else {
for (it=lo; it!=
hi; ++it) ibMapRT[(*it).first] =
kTRUE; }
940 for (it=lo; it!=
hi; ++it)
941 if (ibMapRT.find((*it).first)!=ibMapRT.end()) { ibMap[(*it).first] =
kTRUE; }
944 if (j!=_nDim-1) { ibMapRT = ibMap; }
1009 if (rangeName)
return 0 ;
1022 cxcoutD(
Eval) <<
"Calling RooNDKeysPdf::analyticalIntegral(" <<
GetName() <<
") with code " << code
1023 <<
" and rangeName " << (rangeName?rangeName:
"<none>") << endl;
1035 string rangeNameStr(rangeName) ;
1057 cxcoutD(
Eval) <<
"RooNDKeysPdf::analyticalIntegral() : Found new boundaries ... " << (rangeName?rangeName:
"<none>") << endl;
1062 if (!bi->
filled || newBounds) {
1075 cxcoutD(
Eval) <<
"RooNDKeysPdf::analyticalIntegral() : Using mirrored normalization : " << bi->
nEventsBW << endl;
1082 if (norm<0.) norm=0.;
1087 const vector<Double_t>& weight = (*_weights)[
_idx[bi->
sIdcs[i]]];
1089 vector<Double_t> chi(
_nDim,100.);
1092 if(!doInt[j])
continue;
1095 chi[j] = (x[j]-bi->
xVarLo[j])/weight[j];
1097 chi[j] = (bi->
xVarHi[j]-x[j])/weight[j];
1108 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