88#include <initializer_list>
101bool isReservedExpressionIdentifier(
const std::string &arg)
103 return arg ==
"PI" || arg ==
"EULER" || arg ==
"TMath";
120std::set<std::string> extractArguments(std::string expr)
123 expr.erase(std::remove_if(expr.begin(), expr.end(), [](
unsigned char c) { return std::isspace(c); }), expr.end());
125 std::set<std::string> arguments;
126 size_t startidx = expr.size();
127 for (
size_t i = 0; i < expr.size(); ++i) {
128 if (startidx >= expr.size()) {
129 if (isalpha(expr[i])) {
134 startidx = expr.size();
138 if (!isdigit(expr[i]) && !isalpha(expr[i]) && expr[i] !=
'_') {
139 if (expr[i] ==
'(') {
140 startidx = expr.size();
143 std::string arg(expr.substr(startidx, i - startidx));
144 startidx = expr.size();
145 if (!isReservedExpressionIdentifier(arg)) {
146 arguments.insert(arg);
151 if (startidx < expr.size()) {
152 std::string arg(expr.substr(startidx));
153 if (!isReservedExpressionIdentifier(arg)) {
154 arguments.insert(arg);
160void replaceIdentifier(
TString &expr, std::string_view identifier, std::string_view replacement)
162 std::string in(expr.
Data());
164 out.reserve(in.size());
166 for (std::size_t pos = 0; pos < in.size();) {
167 const bool matches = in.compare(pos, identifier.size(), identifier) == 0;
168 const bool beforeIdentifier =
169 pos > 0 && (std::isalnum(
static_cast<unsigned char>(in[pos - 1])) || in[pos - 1] ==
'_');
170 const std::size_t end = pos + identifier.size();
171 const bool afterIdentifier =
172 end < in.size() && (std::isalnum(
static_cast<unsigned char>(in[end])) || in[end] ==
'_');
173 if (matches && !beforeIdentifier && !afterIdentifier) {
174 out.append(replacement);
177 out.push_back(in[pos]);
185bool isIdentifierChar(
char c)
187 return std::isalnum(
static_cast<unsigned char>(
c)) ||
c ==
'_';
190std::string trimmed(std::string
const &str)
192 const auto begin = str.find_first_not_of(
" \t\n");
193 if (begin == std::string::npos) {
196 return str.substr(begin, str.find_last_not_of(
" \t\n") - begin + 1);
200std::size_t findClosingBracket(std::string
const &str, std::size_t open)
203 for (std::size_t i = open; i < str.size(); ++i) {
204 if (str[i] ==
'(' || str[i] ==
'[') {
206 }
else if ((str[i] ==
')' || str[i] ==
']') && --depth == 0) {
210 return std::string::npos;
214std::vector<std::string> splitTopLevelCommas(std::string
const &str)
216 std::vector<std::string> parts;
218 std::size_t start = 0;
219 for (std::size_t i = 0; i < str.size(); ++i) {
220 if (str[i] ==
'(' || str[i] ==
'[') {
222 }
else if (str[i] ==
')' || str[i] ==
']') {
224 }
else if (str[i] ==
',' && depth == 0) {
225 parts.push_back(str.substr(start, i - start));
229 parts.push_back(str.substr(start));
234std::string stripEnclosingParentheses(std::string str)
237 while (str.size() >= 2 && str.front() ==
'(' && findClosingBracket(str, 0) == str.size() - 1) {
238 str = trimmed(str.substr(1, str.size() - 2));
245std::string ifElseToTernary(std::string
const &expr)
247 static const std::string keyword =
"ifelse";
250 while (pos < expr.size()) {
251 const std::size_t found = expr.find(keyword, pos);
252 if (found == std::string::npos) {
255 const std::size_t
open = expr.find_first_not_of(
" \t", found + keyword.size());
257 (found == 0 || !isIdentifierChar(expr[found - 1])) && open != std::string::npos && expr[open] ==
'(';
258 const std::size_t
close = isCall ? findClosingBracket(expr, open) : std::string::npos;
259 const auto args =
close != std::string::npos ? splitTopLevelCommas(expr.substr(open + 1, close - open - 1))
260 : std::vector<std::string>{};
261 if (args.size() != 3) {
262 out += expr.substr(pos, found + keyword.size() - pos);
263 pos = found + keyword.size();
266 out += expr.substr(pos, found - pos);
267 out +=
"((" + ifElseToTernary(trimmed(args[0])) +
")?(" + ifElseToTernary(trimmed(args[1])) +
"):(" +
268 ifElseToTernary(trimmed(args[2])) +
"))";
271 return out + expr.substr(pos);
274void translateImportedExpression(
TString &expr)
276 replaceIdentifier(expr,
"PI",
"TMath::Pi()");
277 replaceIdentifier(expr,
"EULER",
"TMath::E()");
278 if (std::string(expr.
Data()).find(
"ifelse") != std::string::npos) {
279 expr = ifElseToTernary(expr.
Data()).c_str();
283int readPositiveInteger(
const JSONNode &node,
const std::string &context)
290 value >
static_cast<double>(std::numeric_limits<int>::max())) {
293 return static_cast<int>(
value);
296std::unique_ptr<RooAbsBinning>
297readFormulaAxisBinning(
const JSONNode &axis,
const std::string &axisName,
const std::string &formulaName)
299 const std::string context =
"axis '" + axisName +
"' of generic formula '" + formulaName +
"'";
300 const bool hasEdges = axis.
has_child(
"edges");
301 const bool hasMin = axis.
has_child(
"min");
302 const bool hasMax = axis.
has_child(
"max");
303 const bool hasNBins = axis.
has_child(
"nbins");
305 if (hasEdges && hasNBins) {
310 const JSONNode &edgesNode = axis[
"edges"];
311 if (!edgesNode.
is_seq()) {
315 std::vector<double> edges;
317 for (
const JSONNode &edgeNode : edgesNode.children()) {
318 if (!edgeNode.is_number()) {
321 const double edge = edgeNode.val_double();
322 if (!std::isfinite(edge)) {
325 if (!edges.empty() && edge <= edges.back()) {
328 edges.push_back(edge);
330 if (edges.size() < 2) {
335 if ((hasMin && (!axis[
"min"].is_number() || axis[
"min"].val_double() != edges.front())) ||
336 (hasMax && (!axis[
"max"].is_number() || axis[
"max"].val_double() != edges.back()))) {
339 return std::make_unique<RooBinning>(
static_cast<int>(edges.size() - 1), edges.data());
342 if (!hasMin || !hasMax || !hasNBins) {
346 if (!axis[
"min"].is_number() || !axis[
"max"].is_number()) {
351 if (!std::isfinite(min) || !std::isfinite(max) || max <= min) {
354 return std::make_unique<RooUniformBinning>(min, max, readPositiveInteger(axis[
"nbins"], context));
357template <
class RooArg_t>
358void importFormulaBinnings(RooArg_t &arg,
const JSONNode &node)
364 const JSONNode &axes = node[
"axes"];
367 "' must be a sequence");
370 std::set<std::string> axisNames;
371 for (
const JSONNode &axis : axes.children()) {
374 "' must be a map with a \"name\"");
376 const std::string axisName = axis[
"name"].
val();
377 if (!axisNames.insert(axisName).second) {
381 auto *observable =
dynamic_cast<RooAbsRealLValue *
>(arg.getParameter(axisName.c_str()));
384 "axis '" + axisName +
"' is not a real-valued formula variable of generic formula '" + arg.GetName() +
"'");
387 std::unique_ptr<RooAbsBinning> binning = readFormulaAxisBinning(axis, axisName, arg.GetName());
388 arg.setBinning(*observable, *binning,
false);
392template <
class RooArg_t>
396 if (!
p.has_child(
"expression")) {
399 TString formula(
p[
"expression"].val());
400 translateImportedExpression(formula);
402 for (
const auto &
d : extractArguments(formula.Data())) {
405 RooArg_t arg{
name.c_str(), formula, dependents};
406 importFormulaBinnings(arg,
p);
426std::string arrayComponentName(std::string
const &observable)
428 return observable +
"_constraint";
438 const std::string
value = source.
val();
459 static const std::set<std::string> supportedComponentTypes{
"poisson_dist",
"poisson_continuous_dist",
460 "gaussian_dist",
"normal_dist",
"lognormal_dist"};
461 if (!
p.has_child(
"component_type")) {
462 error(
"missing \"component_type\"");
464 const std::string componentType =
p[
"component_type"].val();
465 if (supportedComponentTypes.find(componentType) == supportedComponentTypes.end()) {
466 error(
"the component_type '" + componentType +
467 "' is not supported, supported are poisson_dist, poisson_continuous_dist, gaussian_dist and "
471 const JSONNode *defaults =
p.find(
"default_parameters");
473 if (!defaults->
is_map()) {
474 error(
"\"default_parameters\" must be a struct");
477 error(
"\"x\" must be given per component, not in \"default_parameters\"");
480 const JSONNode *components =
p.find(
"components");
482 error(
"\"components\" must be a non-empty list");
491 std::vector<std::string> observables;
493 for (
JSONNode const &component : components->children()) {
494 const std::string context =
"component " + std::to_string(observables.size());
495 if (!component.is_map()) {
496 error(context +
" must be a struct");
500 error(context +
" has no \"x\"");
503 error(context +
": \"x\" must be the name of the observable");
505 const std::string
x = xNode->
val();
506 if (std::find(observables.begin(), observables.end(),
x) != observables.end()) {
507 error(
"the observable '" +
x +
"' is used by two components");
509 observables.push_back(
x);
511 const std::string pdfName = arrayComponentName(
x);
512 if (ws.
arg(pdfName)) {
513 error(
"cannot create the component for '" +
x +
"' as '" + pdfName +
514 "', the workspace already has an object of that name");
517 node[
"name"] << pdfName;
518 node[
"type"] << componentType;
520 for (
JSONNode const &field : defaults->children()) {
521 copyValue(node[field.key()], field);
524 for (
JSONNode const &field : component.children()) {
525 copyValue(node[field.key()], field);
530 error(context +
" did not produce a distribution");
537 for (std::size_t i = 0; i < observables.size(); ++i) {
540 error(
"the observable '" + observables[i] +
"' is not a parameter or function");
542 for (std::size_t k = 0; k < observables.size(); ++k) {
543 if (k != i && pdfs[i].dependsOn(*ws.
arg(observables[k]))) {
544 error(
"component " + std::to_string(i) +
" depends on the observable '" + observables[k] +
545 "' of component " + std::to_string(k));
548 for (
RooAbsArg const *server : pdfs[i].servers()) {
549 if (server !=
x && server->dependsOn(*
x)) {
550 error(
"the parameters of component " + std::to_string(i) +
" depend on its own observable '" +
551 observables[i] +
"'");
563using ArrayFieldValue = std::variant<std::string, double>;
565struct ArrayComponent {
568 std::vector<std::pair<std::string, ArrayFieldValue>> fields;
571ArrayFieldValue nameOrNumber(
RooAbsReal const &arg)
574 return static_cast<RooConstVar const &
>(arg).getVal();
576 return std::string{arg.
GetName()};
582std::optional<ArrayComponent> arrayComponentOf(
RooAbsPdf const &pdf, std::string
const *observable =
nullptr)
586 if (
auto const *poisson =
dynamic_cast<RooPoisson const *
>(&pdf)) {
587 out.type =
poisson->getNoRounding() ?
"poisson_continuous_dist" :
"poisson_dist";
589 out.fields = {{
"mean", nameOrNumber(
poisson->getMean())}};
590 }
else if (
auto const *gauss =
dynamic_cast<RooGaussian const *
>(&pdf)) {
591 out.type =
"gaussian_dist";
599 out.fields = {{
"mean", nameOrNumber(*mean)}, {
"sigma", nameOrNumber(gauss->getSigma())}};
600 }
else if (
auto const *lognormal =
dynamic_cast<RooLognormal const *
>(&pdf)) {
601 if (!lognormal->useStandardParametrization()) {
604 out.type =
"lognormal_dist";
605 x = &lognormal->getX();
606 out.fields = {{
"mu", nameOrNumber(lognormal->getMedian())}, {
"sigma", nameOrNumber(lognormal->getShapeK())}};
614 out.x =
x->GetName();
630 std::string
const context =
"the combined_dist '" +
name +
"'";
632 if (
p.has_child(
"extended")) {
638 auto const *componentsNode =
p.find(
"components");
639 if (!componentsNode || !componentsNode->is_seq() || componentsNode->num_children() == 0) {
642 std::map<std::string, RooAbsPdf *> pdfMap;
643 for (
JSONNode const &component : componentsNode->children()) {
644 if (!component.is_map() || !component.has_child(
"dist")) {
647 std::vector<std::string>
const key =
readSelectionKey(component, columns, context);
649 if (pdfMap.find(label) != pdfMap.end()) {
656 if (columns.size() == 1) {
664 std::string
const indexName =
name +
"_index";
673 if (
p.has_child(
"extended")) {
676 const bool extended =
p[
"extended"].val_bool();
677 const std::size_t nSummands =
p.has_child(
"summands") ?
p[
"summands"].num_children() : 0;
678 const std::size_t nCoefficients =
p.has_child(
"coefficients") ?
p[
"coefficients"].num_children() : 0;
679 const std::string counts =
680 std::to_string(nCoefficients) +
" coefficients for " + std::to_string(nSummands) +
" summands";
681 if (extended && nCoefficients > 0 && nCoefficients + 1 == nSummands) {
683 ", which defines a non-extended mixture");
685 if (!extended && nCoefficients == 0 && nSummands > 0) {
687 ", which defines an extended mixture of extended distributions");
689 if (!extended && nCoefficients == nSummands) {
691 "RooFit can use it as extended because it has one coefficient per summand. " +
692 "Don't use the extended likelihood term when fitting it.");
712template <
bool Div
ideByBinW
idth>
733 obs->GetName() +
"' as indicated by parent RooBinSamplingPdf '" +
name +
737 if (!
p.has_child(
"epsilon")) {
740 double epsilon(
p[
"epsilon"].val_double());
747template <
class RooArg_t>
753 if constexpr (std::is_same_v<RooArg_t, RooRealSumPdf>) {
754 const bool extended =
p.has_child(
"extended") &&
p[
"extended"].val_bool();
762template <
class RooArg_t>
766 if (!
p.has_child(
"coefficients")) {
773 for (
const auto &coef :
p[
"coefficients"].children()) {
777 if (order == 0 && (coef.val() ==
"1.0" || coef.val() ==
"1")) {
779 }
else if (coefs.empty() && (coef.val() ==
"0.0" || coef.val() ==
"0")) {
795template <
bool Continuous>
799 bool noRounding = Continuous;
800 if (
p.has_child(
"integer")) {
801 std::string
const type = Continuous ?
"poisson_continuous_dist" :
"poisson_dist";
805 "' has the key \"integer\", which is not part of HS3. The discrete Poisson distribution is "
806 "\"poisson_dist\" and the continuous one is \"poisson_continuous_dist\".");
808 noRounding = !
p[
"integer"].val_bool();
856 if (
p.has_child(
"normalization")) {
858 normSetPtr = &normSet;
861 bool hasDomain =
p.has_child(
"domain");
863 domain =
p[
"domain"].val();
867 hasDomain ? domain.c_str() :
nullptr);
876 Int_t order =
p[
"order"].val_int();
877 double eps =
p[
"eps"].val_double();
878 if (
p.has_child(
"normalization")) {
892 Int_t order =
p[
"ipOrder"].val_int();
895 if (
p.has_child(
"conv_func")) {
910 if (
p.has_child(
"range")) {
911 std::string rangeName =
p[
"range"].val();
926 const std::string muName =
p[
"mu"].val();
927 const std::string sigmaName =
p[
"sigma"].val();
928 const bool isTransformed =
endsWith(muName,
"_lognormal_log");
929 const std::string suffixToRemove = isTransformed ?
"_lognormal_log" :
"";
974 const std::string constParamName =
p[
"c"].val();
975 const bool isInverted =
endsWith(constParamName,
"_exponential_inverted");
976 const std::string suffixToRemove = isInverted ?
"_exponential_inverted" :
"";
987 bool has_cov =
p.has_child(
"covariances");
988 bool has_corr =
p.has_child(
"correlations") &&
p.has_child(
"standard_deviations");
989 if (!has_cov && !has_corr) {
996 auto checkSquare = [&](
const char *key, std::size_t
n) {
997 if (
p[key].num_children() !=
n) {
1001 for (
const auto &row :
p[key].children()) {
1002 if (!row.is_seq() || row.num_children() !=
n) {
1009 int n =
p[
"covariances"].num_children();
1010 checkSquare(
"covariances",
n);
1013 for (
const auto &row :
p[
"covariances"].children()) {
1015 for (
const auto &val : row.children()) {
1016 covmat(i, j) = val.val_double();
1022 std::vector<double> variances;
1023 variances <<
p[
"standard_deviations"];
1024 checkSquare(
"correlations", variances.size());
1025 covmat.
ResizeTo(variances.size(), variances.size());
1027 for (
const auto &row :
p[
"correlations"].children()) {
1029 for (
const auto &val : row.children()) {
1030 covmat(i, j) = val.val_double() * variances[i] * variances[j];
1056 if (!
p.has_child(
"parameters")) {
1061 if (!
p.has_child(
"axes")) {
1062 std::stringstream ss;
1063 ss <<
"No axes given in '" <<
name <<
"'"
1064 <<
". Using default binning (uniform; nbins=100). If needed, export the Workspace to JSON with a newer "
1065 <<
"Root version that supports custom ParamHistFunc binnings(>=6.38.00)." << std::endl;
1085 if (!
p.has_child(
"x")) {
1088 if (!
p.has_child(
"x0") || !
p.has_child(
"y0")) {
1095 std::string algo =
p.has_child(
"interpolation") ?
p[
"interpolation"].val() :
"poly3";
1097 if (algo ==
"poly3") {
1099 }
else if (algo ==
"poly5") {
1103 "': allowed are 'poly3' and 'poly5'");
1105 const bool logx =
p.has_child(
"logx") ?
p[
"logx"].val_bool() :
false;
1106 const bool logy =
p.has_child(
"logy") ?
p[
"logy"].val_bool() :
false;
1109 std::vector<double> x0;
1110 std::vector<double> y0;
1114 if (x0.size() != y0.size()) {
1116 ", y0 has " + std::to_string(y0.size()));
1118 if (x0.size() < 2) {
1124 std::span<const double>(y0.data(), y0.size()), order, logx, logy);
1232 if (
p.has_child(
"x") && !
p[
"x"].is_seq()) {
1244 DeprecatedKeyImporter(std::string key, std::string replacement)
1245 : _key{std::move(key)}, _replacement{std::move(replacement)}
1252 _replacement +
"\" instead.");
1259 const std::string _key;
1260 const std::string _replacement;
1261 mutable bool _warned =
false;
1267const std::initializer_list<const char *> tailKeys = {
"alpha_L",
"n_L",
"alpha_R",
"n_R"};
1269bool hasAny(
const JSONNode &
p, std::initializer_list<const char *> keys)
1271 for (
const char *key : keys) {
1272 if (
p.has_child(key)) {
1279bool hasDoubleSidedKeys(
const JSONNode &
p)
1281 return hasAny(
p, tailKeys) || hasAny(
p, {
"sigma_L",
"sigma_R"});
1289 const std::string context =
type +
" '" +
name +
"'";
1291 const bool asymmetricTails = hasAny(
p, tailKeys);
1292 const bool symmetricTails = hasAny(
p, {
"alpha",
"n"});
1293 if (symmetricTails && !symmetricShorthand) {
1295 "\"n_L\", \"alpha_R\" and \"n_R\"");
1297 if (symmetricTails && asymmetricTails) {
1299 " must not combine \"alpha\"/\"n\" with \"alpha_L\"/\"n_L\"/\"alpha_R\"/\"n_R\"");
1301 if (asymmetricTails || !symmetricTails) {
1302 for (
const char *key : tailKeys) {
1303 if (!
p.has_child(key)) {
1305 "\": \"alpha_L\", \"n_L\", \"alpha_R\" and \"n_R\" are all required");
1308 }
else if (!
p.has_child(
"alpha") || !
p.has_child(
"n")) {
1312 const bool asymmetricWidths = hasAny(
p, {
"sigma_L",
"sigma_R"});
1313 if (asymmetricWidths &&
p.has_child(
"sigma")) {
1316 if (asymmetricWidths && !(
p.has_child(
"sigma_L") &&
p.has_child(
"sigma_R"))) {
1319 if (!asymmetricWidths && !
p.has_child(
"sigma")) {
1342 if (!CrystalBall::hasDoubleSidedKeys(
p)) {
1354 "\"alpha_R\", \"n_R\", \"sigma_L\" or \"sigma_R\" is deprecated, please use "
1355 "\"crystalball_doublesided_dist\" for the double-sided Crystal Ball.");
1358 CrystalBall::importDoubleSided(tool,
p,
"crystalball_dist",
true);
1363 mutable bool _warned =
false;
1368 CrystalBall::importDoubleSided(tool,
p,
"crystalball_doublesided_dist",
false);
1384 if (!pdf->alphaR() || !pdf->nR()) {
1385 elem[
"type"] <<
"crystalball_dist";
1391 elem[
"type"] << key;
1392 if (&pdf->sigmaL() == &pdf->sigmaR()) {
1405template <
class RooArg_t>
1408 const RooArg_t *pdf =
static_cast<const RooArg_t *
>(func);
1409 elem[
"type"] << key;
1412 elem[
"extended"] << (pdf->extendMode() != RooArg_t::CanNotBeExtended);
1416template <
class RooArg_t>
1419 auto const *pdf =
static_cast<const RooArg_t *
>(func);
1420 elem[
"type"] << key;
1423 if constexpr (std::is_same_v<RooArg_t, RooRealSumPdf>) {
1429template <
class RooArg_t>
1432 const RooArg_t *hf =
static_cast<const RooArg_t *
>(func);
1433 elem[
"type"] << key;
1442template <
class RooArg_t>
1446 if (!
p.has_child(
"data")) {
1449 std::unique_ptr<RooDataHist> dataHist =
1451 tool->
wsEmplace<RooArg_t>(
name, *dataHist->get(), *dataHist);
1458 elem[
"type"] << key;
1461 elem[
"epsilon"] << pdf->
epsilon();
1468 elem[
"type"] << (pdf->
divideByBinWidth() ?
"inverse_binvolume" :
"binvolume");
1473void cleanExpression(
TString &expr)
1479 replaceIdentifier(expr,
"TMath::Exp",
"exp");
1480 replaceIdentifier(expr,
"TMath::Min",
"min");
1481 replaceIdentifier(expr,
"TMath::Max",
"max");
1482 replaceIdentifier(expr,
"TMath::Log",
"log");
1483 replaceIdentifier(expr,
"TMath::Log10",
"log10");
1484 replaceIdentifier(expr,
"TMath::Cos",
"cos");
1485 replaceIdentifier(expr,
"TMath::CosH",
"cosh");
1486 replaceIdentifier(expr,
"TMath::Sin",
"sin");
1487 replaceIdentifier(expr,
"TMath::SinH",
"sinh");
1488 replaceIdentifier(expr,
"TMath::Sqrt",
"sqrt");
1489 replaceIdentifier(expr,
"TMath::Power",
"pow");
1490 replaceIdentifier(expr,
"TMath::Erf",
"erf");
1491 replaceIdentifier(expr,
"TMath::Erfc",
"erfc");
1492 replaceIdentifier(expr,
"TMath::Floor",
"floor");
1493 replaceIdentifier(expr,
"TMath::Ceil",
"ceil");
1494 replaceIdentifier(expr,
"TMath::Abs",
"abs");
1495 replaceIdentifier(expr,
"TMath::Tan",
"tan");
1496 replaceIdentifier(expr,
"TMath::TanH",
"tanh");
1497 replaceIdentifier(expr,
"TMath::ASin",
"asin");
1498 replaceIdentifier(expr,
"TMath::ACos",
"acos");
1499 replaceIdentifier(expr,
"TMath::ATan",
"atan");
1500 replaceIdentifier(expr,
"TMath::ATan2",
"atan2");
1501 replaceIdentifier(expr,
"TMath::Pi()",
"PI");
1502 replaceIdentifier(expr,
"TMath::E()",
"EULER");
1505bool ternariesToIfElse(std::string
const &in, std::string &out);
1508bool ternaryPartToIfElse(std::string
const &in, std::string &out)
1511 std::size_t question = std::string::npos;
1513 for (std::size_t i = 0; i < in.size() && question == std::string::npos; ++i) {
1514 const char c = in[i];
1515 if (
c ==
'(' ||
c ==
'[') {
1517 }
else if (
c ==
')' ||
c ==
']') {
1519 }
else if (
c ==
':' && i + 1 < in.size() && in[i + 1] ==
':') {
1521 }
else if (depth == 0 &&
c ==
':') {
1523 }
else if (depth == 0 &&
c ==
'?') {
1525 }
else if (depth == 0 &&
c ==
',') {
1530 if (question == std::string::npos) {
1533 for (std::size_t i = 0; i < in.size(); ++i) {
1534 if (in[i] ==
')' || in[i] ==
']') {
1537 if (in[i] !=
'(' && in[i] !=
'[') {
1541 const std::size_t
close = findClosingBracket(in, i);
1542 if (close == std::string::npos) {
1545 const std::string inner = in.substr(i + 1, close - i - 1);
1546 std::string innerOut;
1547 if (!ternariesToIfElse(inner, innerOut)) {
1551 const std::string before = trimmed(in.substr(0, i));
1552 const bool isGrouping = in[i] ==
'(' && (before.empty() || !isIdentifierChar(before.back()));
1553 if (isGrouping && innerOut != trimmed(inner) &&
startsWith(innerOut,
"ifelse(") &&
1554 findClosingBracket(innerOut, std::string(
"ifelse").
size()) == innerOut.size() - 1) {
1557 out += in[i] + innerOut + in[
close];
1565 std::size_t colon = std::string::npos;
1568 for (std::size_t i = question + 1; i < in.size() && colon == std::string::npos; ++i) {
1569 const char c = in[i];
1570 if (
c ==
'(' ||
c ==
'[') {
1572 }
else if (
c ==
')' ||
c ==
']') {
1574 }
else if (
c ==
':' && i + 1 < in.size() && in[i + 1] ==
':') {
1576 }
else if (depth == 0 &&
c ==
'?') {
1578 }
else if (depth == 0 &&
c ==
':') {
1586 if (colon == std::string::npos) {
1590 std::string condition;
1592 std::string ifFalse;
1593 if (!ternaryPartToIfElse(stripEnclosingParentheses(in.substr(0, question)), condition) ||
1594 !ternaryPartToIfElse(stripEnclosingParentheses(in.substr(question + 1, colon - question - 1)), ifTrue) ||
1595 !ternaryPartToIfElse(stripEnclosingParentheses(in.substr(colon + 1)), ifFalse)) {
1598 if (condition.empty() || ifTrue.empty() || ifFalse.empty()) {
1601 out =
"ifelse(" + condition +
"," + ifTrue +
"," + ifFalse +
")";
1607bool ternariesToIfElse(std::string
const &in, std::string &out)
1611 for (std::string
const &part : splitTopLevelCommas(in)) {
1612 std::string partOut;
1613 if (!ternaryPartToIfElse(part, partOut)) {
1616 out += (first ?
"" :
",") + partOut;
1622template <
class RooArg_t>
1625 const RooArg_t *pdf =
static_cast<const RooArg_t *
>(func);
1626 elem[
"type"] << key;
1627 TString expression(pdf->expression());
1628 cleanExpression(expression);
1635 for (
size_t idx = pdf->nParameters(); idx--;) {
1636 const RooAbsArg *par = pdf->getParameter(idx);
1637 expression.ReplaceAll((
"x[" + std::to_string(idx) +
"]").c_str(), par->
GetName());
1638 expression.ReplaceAll((
"@" + std::to_string(idx)).c_str(), par->
GetName());
1640 if (expression.Contains(
"?")) {
1641 std::string rewritten;
1642 if (ternariesToIfElse(expression.Data(), rewritten)) {
1643 expression = rewritten.c_str();
1646 "expression of '") +
1647 func->
GetName() +
"' to ifelse(), exporting the expression unchanged.");
1650 elem[
"expression"] << expression.Data();
1652 for (
const RooAbsArg *dependent : pdf->dependents()) {
1653 auto const *observable =
dynamic_cast<const RooAbsRealLValue *
>(dependent);
1657 const RooAbsBinning *binning = pdf->getBinning(*observable);
1662 auto &axes = elem[
"axes"];
1663 if (!axes.is_seq()) {
1666 auto &axis = axes.append_child().set_map();
1667 axis[
"name"] << observable->GetName();
1676template <
class RooArg_t>
1679 auto const *pdf =
static_cast<const RooArg_t *
>(func);
1680 elem[
"type"] << key;
1681 elem[
"x"] << pdf->x().GetName();
1682 auto &coefs = elem[
"coefficients"].
set_seq();
1683 for (
int i = 0; i < pdf->lowestOrder(); ++i) {
1686 for (
const auto &coef : pdf->coefList()) {
1694 auto *pdf =
static_cast<const RooPoisson *
>(func);
1695 elem[
"type"] << (pdf->getNoRounding() ?
"poisson_continuous_dist" : key);
1696 elem[
"x"] << pdf->getX().GetName();
1697 elem[
"mean"] << pdf->getMean().GetName();
1707 auto *pdf =
static_cast<const RooDecay *
>(func);
1708 elem[
"type"] << key;
1709 elem[
"t"] << pdf->getT().GetName();
1710 elem[
"tau"] << pdf->getTau().GetName();
1711 elem[
"resolutionModel"] << pdf->getModel().GetName();
1712 elem[
"decayType"] << pdf->getDecayType();
1724 elem[
"type"] << key;
1725 elem[
"x"] << pdf->convVar().GetName();
1733 elem[
"type"] << key;
1734 elem[
"x"] << pdf->convVar().GetName();
1735 elem[
"mean"] << pdf->getMean().GetName();
1736 elem[
"sigma"] << pdf->getSigma().GetName();
1744 auto const *gauss =
static_cast<RooGaussian const *
>(func);
1746 const bool swap = observable && *observable == gauss->getMean().GetName() && !
isLiteralConstVar(gauss->getMean());
1747 elem[
"type"] << key;
1748 writeReference(elem[
"x"], swap ? gauss->getMean() : gauss->getX());
1749 writeReference(elem[
"mean"], swap ? gauss->getX() : gauss->getMean());
1758 elem[
"type"] << key;
1759 elem[
"x"] << pdf->getX().GetName();
1761 auto &m0 = pdf->getMedian();
1762 auto &k = pdf->getShapeK();
1764 if (pdf->useStandardParametrization()) {
1765 elem[
"mu"] << m0.GetName();
1766 elem[
"sigma"] << k.GetName();
1778 elem[
"type"] << key;
1779 elem[
"x"] << pdf->variable().GetName();
1780 auto &
c = pdf->coefficient();
1781 if (pdf->negateCoefficient()) {
1782 elem[
"c"] <<
c.GetName();
1793 elem[
"type"] << key;
1796 elem[
"covariances"].
fill_mat(pdf->covarianceMatrix());
1803 elem[
"type"] << key;
1805 TString formula(pdf->function().GetExpFormula());
1806 formula.ReplaceAll(
"x", pdf->observables()[0].GetName());
1807 formula.ReplaceAll(
"y", pdf->observables()[1].GetName());
1808 formula.ReplaceAll(
"z", pdf->observables()[2].GetName());
1809 for (
size_t i = 0; i < pdf->parameters().
size(); ++i) {
1811 formula.ReplaceAll(pname, pdf->parameters()[i].GetName());
1813 elem[
"expression"] << formula.Data();
1820 elem[
"type"] << key;
1821 elem[
"x"] << pdf->getX().GetName();
1822 elem[
"function"] << pdf->getFunc().GetName();
1823 if (!pdf->getNset().empty()) {
1826 elem[
"order"] << pdf->order();
1827 elem[
"eps"] << pdf->eps();
1834 elem[
"type"] << key;
1835 std::string integrand = integral->integrand().GetName();
1836 elem[
"integrand"] << integrand;
1837 if (integral->intRange()) {
1838 elem[
"domain"] << integral->intRange();
1841 if (
RooArgSet const *funcNormSet = integral->funcNormSet()) {
1850 elem[
"type"] << key;
1851 if (
auto convFunc = pdf->getPdfConvVar()) {
1852 elem[
"conv_func"] << convFunc->GetName();
1854 elem[
"conv_var"] << pdf->getConvVar().GetName();
1855 elem[
"pdf1"] << pdf->getPdf1().GetName();
1856 elem[
"pdf2"] << pdf->getPdf2().GetName();
1857 elem[
"ipOrder"] << pdf->getInterpolationOrder();
1864 elem[
"type"] << key;
1865 if (
auto rangeName = pdf->getRangeName()) {
1866 elem[
"range"] << rangeName->GetName();
1868 elem[
"dist"] << pdf->pdf().GetName();
1869 elem[
"rate"] << pdf->getN().GetName();
1876 elem[
"type"] << key;
1879 auto ¶msNode = elem[
"parameters"].
set_seq();
1883 auto &observablesNode = elem[
"axes"].
set_seq();
1893 auto const *rs =
static_cast<RooSpline const *
>(func);
1895 elem[
"type"] << key;
1898 elem[
"x"] << rs->x().GetName();
1902 elem[
"interpolation"] << (rs->order() == 5 ?
"poly5" :
"poly3");
1903 elem[
"logx"] << rs->logx();
1904 elem[
"logy"] << rs->logy();
1907 TSpline const &sp = rs->spline();
1908 auto &x0 = elem[
"x0"].
set_seq();
1909 auto &y0 = elem[
"y0"].
set_seq();
1912 for (
int i = 0; i <
np; ++i) {
1916 x0.append_child() << xk;
1917 y0.append_child() << yk;
1925 elem[
"type"] << key;
1932 auto *pdf =
static_cast<const RooArgusBG *
>(func);
1933 elem[
"type"] << key;
1944 elem[
"type"] << key;
1953 elem[
"type"] << key;
1963 auto *pdf =
static_cast<const RooCBShape *
>(func);
1964 elem[
"type"] << key;
1976 elem[
"type"] << key;
1984 auto *pdf =
static_cast<const RooEffProd *
>(func);
1985 elem[
"type"] << key;
1993 auto *pdf =
static_cast<const RooGamma *
>(func);
1994 elem[
"type"] << key;
2004 auto *pdf =
static_cast<const RooLandau *
>(func);
2005 elem[
"type"] << key;
2014 auto *pdf =
static_cast<const RooPowerSum *
>(func);
2015 elem[
"type"] << key;
2024 elem[
"type"] << key;
2031 auto *prod =
static_cast<const RooProduct *
>(func);
2032 elem[
"type"] << key;
2041 elem[
"type"] << key;
2049 elem[
"type"] << key;
2056 if (node[
"type"].val() !=
"density_function_dist")
2062 bool selfNormalized =
false;
2064 auto sn = node.find(
"self_normalized");
2067 sn = node.find(
"selfnormalized");
2069 selfNormalized = sn->val_bool();
2081 node[
"type"] << key;
2085 auto const *funcProxy =
dynamic_cast<RooRealProxy const *
>(pdf->getProxy(0));
2086 if (!funcProxy || !funcProxy->absArg())
2089 node[
"function"] << funcProxy->absArg()->GetName();
2090 if (pdf->selfNormalized())
2091 node[
"self_normalized"] <<
true;
2112 FuncExporter(std::string key,
bool autoExportDependants)
2113 : _key{std::move(key)}, _autoExportDependants{autoExportDependants}
2116 std::string
const &key()
const override {
return _key; }
2117 bool autoExportDependants()
const override {
return _autoExportDependants; }
2120 return Func(tool, func, elem, _key);
2124 const std::string _key;
2125 const bool _autoExportDependants;
2135void registerExporter(
TClass const *cl, std::string key,
bool topPriority =
true,
bool autoExportDependants =
true)
2142 registerImporter<importWrapperPdf>(
"density_function_dist");
2143 registerImporter<importExtendPdf>(
"rate_extended_dist");
2145 registerImporter<importCrystalBallDoubleSided>(
"crystalball_doublesided_dist");
2148 std::make_unique<DeprecatedKeyImporter>(
"binsampling",
"binsampling_dist"));
2150 "mixture_resolution_model", std::make_unique<DeprecatedKeyImporter>(
"mixture_resolution_model",
"mixture_model"));
2152 "delta_resolution_model",
"truth_model_function"));
2154 "gauss_resolution_model",
"gauss_model_function"));
2155 registerImporter<importArgus>(
"argus_dist",
false);
2156 registerImporter<importArgus>(
"ARGUS_dist",
false);
2157 registerImporter<importBernstein>(
"bernstein_poly_dist",
false);
2158 registerImporter<importBifurGauss>(
"bifurkated_gaussian_dist",
false);
2159 registerImporter<importChebychev>(
"chebychev_dist",
false);
2160 registerImporter<importEffProd>(
"efficiency_product_pdf_dist",
false);
2161 registerImporter<importGamma>(
"gamma_dist",
false);
2162 registerImporter<importGaussian>(
"gaussian_dist",
false);
2163 registerImporter<importGaussian>(
"normal_dist",
false);
2164 registerImporter<importLandau>(
"landau_dist",
false);
2165 registerImporter<importPowerSum>(
"power_sum_dist",
false);
2166 registerImporter<importProjectedPdf>(
"projected_dist",
false);
2167 registerImporter<importUniform>(
"uniform_dist",
false);
2168 registerImporter<importProduct>(
"product",
false);
2169 registerImporter<importProdPdf>(
"product_dist",
false);
2170 registerImporter<importArrayDist>(
"array_dist",
false);
2171 registerImporter<importAddition>(
"sum",
false);
2172 registerImporter<importAddPdf>(
"mixture_dist",
false);
2173 registerImporter<importAddModel>(
"mixture_model",
false);
2174 registerImporter<importCombinedDist>(
"combined_dist",
false);
2175 registerImporter<importAddModel>(
"mixture_resolution_model",
false);
2176 registerImporter<importBinSamplingPdf>(
"binsampling_dist",
false);
2177 registerImporter<importBinSamplingPdf>(
"binsampling",
false);
2178 registerImporter<importBinWidthFunction<false>>(
"binvolume",
false);
2179 registerImporter<importBinWidthFunction<true>>(
"inverse_binvolume",
false);
2180 registerImporter<importPolynomial<RooLegacyExpPoly>>(
"legacy_exp_poly_dist",
false);
2181 registerImporter<importExponential>(
"exponential_dist",
false);
2182 registerImporter<importFormulaArg<RooFormulaVar>>(
"generic",
false);
2183 registerImporter<importFormulaArg<RooFormulaVar>>(
"generic_function",
false);
2184 registerImporter<importFormulaArg<RooGenericPdf>>(
"generic_dist",
false);
2185 registerImporter<importHist<RooHistFunc>>(
"histogram",
false);
2186 registerImporter<importHist<RooHistFunc>>(
"step",
false);
2187 registerImporter<importHist<RooHistPdf>>(
"histogram_dist",
false);
2188 registerImporter<importLogNormal>(
"lognormal_dist",
false);
2189 registerImporter<importMultiVarGaussian>(
"multivariate_normal_dist",
false);
2190 registerImporter<importPoisson<false>>(
"poisson_dist",
false);
2191 registerImporter<importPoisson<true>>(
"poisson_continuous_dist",
false);
2192 registerImporter<importDecay>(
"decay_dist",
false);
2193 registerImporter<importTruthModel>(
"truth_model_function",
false);
2194 registerImporter<importTruthModel>(
"delta_resolution_model",
false);
2195 registerImporter<importGaussModel>(
"gauss_model_function",
false);
2196 registerImporter<importGaussModel>(
"gauss_resolution_model",
false);
2197 registerImporter<importPolynomial<RooPolynomial>>(
"polynomial_dist",
false);
2198 registerImporter<importPolynomial<RooPolyVar>>(
"polynomial",
false);
2199 registerImporter<importRealSum<RooRealSumPdf>>(
"weighted_sum_dist",
false);
2200 registerImporter<importRealSum<RooRealSumFunc>>(
"weighted_sum",
false);
2201 registerImporter<importRealIntegral>(
"integral",
false);
2202 registerImporter<importDerivative>(
"derivative",
false);
2203 registerImporter<importFFTConvPdf>(
"fft_convolution_dist",
false);
2204 registerImporter<importExtendPdf>(
"extend_pdf",
false);
2205 registerImporter<importParamHistFunc>(
"step",
false);
2206 registerImporter<importSpline>(
"spline",
false);
2209 registerExporter<exportAddPdf<RooAddPdf>>(
RooAddPdf::Class(),
"mixture_dist",
false);
2210 registerExporter<exportAddPdf<RooAddModel>>(
RooAddModel::Class(),
"mixture_model",
false);
2212 registerExporter<exportCrystalBall>(
RooCrystalBall::Class(),
"crystalball_doublesided_dist",
false);
2214 registerExporter<exportPolynomial<RooLegacyExpPoly>>(
RooLegacyExpPoly::Class(),
"legacy_exp_poly_dist",
false);
2217 registerExporter<exportFormulaArg<RooGenericPdf>>(
RooGenericPdf::Class(),
"generic_dist",
false);
2219 registerExporter<exportHist<RooHistPdf>>(
RooHistPdf::Class(),
"histogram_dist",
false);
2224 registerExporter<exportDecay>(
RooDecay::Class(),
"decay_dist",
false,
false);
2227 registerExporter<exportPolynomial<RooPolynomial>>(
RooPolynomial::Class(),
"polynomial_dist",
false);
2228 registerExporter<exportPolynomial<RooPolyVar>>(
RooPolyVar::Class(),
"polynomial",
false);
2230 registerExporter<exportRealSum<RooRealSumPdf>>(
RooRealSumPdf::Class(),
"weighted_sum_dist",
false);
2242 registerExporter<exportCBShape>(
RooCBShape::Class(),
"crystalball_dist",
false);
2244 registerExporter<exportEffProd>(
RooEffProd::Class(),
"efficiency_product_pdf_dist",
false);
2245 registerExporter<exportGamma>(
RooGamma::Class(),
"gamma_dist",
false);
2258 auto component = arrayComponentOf(pdf, observable);
2260 return std::nullopt;
2266 std::map<std::string, std::string>
const &observableOf)
2268 auto error = [&
name](std::string
const &
message) {
2271 if (components.empty()) {
2272 error(
"it has no components");
2274 std::vector<ArrayComponent> comps;
2275 std::set<std::string> observables;
2276 for (
RooAbsPdf const *pdf : components) {
2277 auto recorded = observableOf.find(pdf->GetName());
2278 auto comp = arrayComponentOf(*pdf, recorded != observableOf.end() ? &recorded->second :
nullptr);
2280 error(
"'" + std::string(pdf->GetName()) +
2281 "' cannot be a component, only RooPoisson, RooGaussian and RooLognormal (standard parametrization) "
2282 "over a named observable are supported");
2284 if (!comps.empty() && comp->type != comps.front().type) {
2285 error(
"the components '" + std::string(components.front()->GetName()) +
"' (" + comps.front().type +
2286 ") and '" + pdf->GetName() +
"' (" + comp->type +
") have different types");
2288 if (!observables.insert(comp->x).second) {
2289 error(
"two components have the observable '" + comp->x +
"'");
2291 comps.push_back(std::move(*comp));
2294 elem[
"type"] <<
"array_dist";
2295 elem[
"component_type"] << comps.front().type;
2297 auto write = [](
JSONNode &node, ArrayFieldValue
const &
value) {
2298 std::visit([&node](
auto const &
v) { node <<
v; },
value);
2302 std::set<std::string> defaultKeys;
2303 if (comps.size() > 1) {
2304 for (std::size_t i = 0; i < comps.front().fields.size(); ++i) {
2305 auto const &field = comps.front().fields[i];
2306 if (std::all_of(comps.begin(), comps.end(),
2307 [&](ArrayComponent
const &comp) { return comp.fields[i].second == field.second; })) {
2308 defaultKeys.insert(field.first);
2312 if (!defaultKeys.empty()) {
2314 for (
auto const &field : comps.front().fields) {
2315 if (defaultKeys.find(field.first) != defaultKeys.end()) {
2316 write(defaults[field.first], field.second);
2322 for (ArrayComponent
const &comp : comps) {
2324 node[
"x"] << comp.x;
2325 for (
auto const &field : comp.fields) {
2326 if (defaultKeys.find(field.first) == defaultKeys.end()) {
2327 write(node[field.first], field.second);
void writeArrayDist(JSONNode &elem, std::string const &name, std::vector< RooAbsPdf const * > const &components, std::map< std::string, std::string > const &observableOf)
std::optional< ArrayComponentInfo > arrayComponentInfo(RooAbsPdf const &pdf, std::string const *observable)
void writeReference(JSONNode &node, RooAbsArg const &arg)
bool isHS3VersionBefore(std::string const &version, int major, int minor)
std::vector< RooAbsReal * > paramHistFuncParamsInBinOrder(ParamHistFunc const &func)
RooArgList toParamHistFuncOrder(RooArgList const ¶msInBinOrder, RooAbsCollection const &vars)
std::string selectionKeyToString(std::vector< std::string > const &key)
bool startsWith(std::string_view str, std::string_view prefix)
std::vector< RooCategory * > readSelectionColumns(RooWorkspace const &ws, JSONNode const &node, const char *field, std::string const &context)
bool endsWith(std::string_view str, std::string_view suffix)
std::string selectionLabel(std::vector< std::string > const &key)
std::vector< std::string > readSelectionKey(JSONNode const &component, std::vector< RooCategory * > const &columns, std::string const &context)
bool isLiteralConstVar(RooAbsArg const &arg)
std::string removeSuffix(std::string_view str, std::string_view suffix)
void writeAxisBinning(JSONNode &node, const RooAbsBinning &binning)
std::unique_ptr< RooArgSet > histogramVariablesNamedAfterObservables(RooDataHist const &dh, RooArgSet const &histObs, RooArgSet const &funcObs)
void checkParamHistFuncOrderIsDefined(std::string const &hs3Version, RooAbsCollection const &vars, std::string const &context)
constexpr const char * arrayDistTag
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
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 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 target
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
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 type
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
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.
Abstract base class for RooRealVar binning definitions.
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.
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
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.
RooArgusBG is a RooAbsPdf implementation describing the ARGUS background shape.
Bernstein basis polynomials are positive-definite in the range [0,1].
Bifurcated Gaussian p.d.f with different widths on left and right side of maximum value.
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
PDF implementing the Crystal Ball line shape.
Object to represent discrete states.
Chebychev polynomial p.d.f.
Represents a constant real-valued object.
PDF implementing the generalized Asymmetrical Double-Sided Crystall Ball line shape.
Container class to hold N-dimensional binned data.
double const * weightArray() const
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)...
The class RooEffProd implements the product of a PDF with an efficiency function.
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.
double val_double() const
JSONNode & append_child()
size_t num_children() const
void fill_mat(Matrix const &mat)
JSONNode const * find(std::string const &key) const
bool has_child(std::string const &) const
static std::unique_ptr< JSONTree > create()
Implementation of the Gamma PDF for RooFit/RooStats.
Class RooGaussModel implements a RooResolutionModel that models a Gaussian distribution.
A real-valued function sampled from a multidimensional histogram.
Landau distribution p.d.f.
Multivariate Gaussian p.d.f.
Holds the configuration parameters of the various numeric integrators used by RooRealIntegral.
RooPowerSum implements a power law PDF of the form.
Efficient implementation of a product of PDFs of the form.
Represents the product of a given set of RooAbsReal objects.
A RooAbsPdf implementation that represent a projection of a given input p.d.f and the object returned...
Performs hybrid numerical/analytical integrals of RooAbsReal objects.
Implements a PDF constructed from a sum of functions:
Variable that can be changed from the outside.
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
A RooFit class for creating spline functions.
Joins several RooAbsCategoryLValue objects into a single category.
Use TF1, TF2, TF3 functions as RooFit objects.
Implements a RooResolution model that corresponds to a delta function.
Persistable container for RooFit projects.
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
RooAbsArg * arg(RooStringView name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
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.
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
const char * GetName() const override
Returns name of object.
Base class for spline implementation containing the Draw/Paint methods.
virtual void GetKnot(Int_t i, Double_t &x, Double_t &y) const =0
virtual Int_t GetNp() const
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
double beta(double x, double y)
Calculates the beta function.
void swap(RVec< T > &lhs, RVec< T > &rhs)
double poisson(double x, double par)
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)