173 map<string,TH1*> histMap,
Double_t wgt) :
198 map<string,RooDataHist*> dhistMap,
Double_t wgt) :
228 coutE(InputArguments) <<
"RooDataHist::ctor(" <<
GetName() <<
") ERROR: dimension of input histogram must match "
229 <<
"number of dimension variables" << endl ;
280 RooAbsData(
name,title,
RooArgSet(vars,(
RooAbsArg*)
RooCmdConfig::decodeObjOnTheFly(
"RooDataHist::RooDataHist",
"IndexCat",0,0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)))
289 pc.
defineInt(
"impDens",
"ImportHisto",0) ;
298 pc.
defineSet(
"glObs",
"GlobalObservables",0,0) ;
299 pc.
defineMutex(
"ImportHisto",
"ImportHistoSlice",
"ImportDataHistSlice") ;
321 const char* impSliceNames = pc.
getString(
"impSliceState",
"",
kTRUE) ;
324 const char* impSliceDNames = pc.
getString(
"impSliceDState",
"",
kTRUE) ;
331 importTH1(vars,*impHist,initWgt, impDens) ;
333 }
else if (indexCat) {
336 if (impSliceHistos.
GetSize()>0) {
339 map<string,TH1*> hmap ;
341 for (
const auto& token :
ROOT::Split(impSliceNames,
",")) {
342 auto histo =
static_cast<TH1*
>(hiter.
Next());
350 map<string,RooDataHist*> dmap ;
352 for (
const auto& token :
ROOT::Split(impSliceDNames,
",")) {
381 Int_t offset[3]{0, 0, 0};
406 Int_t ix(0),iy(0),iz(0) ;
407 for (ix=0 ; ix < xvar->
getBins() ; ix++) {
410 for (iy=0 ; iy < yvar->
getBins() ; iy++) {
413 for (iz=0 ; iz < zvar->
getBins() ; iz++) {
432bool checkConsistentAxes(
const TH1*
first,
const TH1* second) {
458 for (
const auto& hiter : hmap) {
461 histo = hiter.second;
463 if (!checkConsistentAxes(histo, hiter.second)) {
464 coutE(InputArguments) <<
"Axes of histogram " << hiter.second->
GetName() <<
" are not consistent with first processed "
465 <<
"histogram " << histo->
GetName() << std::endl;
466 throw std::invalid_argument(
"Axes of inputs for RooDataHist are inconsistent");
470 if (!indexCat.
hasLabel(hiter.first)) {
472 coutI(InputArguments) <<
"RooDataHist::importTH1Set(" <<
GetName() <<
") defining state \"" << hiter.first <<
"\" in index category " << indexCat.
GetName() << endl ;
481 coutE(InputArguments) <<
"RooDataHist::importTH1Set(" <<
GetName() <<
"): dimension of input histogram must match "
482 <<
"number of continuous variables" << endl ;
483 throw std::invalid_argument(
"Inputs histograms for RooDataHist are not compatible with dimensions of variables.");
519 Int_t ic(0),ix(0),iy(0),iz(0) ;
520 for (ic=0 ; ic < icat->
numBins(0) ; ic++) {
523 for (ix=0 ; ix < xvar->
getBins() ; ix++) {
526 for (iy=0 ; iy < yvar->
getBins() ; iy++) {
529 for (iz=0 ; iz < zvar->
getBins() ; iz++) {
559 for (
const auto& diter : dmap) {
562 if (!indexCat.
hasLabel(diter.first)) {
564 coutI(InputArguments) <<
"RooDataHist::importDHistSet(" <<
GetName() <<
") defining state \"" << diter.first <<
"\" in index category " << indexCat.
GetName() << endl ;
575 for (
const auto& diter : dmap) {
579 icat->
setLabel(diter.first.c_str()) ;
597 coutE(InputArguments) <<
"RooDataHist::adjustBinning(" <<
GetName() <<
") ERROR: dimension " << ourVar->
GetName() <<
" must be real" << endl ;
601 const double xlo = theirVar.
getMin();
602 const double xhi = theirVar.
getMax();
607 const double tolerance = 1
e-6 * xbins.averageBinWidth();
610 const double xloAdj = xbins.binLow(xbins.binNumber(xlo + tolerance));
611 const double xhiAdj = xbins.binHigh(xbins.binNumber(xhi - tolerance));
612 xbins.setRange(xloAdj, xhiAdj);
616 if (
true || fabs(xloAdj - xlo) > tolerance || fabs(xhiAdj - xhi) > tolerance) {
617 coutI(DataHandling)<<
"RooDataHist::adjustBinning(" <<
GetName() <<
"): fit range of variable " << ourVar->
GetName() <<
" expanded to nearest bin boundaries: [" << xlo <<
"," << xhi <<
"] --> [" << xloAdj <<
"," << xhiAdj <<
"]" << endl;
623 *offset = xbins.rawBinNumber(xloAdj + tolerance);
629 const double tolerance = 1
e-6 * xbins.averageBinWidth();
632 const double xloAdj = xbins.binLow(xbins.binNumber(xlo + tolerance));
633 const double xhiAdj = xbins.binHigh(xbins.binNumber(xhi - tolerance));
634 xbins.setRange(xloAdj, xhiAdj);
637 if (fabs(xloAdj - xlo) > tolerance || fabs(xhiAdj - xhi) > tolerance) {
638 coutI(DataHandling)<<
"RooDataHist::adjustBinning(" <<
GetName() <<
"): fit range of variable " << ourVar->
GetName() <<
" expanded to nearest bin boundaries: [" << xlo <<
"," << xhi <<
"] --> [" << xloAdj <<
"," << xhiAdj <<
"]" << endl;
645 *offset = xbins.rawBinNumber(xloAdj + tolerance);
681void cloneArray(
double*& ours,
const double* theirs, std::size_t
n) {
682 if (ours)
delete[] ours;
685 ours =
new double[
n];
686 std::copy(theirs, theirs+
n, ours);
690void initArray(
double*& arr, std::size_t
n,
double val) {
691 if (arr)
delete[] arr;
695 std::fill(arr, arr+
n, val);
711 for (
unsigned int i = 0; i <
_vars.
size(); ++i) {
724 _lvbins.emplace_back(binning ? binning->
clone() :
nullptr);
733 for (
const auto var :
_vars) {
738 for (
unsigned int i = 0u; i<
n; i++) {
762 if (!fillTree) return ;
768 Int_t j(0), idx(0), tmp(ibin) ;
774 theBinVolume *= arg2->getBinWidth(idx) ;
776 _binv[ibin] = theBinVolume ;
791 _binbounds.push_back(std::vector<Double_t>());
793 std::vector<Double_t>& bounds =
_binbounds.back();
794 bounds.reserve(2 * it->numBins());
795 for (
Int_t i = 0; i < it->numBins(); ++i) {
796 bounds.push_back(it->binLow(i));
797 bounds.push_back(it->binHigh(i));
808 RooAbsData(other,newname),
RooDirItem(), _arrSize(other._arrSize), _idxMult(other._idxMult), _pbinvCache(other._pbinvCache)
819 for (
const auto rvarg :
_vars) {
879 delete selCacheVars ;
890 std::size_t nStart, std::size_t nStop,
Bool_t )
903 coutE(DataHandling) <<
"RooDataHist::reduceEng(" <<
GetName() <<
") Couldn't deep-clone cut variable, abort," << endl ;
911 const std::size_t nevt = nStop < static_cast<std::size_t>(
numEntries()) ? nStop :
static_cast<std::size_t
>(
numEntries());
912 for (
auto i=nStart; i<nevt ; i++) {
917 for (
const auto arg : *row) {
918 if (!arg->inRange(cutRange)) {
924 if (!doSelect) continue ;
926 if (!cloneVar || cloneVar->
getVal()) {
992 if (&
_vars == &coords)
995 std::size_t masterIdx = 0;
997 for (
unsigned int i=0; i <
_vars.
size(); ++i) {
1004 const RooAbsArg* theVar = fast ? coords[i] : coords.
find(*internalVar);
1007 theVar = internalVar;
1017 assert(
dynamic_cast<const RooAbsReal*
>(theVar));
1018 const double val =
static_cast<const RooAbsReal*
>(theVar)->getVal();
1024 masterIdx +=
_idxMult[i] * cat->
getBin(
static_cast<const char*
>(
nullptr));
1038 cout <<
"_arrSize = " <<
_arrSize << endl ;
1040 cout <<
"wgt[" << i <<
"] = " <<
_wgt[i]
1041 <<
"\tsumw2[" << i <<
"] = " << (
_sumw2 ?
_sumw2[i] : -1.)
1042 <<
"\tvol[" << i <<
"] = " <<
_binv[i] << endl ;
1066 <<
":plotOn: frame does not specify a plot variable" << endl;
1073 <<
":plotOn: dataset doesn't contain plot frame variable" << endl;
1102 coutE(InputArguments) <<
"RooDataHist::weight(" <<
GetName() <<
") ERROR: interpolation order must be positive" << endl ;
1109 if (correctForBinSize) {
1141 coutE(InputArguments) <<
"RooDataHist::weight(" <<
GetName() <<
") ERROR: interpolation order must be positive" << endl ;
1148 if (correctForBinSize) {
1192 double xval = realX.
getVal() ;
1193 double yval = realY.getVal() ;
1198 int ybinLo = ybinC-intOrder/2 - ((yval<binningY.
binCenter(ybinC))?1:0) ;
1199 int ybinM = binningY.
numBins() ;
1202 auto offsetIdx = centralIdx - idxMultY * ybinC;
1204 std::vector<double> yarr(intOrder+1);
1205 std::vector<double> xarr(intOrder+1);
1206 for (
int i=ybinLo ; i<=intOrder+ybinLo ; i++) {
1208 if (i>=0 && i<ybinM) {
1211 xarr[i-ybinLo] = binningY.
binCenter(ibin) ;
1212 }
else if (i>=ybinM) {
1214 ibin = 2*ybinM-i-1 ;
1221 auto centralIdxX = offsetIdx + idxMultY * ibin;
1226 cout <<
"RooDataHist interpolating data is" << endl ;
1228 for (
int q=0;
q<=intOrder ;
q++) cout << xarr[
q] <<
" " ;
1229 cout <<
" yarr = " ;
1230 for (
int q=0;
q<=intOrder ;
q++) cout << yarr[
q] <<
" " ;
1238 coutE(InputArguments) <<
"RooDataHist::weight(" <<
GetName() <<
") interpolation in "
1239 << varInfo.
nRealVars <<
" dimensions not yet implemented" << endl ;
1240 return weightFast(bin,0,correctForBinSize,cdfBoundaries) ;
1265 throw std::invalid_argument(
Form(
"RooDataHist::weightError(%s) error type Auto not allowed here",
GetName())) ;
1269 throw std::invalid_argument(
Form(
"RooDataHist::weightError(%s) error type Expected not allowed here",
GetName())) ;
1331 auto const& binning =
static_cast<RooRealVar&
>(*
_vars[iDim]).getBinning();
1334 int fbinC = binning.binNumber(xval) ;
1335 int fbinLo = fbinC-intOrder/2 - ((xval<binning.binCenter(fbinC))?1:0) ;
1336 int fbinM = binning.numBins() ;
1339 auto offsetIdx = centralIdx - idxMult * fbinC;
1341 std::vector<double> yarr(intOrder+1) ;
1342 std::vector<double> xarr(intOrder+1);
1343 for (
int i=fbinLo ; i<=intOrder+fbinLo ; i++) {
1345 if (i>=0 && i<fbinM) {
1348 xarr[i-fbinLo] = binning.binCenter(ibin) ;
1349 auto idx = offsetIdx + idxMult * ibin;
1350 yarr[i - fbinLo] =
get_wgt(idx);
1351 if (correctForBinSize) yarr[i-fbinLo] /=
_binv[idx] ;
1352 }
else if (i>=fbinM) {
1354 ibin = 2*fbinM-i-1 ;
1355 if (cdfBoundaries) {
1356 xarr[i-fbinLo] = binning.highBound()+1
e-10*(i-fbinM+1) ;
1357 yarr[i-fbinLo] = 1.0 ;
1359 auto idx = offsetIdx + idxMult * ibin;
1360 xarr[i-fbinLo] = 2*binning.highBound()-binning.binCenter(ibin) ;
1361 yarr[i - fbinLo] =
get_wgt(idx);
1362 if (correctForBinSize)
1363 yarr[i - fbinLo] /=
_binv[idx];
1368 if (cdfBoundaries) {
1369 xarr[i-fbinLo] = binning.lowBound()-ibin*(1
e-10) ; ;
1370 yarr[i-fbinLo] = 0.0 ;
1372 auto idx = offsetIdx + idxMult * ibin;
1373 xarr[i-fbinLo] = 2*binning.lowBound()-binning.binCenter(ibin) ;
1374 yarr[i - fbinLo] =
get_wgt(idx);
1375 if (correctForBinSize)
1376 yarr[i - fbinLo] /=
_binv[idx];
1397 if ((sumw2 > 0. || wgt != 1.) && !
_sumw2) {
1408 if (
_sumw2)
_sumw2[idx] += (sumw2 > 0 ? sumw2 : wgt*wgt);
1450 if (wgtErr > 0. && !
_sumw2) {
1457 _wgt[binNumber] = wgt ;
1472 if (
_curIndex == std::numeric_limits<std::size_t>::max()) {
1499 add(dset,&cutVar,wgt) ;
1518 coutE(DataHandling) <<
"RooDataHist::add(" <<
GetName() <<
") Couldn't deep-clone cut variable, abort," << endl ;
1530 if (!cloneVar || cloneVar->
getVal()) {
1563 const double theBinVolume = correctForBinSize ? (inverseBinCor ? 1/
_binv[i] :
_binv[i]) : 1.0 ;
1564 kahanSum +=
get_wgt(i) * theBinVolume;
1595 sliceOnlySet.
remove(sumSet,
true,
true) ;
1598 std::vector<double>
const * pbinv =
nullptr;
1600 if(correctForBinSize && inverseBinCor) {
1602 }
else if(correctForBinSize && !inverseBinCor) {
1610 for (
unsigned int i = 0; i <
_vars.
size(); ++i) {
1614 if (sumSet.
find(*arg)) {
1618 refBin[i] = argLv->
getBin();
1626 std::size_t tmpibin = ibin;
1630 for (
unsigned int ivar = 0; !skip && ivar <
_vars.
size(); ++ivar) {
1633 if (mask[ivar] && idx!=refBin[ivar])
1638 const double theBinVolume = correctForBinSize ? (inverseBinCor ? 1/(*pbinv)[ibin] : (*pbinv)[ibin] ) : 1.0 ;
1665 bool correctForBinSize,
bool inverseBinCor,
1666 const std::map<
const RooAbsArg*, std::pair<double, double> >& ranges,
1667 std::function<
double(
int)> getBinScale)
1675 sliceOnlySet.
remove(sumSet,
true,
true);
1683 std::vector<double> rangeLo(
_vars.
getSize(), -std::numeric_limits<Double_t>::infinity());
1684 std::vector<double> rangeHi(
_vars.
getSize(), +std::numeric_limits<Double_t>::infinity());
1686 for (std::size_t i = 0; i <
_vars.
size(); ++i) {
1695 refBin[i] = argLV->
getBin();
1698 auto it = ranges.find(sumsetv ? sumsetv : slicesetv);
1699 if (ranges.end() != it) {
1700 rangeLo[i] = it->second.first;
1701 rangeHi[i] = it->second.second;
1710 for (
int ivar = 0, tmp = ibin; !skip && ivar <
int(
_vars.
size()); ++ivar) {
1713 if (mask[ivar] && idx!=refBin[ivar]) skip =
true;
1723 Double_t binVolumeSumSetInRange = 1.;
1729 const auto arg =
_vars[ivar];
1730 if (!sumSet.
find(*arg)) {
1737 if (binHi < rangeLo[ivar] || binLo > rangeHi[ivar]) {
1739 binVolumeSumSetInRange = 0.;
1743 binVolumeSumSetFull *= binHi - binLo;
1744 binVolumeSumSetInRange *= std::min(rangeHi[ivar], binHi) - std::max(rangeLo[ivar], binLo);
1746 const Double_t corrPartial = binVolumeSumSetInRange / binVolumeSumSetFull;
1747 if (0. == corrPartial)
continue;
1748 const Double_t corr = correctForBinSize ? (inverseBinCor ? binVolumeSumSetFull /
_binv[ibin] : binVolumeSumSetFull ) : 1.0;
1749 total += getBinScale(ibin)*(
get_wgt(ibin) * corr * corrPartial);
1770 for (
auto const&
v :
_vars) {
1771 code += ((dimSet.
find(*
v) ? 1 : 0) << i) ;
1777 if(!pbinv.empty()) {
1784 for (std::size_t i = 0; i < selDim.size(); ++i) {
1785 selDim[i] = (code >> i) & 1 ;
1790 Int_t idx(0), tmp(ibin) ;
1792 for (
unsigned int j=0; j <
_lvvars.size(); ++j) {
1802 pbinv[ibin] = theBinVolume ;
1842 if (cutSpec==0 && cutRange==0) {
1857 || (select && select->
eval() == 0.)
1864 if (select)
delete select ;
1951 coutE(InputArguments) <<
"RooDataHist::sliceIterator() variable " << sliceArg.
GetName() <<
" is not part of this RooDataHist" << endl ;
1998 for (
const auto arg :
_vars) {
2004 os << arg->GetName() ;
2023 for (
const auto arg :
_vars) {
2024 if (!arg->inRange(
nullptr)) {
2042 const double wgt =
_wgt[i];
2044 if (fabs(std::modf(wgt, &intpart)) > 1.E-10)
2063 os <<
indent <<
" Observables " <<
_vars << endl ;
2065 os <<
indent <<
" Observables: " ;
2088void RooDataHist::Streamer(
TBuffer &R__b) {
2109 RooAbsData::Streamer(R__b);
2110 TTree* X_tree(0) ; R__b >> X_tree;
2111 RooArgSet X_truth ; X_truth.Streamer(R__b);
2112 TString X_blindString ; X_blindString.Streamer(R__b);
2122 RooDirItem::Streamer(R__b);
2139 tmpSet.Streamer(R__b);
2196 for (
const auto real :
_vars) {
2198 if(info.nRealVars == 0) info.realVarIdx1 = iVar;
2199 if(info.nRealVars == 1) info.realVarIdx2 = iVar;
2208 for (
unsigned int i=0; i <
_vars.
size(); ++i) {
2217 info.initialized =
true;
static void indent(ostringstream &buf, int indent_level)
static unsigned int total
char * Form(const char *fmt,...)
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
static KahanSum< T, N > Accumulate(Iterator begin, Iterator end, T initialValue=T{})
Iterate over a range and return an instance of a KahanSum.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
void attachDataSet(const RooAbsData &set)
Replace server nodes with names matching the dataset variable names with those data set variables,...
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual RooAbsBinning * clone(const char *name=0) const =0
Int_t numBins() const
Return number of bins.
virtual Double_t highBound() const =0
virtual Double_t binCenter(Int_t bin) const =0
virtual Int_t binNumber(Double_t x) const =0
virtual Double_t lowBound() const =0
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
virtual void setBin(Int_t ibin, const char *rangeName=0)
Set category to i-th fit bin, which is the i-th registered state.
virtual Int_t getBin(const char *=nullptr) const
Get the index of the plot bin for the current value of this category.
virtual Int_t numBins(const char *rangeName=nullptr) const
Return the number of fit bins ( = number of types )
bool hasLabel(const std::string &label) const
Check if a state with name label exists.
virtual const char * getCurrentLabel() const
Return label string of current state.
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, bool forceIfSizeOne=false)
Sets the value of any argument in our set that also appears in the other set.
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
Storage_t::size_type size() const
Bool_t allInRange(const char *rangeSpec) const
Return true if all contained object report to have their value inside the specified range.
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
virtual void setExternalWeightArray(const Double_t *, const Double_t *, const Double_t *, const Double_t *)
virtual void checkInit() const
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
void SetName(const char *name)
Set the name of the TNamed.
void setGlobalObservables(RooArgSet const &globalObservables)
Sets the global observables stored in this data.
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Interface for detailed printing of object.
virtual Double_t weight() const =0
static StorageType defaultStorageType
virtual Double_t weightSquared() const =0
virtual void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars)
Internal method – Attach dataset copied with cache contents to copied instances of functions.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
virtual RooPlot * plotOn(RooPlot *frame, 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
RooAbsDataStore * _dstore
External variables cached with this data set.
Abstract base class for objects that are lvalues, i.e.
virtual Double_t getBinWidth(Int_t i, const char *rangeName=0) const =0
virtual Int_t getBin(const char *rangeName=0) const =0
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
virtual void setBin(Int_t ibin, const char *rangeName=0)
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
virtual Int_t getBins(const char *name=0) const
Get number of bins of currently defined range.
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values,...
RooCategory is an object to represent discrete states.
bool defineType(const std::string &label)
Define a state with given name.
virtual Bool_t setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
TObject * getObject(const char *name, TObject *obj=0)
Return TObject property registered with name 'name'.
Bool_t defineInt(const char *name, const char *argName, Int_t intNum, Int_t defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
void defineMutex(const char *argName1, const char *argName2)
Define arguments named argName1 and argName2 mutually exclusive.
Bool_t defineObject(const char *name, const char *argName, Int_t setNum, const TObject *obj=0, Bool_t isArray=kFALSE)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
const char * getString(const char *name, const char *defaultValue="", Bool_t convEmptyToNull=kFALSE)
Return string property registered with name 'name'.
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
const RooLinkedList & getObjectList(const char *name)
Return list of objects registered with name 'name'.
Bool_t defineDouble(const char *name, const char *argName, Int_t doubleNum, Double_t defValue=0.)
Define Double_t property name 'name' mapped to Double_t in slot 'doubleNum' in RooCmdArg with name ar...
void defineDependency(const char *refArgName, const char *neededArgName)
Define that processing argument name refArgName requires processing of argument named neededArgName t...
Double_t getDouble(const char *name, Double_t defaultValue=0)
Return Double_t property registered with name 'name'.
Bool_t defineSet(const char *name, const char *argName, Int_t setNum, const RooArgSet *set=0)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
Bool_t defineString(const char *name, const char *argName, Int_t stringNum, const char *defValue="", Bool_t appendMode=kFALSE)
Define Double_t property name 'name' mapped to Double_t in slot 'stringNum' in RooCmdArg with name ar...
RooArgSet * getSet(const char *name, RooArgSet *set=0)
Return RooArgSet property registered with name 'name'.
Bool_t ok(Bool_t verbose) const
Return true of parsing was successful.
Bool_t process(const RooCmdArg &arg)
Process given RooCmdArg.
The RooDataHist is a container class to hold N-dimensional binned data.
void dump2()
Debug stuff, should go...
Int_t getIndex(const RooAbsCollection &coord, Bool_t fast=false) const
Calculate bin number of the given coordinates.
void initialize(const char *binningName=0, Bool_t fillTree=kTRUE)
Initialization procedure: allocate weights array, calculate multipliers needed for N-space to 1-dim a...
double interpolateDim(int iDim, double xval, size_t centralIdx, int intOrder, bool correctForBinSize, bool cdfBoundaries)
Perform boundary safe 'intOrder'-th interpolation of weights in dimension 'dim' at current value 'xva...
friend class RooDataHistSliceIter
void printDataHistogram(std::ostream &os, RooRealVar *obs) const
void SetNameTitle(const char *name, const char *title) override
Change the title of this RooDataHist.
std::vector< double > _maskedWeights
RooAbsData * reduceEng(const RooArgSet &varSubset, const RooFormulaVar *cutVar, const char *cutRange=0, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max(), Bool_t copyCache=kTRUE) override
Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods.
const std::vector< double > & calculatePartialBinVolume(const RooArgSet &dimSet) const
Fill the transient cache with partial bin volumes with up-to-date values for the partial volume speci...
Double_t weight() const override
Return weight of last bin that was requested with get().
double weightInterpolated(const RooArgSet &bin, int intOrder, bool correctForBinSize, bool cdfBoundaries)
Cache for sum of entries ;.
RooAbsData * cacheClone(const RooAbsArg *newCacheOwner, const RooArgSet *newCacheVars, const char *newName=0) override
Construct a clone of this dataset that contains only the cached variables.
RooSpan< const double > getWeightBatch(std::size_t first, std::size_t len, bool sumW2=false) const override
Return event weights of all events in range [first, first+len).
std::unordered_map< int, std::vector< double > > _pbinvCache
void checkBinBounds() const
double weight(std::size_t i) const
Return weight of i-th bin.
void set(std::size_t binNumber, double weight, double wgtErr)
Set bin content of bin that was last loaded with get(std::size_t).
Double_t sumEntries() const override
Sum the weights of all bins.
Double_t weightSquared() const override
Return squared weight of last bin that was requested with get().
virtual void add(const RooArgSet &row, Double_t wgt=1.0)
Add wgt to the bin content enclosed by the coordinates passed in row.
void weightError(double &lo, double &hi, ErrorType etype=Poisson) const override
Return the asymmetric errors on the current weight.
RooDataHist()
Default constructor.
Double_t get_curWgtErrLo() const
virtual void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const override
Print the details on the dataset contents.
ULong64_t _curIndex
Copy of _sumW2, but masked events have a weight of zero.
void importTH1Set(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, TH1 * > hmap, Double_t initWgt, Bool_t doDensityCorrection)
Import data from given set of TH1/2/3 into this RooDataHist.
double weightFast(const RooArgSet &bin, int intOrder, bool correctForBinSize, bool cdfBoundaries)
A faster version of RooDataHist::weight that assumes the passed arguments are aligned with the histog...
RooPlot * plotOn(RooPlot *frame, PlotOpt o) const override
Back end function to plotting functionality.
Double_t get_curSumW2() const
Bool_t isNonPoissonWeighted() const override
Returns true if dataset contains entries with a non-integer weight.
virtual void printArgs(std::ostream &os) const override
Print argument of dataset, i.e. the observable names.
void _adjustBinning(RooRealVar &theirVar, const TAxis &axis, RooRealVar *ourVar, Int_t *offset)
Helper doing the actual work of adjustBinning().
std::vector< std::vector< Double_t > > _binbounds
List of used binnings associated with lvalues.
TIterator * sliceIterator(RooAbsArg &sliceArg, const RooArgSet &otherArgs)
Create an iterator over all bins in a slice defined by the subset of observables listed in sliceArg.
void importTH1(const RooArgList &vars, const TH1 &histo, Double_t initWgt, Bool_t doDensityCorrection)
Import data from given TH1/2/3 into this RooDataHist.
Int_t calcTreeIndex() const
Legacy overload to calculate the tree index from the current value of _vars.
Double_t get_curWgtErrHi() const
~RooDataHist() override
Destructor.
void setAllWeights(Double_t value)
Set all the event weight of all bins to the specified value.
Double_t get_wgt(std::size_t idx) const
void importDHistSet(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, RooDataHist * > dmap, Double_t initWgt)
Import data from given set of TH1/2/3 into this RooDataHist.
std::vector< RooAbsLValue * > _lvvars
Cache for arrays of partial bin volumes.
Int_t numEntries() const override
Return the number of bins.
void cacheValidEntries()
Compute which bins of the dataset are part of the currently set fit range.
void SetName(const char *name) override
Change the name of the RooDataHist.
std::vector< std::unique_ptr< const RooAbsBinning > > _lvbins
List of observables casted as RooAbsLValue.
std::vector< Int_t > _idxMult
void registerWeightArraysToDataStore() const
Hand over pointers to our weight arrays to the data store implementation.
void reset() override
Reset all bin weights to zero.
void adjustBinning(const RooArgList &vars, const TH1 &href, Int_t *offset=0)
Adjust binning specification on first and optionally second and third observable to binning in given ...
std::vector< double > _maskedSumw2
Copy of _wgt, but masked events have a weight of zero.
CacheSumState_t
list of bin bounds per dimension
virtual void printValue(std::ostream &os) const override
Print value of the dataset, i.e. the sum of weights contained in the dataset.
Double_t _cache_sum
Is cache sum valid? Needs to be Int_t instead of CacheSumState_t for subclasses.
VarInfo const & getVarInfo()
Return reference to VarInfo struct with cached histogram variable information that is frequently used...
Double_t binVolume() const
Return volume of current bin.
const RooArgSet * get() const override
Get bin centre of current bin.
Double_t sum(bool correctForBinSize, bool inverseCorr=false) const
Return the sum of the weights of all bins in the histogram.
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories.
void appendToDir(TObject *obj, Bool_t forceMemoryResident=kFALSE)
Append object to directory.
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
Bool_t getPoissonInterval(Int_t n, Double_t &mu1, Double_t &mu2, Double_t nSigma=1) const
Return a confidence interval for the expected number of events given n observed (unweighted) events.
static const RooHistError & instance()
Return a reference to a singleton object that is created the first time this method is called.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
TIterator * MakeIterator(Bool_t forward=kTRUE) const
Create a TIterator for this list.
virtual void Add(TObject *arg)
static Double_t interpolate(Double_t yArr[], Int_t nOrder, Double_t x)
A RooPlot is a plot frame and a container for graphics objects within that frame.
RooAbsRealLValue * getPlotVar() const
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
RooRealVar represents a variable that can be changed from the outside.
void setRange(const char *name, Double_t min, Double_t max)
Set a fit or plotting range.
const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const
Return binning definition with name.
void setBinning(const RooAbsBinning &binning, const char *name=0)
Add given binning under name 'name' with this variable.
A simple container to hold a batch of data values.
constexpr std::span< T >::pointer data() const
constexpr bool empty() const noexcept
RooTreeDataStore is a TTree-backed data storage.
RooVectorDataStore uses std::vectors to store data columns.
const Double_t * GetArray() const
Class to manage histogram axis.
const TArrayD * GetXbins() const
Buffer base class used for serializing objects.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual TList * GetList() const
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t GetNbinsY() const
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual Int_t GetNbinsZ() const
virtual Int_t GetDimension() const
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual Int_t GetNbinsX() const
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Iterator abstract base class.
virtual void Add(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
A TTree represents a columnar dataset.
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Structure to cache information on the histogram variable that is frequently used for histogram weight...