Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
HS3Document.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Jonas Rembser, CERN, Nov 2026
5 *
6 * Copyright (c) 2026, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
12
13#ifndef RooFit_HS3Document_h
14#define RooFit_HS3Document_h
15
16#include <functional>
17#include <map>
18#include <memory>
19#include <optional>
20#include <set>
21#include <string>
22#include <variant>
23#include <vector>
24
25namespace RooFit {
26
27namespace Detail {
28class JSONNode;
29class JSONTree;
30} // namespace Detail
31
32/// Types that represent an HS3 document. They follow the structure of the HS3 standard, and this header must not depend
33/// on RooFit: creating RooFit objects from a document is a separate step.
34namespace HS3 {
35
36struct Version {
37 int major = 0;
38 int minor = 0;
39 int patch = 0;
40};
41
42inline bool operator<(Version const &l, Version const &r)
43{
44 if (l.major != r.major) {
45 return l.major < r.major;
46 }
47 if (l.minor != r.minor) {
48 return l.minor < r.minor;
49 }
50 return l.patch < r.patch;
51}
52
53/// Combines lambdas into one visitor for std::visit(). The compiler complains about the alternatives without lambda.
54template <class... Ts>
55struct overloaded : Ts... {
56 using Ts::operator()...;
57};
58template <class... Ts>
60
61/// A name that says what it refers to, so that for example a DataRef can't be used as a DomainRef.
62template <class Tag>
63struct Ref {
64 std::string name;
65};
66
73
74struct Package {
75 std::string name;
76 std::string version;
77};
78
79struct Metadata {
80 std::string hs3Version; ///< As it was written in the document, empty for fragments of a document.
81 Version version; ///< The parsed version. Versions that can't be parsed count as the oldest one.
82 std::vector<Package> packages;
83 std::vector<std::string> authors;
84 std::vector<std::string> publications;
85 std::optional<std::string> description;
86};
87
89 int nbins = 0;
90};
92 std::vector<double> edges;
93};
94using Binning = std::variant<RegularBinning, EdgesBinning>;
95
96/// The axis of a domain. Infinite bounds are written as null, and bounds can be missing in older documents. The binning
97/// is a RooFit extension. A fixed axis has a single value instead, which excludes bounds and a binning.
98struct DomainAxis {
99 std::string name;
100 std::optional<double> fixedValue;
101 std::optional<double> min;
102 std::optional<double> max;
103 std::optional<Binning> binning;
104};
105
106/// The axis of point data or unbinned data, which can't have a binning.
108 std::string name;
109 std::optional<double> min;
110 std::optional<double> max;
111};
112
113/// The axis of binned data.
115 std::string name;
116 double min = 0.0;
117 double max = 0.0;
119};
120
122 std::string name;
123 std::vector<std::string> categories;
124};
125
126struct Domain {
127 std::string name;
128 std::vector<std::variant<DomainAxis, CategoricalAxis>> axes;
129};
130
131/// The domain in which RooFit writes the ranges of all variables. It is a convention of RooFit, not of the standard.
132inline constexpr char const *defaultDomainName = "default_domain";
133
134/// Where RooFit takes the ranges of variables from: the "default_domain" if there is one, otherwise the first domain by
135/// name that has the variable. The domains must outlive this object.
137public:
138 explicit DomainRanges(std::vector<Domain> const &domains);
139 /// The axis that defines the range of a variable, or null.
140 DomainAxis const *find(std::string const &name) const;
141 /// Whether any domain has the variable.
142 bool contains(std::string const &name) const { return _names.count(name); }
143
144private:
145 std::map<std::string, DomainAxis const *> _ranges;
146 std::set<std::string> _names;
147};
148
150 std::string name;
151 std::optional<std::variant<double, std::string>> value; ///< A string selects the state of a category.
152 bool isConst = false;
153 // RooFit extensions that were written by older versions:
154 std::optional<double> error;
155 std::optional<double> relError;
156 std::optional<int> nbins;
157};
158
160 std::string name;
161 std::vector<ParameterValue> parameters;
162};
163
165 std::vector<double> sigma;
166 std::vector<std::vector<double>> correlation; ///< Empty if there is no correlation.
167};
168
169struct PointData {
170 double value = 0.0;
171 std::optional<double> uncertainty;
172 std::vector<ContinuousAxis> axes;
173};
174
176 std::vector<std::variant<ContinuousAxis, CategoricalAxis>> axes;
177 /// The coordinates, row by row. A value on a categorical axis is the index in the list of categories of that axis.
178 std::vector<double> entries;
179 std::optional<std::vector<double>> weights;
181
182 std::size_t numEntries() const { return axes.empty() ? 0 : entries.size() / axes.size(); }
183};
184
186 std::vector<std::variant<BinnedAxis, CategoricalAxis>> axes;
187 std::vector<double> contents;
188 std::optional<GaussianUncertainty> uncertainty;
189};
190
191/// The sub-data set of a combined data set for one key, which has one label per column.
193 std::vector<std::string> key;
195};
196
197/// Data sets that are selected by a key (HS3 #119). The columns are categorical axes of the domains.
199 std::vector<std::string> columns;
200 std::vector<CombinedDataComponent> components;
201};
202
203struct Data {
204 std::string name;
205 std::variant<PointData, UnbinnedData, BinnedData, CombinedData> body;
206};
207
210 std::variant<DataRef, double> data;
211};
212
214 std::string name;
215 std::vector<LikelihoodTerm> terms;
216 std::vector<DistributionRef> auxDistributions;
217};
218
219struct Analysis {
220 std::string name;
222 std::vector<ParameterRef> parametersOfInterest;
223 std::vector<DomainRef> domains;
224 std::optional<ParameterPointRef> init;
225 std::optional<DistributionRef> prior;
226};
227
228/// A distribution or function that is not interpreted by the document, but by the importers that are registered for
229/// its type in RooFit::JSONIO::importers().
231 std::string type;
232 Detail::JSONNode const *node = nullptr;
233};
234
236 Add,
237 Mult
238};
239
241 Poly1,
242 Poly2,
243 Poly6,
244 Exp
245};
246
247/// How a modifier of a HistFactory distribution interpolates and extrapolates its effect.
251 std::optional<InterpolationFunction> out; ///< If not set, the function inside the bounds is used outside as well.
252};
253
254inline bool operator==(Interpolation const &l, Interpolation const &r)
255{
256 return l.type == r.type && l.in == r.in && l.out == r.out;
257}
258inline bool operator!=(Interpolation const &l, Interpolation const &r)
259{
260 return !(l == r);
261}
262inline bool operator<(Interpolation const &l, Interpolation const &r)
263{
264 if (l.type != r.type) {
265 return l.type < r.type;
266 }
267 if (l.in != r.in) {
268 return l.in < r.in;
269 }
270 return l.out < r.out;
271}
272
275inline constexpr Interpolation multiplicativePiecewiseExponential{InterpolationType::Mult, InterpolationFunction::Exp,
276 std::nullopt};
281inline constexpr Interpolation multiplicativePolynomialExponential{
285
286char const *toString(InterpolationType type);
287char const *toString(InterpolationFunction function);
288
289/// The RooFit classes that implement the interpolations, which encode them with integer codes.
291 Piecewise,
293};
294
295/// The interpolation for an integer code, or nothing if the class doesn't support the code.
296std::optional<Interpolation> interpolationFromCode(int code, InterpolationClass interpolationClass);
297/// The integer code of an interpolation, or nothing if the class can't represent the interpolation.
298std::optional<int> codeFromInterpolation(Interpolation const &interpolation, InterpolationClass interpolationClass);
299
300/// The constraint types that older documents named, for which RooFit creates the constraint terms.
301enum class ConstraintType {
302 Gauss,
303 Poisson,
305};
306
307char const *toString(ConstraintType type);
308
309/// The parameter of the modifier is not constrained.
311
312/// The constraint term is a distribution of the document, named in "constraints".
315 /// Named in "constraint_name" by an older document, whose constraint distributions of normsys and histosys
316 /// modifiers may use the global observable "nom_<parameter>" without defining it, because RooFit created it.
317 bool legacyName = false;
318};
319
320using Constraint = std::variant<Unconstrained, ConstraintType, ConstraintPdf>;
321
323{
324 return true;
325}
326inline bool operator==(ConstraintPdf const &l, ConstraintPdf const &r)
327{
328 return l.pdf.name == r.pdf.name;
329}
330
336
337struct NormSys {
338 std::string name;
340 double hi = 1.0;
341 double lo = 1.0;
343 std::optional<Interpolation> interpolation;
344};
345
347 std::vector<double> contents;
348 std::optional<std::vector<double>> errors; ///< Not in the standard, but older versions of RooFit read them.
349};
350
359
360/// The gamma parameters are constant, which is a RooFit extension.
362
363/// Every gamma parameter has its own constraint term, or none, as named in "constraints".
365 std::vector<std::optional<DistributionRef>> pdfs;
366};
367
368using GammaConstraint = std::variant<Unconstrained, ConstraintType, ConstantGammas, GammaConstraintPdfs>;
369
370/// Scales each bin by its own parameter. The modifier type "shapesys" is a deprecated alias of "shapefactor".
371struct ShapeSys {
372 std::string name;
373 std::vector<ParameterRef> parameters; ///< If empty, the parameters are named after the modifier.
374 std::vector<double> vals;
376};
377
378/// Scales each bin by a parameter, that is constrained by the statistical uncertainty of all samples that have this
379/// modifier.
380struct StatError {
381 std::string name;
382 std::vector<ParameterRef> parameters; ///< If empty, the parameters are named after the channel.
384};
385
386/// Multiplies the sample with a function of the document.
388 std::string name;
389};
390
391using Modifier = std::variant<NormFactor, NormSys, HistoSys, ShapeSys, StatError, CustomModifier>;
392
393struct Sample {
394 std::string name;
395 std::vector<double> contents;
396 std::optional<std::vector<double>> errors;
397 std::vector<Modifier> modifiers;
398};
399
400/// Settings of the staterror modifiers that apply to the whole channel. This is a RooFit extension.
402 double relThreshold = 0.0;
404 /// Samples without "errors" have Poisson uncertainties, as in documents before HS3 0.3.
406};
407
409 std::vector<BinnedAxis> axes;
410 std::optional<Interpolation> defaultInterpolation;
411 std::vector<Sample> samples;
413};
414
416 std::string name;
417 std::variant<GenericObject, HistFactoryDist> body;
418};
419
420struct Function {
421 std::string name;
423};
424
425/// A name, or a number for a constant.
426using NameOrNumber = std::variant<std::string, double>;
427
428/// The function "interpolation" of RooFit, implemented by PiecewiseInterpolation: a nominal function plus the
429/// interpolated differences to the variations "high" and "low" for each parameter.
431 std::string nominal;
432 std::vector<NameOrNumber> parameters;
433 std::vector<NameOrNumber> high;
434 std::vector<NameOrNumber> low;
435 std::vector<Interpolation> interpolations; ///< One per parameter.
436 bool positiveDefinite = false;
437};
438
439/// The function "interpolation0d" of RooFit, implemented by FlexibleInterpVar: a nominal value plus the interpolated
440/// differences to the variations "high" and "low" for each parameter.
442 double nominal = 0.0;
443 std::vector<std::string> parameters;
444 std::vector<double> high;
445 std::vector<double> low;
446 std::vector<Interpolation> interpolations; ///< One per parameter.
447};
448
449// The following types are stored in the "misc" section, for which the HS3 standard doesn't prescribe a format.
450
452 std::map<std::string, std::string> dict;
453 std::vector<std::string> tags;
454 bool isConstVar = false; ///< How ROOT versions before HS3 0.3 marked named RooConstVars.
455};
456
458 std::string indexCat;
459 std::vector<std::string> labels;
460 std::vector<int> indices;
461 std::vector<DistributionRef> distributions;
462};
463
465 std::string indexCat;
466 std::vector<std::string> labels;
467 std::vector<int> indices;
468};
469
471 std::optional<std::string> mcName;
472 std::optional<std::string> pdfName;
473 std::optional<std::string> combinedDataName;
474 /// The observables of the ModelConfig, written if no data set of the likelihood gives them.
475 std::optional<std::vector<std::string>> observables;
476};
477
478struct StepWidth {
479 std::string name;
480 double width = 0.0;
481};
482
483/// The content of misc.ROOT_internal and misc.minimization.
485 std::map<std::string, Attributes> attributes;
486 std::map<std::string, CombinedDistribution> combinedDistributions;
487 std::map<std::string, CombinedDataset> combinedDatasets;
488 std::map<std::string, ModelConfigInfo> modelConfigs;
489 std::vector<StepWidth> stepWidths;
490 /// The constraint terms of HistFactory distributions that no modifier names, by distribution. They are
491 /// also listed in the "aux_distributions" of the likelihoods, which is what other implementations use.
492 std::map<std::string, std::vector<DistributionRef>> channelConstraints;
493 /// Axes that the components of a combined data set share, but that are no variate of any distribution, e.g. an
494 /// event number, by combined data set. They have no statistical meaning, and may be shared.
495 std::map<std::string, std::vector<std::string>> bookkeepingColumns;
496};
497
499 enum class Severity {
500 Warning,
501 Error
502 };
504 std::string path; ///< Where in the document, for example "distributions[3](pdf).x".
505 std::string message;
506};
507
508using Diagnostics = std::vector<Diagnostic>;
509
510/// Whether there is a diagnostic with error severity.
511bool hasErrors(Diagnostics const &diagnostics);
512
513} // namespace HS3
514
515class HS3Document;
517
518namespace HS3 {
519struct ValidateOptions;
520std::optional<ValidatedHS3Document>
521validate(HS3Document doc, Diagnostics &diagnostics, ValidateOptions const &options);
522} // namespace HS3
523
524/// An HS3 document. It is move-only, because generic objects refer to the JSON tree that the document was read from.
526public:
528 std::vector<HS3::Distribution> distributions;
529 std::vector<HS3::Function> functions;
530 std::vector<HS3::Data> data;
531 std::vector<HS3::Likelihood> likelihoods;
532 std::vector<HS3::Domain> domains;
533 std::vector<HS3::ParameterPoint> parameterPoints;
534 std::vector<HS3::Analysis> analyses;
536
537 HS3Document() = default;
540 HS3Document(HS3Document const &) = delete;
542};
543
544namespace HS3 {
545
546/// Options for upgradeDocument() and parseDocument().
548 /// Fragments of a document can be imported without metadata.
549 bool requireMetadata = true;
550 /// If false, HistFactory distributions stay generic objects, because a user registered their own importer.
551 bool typedHistFactory = true;
552};
553
554/// Rewrites everything that older versions of RooFit wrote in a way that is not part of the standard into the form that
555/// parseDocument() understands.
556void upgradeDocument(Detail::JSONNode &root, Diagnostics &diagnostics, ParseOptions const &options = {});
557
558/// Same as upgradeDocument(), but for a single HistFactory distribution that doesn't come with a document. Names that
559/// can't be resolved in the document are assumed to refer to distributions.
560void upgradeHistFactoryDist(Detail::JSONNode &distribution, Version const &version, Diagnostics &diagnostics);
561
562/// Reads a document. The generic objects in the document refer to nodes of the JSON tree, so the tree must outlive the
563/// document. Problems are reported in `diagnostics`, and if there are errors the document must not be used.
564HS3Document parseDocument(Detail::JSONNode const &root, Diagnostics &diagnostics, ParseOptions const &options = {});
565
566/// Reads a HistFactory distribution that doesn't come with a document.
567HistFactoryDist parseHistFactoryDist(Detail::JSONNode const &distribution, Diagnostics &diagnostics);
568
569/// Reads the axes of binned data that doesn't come with a document.
570std::vector<BinnedAxis> parseBinnedAxes(Detail::JSONNode const &axes, Diagnostics &diagnostics);
571
572/// Reads the functions "interpolation" and "interpolation0d", which don't come with a document. Older versions of
573/// RooFit wrote integer "interpolationCodes" instead of "interpolations".
574InterpolatedFunction parseInterpolatedFunction(Detail::JSONNode const &node, Diagnostics &diagnostics);
575InterpolatedNumber parseInterpolatedNumber(Detail::JSONNode const &node, Diagnostics &diagnostics);
576
577/// Writes everything but the distributions and functions, which are written one by one while they are exported: the
578/// generic ones by the exporters, and the others with functions like writeHistFactoryDist().
579void writeDocument(Detail::JSONNode &root, HS3Document const &doc);
580
581/// Writes a HistFactory distribution, without its name.
582void writeHistFactoryDist(Detail::JSONNode &node, HistFactoryDist const &dist);
583
584/// Writes the functions "interpolation" and "interpolation0d", with a single interpolation if they are all the same.
585void writeInterpolatedFunction(Detail::JSONNode &node, InterpolatedFunction const &function);
586void writeInterpolatedNumber(Detail::JSONNode &node, InterpolatedNumber const &function);
587
588void writeInterpolation(Detail::JSONNode &node, Interpolation const &interpolation);
589
590/// Writes a number, as an integer if it has no fractional part.
591void writeNumber(Detail::JSONNode &node, double value);
592
593/// Writes an array of numbers, each as an integer if it has no fractional part.
594void writeContents(Detail::JSONNode &node, std::vector<double> const &values);
595
596/// Options for validate().
598 /// Whether the document has to follow the current standard, or if older conventions of RooFit are tolerated.
599 bool strict = false;
600 /// Whether a name that is not defined in the document is known in some other way, e.g. in the workspace.
601 std::function<bool(std::string const &)> isExternal;
602};
603
604} // namespace HS3
605
606/// A document that passed validate(). Only validate() can create it, so the code that builds RooFit objects can rely on
607/// the checks.
609public:
610 HS3Document const &doc() const { return _doc; }
611
612private:
613 explicit ValidatedHS3Document(HS3Document doc) : _doc{std::move(doc)} {}
614 friend std::optional<ValidatedHS3Document>
616
618};
619
620namespace HS3 {
621
622/// Checks what can be checked without knowing how the objects are built: unique names, that the references can be
623/// resolved, and that the sizes of arrays are consistent. Gives nothing if there are errors.
624std::optional<ValidatedHS3Document>
625validate(HS3Document doc, Diagnostics &diagnostics, ValidateOptions const &options = {});
626
627/// The checks of validate(), for a document that is still needed if it doesn't pass them.
628void checkDocument(HS3Document const &doc, Diagnostics &diagnostics, ValidateOptions const &options = {});
629
630/// Same as validate(), but for a single HistFactory distribution that doesn't come with a document.
631void validateHistFactoryDist(HistFactoryDist const &dist, std::string const &name, Diagnostics &diagnostics);
632
633/// Reads the leading "MAJOR.MINOR" and the optional ".PATCH" of an HS3 version string.
634bool parseVersion(std::string const &version, Version &out);
635
636/// Combines the modifiers of a sample that have the same type and name, which HistFactory models can have but
637/// documents can't: normsys by multiplying their variations, and histosys by adding up their differences to the
638/// nominal contents. The modifiers of a type must be sorted by name. Other duplicates are errors.
639void mergeDuplicateModifiers(HistFactoryDist &dist, std::string const &channel, Diagnostics &diagnostics);
640
641/// Makes the most common interpolation of the modifiers the "default_interpolation", which they then don't repeat.
642void factorOutDefaultInterpolation(HistFactoryDist &dist);
643
644} // namespace HS3
645} // namespace RooFit
646
647#endif
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 r
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
char name[80]
Definition TGX11.cxx:142
An HS3 document. It is move-only, because generic objects refer to the JSON tree that the document wa...
std::vector< HS3::Analysis > analyses
std::vector< HS3::Data > data
HS3::Metadata metadata
HS3Document(HS3Document const &)=delete
std::vector< HS3::Likelihood > likelihoods
std::vector< HS3::Function > functions
std::vector< HS3::ParameterPoint > parameterPoints
HS3Document & operator=(HS3Document const &)=delete
HS3::RooFitInternal rooFit
std::vector< HS3::Domain > domains
HS3Document(HS3Document &&)=default
std::vector< HS3::Distribution > distributions
HS3Document & operator=(HS3Document &&)=default
Where RooFit takes the ranges of variables from: the "default_domain" if there is one,...
DomainAxis const * find(std::string const &name) const
The axis that defines the range of a variable, or null.
bool contains(std::string const &name) const
Whether any domain has the variable.
DomainRanges(std::vector< Domain > const &domains)
std::map< std::string, DomainAxis const * > _ranges
std::set< std::string > _names
A document that passed validate().
ValidatedHS3Document(HS3Document doc)
HS3Document const & doc() const
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.
void validateHistFactoryDist(HistFactoryDist const &dist, std::string const &name, Diagnostics &diagnostics)
Same as validate(), but for a single HistFactory distribution that doesn't come with a document.
void writeNumber(Detail::JSONNode &node, double value)
Writes a number, as an integer if it has no fractional part.
void checkDocument(HS3Document const &doc, Diagnostics &diagnostics, ValidateOptions const &options={})
The checks of validate(), for a document that is still needed if it doesn't pass them.
void writeInterpolatedFunction(Detail::JSONNode &node, InterpolatedFunction const &function)
Writes the functions "interpolation" and "interpolation0d", with a single interpolation if they are a...
std::variant< NormFactor, NormSys, HistoSys, ShapeSys, StatError, CustomModifier > Modifier
std::variant< RegularBinning, EdgesBinning > Binning
Definition HS3Document.h:94
InterpolationClass
The RooFit classes that implement the interpolations, which encode them with integer codes.
constexpr char const * defaultDomainName
The domain in which RooFit writes the ranges of all variables. It is a convention of RooFit,...
std::optional< ValidatedHS3Document > validate(HS3Document doc, Diagnostics &diagnostics, ValidateOptions const &options)
Checks what can be checked without knowing how the objects are built: unique names,...
void mergeDuplicateModifiers(HistFactoryDist &dist, std::string const &channel, Diagnostics &diagnostics)
Combines the modifiers of a sample that have the same type and name, which HistFactory models can hav...
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.
Definition HS3Parser.cxx:64
void factorOutDefaultInterpolation(HistFactoryDist &dist)
Makes the most common interpolation of the modifiers the "default_interpolation", which they then don...
bool operator<(Version const &l, Version const &r)
Definition HS3Document.h:42
char const * toString(InterpolationType type)
InterpolatedNumber parseInterpolatedNumber(Detail::JSONNode const &node, Diagnostics &diagnostics)
bool operator!=(Interpolation const &l, Interpolation const &r)
void upgradeHistFactoryDist(Detail::JSONNode &distribution, Version const &version, Diagnostics &diagnostics)
Same as upgradeDocument(), but for a single HistFactory distribution that doesn't come with a documen...
void writeDocument(Detail::JSONNode &root, HS3Document const &doc)
Writes everything but the distributions and functions, which are written one by one while they are ex...
InterpolatedFunction parseInterpolatedFunction(Detail::JSONNode const &node, Diagnostics &diagnostics)
Reads the functions "interpolation" and "interpolation0d", which don't come with a document.
void writeContents(Detail::JSONNode &node, std::vector< double > const &values)
Writes an array of numbers, each as an integer if it has no fractional part.
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.
Definition HS3Parser.cxx:83
constexpr Interpolation multiplicativePolynomialLinear
bool hasErrors(Diagnostics const &diagnostics)
Whether there is a diagnostic with error severity.
Definition HS3Parser.cxx:94
void writeInterpolatedNumber(Detail::JSONNode &node, InterpolatedNumber const &function)
void writeHistFactoryDist(Detail::JSONNode &node, HistFactoryDist const &dist)
Writes a HistFactory distribution, without its name.
std::vector< Diagnostic > Diagnostics
void writeInterpolation(Detail::JSONNode &node, Interpolation const &interpolation)
std::variant< Unconstrained, ConstraintType, ConstantGammas, GammaConstraintPdfs > GammaConstraint
void upgradeDocument(Detail::JSONNode &root, Diagnostics &diagnostics, ParseOptions const &options={})
Rewrites everything that older versions of RooFit wrote in a way that is not part of the standard int...
bool parseVersion(std::string const &version, Version &out)
Reads the leading "MAJOR.MINOR" and the optional ".PATCH" of an HS3 version string.
overloaded(Ts...) -> overloaded< Ts... >
std::variant< Unconstrained, ConstraintType, ConstraintPdf > Constraint
std::vector< BinnedAxis > parseBinnedAxes(Detail::JSONNode const &axes, Diagnostics &diagnostics)
Reads the axes of binned data that doesn't come with a document.
bool operator==(Interpolation const &l, Interpolation const &r)
constexpr Interpolation additiveQuadraticLinear
constexpr Interpolation additivePiecewiseLinear
HS3Document parseDocument(Detail::JSONNode const &root, Diagnostics &diagnostics, ParseOptions const &options={})
Reads a document.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:73
std::optional< DistributionRef > prior
std::optional< ParameterPointRef > init
LikelihoodRef likelihood
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
The axis of binned data.
std::vector< std::variant< BinnedAxis, CategoricalAxis > > axes
std::optional< GaussianUncertainty > uncertainty
std::vector< double > contents
std::vector< std::string > categories
The sub-data set of a combined data set for one key, which has one label per column.
std::vector< std::string > key
Data sets that are selected by a key (HS3 #119). The columns are categorical axes of the domains.
std::vector< CombinedDataComponent > components
std::vector< std::string > columns
std::vector< int > indices
std::vector< std::string > labels
std::vector< std::string > labels
std::vector< DistributionRef > distributions
The gamma parameters are constant, which is a RooFit extension.
The constraint term is a distribution of the document, named in "constraints".
bool legacyName
Named in "constraint_name" by an older document, whose constraint distributions of normsys and histos...
The axis of point data or unbinned data, which can't have a binning.
std::optional< double > max
std::optional< double > min
Multiplies the sample with a function of the document.
std::string name
std::variant< PointData, UnbinnedData, BinnedData, CombinedData > body
std::string path
Where in the document, for example "distributions[3](pdf).x".
std::variant< GenericObject, HistFactoryDist > body
The axis of a domain.
Definition HS3Document.h:98
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
Definition HS3Document.h:92
Every gamma parameter has its own constraint term, or none, as named in "constraints".
std::vector< std::optional< DistributionRef > > pdfs
std::vector< std::vector< double > > correlation
Empty if there is no correlation.
std::vector< double > sigma
A distribution or function that is not interpreted by the document, but by the importers that are reg...
Detail::JSONNode const * node
std::optional< Interpolation > defaultInterpolation
std::vector< Sample > samples
std::vector< BinnedAxis > axes
std::vector< double > contents
std::optional< std::vector< double > > errors
Not in the standard, but older versions of RooFit read them.
std::optional< Interpolation > interpolation
HistoSysVariation lo
HistoSysVariation hi
ParameterRef parameter
The function "interpolation" of RooFit, implemented by PiecewiseInterpolation: a nominal function plu...
std::vector< Interpolation > interpolations
One per parameter.
std::vector< NameOrNumber > parameters
std::vector< NameOrNumber > low
std::vector< NameOrNumber > high
The function "interpolation0d" of RooFit, implemented by FlexibleInterpVar: a nominal value plus the ...
std::vector< double > high
std::vector< double > low
std::vector< std::string > parameters
std::vector< Interpolation > interpolations
One per parameter.
How a modifier of a HistFactory distribution interpolates and extrapolates its effect.
InterpolationType type
InterpolationFunction in
std::optional< InterpolationFunction > out
If not set, the function inside the bounds is used outside as well.
DistributionRef distribution
std::variant< DataRef, double > data
std::vector< DistributionRef > auxDistributions
std::vector< LikelihoodTerm > terms
std::optional< std::string > description
Definition HS3Document.h:85
std::string hs3Version
As it was written in the document, empty for fragments of a document.
Definition HS3Document.h:80
std::vector< std::string > publications
Definition HS3Document.h:84
Version version
The parsed version. Versions that can't be parsed count as the oldest one.
Definition HS3Document.h:81
std::vector< std::string > authors
Definition HS3Document.h:83
std::vector< Package > packages
Definition HS3Document.h:82
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
ParameterRef parameter
std::optional< Interpolation > interpolation
std::string version
Definition HS3Document.h:76
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().
bool typedHistFactory
If false, HistFactory distributions stay generic objects, because a user registered their own importe...
bool requireMetadata
Fragments of a document can be imported without metadata.
std::optional< double > uncertainty
std::vector< ContinuousAxis > axes
A name that says what it refers to, so that for example a DataRef can't be used as a DomainRef.
Definition HS3Document.h:63
std::string name
Definition HS3Document.h:64
The content of misc.ROOT_internal and misc.minimization.
std::map< std::string, Attributes > attributes
std::map< std::string, std::vector< DistributionRef > > channelConstraints
The constraint terms of HistFactory distributions that no modifier names, by distribution.
std::map< std::string, CombinedDataset > combinedDatasets
std::vector< StepWidth > stepWidths
std::map< std::string, std::vector< std::string > > bookkeepingColumns
Axes that the components of a combined data set share, but that are no variate of any distribution,...
std::map< std::string, CombinedDistribution > combinedDistributions
std::map< std::string, ModelConfigInfo > modelConfigs
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...
std::vector< ParameterRef > parameters
If empty, the parameters are named after the modifier.
GammaConstraint constraint
std::vector< double > vals
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....
Scales each bin by a parameter, that is constrained by the statistical uncertainty of all samples tha...
std::vector< ParameterRef > parameters
If empty, the parameters are named after the channel.
GammaConstraint constraint
std::optional< std::vector< double > > weights
std::vector< std::variant< ContinuousAxis, CategoricalAxis > > axes
std::vector< double > entries
The coordinates, row by row. A value on a categorical axis is the index in the list of categories of ...
std::size_t numEntries() const
The parameter of the modifier is not constrained.
Options for validate().
bool strict
Whether the document has to follow the current standard, or if older conventions of RooFit are tolera...
std::function< bool(std::string const &) isExternal)
Whether a name that is not defined in the document is known in some other way, e.g....
Combines lambdas into one visitor for std::visit(). The compiler complains about the alternatives wit...
Definition HS3Document.h:55
TLine l
Definition textangle.C:4