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
191struct Data {
192 std::string name;
193 std::variant<PointData, UnbinnedData, BinnedData> body;
194};
195
198 std::variant<DataRef, double> data;
199};
200
202 std::string name;
203 std::vector<LikelihoodTerm> terms;
204 std::vector<DistributionRef> auxDistributions;
205};
206
207struct Analysis {
208 std::string name;
210 std::vector<ParameterRef> parametersOfInterest;
211 std::vector<DomainRef> domains;
212 std::optional<ParameterPointRef> init;
213 std::optional<DistributionRef> prior;
214};
215
216/// A distribution or function that is not interpreted by the document, but by the importers that are registered for
217/// its type in RooFit::JSONIO::importers(), or by the factory expressions.
219 std::string type;
220 Detail::JSONNode const *node = nullptr;
221};
222
224 Add,
225 Mult
226};
227
229 Poly1,
230 Poly2,
231 Poly6,
232 Exp
233};
234
235/// How a modifier of a HistFactory distribution interpolates and extrapolates its effect.
239 std::optional<InterpolationFunction> out; ///< If not set, the function inside the bounds is used outside as well.
240};
241
242inline bool operator==(Interpolation const &l, Interpolation const &r)
243{
244 return l.type == r.type && l.in == r.in && l.out == r.out;
245}
246inline bool operator!=(Interpolation const &l, Interpolation const &r)
247{
248 return !(l == r);
249}
250inline bool operator<(Interpolation const &l, Interpolation const &r)
251{
252 if (l.type != r.type) {
253 return l.type < r.type;
254 }
255 if (l.in != r.in) {
256 return l.in < r.in;
257 }
258 return l.out < r.out;
259}
260
263inline constexpr Interpolation multiplicativePiecewiseExponential{InterpolationType::Mult, InterpolationFunction::Exp,
264 std::nullopt};
269inline constexpr Interpolation multiplicativePolynomialExponential{
273
274char const *toString(InterpolationType type);
275char const *toString(InterpolationFunction function);
276
277/// The RooFit classes that implement the interpolations, which encode them with integer codes.
279 Piecewise,
281};
282
283/// The interpolation for an integer code, or nothing if the class doesn't support the code.
284std::optional<Interpolation> interpolationFromCode(int code, InterpolationClass interpolationClass);
285/// The integer code of an interpolation, or nothing if the class can't represent the interpolation.
286std::optional<int> codeFromInterpolation(Interpolation const &interpolation, InterpolationClass interpolationClass);
287
288/// The constraint types that older documents named, for which RooFit creates the constraint terms.
289enum class ConstraintType {
290 Gauss,
291 Poisson,
293};
294
295char const *toString(ConstraintType type);
296
297/// The parameter of the modifier is not constrained.
299
300/// The constraint term is a distribution of the document, named in "constraints".
304
305using Constraint = std::variant<Unconstrained, ConstraintType, ConstraintPdf>;
306
308{
309 return true;
310}
311inline bool operator==(ConstraintPdf const &l, ConstraintPdf const &r)
312{
313 return l.pdf.name == r.pdf.name;
314}
315
321
322struct NormSys {
323 std::string name;
325 double hi = 1.0;
326 double lo = 1.0;
328 std::optional<Interpolation> interpolation;
329};
330
332 std::vector<double> contents;
333 std::optional<std::vector<double>> errors; ///< Not in the standard, but older versions of RooFit read them.
334};
335
344
345/// The gamma parameters are constant, which is a RooFit extension.
347
348/// Every gamma parameter has its own constraint term, or none, as named in "constraints".
350 std::vector<std::optional<DistributionRef>> pdfs;
351};
352
353using GammaConstraint = std::variant<Unconstrained, ConstraintType, ConstantGammas, GammaConstraintPdfs>;
354
355/// Scales each bin by its own parameter. The modifier type "shapesys" is a deprecated alias of "shapefactor".
356struct ShapeSys {
357 std::string name;
358 std::vector<ParameterRef> parameters; ///< If empty, the parameters are named after the modifier.
359 std::vector<double> vals;
361};
362
363/// Scales each bin by a parameter, that is constrained by the statistical uncertainty of all samples that have this
364/// modifier.
365struct StatError {
366 std::string name;
367 std::vector<ParameterRef> parameters; ///< If empty, the parameters are named after the channel.
369};
370
371/// Multiplies the sample with a function of the document.
373 std::string name;
374};
375
376using Modifier = std::variant<NormFactor, NormSys, HistoSys, ShapeSys, StatError, CustomModifier>;
377
378struct Sample {
379 std::string name;
380 std::vector<double> contents;
381 std::optional<std::vector<double>> errors;
382 std::vector<Modifier> modifiers;
383};
384
385/// Settings of the staterror modifiers that apply to the whole channel. This is a RooFit extension.
387 double relThreshold = 0.0;
389 /// Samples without "errors" have Poisson uncertainties, as in documents before HS3 0.3.
391};
392
394 std::vector<BinnedAxis> axes;
395 std::optional<Interpolation> defaultInterpolation;
396 std::vector<Sample> samples;
398};
399
401 std::string name;
402 std::variant<GenericObject, HistFactoryDist> body;
403};
404
405struct Function {
406 std::string name;
408};
409
410/// A name, or a number for a constant.
411using NameOrNumber = std::variant<std::string, double>;
412
413/// The function "interpolation" of RooFit, implemented by PiecewiseInterpolation: a nominal function plus the
414/// interpolated differences to the variations "high" and "low" for each parameter.
416 std::string nominal;
417 std::vector<NameOrNumber> parameters;
418 std::vector<NameOrNumber> high;
419 std::vector<NameOrNumber> low;
420 std::vector<Interpolation> interpolations; ///< One per parameter.
421 bool positiveDefinite = false;
422};
423
424/// The function "interpolation0d" of RooFit, implemented by FlexibleInterpVar: a nominal value plus the interpolated
425/// differences to the variations "high" and "low" for each parameter.
427 double nominal = 0.0;
428 std::vector<std::string> parameters;
429 std::vector<double> high;
430 std::vector<double> low;
431 std::vector<Interpolation> interpolations; ///< One per parameter.
432};
433
434// The following types are stored in the "misc" section, for which the HS3 standard doesn't prescribe a format.
435
437 std::map<std::string, std::string> dict;
438 std::vector<std::string> tags;
439 bool isConstVar = false; ///< How ROOT versions before HS3 0.3 marked named RooConstVars.
440};
441
443 std::string indexCat;
444 std::vector<std::string> labels;
445 std::vector<int> indices;
446 std::vector<DistributionRef> distributions;
447};
448
450 std::string indexCat;
451 std::vector<std::string> labels;
452 std::vector<int> indices;
453};
454
456 std::optional<std::string> mcName;
457 std::optional<std::string> pdfName;
458 std::optional<std::string> combinedDataName;
459};
460
461struct StepWidth {
462 std::string name;
463 double width = 0.0;
464};
465
466/// The content of misc.ROOT_internal and misc.minimization.
468 std::map<std::string, Attributes> attributes;
469 std::map<std::string, CombinedDistribution> combinedDistributions;
470 std::map<std::string, CombinedDataset> combinedDatasets;
471 std::map<std::string, ModelConfigInfo> modelConfigs;
472 std::vector<StepWidth> stepWidths;
473 /// The constraint terms of HistFactory distributions that no modifier names, by distribution. They are
474 /// also listed in the "aux_distributions" of the likelihoods, which is what other implementations use.
475 std::map<std::string, std::vector<DistributionRef>> channelConstraints;
476};
477
479 enum class Severity {
480 Warning,
481 Error
482 };
484 std::string path; ///< Where in the document, for example "distributions[3](pdf).x".
485 std::string message;
486};
487
488using Diagnostics = std::vector<Diagnostic>;
489
490/// Whether there is a diagnostic with error severity.
491bool hasErrors(Diagnostics const &diagnostics);
492
493} // namespace HS3
494
495class HS3Document;
497
498namespace HS3 {
499struct ValidateOptions;
500std::optional<ValidatedHS3Document>
501validate(HS3Document doc, Diagnostics &diagnostics, ValidateOptions const &options);
502} // namespace HS3
503
504/// An HS3 document. It is move-only, because generic objects refer to the JSON tree that the document was read from.
506public:
508 std::vector<HS3::Distribution> distributions;
509 std::vector<HS3::Function> functions;
510 std::vector<HS3::Data> data;
511 std::vector<HS3::Likelihood> likelihoods;
512 std::vector<HS3::Domain> domains;
513 std::vector<HS3::ParameterPoint> parameterPoints;
514 std::vector<HS3::Analysis> analyses;
516
517 HS3Document() = default;
520 HS3Document(HS3Document const &) = delete;
522};
523
524namespace HS3 {
525
526/// Options for upgradeDocument() and parseDocument().
528 /// Fragments of a document can be imported without metadata.
529 bool requireMetadata = true;
530 /// If false, HistFactory distributions stay generic objects, because a user registered their own importer.
531 bool typedHistFactory = true;
532};
533
534/// Rewrites everything that older versions of RooFit wrote in a way that is not part of the standard into the form that
535/// parseDocument() understands.
536void upgradeDocument(Detail::JSONNode &root, Diagnostics &diagnostics, ParseOptions const &options = {});
537
538/// Same as upgradeDocument(), but for a single HistFactory distribution that doesn't come with a document. Names that
539/// can't be resolved in the document are assumed to refer to distributions.
540void upgradeHistFactoryDist(Detail::JSONNode &distribution, Version const &version, Diagnostics &diagnostics);
541
542/// Reads a document. The generic objects in the document refer to nodes of the JSON tree, so the tree must outlive the
543/// document. Problems are reported in `diagnostics`, and if there are errors the document must not be used.
544HS3Document parseDocument(Detail::JSONNode const &root, Diagnostics &diagnostics, ParseOptions const &options = {});
545
546/// Reads a HistFactory distribution that doesn't come with a document.
547HistFactoryDist parseHistFactoryDist(Detail::JSONNode const &distribution, Diagnostics &diagnostics);
548
549/// Reads the axes of binned data that doesn't come with a document.
550std::vector<BinnedAxis> parseBinnedAxes(Detail::JSONNode const &axes, Diagnostics &diagnostics);
551
552/// Reads the functions "interpolation" and "interpolation0d", which don't come with a document. Older versions of
553/// RooFit wrote integer "interpolationCodes" instead of "interpolations".
554InterpolatedFunction parseInterpolatedFunction(Detail::JSONNode const &node, Diagnostics &diagnostics);
555InterpolatedNumber parseInterpolatedNumber(Detail::JSONNode const &node, Diagnostics &diagnostics);
556
557/// Writes everything but the distributions and functions, which are written one by one while they are exported: the
558/// generic ones by the exporters, and the others with functions like writeHistFactoryDist().
559void writeDocument(Detail::JSONNode &root, HS3Document const &doc);
560
561/// Writes a HistFactory distribution, without its name.
562void writeHistFactoryDist(Detail::JSONNode &node, HistFactoryDist const &dist);
563
564/// Writes the functions "interpolation" and "interpolation0d", with a single interpolation if they are all the same.
565void writeInterpolatedFunction(Detail::JSONNode &node, InterpolatedFunction const &function);
566void writeInterpolatedNumber(Detail::JSONNode &node, InterpolatedNumber const &function);
567
568void writeInterpolation(Detail::JSONNode &node, Interpolation const &interpolation);
569
570/// Writes a number, as an integer if it has no fractional part.
571void writeNumber(Detail::JSONNode &node, double value);
572
573/// Writes an array of numbers, each as an integer if it has no fractional part.
574void writeContents(Detail::JSONNode &node, std::vector<double> const &values);
575
576/// Options for validate().
578 /// Whether the document has to follow the current standard, or if older conventions of RooFit are tolerated.
579 bool strict = false;
580 /// Whether a name that is not defined in the document is known in some other way, e.g. in the workspace.
581 std::function<bool(std::string const &)> isExternal;
582};
583
584} // namespace HS3
585
586/// A document that passed validate(). Only validate() can create it, so the code that builds RooFit objects can rely on
587/// the checks.
589public:
590 HS3Document const &doc() const { return _doc; }
591
592private:
593 explicit ValidatedHS3Document(HS3Document doc) : _doc{std::move(doc)} {}
594 friend std::optional<ValidatedHS3Document>
596
598};
599
600namespace HS3 {
601
602/// Checks what can be checked without knowing how the objects are built: unique names, that the references can be
603/// resolved, and that the sizes of arrays are consistent. Gives nothing if there are errors.
604std::optional<ValidatedHS3Document>
605validate(HS3Document doc, Diagnostics &diagnostics, ValidateOptions const &options = {});
606
607/// The checks of validate(), for a document that is still needed if it doesn't pass them.
608void checkDocument(HS3Document const &doc, Diagnostics &diagnostics, ValidateOptions const &options = {});
609
610/// Same as validate(), but for a single HistFactory distribution that doesn't come with a document.
611void validateHistFactoryDist(HistFactoryDist const &dist, std::string const &name, Diagnostics &diagnostics);
612
613/// Reads the leading "MAJOR.MINOR" and the optional ".PATCH" of an HS3 version string.
614bool parseVersion(std::string const &version, Version &out);
615
616/// Combines the modifiers of a sample that have the same type and name, which HistFactory models can have but
617/// documents can't: normsys by multiplying their variations, and histosys by adding up their differences to the
618/// nominal contents. The modifiers of a type must be sorted by name. Other duplicates are errors.
619void mergeDuplicateModifiers(HistFactoryDist &dist, std::string const &channel, Diagnostics &diagnostics);
620
621/// Makes the most common interpolation of the modifiers the "default_interpolation", which they then don't repeat.
622void factorOutDefaultInterpolation(HistFactoryDist &dist);
623
624} // namespace HS3
625} // namespace RooFit
626
627#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
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".
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 > 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::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, 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