78 return arg ==
"PI" || arg ==
"EULER" || arg ==
"TMath";
100 std::set<std::string> arguments;
102 for (
size_t i = 0; i <
expr.size(); ++i) {
114 if (
expr[i] ==
'(') {
121 arguments.insert(arg);
129 arguments.insert(arg);
137 std::string
in(
expr.Data());
139 out.reserve(
in.size());
141 for (std::size_t pos = 0; pos <
in.size();) {
144 pos > 0 && (std::isalnum(
static_cast<unsigned char>(
in[pos - 1])) ||
in[pos - 1] ==
'_');
145 const std::size_t end = pos +
identifier.size();
147 end <
in.size() && (std::isalnum(
static_cast<unsigned char>(
in[end])) ||
in[end] ==
'_');
152 out.push_back(
in[pos]);
166template <
class RooArg_t>
170 if (!
p.has_child(
"expression")) {
173 TString formula(
p[
"expression"].val());
231template <
bool Div
ideByBinW
idth>
249 obs->GetName() +
"' as indicated by parent RooBinSamplingPdf '" +
name +
253 if (!
p.has_child(
"epsilon")) {
256 double epsilon(
p[
"epsilon"].val_double());
268 if (
p.has_child(
"extended") &&
p[
"extended"].val_bool()) {
284template <
class RooArg_t>
288 if (!
p.has_child(
"coefficients")) {
295 for (
const auto &coef :
p[
"coefficients"].children()) {
299 if (order == 0 && (coef.val() ==
"1.0" || coef.val() ==
"1")) {
301 }
else if (coefs.empty() && (coef.val() ==
"0.0" || coef.val() ==
"0")) {
358 if (
p.has_child(
"normalization")) {
365 domain =
p[
"domain"].val();
378 Int_t order =
p[
"order"].val_int();
379 double eps =
p[
"eps"].val_double();
380 if (
p.has_child(
"normalization")) {
394 Int_t order =
p[
"ipOrder"].val_int();
397 if (
p.has_child(
"conv_func")) {
411 if (
p.has_child(
"range")) {
427 const std::string
muName =
p[
"mu"].val();
428 const std::string
sigmaName =
p[
"sigma"].val();
488 bool has_cov =
p.has_child(
"covariances");
489 bool has_corr =
p.has_child(
"correlations") &&
p.has_child(
"standard_deviations");
497 int n =
p[
"covariances"].num_children();
500 for (
const auto &row :
p[
"covariances"].children()) {
502 for (
const auto &val : row.children()) {
503 covmat(i,
j) = val.val_double();
510 for (
const auto &
v :
p[
"standard_deviations"].children()) {
515 for (
const auto &row :
p[
"correlations"].children()) {
517 for (
const auto &val : row.children()) {
532 std::map<std::string, std::unique_ptr<RooRealVar>>
varMap;
536 const std::string
name = node[
"name"].val();
537 std::unique_ptr<RooRealVar> obs;
539 if (node.has_child(
"edges")) {
540 std::vector<double> edges;
541 for (
const auto &
bound : node[
"edges"].children()) {
542 edges.push_back(
bound.val_double());
544 obs = std::make_unique<RooRealVar>(
name.c_str(),
name.c_str(), edges.front(), edges.back());
545 RooBinning bins(obs->getMin(), obs->getMax());
548 obs->setBinning(bins);
550 obs = std::make_unique<RooRealVar>(
name.c_str(),
name.c_str(), node[
"min"].val_double(),
551 node[
"max"].val_double());
552 obs->setBins(node[
"nbins"].val_int());
566 vars.
addOwned(std::move(it->second));
574 if (!
p.has_child(
"parameters")) {
579 if (!
p.has_child(
"axes")) {
580 std::stringstream
ss;
581 ss <<
"No axes given in '" <<
name <<
"'"
582 <<
". Using default binning (uniform; nbins=100). If needed, export the Workspace to JSON with a newer "
583 <<
"Root version that supports custom ParamHistFunc binnings(>=6.38.00)." << std::endl;
597 if (!
p.has_child(
"x")) {
600 if (!
p.has_child(
"x0") || !
p.has_child(
"y0")) {
607 std::string
algo =
p.has_child(
"interpolation") ?
p[
"interpolation"].val() :
"poly3";
611 else if (
algo ==
"poly5")
615 "': allowed are 'poly3' and 'poly5'");
617 const bool logx =
p.has_child(
"logx") ?
p[
"logx"].val_bool() :
false;
618 const bool logy =
p.has_child(
"logy") ?
p[
"logy"].val_bool() :
false;
621 std::vector<double> x0;
622 std::vector<double>
y0;
623 x0.reserve(
p[
"x0"].num_children());
624 y0.reserve(
p[
"y0"].num_children());
626 for (
const auto &
v :
p[
"x0"].children())
627 x0.push_back(
v.val_double());
628 for (
const auto &
v :
p[
"y0"].children())
629 y0.push_back(
v.val_double());
631 if (x0.size() !=
y0.size()) {
633 ", y0 has " + std::to_string(
y0.size()));
641 std::span<const double>(
y0.data(),
y0.size()), order, logx, logy);
649template <
class RooArg_t>
656 elem[
"extended"] << (pdf->extendMode() != RooArg_t::CanNotBeExtended);
679template <
class RooArg_t>
685 tool->exportHisto(*
dh.get(),
dh.numEntries(),
dh.weightArray(),
elem[
"data"].set_map());
689template <
class RooArg_t>
693 if (!
p.has_child(
"data")) {
696 std::unique_ptr<RooDataHist> dataHist =
706 elem[
"pdf"] << pdf->
pdf().GetName();
752template <
class RooArg_t>
757 TString expression(pdf->expression());
765 for (
size_t idx = pdf->nParameters(); idx--;) {
766 const RooAbsArg *par = pdf->getParameter(idx);
767 expression.ReplaceAll((
"x[" + std::to_string(idx) +
"]").c_str(), par->
GetName());
768 expression.ReplaceAll((
"@" + std::to_string(idx)).c_str(), par->
GetName());
770 elem[
"expression"] << expression.Data();
780 elem[
"x"] << pdf->x().GetName();
781 auto &coefs =
elem[
"coefficients"].set_seq();
782 for (
int i = 0; i < pdf->lowestOrder(); ++i) {
783 coefs.append_child() << (i == 0 ? 1.0 : 0.0);
785 for (
const auto &coef : pdf->coefList()) {
786 coefs.append_child() << coef->GetName();
790template <
class RooArg_t>
800 auto *pdf =
static_cast<const RooPoisson *
>(func);
802 elem[
"x"] << pdf->getX().GetName();
803 elem[
"mean"] << pdf->getMean().GetName();
804 elem[
"integer"] << !pdf->getNoRounding();
810 auto *pdf =
static_cast<const RooDecay *
>(func);
812 elem[
"t"] << pdf->getT().GetName();
813 elem[
"tau"] << pdf->getTau().GetName();
814 elem[
"resolutionModel"] << pdf->getModel().GetName();
815 elem[
"decayType"] << pdf->getDecayType();
824 elem[
"x"] << pdf->convVar().GetName();
833 elem[
"x"] << pdf->convVar().GetName();
834 elem[
"mean"] << pdf->getMean().GetName();
835 elem[
"sigma"] << pdf->getSigma().GetName();
844 elem[
"x"] << pdf->getX().GetName();
846 auto &m0 = pdf->getMedian();
847 auto &k = pdf->getShapeK();
849 if (pdf->useStandardParametrization()) {
850 elem[
"mu"] << m0.GetName();
851 elem[
"sigma"] << k.GetName();
853 elem[
"mu"] <<
tool->exportTransformed(&m0,
"_lognormal_log",
"log(%s)");
854 elem[
"sigma"] <<
tool->exportTransformed(&k,
"_lognormal_log",
"log(%s)");
864 elem[
"x"] << pdf->variable().GetName();
865 auto &
c = pdf->coefficient();
866 if (pdf->negateCoefficient()) {
867 elem[
"c"] <<
c.GetName();
869 elem[
"c"] <<
tool->exportTransformed(&
c,
"_exponential_inverted",
"-%s");
881 elem[
"covariances"].fill_mat(pdf->covarianceMatrix());
890 TString formula(pdf->function().GetExpFormula());
891 formula.ReplaceAll(
"x", pdf->observables()[0].GetName());
892 formula.ReplaceAll(
"y", pdf->observables()[1].GetName());
893 formula.ReplaceAll(
"z", pdf->observables()[2].GetName());
894 for (
size_t i = 0; i < pdf->parameters().
size(); ++i) {
896 formula.ReplaceAll(
pname, pdf->parameters()[i].GetName());
898 elem[
"expression"] << formula.Data();
906 elem[
"x"] << pdf->getX().GetName();
907 elem[
"function"] << pdf->getFunc().GetName();
908 if (!pdf->getNset().empty()) {
911 elem[
"order"] << pdf->order();
912 elem[
"eps"] << pdf->eps();
920 std::string integrand = integral->integrand().GetName();
922 elem[
"integrand"] << integrand;
923 if (integral->intRange()) {
924 elem[
"domain"] << integral->intRange();
927 if (
RooArgSet const *funcNormSet = integral->funcNormSet()) {
937 if (
auto convFunc = pdf->getPdfConvVar()) {
940 elem[
"conv_var"] << pdf->getConvVar().GetName();
941 elem[
"pdf1"] << pdf->getPdf1().GetName();
942 elem[
"pdf2"] << pdf->getPdf2().GetName();
943 elem[
"ipOrder"] << pdf->getInterpolationOrder();
951 if (
auto rangeName = pdf->getRangeName()) {
954 elem[
"pdf"] << pdf->pdf().GetName();
955 elem[
"norm"] << pdf->getN().GetName();
975 auto const *
rs =
static_cast<RooSpline const *
>(func);
980 elem[
"x"] <<
rs->x().GetName();
984 elem[
"interpolation"] << (
rs->order() == 5 ?
"poly5" :
"poly3");
985 elem[
"logx"] <<
rs->logx();
986 elem[
"logy"] <<
rs->logy();
990 auto &x0 =
elem[
"x0"].set_seq();
991 auto &
y0 =
elem[
"y0"].set_seq();
993 const int np =
sp.GetNp();
994 for (
int i = 0; i <
np; ++i) {
995 double xk = 0.0,
yk = 0.0;
997 x0.append_child() <<
xk;
998 y0.append_child() <<
yk;
1006 if (node[
"type"].val() !=
"density_function_dist")
1012 bool selfNormalized =
false;
1014 if (
auto sn = node.find(
"selfNormalized"))
1015 selfNormalized =
sn->val_bool();
1027 node[
"type"] << key;
1035 node[
"function"] <<
funcProxy->absArg()->GetName();
1036 if (pdf->selfNormalized())
1037 node[
"selfnormalized"] <<
true;
1058 FuncExporter(std::string key) : _key{std::
move(key)} {}
1059 std::string
const &key()
const override {
return _key; }
1062 return Func(
tool, func,
elem, _key);
1066 const std::string _key;
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.
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.
TClass instances represent classes, structs and namespaces in the ROOT type system.
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.
static bool registerImporter(const std::string &key, bool topPriority=true)
bool registerImporter(const std::string &key, std::unique_ptr< const Importer > f, bool topPriority=true)
static bool registerExporter(const TClass *key, bool topPriority=true)
bool registerExporter(const TClass *key, std::unique_ptr< const Exporter > f, bool topPriority=true)
#define STATIC_EXECUTE(MY_FUNC)