92 std::set<std::string> arguments;
94 for (
size_t i = 0; i <
expr.size(); ++i) {
106 if (
expr[i] ==
'(') {
112 arguments.insert(arg);
122template <
class RooArg_t>
128 if (!
p.has_child(
"expression")) {
131 TString formula(
p[
"expression"].val());
226 obs->GetName() +
"' as indicated by parent RooBinSamplingPdf '" +
name +
230 if (!
p.has_child(
"epsilon")) {
233 double epsilon(
p[
"epsilon"].val_double());
248 if (
p.has_child(
"extended") &&
p[
"extended"].val_bool()) {
267template <
class RooArg_t>
273 if (!
p.has_child(
"coefficients")) {
280 for (
const auto &coef :
p[
"coefficients"].children()) {
284 if (order == 0 && coef.val() ==
"1.0") {
286 }
else if (coefs.empty() && coef.val() ==
"0.0") {
358 if (
p.has_child(
"normalization")) {
365 domain =
p[
"domain"].val();
381 Int_t order =
p[
"order"].val_int();
382 double eps =
p[
"eps"].val_double();
383 if (
p.has_child(
"normalization")) {
400 Int_t order =
p[
"ipOrder"].val_int();
403 if (
p.has_child(
"conv_func")) {
420 if (
p.has_child(
"range")) {
439 const std::string
muName =
p[
"mu"].val();
440 const std::string
sigmaName =
p[
"sigma"].val();
506 if (!
p.has_child(
"coefficients")) {
513 for (
const auto &coef :
p[
"coefficients"].children()) {
517 if (order == 0 && coef.val() ==
"1.0") {
519 }
else if (coefs.empty() && coef.val() ==
"0.0") {
537 bool has_cov =
p.has_child(
"covariances");
538 bool has_corr =
p.has_child(
"correlations") &&
p.has_child(
"standard_deviations");
546 int n =
p[
"covariances"].num_children();
549 for (
const auto &row :
p[
"covariances"].children()) {
551 for (
const auto &val : row.children()) {
552 covmat(i,
j) = val.val_double();
559 for (
const auto &
v :
p[
"standard_deviations"].children()) {
564 for (
const auto &row :
p[
"correlations"].children()) {
566 for (
const auto &val : row.children()) {
585 if (!
p.has_child(
"axes")) {
586 std::stringstream
ss;
587 ss <<
"No axes given in '" <<
name <<
"'"
588 <<
". Using default binning (uniform; nbins=100). If needed, export the Workspace to JSON with a newer "
589 <<
"Root version that supports custom ParamHistFunc binnings(>=6.38.00)." << std::endl;
602 std::map<std::string, std::unique_ptr<RooRealVar>>
varMap;
606 const std::string
name = node[
"name"].val();
607 std::unique_ptr<RooRealVar> obs;
609 if (node.has_child(
"edges")) {
610 std::vector<double> edges;
611 for (
const auto &
bound : node[
"edges"].children()) {
612 edges.push_back(
bound.val_double());
614 obs = std::make_unique<RooRealVar>(
name.c_str(),
name.c_str(), edges.front(), edges.back());
615 RooBinning bins(obs->getMin(), obs->getMax());
618 obs->setBinning(bins);
620 obs = std::make_unique<RooRealVar>(
name.c_str(),
name.c_str(), node[
"min"].val_double(),
621 node[
"max"].val_double());
622 obs->setBins(node[
"nbins"].val_int());
630 for (
int i = 0; i <
varList.getSize(); ++i) {
637 vars.
addOwned(std::move(it->second));
651 if (!
p.has_child(
"x")) {
654 if (!
p.has_child(
"x0") || !
p.has_child(
"y0")) {
661 std::string
algo =
p.has_child(
"interpolation") ?
p[
"interpolation"].val() :
"poly3";
665 else if (
algo ==
"poly5")
669 "': allowed are 'poly3' and 'poly5'");
671 const bool logx =
p.has_child(
"logx") ?
p[
"logx"].val_bool() :
false;
672 const bool logy =
p.has_child(
"logy") ?
p[
"logy"].val_bool() :
false;
675 std::vector<double> x0;
676 std::vector<double>
y0;
677 x0.reserve(
p[
"x0"].num_children());
678 y0.reserve(
p[
"y0"].num_children());
680 for (
const auto &
v :
p[
"x0"].children())
681 x0.push_back(
v.val_double());
682 for (
const auto &
v :
p[
"y0"].children())
683 y0.push_back(
v.val_double());
685 if (x0.size() !=
y0.size()) {
687 ", y0 has " + std::to_string(
y0.size()));
695 std::span<const double>(
y0.data(),
y0.size()), order, logx, logy);
704template <
class RooArg_t>
707 std::string
const &key()
const override;
711 elem[
"type"] << key();
714 elem[
"extended"] << (pdf->extendMode() != RooArg_t::CanNotBeExtended);
721 std::string
const &key()
const override;
725 elem[
"type"] << key();
735 std::string
const &key()
const override;
739 elem[
"type"] << key();
748 std::string
const &key()
const override;
752 elem[
"type"] << key();
754 tool->exportHisto(*
dh.get(),
dh.numEntries(),
dh.weightArray(),
elem[
"data"].set_map());
764 if (!
p.has_child(
"data")) {
767 std::unique_ptr<RooDataHist> dataHist =
776 std::string
const &key()
const override;
780 elem[
"type"] << key();
782 tool->exportHisto(*
dh.get(),
dh.numEntries(),
dh.weightArray(),
elem[
"data"].set_map());
792 if (!
p.has_child(
"data")) {
795 std::unique_ptr<RooDataHist> dataHist =
804 std::string
const &key()
const override;
808 elem[
"type"] << key();
809 elem[
"pdf"] << pdf->
pdf().GetName();
818 std::string
const &key()
const override;
822 elem[
"type"] << key();
829template <
class RooArg_t>
832 std::string
const &key()
const override;
836 elem[
"type"] << key();
837 TString expression(pdf->expression());
845 for (
size_t idx = pdf->nParameters(); idx--;) {
846 const RooAbsArg *par = pdf->getParameter(idx);
847 expression.ReplaceAll((
"x[" + std::to_string(idx) +
"]").c_str(), par->
GetName());
848 expression.ReplaceAll((
"@" + std::to_string(idx)).c_str(), par->
GetName());
850 elem[
"expression"] << expression.Data();
857 expr.ReplaceAll(
"TMath::Exp",
"exp");
858 expr.ReplaceAll(
"TMath::Min",
"min");
859 expr.ReplaceAll(
"TMath::Max",
"max");
860 expr.ReplaceAll(
"TMath::Log",
"log");
861 expr.ReplaceAll(
"TMath::Cos",
"cos");
862 expr.ReplaceAll(
"TMath::Sin",
"sin");
863 expr.ReplaceAll(
"TMath::Sqrt",
"sqrt");
864 expr.ReplaceAll(
"TMath::Power",
"pow");
865 expr.ReplaceAll(
"TMath::Erf",
"erf");
874 elem[
"x"] << pdf->x().GetName();
875 auto &coefs =
elem[
"coefficients"].set_seq();
876 for (
int i = 0; i < pdf->lowestOrder(); ++i) {
877 coefs.append_child() << (i == 0 ?
"1.0" :
"0.0");
879 for (
const auto &coef : pdf->coefList()) {
880 coefs.append_child() << coef->GetName();
884template <
class RooArg_t>
887 std::string
const &key()
const override;
890 elem[
"type"] << key();
898 std::string
const &key()
const override;
901 elem[
"type"] << key();
909 std::string
const &key()
const override;
912 auto *pdf =
static_cast<const RooPoisson *
>(func);
913 elem[
"type"] << key();
914 elem[
"x"] << pdf->getX().GetName();
915 elem[
"mean"] << pdf->getMean().GetName();
916 elem[
"integer"] << !pdf->getNoRounding();
923 std::string
const &key()
const override;
926 auto *pdf =
static_cast<const RooDecay *
>(func);
927 elem[
"type"] << key();
928 elem[
"t"] << pdf->getT().GetName();
929 elem[
"tau"] << pdf->getTau().GetName();
930 elem[
"resolutionModel"] << pdf->getModel().GetName();
931 elem[
"decayType"] << pdf->getDecayType();
939 std::string
const &key()
const override;
943 elem[
"type"] << key();
944 elem[
"x"] << pdf->convVar().GetName();
952 std::string
const &key()
const override;
956 elem[
"type"] << key();
957 elem[
"x"] << pdf->convVar().GetName();
958 elem[
"mean"] << pdf->getMean().GetName();
959 elem[
"sigma"] << pdf->getSigma().GetName();
966 std::string
const &key()
const override;
971 elem[
"type"] << key();
972 elem[
"x"] << pdf->getX().GetName();
974 auto &m0 = pdf->getMedian();
975 auto &k = pdf->getShapeK();
977 if (pdf->useStandardParametrization()) {
978 elem[
"mu"] << m0.GetName();
979 elem[
"sigma"] << k.GetName();
981 elem[
"mu"] <<
tool->exportTransformed(&m0,
"_lognormal_log",
"log(%s)");
982 elem[
"sigma"] <<
tool->exportTransformed(&k,
"_lognormal_log",
"log(%s)");
991 std::string
const &key()
const override;
995 elem[
"type"] << key();
996 elem[
"x"] << pdf->variable().GetName();
997 auto &
c = pdf->coefficient();
998 if (pdf->negateCoefficient()) {
999 elem[
"c"] <<
c.GetName();
1001 elem[
"c"] <<
tool->exportTransformed(&
c,
"_exponential_inverted",
"-%s");
1010 std::string
const &key()
const override;
1014 elem[
"type"] << key();
1017 elem[
"covariances"].fill_mat(pdf->covarianceMatrix());
1024 std::string
const &key()
const override;
1028 elem[
"type"] << key();
1030 TString formula(pdf->function().GetExpFormula());
1031 formula.ReplaceAll(
"x", pdf->observables()[0].GetName());
1032 formula.ReplaceAll(
"y", pdf->observables()[1].GetName());
1033 formula.ReplaceAll(
"z", pdf->observables()[2].GetName());
1034 for (
size_t i = 0; i < pdf->parameters().
size(); ++i) {
1036 formula.ReplaceAll(
pname, pdf->parameters()[i].GetName());
1038 elem[
"expression"] << formula.Data();
1045 std::string
const &key()
const override;
1049 elem[
"type"] << key();
1050 elem[
"x"] << pdf->getX().GetName();
1051 elem[
"function"] << pdf->getFunc().GetName();
1052 if (!pdf->getNset().empty()) {
1055 elem[
"order"] << pdf->order();
1056 elem[
"eps"] << pdf->eps();
1063 std::string
const &key()
const override;
1067 elem[
"type"] << key();
1068 std::string integrand = integral->integrand().GetName();
1070 elem[
"integrand"] << integrand;
1071 if (integral->intRange()) {
1072 elem[
"domain"] << integral->intRange();
1075 if (
RooArgSet const *funcNormSet = integral->funcNormSet()) {
1084 std::string
const &key()
const override;
1088 elem[
"type"] << key();
1089 if (
auto convFunc = pdf->getPdfConvVar()) {
1092 elem[
"conv_var"] << pdf->getConvVar().GetName();
1093 elem[
"pdf1"] << pdf->getPdf1().GetName();
1094 elem[
"pdf2"] << pdf->getPdf2().GetName();
1095 elem[
"ipOrder"] << pdf->getInterpolationOrder();
1102 std::string
const &key()
const override;
1106 elem[
"type"] << key();
1107 if (
auto rangeName = pdf->getRangeName()) {
1110 elem[
"pdf"] << pdf->pdf().GetName();
1111 elem[
"norm"] << pdf->getN().GetName();
1118 std::string
const &key()
const override;
1122 elem[
"type"] << key();
1135 std::string
name = var->GetName();
1139 auto const &binning = var->getBinning();
1140 if (binning.isUniform()) {
1141 obsNode[
"min"] << var->getMin();
1142 obsNode[
"max"] << var->getMax();
1143 obsNode[
"nbins"] << var->getBins();
1145 auto &edges =
obsNode[
"edges"].set_seq();
1146 edges.append_child() << binning.binLow(0);
1147 for (
int i = 0; i < binning.numBins(); ++i) {
1148 edges.append_child() << binning.binHigh(i);
1157 std::string
const &key()
const override;
1161 auto const *
rs =
static_cast<RooSpline const *
>(func);
1163 elem[
"type"] << key();
1166 elem[
"x"] <<
rs->x().GetName();
1170 elem[
"interpolation"] << (
rs->order() == 5 ?
"poly5" :
"poly3");
1171 elem[
"logx"] <<
rs->logx();
1172 elem[
"logy"] <<
rs->logy();
1176 auto &x0 =
elem[
"x0"].set_seq();
1177 auto &
y0 =
elem[
"y0"].set_seq();
1179 const int np =
sp.GetNp();
1180 for (
int i = 0; i <
np; ++i) {
1181 double xk = 0.0,
yk = 0.0;
1183 x0.append_child() <<
xk;
1184 y0.append_child() <<
yk;
1191#define DEFINE_EXPORTER_KEY(class_name, name) \
1192 std::string const &class_name::key() const \
1194 const static std::string keystring = name; \
#define DEFINE_EXPORTER_KEY(class_name, name)
bool endsWith(std::string_view str, std::string_view suffix)
std::string removeSuffix(std::string_view str, std::string_view suffix)
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
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 np
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value and implements functionality common to al...
RooAddModel is an efficient implementation of a sum of PDFs of the form.
Efficient implementation of a sum of PDFs of the form.
Calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
The RooBinSamplingPdf is supposed to be used as an adapter between a continuous PDF and a binned dist...
const RooAbsPdf & pdf() const
const RooAbsReal & observable() const
Returns the bin width (or volume) given a RooHistFunc.
bool divideByBinWidth() const
const RooHistFunc & histFunc() const
Implements a RooAbsBinning in terms of an array of boundary values, posing no constraints on the choi...
Container class to hold N-dimensional binned data.
Single or double sided decay function that can be analytically convolved with any RooResolutionModel ...
Represents the first, second, or third order derivative of any RooAbsReal as calculated (numerically)...
RooExtendPdf is a wrapper around an existing PDF that adds a parameteric extended likelihood term to ...
PDF for the numerical (FFT) convolution of two PDFs.
Class RooGaussModel implements a RooResolutionModel that models a Gaussian distribution.
A real-valued function sampled from a multidimensional histogram.
A probability density function sampled from a multidimensional histogram.
RooLegacyExpPoly implements a polynomial PDF of the form.
Multivariate Gaussian p.d.f.
Holds the configuration parameters of the various numeric integrators used by RooRealIntegral.
Efficient implementation of a product of PDFs of the form.
Represents the product of a given set of RooAbsReal objects.
Performs hybrid numerical/analytical integrals of RooAbsReal objects.
const RooArgList & coefList() const
const RooArgList & funcList() const
Implements a PDF constructed from a sum of functions:
const RooArgList & funcList() const
ExtendMode extendMode() const override
Returns ability of PDF to provide extended likelihood terms.
const RooArgList & coefList() const
Variable that can be changed from the outside.
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
A RooFit class for creating spline functions.
Use TF1, TF2, TF3 functions as RooFit objects.
Implements a RooResolution model that corresponds to a delta function.
const char * GetName() const override
Returns name of object.
Base class for spline implementation containing the Draw/Paint methods.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
#define STATIC_EXECUTE(MY_FUNC)