172 map<string,TH1*> histMap,
double wgt) :
197 map<string,RooDataHist*> dhistMap,
double wgt) :
228 <<
"number of dimension variables" << endl ;
279 RooAbsData(
name,title,
RooArgSet(vars,(
RooAbsArg*)
RooCmdConfig::decodeObjOnTheFly(
"RooDataHist::RooDataHist",
"IndexCat",0,0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)))
287 pc.defineObject(
"impHist",
"ImportHisto",0) ;
288 pc.defineInt(
"impDens",
"ImportHisto",0) ;
289 pc.defineObject(
"indexCat",
"IndexCat",0) ;
290 pc.defineObject(
"impSliceHist",
"ImportHistoSlice",0,0,
true) ;
291 pc.defineString(
"impSliceState",
"ImportHistoSlice",0,
"",
true) ;
292 pc.defineObject(
"impSliceDHist",
"ImportDataHistSlice",0,0,
true) ;
293 pc.defineString(
"impSliceDState",
"ImportDataHistSlice",0,
"",
true) ;
294 pc.defineDouble(
"weight",
"Weight",0,1) ;
295 pc.defineObject(
"dummy1",
"ImportDataHistSliceMany",0) ;
296 pc.defineObject(
"dummy2",
"ImportHistoSliceMany",0) ;
297 pc.defineSet(
"glObs",
"GlobalObservables",0,0) ;
298 pc.defineMutex(
"ImportHisto",
"ImportHistoSlice",
"ImportDataHistSlice") ;
299 pc.defineDependency(
"ImportHistoSlice",
"IndexCat") ;
300 pc.defineDependency(
"ImportDataHistSlice",
"IndexCat") ;
317 TH1* impHist =
static_cast<TH1*
>(
pc.getObject(
"impHist")) ;
318 bool impDens =
pc.getInt(
"impDens") ;
319 double initWgt =
pc.getDouble(
"weight") ;
320 const char* impSliceNames =
pc.getString(
"impSliceState",
"",
true) ;
321 const RooLinkedList& impSliceHistos =
pc.getObjectList(
"impSliceHist") ;
323 const char* impSliceDNames =
pc.getString(
"impSliceDState",
"",
true) ;
324 const RooLinkedList& impSliceDHistos =
pc.getObjectList(
"impSliceDHist") ;
330 importTH1(vars,*impHist,initWgt, impDens) ;
332 }
else if (indexCat) {
335 if (!impSliceHistos.
empty()) {
338 std::map<std::string,TH1*> hmap ;
340 for (
const auto& token :
ROOT::Split(impSliceNames,
",")) {
341 auto histo =
static_cast<TH1*
>(hiter.
Next());
349 std::map<std::string,RooDataHist*> dmap ;
351 for (
const auto& token :
ROOT::Split(impSliceDNames,
",")) {
405 Int_t ix(0),iy(0),iz(0) ;
406 for (ix=0 ; ix < xvar->
getBins() ; ix++) {
409 for (iy=0 ; iy < yvar->
getBins() ; iy++) {
412 for (iz=0 ; iz < zvar->
getBins() ; iz++) {
414 double bv = doDensityCorrection ?
binVolume(vset) : 1;
418 double bv = doDensityCorrection ?
binVolume(vset) : 1;
423 double bv = doDensityCorrection ?
binVolume(vset) : 1 ;
432 return first->GetDimension() ==
second->GetDimension()
436 &&
first->GetXaxis()->GetXmin() ==
second->GetXaxis()->GetXmin()
437 &&
first->GetXaxis()->GetXmax() ==
second->GetXaxis()->GetXmax()
438 && (
first->GetNbinsY() == 1 || (
first->GetYaxis()->GetXmin() ==
second->GetYaxis()->GetXmin()
439 &&
first->GetYaxis()->GetXmax() ==
second->GetYaxis()->GetXmax() ) )
440 && (
first->GetNbinsZ() == 1 || (
first->GetZaxis()->GetXmin() ==
second->GetZaxis()->GetXmin()
441 &&
first->GetZaxis()->GetXmax() ==
second->GetZaxis()->GetXmax() ) );
447 constexpr double tolerance = 1
e-6;
449 auto const& vars1 = *
h1.get();
450 auto const& vars2 = *h2.
get();
453 if(!vars1.hasSameLayout(vars2)) {
457 for(std::size_t iVar = 0; iVar < vars1.size(); ++iVar) {
458 auto * var1 =
dynamic_cast<RooRealVar*
>(vars1[iVar]);
459 auto * var2 =
dynamic_cast<RooRealVar*
>(vars2[iVar]);
462 if((!var1 && var2) || (var1 && !var2))
return false;
469 auto const& bng2 = var2->getBinning();
472 if(bng1.numBins() != bng2.numBins())
return false;
474 std::size_t nBins = bng1.
numBins();
477 for(std::size_t iBin = 0; iBin < nBins; ++iBin) {
478 double v1 = bng1.binLow(iBin);
479 double v2 = bng2.binLow(iBin);
482 double v1 = bng1.binHigh(nBins - 1);
483 double v2 = bng2.binHigh(nBins - 1);
502 for (
const auto& hiter : hmap) {
505 histo = hiter.second;
507 if (!checkConsistentAxes(histo, hiter.second)) {
508 coutE(
InputArguments) <<
"Axes of histogram " << hiter.second->GetName() <<
" are not consistent with first processed "
509 <<
"histogram " << histo->
GetName() << std::endl;
510 throw std::invalid_argument(
"Axes of inputs for RooDataHist are inconsistent");
514 if (!indexCat.
hasLabel(hiter.first)) {
516 coutI(
InputArguments) <<
"RooDataHist::importTH1Set(" <<
GetName() <<
") defining state \"" << hiter.first <<
"\" in index category " << indexCat.
GetName() << endl ;
526 <<
"number of continuous variables" << endl ;
527 throw std::invalid_argument(
"Inputs histograms for RooDataHist are not compatible with dimensions of variables.");
563 Int_t ic(0),ix(0),iy(0),iz(0) ;
564 for (ic=0 ; ic < icat->
numBins(0) ; ic++) {
567 for (ix=0 ; ix < xvar->
getBins() ; ix++) {
570 for (iy=0 ; iy < yvar->
getBins() ; iy++) {
573 for (iz=0 ; iz < zvar->
getBins() ; iz++) {
575 double bv = doDensityCorrection ?
binVolume(vset)/avgBV : 1;
579 double bv = doDensityCorrection ?
binVolume(vset)/avgBV : 1;
584 double bv = doDensityCorrection ?
binVolume(vset)/avgBV : 1;
605 for (
const auto& diter : dmap) {
607 std::string
const& label = diter.first;
610 if(!dhistForBinning) {
611 dhistForBinning = dhist;
614 if(!hasConsistentLayoutAndBinning(*dhistForBinning, *dhist)) {
616 <<
"histogram " << dhistForBinning->
GetName() << std::endl;
617 throw std::invalid_argument(
"Layout or binning of inputs for RooDataHist is inconsistent");
624 coutI(
InputArguments) <<
"RooDataHist::importDHistSet(" <<
GetName() <<
") defining state \"" << label <<
"\" in index category " << indexCat.
GetName() << endl ;
626 if (!icat->hasLabel(label)) {
627 icat->defineType(label) ;
632 for(
auto * theirVar : dynamic_range_cast<RooRealVar*>(dhistForBinning->
_vars)) {
634 if(!theirVar || !ourVar)
continue;
642 for (
const auto& diter : dmap) {
643 std::string
const& label = diter.first;
646 icat->setLabel(label.c_str()) ;
669 coutE(
InputArguments) <<
"RooDataHist::adjustBinning(" << ownName <<
") ERROR: dimension " << ourVarName
670 <<
" must be real\n";
671 throw std::logic_error(
"Incorrect type object (" + ourVarName +
672 ") passed as argument to RooDataHist::_adjustBinning. Please report this issue.");
675 const double xlo = theirVar.
getMin();
676 const double xhi = theirVar.
getMax();
681 const double tolerance = 1
e-6 *
xbins.averageBinWidth();
684 const double xloAdj =
xbins.binLow(
xbins.binNumber(xlo + tolerance));
685 const double xhiAdj =
xbins.binHigh(
xbins.binNumber(xhi - tolerance));
686 xbins.setRange(xloAdj, xhiAdj);
690 if (
true ||
fabs(xloAdj - xlo) > tolerance ||
fabs(xhiAdj - xhi) > tolerance) {
691 coutI(
DataHandling) <<
"RooDataHist::adjustBinning(" << ownName <<
"): fit range of variable " << ourVarName
692 <<
" expanded to nearest bin boundaries: [" << xlo <<
"," << xhi <<
"] --> [" << xloAdj
693 <<
"," << xhiAdj <<
"]"
706 const double tolerance = 1
e-6 *
xbins.averageBinWidth();
709 const double xloAdj =
xbins.binLow(
xbins.binNumber(xlo + tolerance));
710 const double xhiAdj =
xbins.binHigh(
xbins.binNumber(xhi - tolerance));
711 xbins.setRange(xloAdj, xhiAdj);
714 if (
fabs(xloAdj - xlo) > tolerance ||
fabs(xhiAdj - xhi) > tolerance) {
715 coutI(
DataHandling) <<
"RooDataHist::adjustBinning(" << ownName <<
"): fit range of variable " << ourVarName
716 <<
" expanded to nearest bin boundaries: [" << xlo <<
"," << xhi <<
"] --> [" << xloAdj
717 <<
"," << xhiAdj <<
"]"
761void cloneArray(
double*& ours,
const double* theirs, std::size_t
n) {
762 if (ours)
delete[] ours;
765 ours =
new double[
n];
766 std::copy(theirs, theirs+
n, ours);
770void initArray(
double*& arr, std::size_t
n,
double val) {
771 if (arr)
delete[] arr;
791 for (
unsigned int i = 0; i <
_vars.
size(); ++i) {
804 _lvbins.emplace_back(binning ? binning->
clone() :
nullptr);
813 for (
const auto var :
_vars) {
818 for (
unsigned int i = 0u; i<
n; i++) {
842 if (!fillTree) return ;
848 Int_t j(0), idx(0), tmp(ibin) ;
849 double theBinVolume(1) ;
854 theBinVolume *= arg2->getBinWidth(idx) ;
856 _binv[ibin] = theBinVolume ;
873 std::vector<double>& bounds =
_binbounds.back();
874 bounds.reserve(2 * it->numBins());
875 for (
Int_t i = 0; i < it->numBins(); ++i) {
876 bounds.push_back(it->binLow(i));
877 bounds.push_back(it->binHigh(i));
888 RooAbsData(other,newname),
RooDirItem(), _arrSize(other._arrSize), _idxMult(other._idxMult), _pbinvCache(other._pbinvCache)
899 for (
const auto rvarg :
_vars) {
952 std::size_t nStart, std::size_t nStop)
965 coutE(
DataHandling) <<
"RooDataHist::reduceEng(" <<
GetName() <<
") Couldn't deep-clone cut variable, abort," << endl ;
973 const std::size_t nevt = nStop < static_cast<std::size_t>(
numEntries()) ? nStop :
static_cast<std::size_t
>(
numEntries());
974 for (
auto i=nStart; i<nevt ; i++) {
977 bool doSelect(
true) ;
979 for (
const auto arg : *row) {
980 if (!arg->inRange(cutRange)) {
986 if (!doSelect) continue ;
988 if (!cloneVar || cloneVar->
getVal()) {
1054 if (&
_vars == &coords)
1057 std::size_t masterIdx = 0;
1059 for (
unsigned int i=0; i <
_vars.
size(); ++i) {
1066 const RooAbsArg* theVar = fast ? coords[i] : coords.
find(*internalVar);
1069 theVar = internalVar;
1079 assert(
dynamic_cast<const RooAbsReal*
>(theVar));
1080 const double val =
static_cast<const RooAbsReal*
>(theVar)->getVal();
1086 masterIdx +=
_idxMult[i] * cat->getBin(
static_cast<const char*
>(
nullptr));
1100 cout <<
"_arrSize = " <<
_arrSize << endl ;
1102 cout <<
"wgt[" << i <<
"] = " <<
_wgt[i]
1103 <<
"\tsumw2[" << i <<
"] = " << (
_sumw2 ?
_sumw2[i] : -1.)
1104 <<
"\tvol[" << i <<
"] = " <<
_binv[i] << endl ;
1128 <<
":plotOn: frame does not specify a plot variable" << endl;
1135 <<
":plotOn: dataset doesn't contain plot frame variable" << endl;
1171 if (correctForBinSize) {
1210 if (correctForBinSize) {
1254 double xval = realX.
getVal() ;
1255 double yval = realY.getVal() ;
1260 int ybinLo = ybinC-intOrder/2 - ((yval<binningY.
binCenter(ybinC))?1:0) ;
1261 int ybinM = binningY.
numBins() ;
1264 auto offsetIdx = centralIdx - idxMultY * ybinC;
1266 std::vector<double> yarr(intOrder+1);
1267 std::vector<double> xarr(intOrder+1);
1268 for (
int i=ybinLo ; i<=intOrder+ybinLo ; i++) {
1270 if (i>=0 && i<ybinM) {
1273 xarr[i-ybinLo] = binningY.
binCenter(ibin) ;
1274 }
else if (i>=ybinM) {
1276 ibin = 2*ybinM-i-1 ;
1283 auto centralIdxX = offsetIdx + idxMultY * ibin;
1288 cout <<
"RooDataHist interpolating data is" << endl ;
1290 for (
int q=0;
q<=intOrder ;
q++) cout << xarr[
q] <<
" " ;
1291 cout <<
" yarr = " ;
1292 for (
int q=0;
q<=intOrder ;
q++) cout << yarr[
q] <<
" " ;
1301 << varInfo.
nRealVars <<
" dimensions not yet implemented" << endl ;
1302 return weightFast(bin,0,correctForBinSize,cdfBoundaries) ;
1327 throw std::invalid_argument(
Form(
"RooDataHist::weightError(%s) error type Auto not allowed here",
GetName())) ;
1331 throw std::invalid_argument(
Form(
"RooDataHist::weightError(%s) error type Expected not allowed here",
GetName())) ;
1393 auto const& binning =
static_cast<RooRealVar&
>(*
_vars[iDim]).getBinning();
1396 int fbinC = binning.binNumber(xval) ;
1397 int fbinLo = fbinC-intOrder/2 - ((xval<binning.binCenter(fbinC))?1:0) ;
1398 int fbinM = binning.numBins() ;
1401 auto offsetIdx = centralIdx - idxMult * fbinC;
1403 std::vector<double> yarr(intOrder+1) ;
1404 std::vector<double> xarr(intOrder+1);
1405 for (
int i=fbinLo ; i<=intOrder+fbinLo ; i++) {
1407 if (i>=0 && i<fbinM) {
1410 xarr[i-fbinLo] = binning.binCenter(ibin) ;
1411 auto idx = offsetIdx + idxMult * ibin;
1412 yarr[i - fbinLo] =
get_wgt(idx);
1413 if (correctForBinSize) yarr[i-fbinLo] /=
_binv[idx] ;
1414 }
else if (i>=fbinM) {
1416 ibin = 2*fbinM-i-1 ;
1417 if (cdfBoundaries) {
1418 xarr[i-fbinLo] = binning.highBound()+1
e-10*(i-fbinM+1) ;
1419 yarr[i-fbinLo] = 1.0 ;
1421 auto idx = offsetIdx + idxMult * ibin;
1422 xarr[i-fbinLo] = 2*binning.highBound()-binning.binCenter(ibin) ;
1423 yarr[i - fbinLo] =
get_wgt(idx);
1424 if (correctForBinSize)
1425 yarr[i - fbinLo] /=
_binv[idx];
1430 if (cdfBoundaries) {
1431 xarr[i-fbinLo] = binning.lowBound()-ibin*(1
e-10) ; ;
1432 yarr[i-fbinLo] = 0.0 ;
1434 auto idx = offsetIdx + idxMult * ibin;
1435 xarr[i-fbinLo] = 2*binning.lowBound()-binning.binCenter(ibin) ;
1436 yarr[i - fbinLo] =
get_wgt(idx);
1437 if (correctForBinSize)
1438 yarr[i - fbinLo] /=
_binv[idx];
1459 if ((sumw2 > 0. || wgt != 1.) && !
_sumw2) {
1470 if (
_sumw2)
_sumw2[idx] += (sumw2 > 0 ? sumw2 : wgt*wgt);
1512 if (wgtErr > 0. && !
_sumw2) {
1519 _wgt[binNumber] = wgt ;
1534 if (
_curIndex == std::numeric_limits<std::size_t>::max()) {
1561 add(dset,&cutVar,wgt) ;
1592 if (!cloneVar || cloneVar->
getVal()) {
1625 const double theBinVolume = correctForBinSize ? (inverseBinCor ? 1/
_binv[i] :
_binv[i]) : 1.0 ;
1626 kahanSum +=
get_wgt(i) * theBinVolume;
1657 sliceOnlySet.
remove(sumSet,
true,
true) ;
1660 std::vector<double>
const * pbinv =
nullptr;
1662 if(correctForBinSize && inverseBinCor) {
1664 }
else if(correctForBinSize && !inverseBinCor) {
1672 for (
unsigned int i = 0; i <
_vars.
size(); ++i) {
1676 if (sumSet.
find(*arg)) {
1680 refBin[i] = argLv->
getBin();
1688 std::size_t tmpibin = ibin;
1692 for (
unsigned int ivar = 0; !skip && ivar <
_vars.
size(); ++ivar) {
1695 if (
mask[ivar] && idx!=refBin[ivar])
1700 const double theBinVolume = correctForBinSize ? (inverseBinCor ? 1/(*pbinv)[ibin] : (*pbinv)[ibin] ) : 1.0 ;
1727 bool correctForBinSize,
bool inverseBinCor,
1728 const std::map<
const RooAbsArg*, std::pair<double, double> >& ranges,
1737 sliceOnlySet.
remove(sumSet,
true,
true);
1745 std::vector<double> rangeLo(
_vars.
getSize(), -std::numeric_limits<double>::infinity());
1746 std::vector<double> rangeHi(
_vars.
getSize(), +std::numeric_limits<double>::infinity());
1748 for (std::size_t i = 0; i <
_vars.
size(); ++i) {
1757 refBin[i] = argLV->
getBin();
1760 auto it = ranges.find(sumsetv ? sumsetv : slicesetv);
1761 if (ranges.end() != it) {
1762 rangeLo[i] = it->second.first;
1763 rangeHi[i] = it->second.second;
1772 for (
int ivar = 0, tmp = ibin; !skip && ivar <
int(
_vars.
size()); ++ivar) {
1775 if (
mask[ivar] && idx!=refBin[ivar]) skip =
true;
1784 double binVolumeSumSetFull = 1.;
1785 double binVolumeSumSetInRange = 1.;
1791 const auto arg =
_vars[ivar];
1792 if (!sumSet.
find(*arg)) {
1797 const double binLo =
_binbounds[ivar][2 * idx];
1798 const double binHi =
_binbounds[ivar][2 * idx + 1];
1799 if (binHi < rangeLo[ivar] || binLo > rangeHi[ivar]) {
1801 binVolumeSumSetInRange = 0.;
1805 binVolumeSumSetFull *= binHi - binLo;
1806 binVolumeSumSetInRange *= std::min(rangeHi[ivar], binHi) - std::max(rangeLo[ivar], binLo);
1808 const double corrPartial = binVolumeSumSetInRange / binVolumeSumSetFull;
1809 if (0. == corrPartial)
continue;
1810 const double corr = correctForBinSize ? (inverseBinCor ? binVolumeSumSetFull /
_binv[ibin] : binVolumeSumSetFull ) : 1.0;
1811 total += getBinScale(ibin)*(
get_wgt(ibin) * corr * corrPartial);
1832 for (
auto const&
v :
_vars) {
1833 code += ((dimSet.
find(*
v) ? 1 : 0) << i) ;
1839 if(!pbinv.empty()) {
1846 for (std::size_t i = 0; i < selDim.size(); ++i) {
1847 selDim[i] = (code >> i) & 1 ;
1852 Int_t idx(0), tmp(ibin) ;
1853 double theBinVolume(1) ;
1854 for (
unsigned int j=0; j <
_lvvars.size(); ++j) {
1864 pbinv[ibin] = theBinVolume ;
1899 if (cutSpec==0 && cutRange==0) {
1919 if (select)
delete select ;
2006 coutE(
InputArguments) <<
"RooDataHist::sliceIterator() variable " << sliceArg.
GetName() <<
" is not part of this RooDataHist" << endl ;
2053 for (
const auto arg :
_vars) {
2059 os << arg->GetName() ;
2072 const double wgt =
_wgt[i];
2074 if (
fabs(std::modf(wgt, &intpart)) > 1.E-10)
2093 os <<
indent <<
" Observables " <<
_vars << endl ;
2095 os <<
indent <<
" Observables: " ;
2140 TTree* X_tree(0) ; R__b >> X_tree;
2218 for (
const auto real :
_vars) {
2220 if(info.nRealVars == 0) info.realVarIdx1 = iVar;
2221 if(info.nRealVars == 1) info.realVarIdx2 = iVar;
2230 for (
unsigned int i=0; i <
_vars.
size(); ++i) {
2239 info.initialized =
true;
static void indent(ostringstream &buf, int indent_level)
static unsigned int total
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 GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
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
virtual double binCenter(Int_t bin) const =0
Int_t numBins() const
Return number of bins.
virtual double highBound() const =0
virtual double lowBound() const =0
virtual Int_t binNumber(double x) const =0
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
Int_t numBins(const char *rangeName=nullptr) const override
Return the number of fit bins ( = number of types )
void setBin(Int_t ibin, const char *rangeName=0) override
Set category to i-th fit bin, which is the i-th registered state.
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.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, bool forceIfSizeOne=false)
Sets the value of any argument in our set that also appears in the other set.
bool allInRange(const char *rangeSpec) const
Return true if all contained object report to have their value inside the specified range.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of 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 selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
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 checkInit() const
virtual void setExternalWeightArray(const double *, const double *, const double *, const double *)
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual double weight() const =0
virtual const RooArgSet * get() const
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Interface for detailed printing of object.
void setGlobalObservables(RooArgSet const &globalObservables)
Sets the global observables stored in this data.
static StorageType defaultStorageType
RooArgSet _vars
Dimensions of this data set.
RooArgSet _cachedVars
! External variables cached with this data set
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
virtual double weightSquared() const =0
void Streamer(TBuffer &) override
Stream an object of class RooAbsData.
RooAbsDataStore * _dstore
Data storage implementation.
Abstract base class for objects that are lvalues, i.e.
virtual double 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 getMax(const char *name=0) const
Get maximum of currently defined range.
void setBin(Int_t ibin, const char *rangeName=0) override
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
virtual double getMin(const char *name=0) const
Get minimum of currently defined range.
virtual Int_t getBins(const char *name=0) const
Get number of bins of currently defined range.
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.
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.
void Streamer(TBuffer &) override
Stream an object of class TObject.
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.
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.
The RooDataHist is a container class to hold N-dimensional binned data.
double sum(bool correctForBinSize, bool inverseCorr=false) const
Return the sum of the weights of all bins in the histogram.
void dump2()
Debug stuff, should go...
double get_curWgtErrLo() const
virtual void add(const RooArgSet &row, double wgt=1.0)
Add wgt to the bin content enclosed by the coordinates passed in row.
void setAllWeights(double value)
Set all the event weight of all bins to the specified value.
Int_t _cache_sum_valid
! Is cache sum valid? Needs to be Int_t instead of CacheSumState_t for subclasses.
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...
double weightSquared() const override
Return squared weight of last bin that was requested with get().
friend class RooDataHistSliceIter
void importTH1(const RooArgList &vars, const TH1 &histo, double initWgt, bool doDensityCorrection)
Import data from given TH1/2/3 into this RooDataHist.
void printDataHistogram(std::ostream &os, RooRealVar *obs) const
TClass * IsA() const override
void SetNameTitle(const char *name, const char *title) override
Change the title of this RooDataHist.
double _cache_sum
! Cache for sum of entries ;
Int_t getIndex(const RooAbsCollection &coord, bool fast=false) const
Calculate bin number of the given coordinates.
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 weightInterpolated(const RooArgSet &bin, int intOrder, bool correctForBinSize, bool cdfBoundaries)
Return the weight at given coordinates with interpolation.
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
! Cache for arrays of partial bin volumes
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 get_curWgtErrHi() const
void weightError(double &lo, double &hi, ErrorType etype=Poisson) const override
Return the asymmetric errors on the current weight.
double * _errHi
[_arrSize] High-side error on weight array
void importTH1Set(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, TH1 * > hmap, double initWgt, bool doDensityCorrection)
Import data from given set of TH1/2/3 into this RooDataHist.
double * _binv
[_arrSize] Bin volume array
RooDataHist()
Default constructor.
ULong64_t _curIndex
Current index.
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 weight() const override
Return weight of last bin that was requested with get().
std::vector< std::vector< double > > _binbounds
! list of bin bounds per dimension
void printArgs(std::ostream &os) const override
Print argument of dataset, i.e. the observable names.
void importDHistSet(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, RooDataHist * > dmap, double initWgt)
Import data from given set of TH1/2/3 into this RooDataHist.
void _adjustBinning(RooRealVar &theirVar, const TAxis &axis, RooRealVar *ourVar, Int_t *offset)
Helper doing the actual work of adjustBinning().
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Print the details on the dataset contents.
double * _sumw2
[_arrSize] Sum of weights^2
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.
Int_t calcTreeIndex() const
Legacy overload to calculate the tree index from the current value of _vars.
~RooDataHist() override
Destructor.
bool isNonPoissonWeighted() const override
Returns true if dataset contains entries with a non-integer weight.
double get_wgt(std::size_t idx) const
void initialize(const char *binningName=0, bool fillTree=true)
Initialization procedure: allocate weights array, calculate multipliers needed for N-space to 1-dim a...
std::vector< RooAbsLValue * > _lvvars
! List of observables casted as RooAbsLValue
Int_t numEntries() const override
Return the number of bins.
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()) override
Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods.
void SetName(const char *name) override
Change the name of the RooDataHist.
std::vector< std::unique_ptr< const RooAbsBinning > > _lvbins
! List of used binnings associated with lvalues
void Streamer(TBuffer &) override
Stream an object of class RooDataHist.
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.
double * _errLo
[_arrSize] Low-side error on weight array
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 ...
double * _wgt
[_arrSize] Weight array
void printValue(std::ostream &os) const override
Print value of the dataset, i.e. the sum of weights contained in the dataset.
VarInfo const & getVarInfo()
Return reference to VarInfo struct with cached histogram variable information that is frequently used...
const RooArgSet * get() const override
Get bin centre of current bin.
double binVolume() const
Return volume of current bin.
double get_curSumW2() const
double sumEntries() const override
Sum the weights of all bins.
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories.
virtual void Streamer(TBuffer &)
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
TDirectory * _dir
! Associated directory
void appendToDir(TObject *obj, bool forceMemoryResident=false)
Append object to directory.
static const RooHistError & instance()
Return a reference to a singleton object that is created the first time this method is called.
bool getPoissonInterval(Int_t n, double &mu1, double &mu2, double nSigma=1) const
Return a confidence interval for the expected number of events given n observed (unweighted) events.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
TIterator * MakeIterator(bool forward=true) const
Create a TIterator for this list.
static double interpolate(double yArr[], Int_t nOrder, double 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.
const RooAbsBinning & getBinning(const char *name=0, bool verbose=true, bool createOnTheFly=false) const override
Return binning definition with name.
void setRange(const char *name, double min, double max)
Set a fit or plotting range.
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.
The RooStringView is a wrapper around a C-syle string that can also be constructed from a std::string...
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 Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual Int_t GetDimension() const
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Iterator abstract base class.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Mother of all ROOT objects.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Streamer(TBuffer &)
Stream a string object.
A TTree represents a columnar dataset.
RVec< PromoteType< T > > abs(const RVec< T > &v)
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
void init()
Inspect hardware capabilities, and load the optimal library for RooFit computations.
static constexpr double pc
static constexpr double second
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
const double xbins[xbins_n]
Structure to cache information on the histogram variable that is frequently used for histogram weight...