93 std::set<std::string> arguments;
95 for (
size_t i = 0; i <
expr.size(); ++i) {
107 if (
expr[i] ==
'(') {
113 arguments.insert(arg);
123template <
class RooArg_t>
129 if (!
p.has_child(
"expression")) {
132 TString formula(
p[
"expression"].val());
227 obs->GetName() +
"' as indicated by parent RooBinSamplingPdf '" +
name +
231 if (!
p.has_child(
"epsilon")) {
234 double epsilon(
p[
"epsilon"].val_double());
249 if (
p.has_child(
"extended") &&
p[
"extended"].val_bool()) {
268template <
class RooArg_t>
274 if (!
p.has_child(
"coefficients")) {
281 for (
const auto &coef :
p[
"coefficients"].children()) {
285 if (order == 0 && coef.val() ==
"1.0") {
287 }
else if (coefs.empty() && coef.val() ==
"0.0") {
359 if (
p.has_child(
"normalization")) {
366 domain =
p[
"domain"].val();
382 Int_t order =
p[
"order"].val_int();
383 double eps =
p[
"eps"].val_double();
384 if (
p.has_child(
"normalization")) {
401 Int_t order =
p[
"ipOrder"].val_int();
404 if (
p.has_child(
"conv_func")) {
421 if (
p.has_child(
"range")) {
440 const std::string
muName =
p[
"mu"].val();
441 const std::string
sigmaName =
p[
"sigma"].val();
507 bool has_cov =
p.has_child(
"covariances");
508 bool has_corr =
p.has_child(
"correlations") &&
p.has_child(
"standard_deviations");
516 int n =
p[
"covariances"].num_children();
519 for (
const auto &row :
p[
"covariances"].children()) {
521 for (
const auto &val : row.children()) {
522 covmat(i,
j) = val.val_double();
529 for (
const auto &
v :
p[
"standard_deviations"].children()) {
534 for (
const auto &row :
p[
"correlations"].children()) {
536 for (
const auto &val : row.children()) {
555 if (!
p.has_child(
"axes")) {
556 std::stringstream
ss;
557 ss <<
"No axes given in '" <<
name <<
"'"
558 <<
". Using default binning (uniform; nbins=100). If needed, export the Workspace to JSON with a newer "
559 <<
"Root version that supports custom ParamHistFunc binnings(>=6.38.00)." << std::endl;
572 std::map<std::string, std::unique_ptr<RooRealVar>>
varMap;
576 const std::string
name = node[
"name"].val();
577 std::unique_ptr<RooRealVar> obs;
579 if (node.has_child(
"edges")) {
580 std::vector<double> edges;
581 for (
const auto &
bound : node[
"edges"].children()) {
582 edges.push_back(
bound.val_double());
584 obs = std::make_unique<RooRealVar>(
name.c_str(),
name.c_str(), edges.front(), edges.back());
585 RooBinning bins(obs->getMin(), obs->getMax());
588 obs->setBinning(bins);
590 obs = std::make_unique<RooRealVar>(
name.c_str(),
name.c_str(), node[
"min"].val_double(),
591 node[
"max"].val_double());
592 obs->setBins(node[
"nbins"].val_int());
606 vars.
addOwned(std::move(it->second));
620 if (!
p.has_child(
"x")) {
623 if (!
p.has_child(
"x0") || !
p.has_child(
"y0")) {
630 std::string
algo =
p.has_child(
"interpolation") ?
p[
"interpolation"].val() :
"poly3";
634 else if (
algo ==
"poly5")
638 "': allowed are 'poly3' and 'poly5'");
640 const bool logx =
p.has_child(
"logx") ?
p[
"logx"].val_bool() :
false;
641 const bool logy =
p.has_child(
"logy") ?
p[
"logy"].val_bool() :
false;
644 std::vector<double> x0;
645 std::vector<double>
y0;
646 x0.reserve(
p[
"x0"].num_children());
647 y0.reserve(
p[
"y0"].num_children());
649 for (
const auto &
v :
p[
"x0"].children())
650 x0.push_back(
v.val_double());
651 for (
const auto &
v :
p[
"y0"].children())
652 y0.push_back(
v.val_double());
654 if (x0.size() !=
y0.size()) {
656 ", y0 has " + std::to_string(
y0.size()));
664 std::span<const double>(
y0.data(),
y0.size()), order, logx, logy);
673template <
class RooArg_t>
676 std::string
const &key()
const override;
680 elem[
"type"] << key();
683 elem[
"extended"] << (pdf->extendMode() != RooArg_t::CanNotBeExtended);
690 std::string
const &key()
const override;
694 elem[
"type"] << key();
704 std::string
const &key()
const override;
708 elem[
"type"] << key();
715template <
class RooArg_t>
718 std::string
const &key()
const override;
722 elem[
"type"] << key();
724 tool->exportHisto(*
dh.get(),
dh.numEntries(),
dh.weightArray(),
elem[
"data"].set_map());
729template <
class RooArg_t>
735 if (!
p.has_child(
"data")) {
738 std::unique_ptr<RooDataHist> dataHist =
747 std::string
const &key()
const override;
751 elem[
"type"] << key();
752 elem[
"pdf"] << pdf->
pdf().GetName();
761 std::string
const &key()
const override;
765 elem[
"type"] << key();
772template <
class RooArg_t>
775 std::string
const &key()
const override;
779 elem[
"type"] << key();
780 TString expression(pdf->expression());
788 for (
size_t idx = pdf->nParameters(); idx--;) {
789 const RooAbsArg *par = pdf->getParameter(idx);
790 expression.ReplaceAll((
"x[" + std::to_string(idx) +
"]").c_str(), par->
GetName());
791 expression.ReplaceAll((
"@" + std::to_string(idx)).c_str(), par->
GetName());
793 elem[
"expression"] << expression.Data();
800 expr.ReplaceAll(
"TMath::Exp",
"exp");
801 expr.ReplaceAll(
"TMath::Min",
"min");
802 expr.ReplaceAll(
"TMath::Max",
"max");
803 expr.ReplaceAll(
"TMath::Log",
"log");
804 expr.ReplaceAll(
"TMath::Cos",
"cos");
805 expr.ReplaceAll(
"TMath::Sin",
"sin");
806 expr.ReplaceAll(
"TMath::Sqrt",
"sqrt");
807 expr.ReplaceAll(
"TMath::Power",
"pow");
808 expr.ReplaceAll(
"TMath::Erf",
"erf");
817 elem[
"x"] << pdf->x().GetName();
818 auto &coefs =
elem[
"coefficients"].set_seq();
819 for (
int i = 0; i < pdf->lowestOrder(); ++i) {
820 coefs.append_child() << (i == 0 ?
"1.0" :
"0.0");
822 for (
const auto &coef : pdf->coefList()) {
823 coefs.append_child() << coef->GetName();
827template <
class RooArg_t>
830 std::string
const &key()
const override;
833 elem[
"type"] << key();
841 std::string
const &key()
const override;
844 auto *pdf =
static_cast<const RooPoisson *
>(func);
845 elem[
"type"] << key();
846 elem[
"x"] << pdf->getX().GetName();
847 elem[
"mean"] << pdf->getMean().GetName();
848 elem[
"integer"] << !pdf->getNoRounding();
855 std::string
const &key()
const override;
858 auto *pdf =
static_cast<const RooDecay *
>(func);
859 elem[
"type"] << key();
860 elem[
"t"] << pdf->getT().GetName();
861 elem[
"tau"] << pdf->getTau().GetName();
862 elem[
"resolutionModel"] << pdf->getModel().GetName();
863 elem[
"decayType"] << pdf->getDecayType();
871 std::string
const &key()
const override;
875 elem[
"type"] << key();
876 elem[
"x"] << pdf->convVar().GetName();
884 std::string
const &key()
const override;
888 elem[
"type"] << key();
889 elem[
"x"] << pdf->convVar().GetName();
890 elem[
"mean"] << pdf->getMean().GetName();
891 elem[
"sigma"] << pdf->getSigma().GetName();
898 std::string
const &key()
const override;
903 elem[
"type"] << key();
904 elem[
"x"] << pdf->getX().GetName();
906 auto &m0 = pdf->getMedian();
907 auto &k = pdf->getShapeK();
909 if (pdf->useStandardParametrization()) {
910 elem[
"mu"] << m0.GetName();
911 elem[
"sigma"] << k.GetName();
913 elem[
"mu"] <<
tool->exportTransformed(&m0,
"_lognormal_log",
"log(%s)");
914 elem[
"sigma"] <<
tool->exportTransformed(&k,
"_lognormal_log",
"log(%s)");
923 std::string
const &key()
const override;
927 elem[
"type"] << key();
928 elem[
"x"] << pdf->variable().GetName();
929 auto &
c = pdf->coefficient();
930 if (pdf->negateCoefficient()) {
931 elem[
"c"] <<
c.GetName();
933 elem[
"c"] <<
tool->exportTransformed(&
c,
"_exponential_inverted",
"-%s");
942 std::string
const &key()
const override;
946 elem[
"type"] << key();
949 elem[
"covariances"].fill_mat(pdf->covarianceMatrix());
956 std::string
const &key()
const override;
960 elem[
"type"] << key();
962 TString formula(pdf->function().GetExpFormula());
963 formula.ReplaceAll(
"x", pdf->observables()[0].GetName());
964 formula.ReplaceAll(
"y", pdf->observables()[1].GetName());
965 formula.ReplaceAll(
"z", pdf->observables()[2].GetName());
966 for (
size_t i = 0; i < pdf->parameters().
size(); ++i) {
968 formula.ReplaceAll(
pname, pdf->parameters()[i].GetName());
970 elem[
"expression"] << formula.Data();
977 std::string
const &key()
const override;
981 elem[
"type"] << key();
982 elem[
"x"] << pdf->getX().GetName();
983 elem[
"function"] << pdf->getFunc().GetName();
984 if (!pdf->getNset().empty()) {
987 elem[
"order"] << pdf->order();
988 elem[
"eps"] << pdf->eps();
995 std::string
const &key()
const override;
999 elem[
"type"] << key();
1000 std::string integrand = integral->integrand().GetName();
1002 elem[
"integrand"] << integrand;
1003 if (integral->intRange()) {
1004 elem[
"domain"] << integral->intRange();
1007 if (
RooArgSet const *funcNormSet = integral->funcNormSet()) {
1016 std::string
const &key()
const override;
1020 elem[
"type"] << key();
1021 if (
auto convFunc = pdf->getPdfConvVar()) {
1024 elem[
"conv_var"] << pdf->getConvVar().GetName();
1025 elem[
"pdf1"] << pdf->getPdf1().GetName();
1026 elem[
"pdf2"] << pdf->getPdf2().GetName();
1027 elem[
"ipOrder"] << pdf->getInterpolationOrder();
1034 std::string
const &key()
const override;
1038 elem[
"type"] << key();
1039 if (
auto rangeName = pdf->getRangeName()) {
1042 elem[
"pdf"] << pdf->pdf().GetName();
1043 elem[
"norm"] << pdf->getN().GetName();
1050 std::string
const &key()
const override;
1054 elem[
"type"] << key();
1067 std::string
name = var->GetName();
1071 auto const &binning = var->getBinning();
1072 if (binning.isUniform()) {
1073 obsNode[
"min"] << var->getMin();
1074 obsNode[
"max"] << var->getMax();
1075 obsNode[
"nbins"] << var->getBins();
1077 auto &edges =
obsNode[
"edges"].set_seq();
1078 edges.append_child() << binning.binLow(0);
1079 for (
int i = 0; i < binning.numBins(); ++i) {
1080 edges.append_child() << binning.binHigh(i);
1089 std::string
const &key()
const override;
1093 auto const *
rs =
static_cast<RooSpline const *
>(func);
1095 elem[
"type"] << key();
1098 elem[
"x"] <<
rs->x().GetName();
1102 elem[
"interpolation"] << (
rs->order() == 5 ?
"poly5" :
"poly3");
1103 elem[
"logx"] <<
rs->logx();
1104 elem[
"logy"] <<
rs->logy();
1108 auto &x0 =
elem[
"x0"].set_seq();
1109 auto &
y0 =
elem[
"y0"].set_seq();
1111 const int np =
sp.GetNp();
1112 for (
int i = 0; i <
np; ++i) {
1113 double xk = 0.0,
yk = 0.0;
1115 x0.append_child() <<
xk;
1116 y0.append_child() <<
yk;
1127 if (node[
"type"].val() !=
"density_function_dist")
1133 bool selfNormalized =
false;
1135 if (
auto sn = node.find(
"selfNormalized"))
1136 selfNormalized =
sn->val_bool();
1145 std::string
const &key()
const override;
1153 node[
"type"] <<
"density_function_dist";
1161 node[
"function"] <<
funcProxy->absArg()->GetName();
1162 if (pdf->selfNormalized())
1163 node[
"selfnormalized"] <<
true;
1169#define DEFINE_EXPORTER_KEY(class_name, name) \
1170 std::string const &class_name::key() const \
1172 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, true, Range_t > dynamic_range_cast(Range_t &&coll)
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.
RooAbsProxy * getProxy(Int_t index) const
Return the nth proxy from the proxy list.
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.
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.
The RooWrapperPdf is a class that can be used to convert a function into a PDF.
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)