13#ifndef RooFit_HS3Document_h
14#define RooFit_HS3Document_h
44 if (
l.major !=
r.major) {
45 return l.major <
r.major;
47 if (
l.minor !=
r.minor) {
48 return l.minor <
r.minor;
50 return l.patch <
r.patch;
56 using Ts::operator()...;
94using Binning = std::variant<RegularBinning, EdgesBinning>;
101 std::optional<double>
min;
102 std::optional<double>
max;
109 std::optional<double>
min;
110 std::optional<double>
max;
128 std::vector<std::variant<DomainAxis, CategoricalAxis>>
axes;
138 explicit DomainRanges(std::vector<Domain>
const &domains);
145 std::map<std::string, DomainAxis const *>
_ranges;
151 std::optional<std::variant<double, std::string>>
value;
172 std::vector<ContinuousAxis>
axes;
176 std::vector<std::variant<ContinuousAxis, CategoricalAxis>>
axes;
186 std::vector<std::variant<BinnedAxis, CategoricalAxis>>
axes;
193 std::variant<PointData, UnbinnedData, BinnedData>
body;
198 std::variant<DataRef, double>
data;
212 std::optional<ParameterPointRef>
init;
213 std::optional<DistributionRef>
prior;
239 std::optional<InterpolationFunction>
out;
244 return l.type ==
r.type &&
l.in ==
r.in &&
l.out ==
r.out;
252 if (
l.type !=
r.type) {
253 return l.type <
r.type;
258 return l.out <
r.out;
275char const *
toString(InterpolationFunction function);
286std::optional<int>
codeFromInterpolation(Interpolation
const &interpolation, InterpolationClass interpolationClass);
305using Constraint = std::variant<Unconstrained, ConstraintType, ConstraintPdf>;
313 return l.pdf.name ==
r.pdf.name;
333 std::optional<std::vector<double>>
errors;
350 std::vector<std::optional<DistributionRef>>
pdfs;
353using GammaConstraint = std::variant<Unconstrained, ConstraintType, ConstantGammas, GammaConstraintPdfs>;
376using Modifier = std::variant<NormFactor, NormSys, HistoSys, ShapeSys, StatError, CustomModifier>;
381 std::optional<std::vector<double>>
errors;
402 std::variant<GenericObject, HistFactoryDist>
body;
418 std::vector<NameOrNumber>
high;
419 std::vector<NameOrNumber>
low;
437 std::map<std::string, std::string>
dict;
499struct ValidateOptions;
500std::optional<ValidatedHS3Document>
559void writeDocument(Detail::JSONNode &root, HS3Document
const &doc);
574void writeContents(Detail::JSONNode &node, std::vector<double>
const &values);
594 friend std::optional<ValidatedHS3Document>
604std::optional<ValidatedHS3Document>
614bool parseVersion(std::string
const &version, Version &out);
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
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
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
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.
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)
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.
constexpr Interpolation multiplicativePolynomialLinear
bool hasErrors(Diagnostics const &diagnostics)
Whether there is a diagnostic with error severity.
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...
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::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
std::vector< int > indices
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::variant< PointData, UnbinnedData, BinnedData > body
std::string path
Where in the document, for example "distributions[3](pdf).x".
std::variant< GenericObject, HistFactoryDist > 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
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
StatErrorConfig statError
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
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.
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 > pdfName
std::optional< std::string > mcName
std::optional< std::string > combinedDataName
std::optional< Interpolation > interpolation
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.
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....
GammaConstraint constraint
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
bool hasEntriesUncertainties
The parameter of the modifier is not constrained.
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...