36struct InterpolationCodes {
42constexpr int kUnrepresentable = -1;
45constexpr InterpolationCodes interpolationTable[]{
55int codeForClass(InterpolationCodes
const &row, InterpolationClass interpolationClass)
72 for (
auto const &row : interpolationTable) {
73 const int rowCode = codeForClass(row, interpolationClass);
74 if (rowCode != kUnrepresentable && rowCode == code) {
75 return row.descriptor;
83 for (
auto const &row : interpolationTable) {
84 const int rowCode = codeForClass(row, interpolationClass);
85 if (rowCode != kUnrepresentable && row.descriptor == interpolation) {
94 return std::any_of(diagnostics.begin(), diagnostics.end(),
95 [](
Diagnostic const &
d) { return d.severity == Diagnostic::Severity::Error; });
98std::string Cursor::path()
const
111 out +=
"[" + std::to_string(
_index) +
"]";
113 out +=
"(" +
_node[
"name"].
val() +
")";
118void Cursor::error(std::string
const &
message)
const
123void Cursor::warning(std::string
const &
message)
const
128std::size_t Cursor::numErrors()
const
131 [](
Diagnostic const &
d) { return d.severity == Diagnostic::Severity::Error; });
142 _seen.emplace_back(key);
156 const std::string key =
child.key();
165 if (
c.node().is_container() ||
c.node().is_null()) {
166 c.error(
"must be a string");
169 out =
c.node().val();
174 if (!
c.node().is_number()) {
175 c.error(
"must be a number");
178 out =
c.node().val_double();
184 const double value =
c.node().is_number() ?
c.node().val_double() : 0.5;
185 if (
value != std::floor(
value) || std::abs(
value) >
static_cast<double>(std::numeric_limits<int>::max())) {
186 c.error(
"must be an integer");
189 out =
static_cast<int>(
value);
194 if (std::optional<bool>
value =
c.node().try_val_bool()) {
197 c.error(
"must be a boolean");
204 auto readNumber = [&](
int &number) {
205 const std::size_t begin = pos;
206 while (pos < version.size() && std::isdigit(
static_cast<unsigned char>(version[pos]))) {
210 if (pos == begin || pos - begin > 9) {
213 number = std::stoi(version.substr(begin, pos - begin));
217 if (!readNumber(parsed.
major) || pos >= version.size() || version[pos] !=
'.') {
221 if (!readNumber(parsed.
minor)) {
224 if (pos < version.size() && version[pos] ==
'.') {
226 if (!readNumber(parsed.
patch)) {
237void readBound(Reader &ar,
const char *key, std::optional<double> &out,
double valueIfNull)
243 if (
c.node().is_null()) {
251constexpr double infinity = std::numeric_limits<double>::infinity();
254void readEdges(Reader &ar, std::string
const &axisName, std::vector<double> &edges)
257 const std::string context =
"\"edges\" of axis '" + axisName +
"' must ";
258 if (!
c.node().is_seq()) {
259 c.error(context +
"be a list");
263 for (std::size_t i = 1; i < edges.size(); ++i) {
264 if (!(edges[i] > edges[i - 1])) {
265 c.error(context +
"be strictly ascending");
269 if (edges.size() < 2) {
270 c.error(context +
"contain at least two values");
279 ar(
"version",
p.version);
284 ar(
"name", axis.
name);
287 if (ar.
has(
"value")) {
288 for (
const char *key : {
"min",
"max",
"nbins",
"edges",
"categories"}) {
290 ar.
cursor().
error(
"the axis '" + axis.
name +
"' has \"value\" and \"" + key +
291 "\", which exclude each other");
298 readBound(ar,
"min", axis.
min, -infinity);
299 readBound(ar,
"max", axis.
max, infinity);
300 if (ar.
has(
"edges")) {
303 ar(
"edges", binning.
edges);
304 if (!binning.
edges.empty()) {
312 axis.
binning = std::move(binning);
313 }
else if (ar.
has(
"nbins")) {
315 ar(
"nbins", binning.
nbins);
316 if (binning.
nbins != 0) {
324 ar(
"name", axis.
name);
327 readBound(ar,
"min", axis.
min, -infinity);
328 readBound(ar,
"max", axis.
max, infinity);
333 ar(
"name", axis.
name);
334 if (ar.
has(
"edges")) {
337 if (binning.
edges.size() >= 2) {
342 std::optional<double> min;
343 std::optional<double> max;
346 if ((min && *min != axis.
min) || (max && *max != axis.
max)) {
347 ar.
cursor().
error(
"\"min\" and \"max\" of axis '" + axis.
name +
"' must agree with the \"edges\"");
349 if (ar.
has(
"nbins")) {
350 ar.
cursor().
error(
"axis '" + axis.
name +
"' must not have both \"edges\" and \"nbins\"");
352 axis.
binning = std::move(binning);
358 ar(
"nbins", binning.
nbins);
365 ar(
"name", axis.
name);
366 for (
const char *key : {
"min",
"max",
"nbins",
"edges"}) {
368 ar.
cursor().
error(
"the axis '" + axis.
name +
"' is categorical and must not have \"" + key +
"\"");
371 ar.
has(
"categories");
374 ar.
cursor().
error(
"the axis '" + axis.
name +
"': \"categories\" must be a non-empty list of strings");
380 if (label.is_container() || label.is_null() || label.is_number()) {
381 ar.
cursor().
error(
"the axis '" + axis.
name +
"': the entries of \"categories\" must be strings");
385 ar.
cursor().
error(
"the axis '" + axis.
name +
"': the category \"" + label.val() +
"\" is listed twice");
393template <
class Axis_t>
397 if (ar.
has(
"categories") && !(std::is_same_v<Axis_t, DomainAxis> && ar.
has(
"value"))) {
398 describe(ar, out.template emplace<CategoricalAxis>());
400 describe(ar, out.template emplace<Axis_t>());
406 ar(
"name", domain.
name);
409 if (
type !=
"product_domain") {
410 ar.
cursor().
error(
"only domains of type \"product_domain\" are currently supported!");
418 ar(
"name", out.
name);
419 if (ar.
has(
"value")) {
426 out.
value = std::move(label);
430 ar(
"err", out.
error);
432 ar(
"nbins", out.
nbins);
437 ar(
"name", point.
name);
443 ar(
"value",
data.value);
444 ar(
"uncertainty",
data.uncertainty);
451 ar(
"weights",
data.weights);
452 data.hasEntriesUncertainties = ar.
has(
"entries_uncertainties");
454 if (!ar.
has(
"entries")) {
455 ar.
cursor().
error(
"does not define the required component \"entries\"");
460 entries.
error(
"key 'entries' is not a list!");
464 ar.
cursor().
error(
"inconsistent number of entries and weights!");
468 std::size_t iRow = 0;
470 Cursor rowCursor{row, entries, iRow};
472 rowCursor.
error(
"coordinate point '" + std::to_string(iRow) +
"' is not a list!");
475 if (row.num_children() !=
data.axes.size()) {
476 rowCursor.error(
"inconsistent number of entries and observables!");
479 std::size_t iAxis = 0;
482 if (
auto const *category = std::get_if<CategoricalAxis>(&
data.axes[iAxis])) {
485 auto found = std::find(category->categories.begin(), category->categories.end(), label);
486 if (found == category->categories.end()) {
487 valueCursor.error(
"'" + label +
"' is not a category of the axis '" + category->name +
"'");
490 data.entries.push_back(
static_cast<double>(std::distance(category->categories.begin(), found)));
492 double coordinate = 0.0;
494 data.entries.push_back(coordinate);
504 if (ar.
has(
"type")) {
507 if (
type !=
"gaussian_uncertainty") {
511 ar(
"sigma", uncertainty.
sigma);
512 if (ar.
has(
"correlation")) {
515 if (
c.node().is_seq()) {
517 }
else if (!
c.node().is_number() ||
c.node().val_double() != 0.0) {
518 c.error(
"must be a matrix or 0");
526 ar(
"contents",
data.contents);
527 ar(
"uncertainty",
data.uncertainty);
529 if (ar.
has(
"errors")) {
532 errors.
error(
"errors are not in list form");
533 }
else if (!
data.uncertainty) {
534 data.uncertainty.emplace();
543template <
class Ref_t>
547 auto nonEmptyList = [&](
const char *key) ->
JSONNode const * {
548 if (!ar.
has(key) || !
c.node()[key].is_seq() ||
c.node()[key].num_children() == 0) {
551 return &
c.node()[key];
553 JSONNode const *columns = nonEmptyList(
"columns");
554 for (std::size_t i = 0; columns && i < columns->
num_children(); ++i) {
563 c.error(
"\"columns\" of " + context +
" must be a non-empty list of names of categorical axes");
566 JSONNode const *components = nonEmptyList(
"components");
568 c.error(
"\"components\" of " + context +
" must be a non-empty list");
572 if (!node.is_map() || !node.has_child(
"key") || !node.has_child(refKey)) {
573 c.error(
"every component of " + context +
" must have a \"key\" and a \"" + refKey +
"\"");
580 component.
key.push_back(label.is_container() ? std::string{} : label.val());
583 c.error(
"every component of " + context +
" must have a \"key\" with " + std::to_string(out.
columns.size()) +
584 " labels, one per column");
587 component.
ref.name = node[refKey].val();
593 ar(
"name", out.
name);
596 if (
type ==
"binned") {
598 }
else if (
type ==
"unbinned") {
600 }
else if (
type ==
"point") {
602 }
else if (
type ==
"combined") {
603 std::string
const context =
"the combined data set '" + out.
name +
"'";
605 if (ar.
has(
"axes")) {
606 ar.
cursor().
error(context +
" must not have \"axes\": its columns are declared by the domains");
610 }
else if (ar.
has(
"type")) {
617 ar(
"name", likelihood.
name);
620 std::vector<DistributionRef> distributions;
621 ar(
"distributions", distributions);
622 if (!ar.
has(
"data")) {
623 ar.
cursor().
error(
"does not define the required component \"data\"");
628 if (
data.node().is_null()) {
630 for (
auto &distribution : distributions) {
631 likelihood.
terms.push_back({std::move(distribution), std::monostate{}});
635 if (!
data.node().is_seq()) {
636 data.error(
"must be an array");
639 if (
data.node().num_children() != distributions.size()) {
640 ar.
cursor().
error(
"\"distributions\" and \"data\" must have the same length");
643 likelihood.
terms.reserve(distributions.size());
649 if (node.is_number() || (!node.is_container() && !node.is_null() && node.val() ==
"0")) {
650 term.
data = node.is_number() ? node.val_double() : 0.0;
654 term.
data = std::move(ref);
656 likelihood.
terms.push_back(std::move(term));
663 ar(
"name", analysis.
name);
667 auto isLegacy = [&](
const char *key,
const char *legacyKey) {
668 if (ar.
has(key) || !ar.
has(legacyKey)) {
671 ar.
cursor().
warning(std::string(
"the key \"") + legacyKey +
"\" of analysis '" + analysis.
name +
672 "' is deprecated, please use \"" + key +
"\" instead.");
675 ar.
optional(isLegacy(
"parameters_of_interest",
"parameter_of_interest") ?
"parameter_of_interest"
676 :
"parameters_of_interest",
678 if (!isLegacy(
"domains",
"domain")) {
683 analysis.
domains.emplace_back();
684 ar(
"domain", analysis.
domains.back());
686 ar(
"init", analysis.
init);
687 ar(
"prior", analysis.
prior);
693std::optional<InterpolationType> interpolationTypeFromString(std::string
const &str)
703std::optional<InterpolationFunction> interpolationFunctionFromString(std::string
const &str)
746 c.error(
"must be a struct with components 'type', 'in', and 'out'");
751 for (
const char *component : {
"type",
"in",
"out"}) {
752 if (!reader.has(component)) {
753 c.error(std::string(
"does not define the required '") + component +
"' component");
757 JSONNode const &typeNode = node[
"type"];
758 JSONNode const &inNode = node[
"in"];
759 JSONNode const &outNode = node[
"out"];
761 c.error(
"components 'type' and 'in' must be strings");
765 auto type = interpolationTypeFromString(typeNode.
val());
767 c.error(
"has unknown interpolation type '" + typeNode.
val() +
"'");
770 auto in = interpolationFunctionFromString(inNode.
val());
772 c.error(
"has unknown interpolation function '" + inNode.
val() +
"'");
781 c.error(
"component 'out' must be a string or null");
784 out.
out = interpolationFunctionFromString(outNode.
val());
786 c.error(
"has unknown extrapolation function '" + outNode.
val() +
"'");
796std::optional<ConstraintType> readConstraintType(
Cursor const &
c)
805 c.error(
"unknown constraint type '" +
value +
"', supported are \"Gauss\", \"Poisson\" and \"LogNormal\"");
811void readSingleEntry(Reader &ar,
const char *key, T &out)
814 if (!
c.node().is_seq() ||
c.node().num_children() != 1) {
815 c.error(
"must be an array with one entry");
821void readConstraint(Reader &ar,
Constraint &out)
823 if (ar.has(
"constraints")) {
824 std::optional<DistributionRef> pdf;
825 readSingleEntry(ar,
"constraints", pdf);
827 out = ConstraintPdf{std::move(*pdf)};
829 }
else if (ar.has(
"constraint_name")) {
831 ar(
"constraint_name", pdf.pdf);
832 pdf.legacyName =
true;
833 out = std::move(pdf);
834 }
else if (ar.has(
"constraint")) {
835 if (
auto type = readConstraintType(ar.child(
"constraint"))) {
843 if (ar.has(
"constraints")) {
844 ar(
"constraints", out.emplace<GammaConstraintPdfs>().pdfs);
845 }
else if (ar.has(
"constraint")) {
846 Cursor c = ar.child(
"constraint");
848 if (!
c.node().is_container() && !
c.node().is_null() &&
c.node().val() ==
"Const") {
849 out = ConstantGammas{};
850 }
else if (
auto type = readConstraintType(
c)) {
861 if (ar.
has(
"parameters")) {
862 readSingleEntry(ar,
"parameters", parameter);
864 ar(
"parameter", parameter);
873 readConstraint(ar,
m.constraint);
879 ar(
"errors", variation.
errors);
883template <
class Modifier_t>
892 readConstraint(ar,
m.constraint);
893 ar(
"interpolation",
m.interpolation);
899 if (ar.
has(
"parameter")) {
901 ar(
"parameter",
m.name);
904 if (ar.
has(
"data")) {
907 readGammaConstraint(ar,
m.constraint);
914 readGammaConstraint(ar,
m.constraint);
926 if (
type ==
"normfactor") {
928 }
else if (
type ==
"normsys") {
930 }
else if (
type ==
"histosys") {
932 }
else if (
type ==
"shapesys" ||
type ==
"shapefactor") {
934 }
else if (
type ==
"staterror") {
936 }
else if (
type ==
"custom") {
938 }
else if (ar.
has(
"type")) {
940 if (ar.
has(
"name")) {
949 ar(
"name", sample.
name);
969 if (axis.is_map() && axis.has_child(
"categories")) {
970 ar.
cursor().
error(
"the axis '" + (axis.has_child(
"name") ? axis[
"name"].val() : std::string{}) +
971 "' is categorical, but the axes of a HistFactory prediction are binned");
976 ar(
"axes", dist.axes);
977 ar(
"default_interpolation", dist.defaultInterpolation);
978 ar(
"samples", dist.samples);
979 if (ar.
has(
"staterror")) {
986void readDistribution(
Cursor const &
c, Distribution &out, ParseOptions
const &options)
988 if (!
c.node().is_map()) {
989 c.error(
"must be a struct");
993 ar(
"name", out.name);
996 if (options.typedHistFactory &&
type ==
"histfactory_dist") {
997 describe(ar, out.body.emplace<HistFactoryDist>());
998 }
else if (
type ==
"combined_dist") {
999 std::string
const context =
"the combined_dist '" + out.name +
"'";
1001 if (ar.has(
"extended")) {
1002 c.error(context +
" must not have \"extended\": whether it is extended follows from its components");
1007 out.body = GenericObject{
type, &
c.node()};
1017 ar(
"name", out.
name);
1026 if (ar.
has(
"dict")) {
1027 ar(
"dict", attributes.
dict);
1030 if (ar.
has(
"is_const_var")) {
1032 ar(
"is_const_var", isConstVar);
1040 ar(
"labels", info.
labels);
1044 ar.
cursor().
error(
"mismatch in number of labels, indices and distributions!");
1051 ar(
"labels", info.
labels);
1054 ar.
cursor().
error(
"mismatch in number of indices and labels!");
1060 ar(
"mcName", info.
mcName);
1070void readStepWidths(
Cursor const &misc, std::vector<StepWidth> &out)
1072 JSONNode const *node = misc.node().find(
"minimization",
"parameter_stepwidths");
1077 misc.warning(
"minimization.parameter_stepwidths is not a sequence, skipping.");
1080 for (
JSONNode const &item : node->children()) {
1081 if (!item.is_map() || !item.has_child(
"name") || !item.has_child(
"step_width") ||
1082 !item[
"step_width"].is_number() || item[
"name"].is_container() || item[
"name"].is_null()) {
1083 misc.warning(
"skipping malformed parameter_stepwidths entry.");
1086 out.push_back({item[
"name"].val(), item[
"step_width"].val_double()});
1090void readMisc(
Cursor const &root, RooFitInternal &out)
1092 if (!root.node().has_child(
"misc")) {
1095 Cursor misc{root.node()[
"misc"], root,
"misc"};
1096 if (!misc.node().is_map()) {
1099 readStepWidths(misc, out.stepWidths);
1100 if (!misc.node().has_child(
"ROOT_internal")) {
1103 Cursor internal{misc.node()[
"ROOT_internal"], misc,
"ROOT_internal"};
1104 if (!internal.node().is_map()) {
1107 Reader ar{internal};
1108 ar.optional(
"attributes", out.attributes);
1109 ar.optional(
"combined_distributions", out.combinedDistributions);
1110 ar.optional(
"combined_datasets", out.combinedDatasets);
1111 ar.optional(
"ModelConfigs", out.modelConfigs);
1112 ar.optional(
"histfactory_constraints", out.channelConstraints);
1113 ar.optional(
"auxiliary_channels", out.auxiliaryChannels);
1114 ar.optional(
"bookkeeping_columns", out.bookkeepingColumns);
1117void readMetadata(
Cursor const &root, Metadata &out)
1119 JSONNode const *metadata = root.node().find(
"metadata");
1120 JSONNode const *versionNode = metadata ? metadata->
find(
"hs3_version") :
nullptr;
1122 std::stringstream ss;
1123 ss <<
"The HS3 version is missing in the JSON!\n"
1124 <<
"Please include the HS3 version in the metadata field, e.g.:\n"
1125 <<
" \"metadata\" :\n"
1129 root.error(ss.str());
1132 Cursor metadataCursor{*metadata, root,
"metadata"};
1133 Cursor versionCursor{*versionNode, metadataCursor,
"hs3_version"};
1135 versionCursor.error(std::string(
"The HS3 version in the metadata must be a string, e.g. \"") +
supportedVersion +
1139 out.hs3Version = versionNode->
val();
1144 versionCursor.warning(
"cannot parse hs3_version '" + out.hs3Version +
1145 "', expected a string of the form \"MAJOR.MINOR\".");
1146 }
else if (supported < Version{out.version.major, out.version.minor}) {
1147 versionCursor.warning(
"the document has hs3_version '" + out.hs3Version +
1148 "', which is newer than the version supported by this RooFit ('" +
supportedVersion +
1149 "'). Some content might not be imported correctly.");
1152 Reader ar{metadataCursor};
1153 ar.has(
"hs3_version");
1154 ar.optional(
"packages", out.packages);
1155 ar.optional(
"authors", out.authors);
1156 ar.optional(
"publications", out.publications);
1157 ar(
"description", out.description);
1174 if (ar.has(
"distributions") && !root[
"distributions"].
is_null()) {
1175 Cursor distributions{root[
"distributions"],
cursor,
"distributions"};
1176 if (!distributions.node().is_seq()) {
1177 distributions.error(
"must be an array");
1180 doc.
distributions.reserve(distributions.node().num_children());
1181 for (
JSONNode const &item : distributions.node().children()) {
1188 ar.optional(
"functions", doc.
functions);
1189 ar.optional(
"data", doc.
data);
1191 ar.optional(
"domains", doc.
domains);
1193 ar.optional(
"analyses", doc.
analyses);
1202 if (!distribution.
is_map()) {
1203 cursor.error(
"must be a struct");
1215 if (
c.node().is_number()) {
1216 out =
c.node().val_double();
1226 c.error(
"must be a structured interpolation or a legacy integer code");
1227 return std::nullopt;
1229 const std::string
value = node.
val();
1233 c.error(
"has invalid legacy interpolation code '" +
value +
"'");
1234 return std::nullopt;
1237 if (!interpolation) {
1238 c.error(std::string(
"has unsupported ") +
1242 return interpolation;
1249void readInterpolations(Reader &ar, std::size_t nParameters, InterpolationClass interpolationClass,
1250 std::vector<Interpolation> &out)
1253 if (ar.has(
"interpolations")) {
1254 Cursor c = ar.child(
"interpolations");
1255 const std::size_t errorsBefore =
c.numErrors();
1256 std::vector<Interpolation> interpolations;
1258 const std::size_t
size = interpolations.size();
1259 if (
c.numErrors() != errorsBefore) {
1262 if (nParameters == 0 ?
size != 0 :
size != 1 &&
size != nParameters) {
1263 c.error(
"component 'interpolations' must contain either one descriptor or one descriptor per parameter (got " +
1264 std::to_string(
size) +
" for " + std::to_string(nParameters) +
" parameters)");
1265 }
else if (
size == 1) {
1266 out.assign(nParameters, interpolations.front());
1268 out = std::move(interpolations);
1272 if (!ar.has(
"interpolationCodes")) {
1275 Cursor c = ar.child(
"interpolationCodes");
1276 if (!
c.node().is_seq() ||
c.node().num_children() != nParameters) {
1277 c.error(
"legacy component 'interpolationCodes' must contain one code per parameter (got " +
1278 std::to_string(
c.node().is_seq() ?
c.node().num_children() : 0) +
" for " + std::to_string(nParameters) +
1285 out[i] = *interpolation;
1292template <
class Function_t,
class Fn>
1293Function_t parseInterpolated(
JSONNode const &node,
Diagnostics &diagnostics, InterpolationClass interpolationClass,
1299 cursor.error(
"must be a struct");
1302 const std::size_t errorsBefore =
cursor.numErrors();
1306 ar(
"nom", out.nominal);
1307 ar(
"vars", out.parameters);
1308 ar(
"high", out.high);
1310 readOthers(ar, out);
1311 if (
cursor.numErrors() == errorsBefore &&
1312 (out.high.size() != out.parameters.size() || out.low.size() != out.parameters.size())) {
1313 cursor.error(
"has non-matching lengths of 'vars', 'high' and 'low'");
1315 readInterpolations(ar, out.parameters.size(), interpolationClass, out.interpolations);
1324 readDistribution(
Cursor{distribution, diagnostics}, out, {});
1337 std::vector<BinnedAxis> out;
1344 return parseInterpolated<InterpolatedFunction>(
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 data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
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 result
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 child
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
double val_double() const
bool is_container() const
size_t num_children() const
JSONNode const * find(std::string const &key) const
The component at the end of a path of keys, or nullptr if a component on the path doesn't exist.
bool has_child(std::string const &) const
JSONNode & child(size_t pos)
An HS3 document. It is move-only, because generic objects refer to the JSON tree of the document.
std::vector< HS3::Analysis > analyses
std::vector< HS3::Data > data
std::vector< HS3::Likelihood > likelihoods
std::vector< HS3::Function > functions
std::vector< HS3::ParameterPoint > parameterPoints
HS3::RooFitInternal rooFit
std::vector< HS3::Domain > domains
std::vector< HS3::Distribution > distributions
A position in the JSON tree.
std::size_t numErrors() const
void warning(std::string const &message) const
Detail::JSONNode const & node() const
Diagnostics & _diagnostics
Detail::JSONNode const & _node
void error(std::string const &message) const
Reads the components of a struct.
void ignoreUnread()
Don't report the components that were not read, because they are read later by someone else.
~Reader()
Reports the components that were not read, unless reading the struct gave an error.
Reader(Cursor const &cursor)
bool has(const char *key)
Whether the struct has a component. Checking for a component counts as reading it.
std::vector< std::string > _seen
void optional(const char *key, T &field)
Read a component that can be omitted or null, which leaves the field as it is, e.g....
void nested(const char *key, Fn &&fn)
Read the components of a struct that is nested in a component.
std::size_t _nErrorsBefore
Cursor const & cursor() const
Cursor child(const char *key) const
The position of a component.
Types that represent an HS3 document.
std::variant< std::string, double > NameOrNumber
A name, or a number for a constant.
HistFactoryDist parseHistFactoryDist(Detail::JSONNode const &distribution, Diagnostics &diagnostics)
Reads a HistFactory distribution that doesn't come with a document.
std::variant< NormFactor, NormSys, HistoSys, ShapeSys, StatError, CustomModifier > Modifier
constexpr auto supportedVersion
Distribution parseDistribution(Detail::JSONNode const &distribution, Diagnostics &diagnostics)
Reads a distribution that doesn't come with a document.
void describeSys(Reader &ar, Modifier_t &m)
InterpolationClass
The RooFit classes that implement the interpolations, which encode them with integer codes.
constexpr Interpolation multiplicativePolynomialExponential
void readValue(Cursor const &c, std::string &out)
constexpr Interpolation additivePolynomialLinear
void readParameter(Reader &ar, ParameterRef ¶meter)
void describe(Reader &ar, Package &p)
ConstraintType
The constraint types that older documents named, for which RooFit creates the constraint terms.
std::optional< Interpolation > interpolationFromCode(int code, InterpolationClass interpolationClass)
The interpolation for an integer code, or nothing if the class doesn't support the code.
char const * toString(InterpolationType type)
InterpolatedNumber parseInterpolatedNumber(Detail::JSONNode const &node, Diagnostics &diagnostics)
std::optional< Interpolation > readInterpolationCode(Cursor const &c, InterpolationClass interpolationClass)
Reads an integer interpolation code, as older versions of RooFit wrote them.
InterpolatedFunction parseInterpolatedFunction(Detail::JSONNode const &node, Diagnostics &diagnostics)
Reads the functions "interpolation" and "interpolation0d", which don't come with a document.
void readCombined(Reader &ar, std::string const &context, const char *refKey, Combined< Ref_t > &out)
std::optional< int > codeFromInterpolation(Interpolation const &interpolation, InterpolationClass interpolationClass)
The integer code of an interpolation, or nothing if the class can't represent the interpolation.
constexpr Interpolation multiplicativePolynomialLinear
bool hasErrors(Diagnostics const &diagnostics)
Whether there is a diagnostic with error severity.
constexpr Interpolation multiplicativePiecewiseExponential
std::vector< Diagnostic > Diagnostics
std::variant< Unconstrained, ConstraintType, ConstantGammas, GammaConstraintPdfs > GammaConstraint
bool parseVersion(std::string const &version, Version &out)
Reads the leading "MAJOR.MINOR" and the optional ".PATCH" of an HS3 version string.
std::variant< Unconstrained, ConstraintType, ConstraintPdf > Constraint
Data parseData(Detail::JSONNode const &data, Diagnostics &diagnostics)
Reads a data set that doesn't come with a document.
std::vector< BinnedAxis > parseBinnedAxes(Detail::JSONNode const &axes, Diagnostics &diagnostics)
Reads the axes of binned data that doesn't come with a document.
constexpr Interpolation additiveQuadraticLinear
constexpr Interpolation additivePiecewiseLinear
HS3Document parseDocument(Detail::JSONNode const &root, Diagnostics &diagnostics, ParseOptions const &options={})
Reads a document.
Combined< DistributionRef > CombinedDist
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
std::optional< DistributionRef > prior
std::optional< ParameterPointRef > init
std::vector< DomainRef > domains
std::vector< ParameterRef > parametersOfInterest
bool isConstVar
How ROOT versions before HS3 0.3 marked named RooConstVars.
std::vector< std::string > tags
std::map< std::string, std::string > dict
std::vector< std::string > categories
The data set or distribution that a combined data set or distribution selects for one key,...
std::vector< std::string > key
The data set of a RooSimultaneous as older versions of RooFit wrote it. It is only read.
std::vector< int > indices
std::vector< std::string > labels
A RooSimultaneous as older versions of RooFit wrote it, before HS3 had combined distributions....
std::vector< std::string > labels
std::vector< DistributionRef > distributions
std::vector< int > indices
Data sets or distributions that are selected by a key (HS3 #119). The columns are categorical axes of...
std::vector< CombinedComponent< Ref_t > > components
std::vector< std::string > columns
The axis of point data or unbinned data, which can't have a binning.
std::optional< double > max
std::optional< double > min
bool hasFixedValue
Whether the axis has a fixed "value", which is only allowed in domains.
Multiplies the sample with a function of the document.
std::variant< PointData, UnbinnedData, BinnedData, CombinedData > body
std::optional< double > min
std::optional< double > max
std::optional< Binning > binning
std::optional< double > fixedValue
std::vector< std::variant< DomainAxis, CategoricalAxis > > axes
std::vector< double > edges
std::vector< std::vector< double > > correlation
Empty if there is no correlation.
std::vector< double > sigma
Detail::JSONNode const * node
The object in the JSON tree that the document was read from.
std::vector< double > contents
std::optional< std::vector< double > > errors
Not in the standard, but older versions of RooFit read them.
The function "interpolation" of RooFit, implemented by PiecewiseInterpolation: a nominal function plu...
The function "interpolation0d" of RooFit, implemented by FlexibleInterpVar: a nominal value plus the ...
How a modifier of a HistFactory distribution interpolates and extrapolates its effect.
std::optional< InterpolationFunction > out
If not set, the function inside the bounds is used outside as well.
The data of a likelihood term: a data set, a number given in-line, or none (std::monostate) in a pure...
DistributionRef distribution
std::variant< DataRef, double, std::monostate > data
bool pureModel
Whether "data" is null: the likelihood only groups the distributions of a model without data (e....
std::vector< DistributionRef > auxDistributions
std::vector< LikelihoodTerm > terms
std::optional< std::string > pdfName
std::optional< std::vector< std::string > > observables
The observables of the ModelConfig, written if no data set of the likelihood gives them.
std::optional< std::string > mcName
std::optional< std::string > combinedDataName
std::vector< ParameterValue > parameters
std::optional< std::variant< double, std::string > > value
A string selects the state of a category.
std::optional< int > nbins
std::optional< double > error
std::optional< double > relError
Options for upgradeDocument() and parseDocument().
A name that says what it refers to, so that for example a DataRef can't be used as a DomainRef.
std::vector< double > contents
std::optional< std::vector< double > > errors
std::vector< Modifier > modifiers
Scales each bin by its own parameter. The modifier type "shapesys" is a deprecated alias of "shapefac...
Settings of the staterror modifiers that apply to the whole channel. This is a RooFit extension.
bool impliedPoissonErrors
Samples without "errors" have Poisson uncertainties, as in documents before HS3 0....
GammaConstraint constraint
Scales each bin by a parameter, that is constrained by the statistical uncertainty of all samples tha...