Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8c7edef
[RF][HS3] Reject circular dependencies on import
guitargeek Nov 5, 2026
d04c853
[RF][HS3] Reject unknown parameters of interest
guitargeek Nov 5, 2026
781ac09
[RF][HS3] Add a typed representation of HS3 documents
guitargeek Nov 5, 2026
482002b
[RF][HS3] Import documents through their typed representation
guitargeek Nov 5, 2026
72fea96
[RF][HS3] Build HistFactory distributions from typed modifiers
guitargeek Nov 5, 2026
d3b5275
[RF][HS3] Report components that are ignored on import
guitargeek Nov 5, 2026
131b710
[RF][HS3] Validate documents before building them
guitargeek Nov 5, 2026
030762f
[RF][HS3] Export documents through their typed representation
guitargeek Nov 5, 2026
5749b5f
[RF][HS3] Use the type keys of the standard for resolution models
guitargeek Nov 5, 2026
1952c39
[RF][HS3] Check "min" and "max" of irregular binnings
guitargeek Nov 10, 2026
cf615f0
[RF][HS3] Read and write the prior of analyses
guitargeek Nov 10, 2026
991789a
[RF][HS3] Keep the constraint terms of HistFactory channels
guitargeek Nov 10, 2026
a1cb2ad
[RF][HS3] Warn about uncertainties of data that RooFit ignores
guitargeek Nov 5, 2026
e634453
[RF][HS3] Reject analyses with objects of the wrong kind
guitargeek Nov 9, 2026
835f4b5
[RF][HS3] Move the Domains helper into RooJSONFactoryWSTool.cxx
guitargeek Nov 10, 2026
d154847
[RF][HS3] Replace the Domains helper with functions on the document
guitargeek Nov 10, 2026
f441c54
[RF][HS3] Export HistFactory channels directly as typed distributions
guitargeek Nov 10, 2026
11e97a2
[RF][HS3] Read and write the interpolation functions as typed structs
guitargeek Nov 10, 2026
a0c9288
[RF][HS3] Remove duplicated and dead code from the HS3 tool
guitargeek Nov 10, 2026
ce3c956
[RF][HS3] Don't promise a Writer in the documentation of HS3::Reader
guitargeek Nov 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions roofit/hs3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooFitHS3
HEADERS
${ROOFITHS3_HEADERS}
SOURCES
src/Domains.cxx
src/HS3Document.cxx
src/HS3Parser.cxx
src/HS3Upgrade.cxx
src/HS3Validate.cxx
src/HS3Writer.cxx
src/JSONInterface.cxx
src/JSONIO.cxx
src/RooJSONFactoryWSTool.cxx
Expand Down Expand Up @@ -48,8 +52,11 @@ target_sources(
FILES
${RELATIVE_INC_HEADERS}
# LinkDef.h # seemingly not being used by ROOT_STANDARD_LIBRARY_PACKAGE call
src/Domains.h
src/HS3Builder.h
src/HS3Document.h
src/HS3Schema.h
src/JSONIOUtils.h
src/JSONReadRecorder.h
src/static_execute.h
)

Expand Down
3 changes: 3 additions & 0 deletions roofit/hs3/inc/RooFit/Detail/JSONInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class JSONNode {
JSONNode &set_seq();
JSONNode &set_null();
void clear();
/// Remove a child of a map, if it exists.
void erase(std::string const &key);

std::string key() const;
std::string val() const;
Expand Down Expand Up @@ -188,6 +190,7 @@ class JSONNode {

private:
friend class JSONTree;
friend class JSONReadRecorder;

// Owns the values and the nodes of a tree. It is defined in the only source file that knows the JSON library.
class Storage;
Expand Down
56 changes: 31 additions & 25 deletions roofit/hs3/inc/RooFitHS3/RooJSONFactoryWSTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,24 @@
#include <map>
#include <stdexcept>
#include <set>
#include <unordered_map>
#include <vector>

class RooJSONFactoryWSTool;

namespace RooFit {
namespace JSONIO {
namespace Detail {
class Domains;
}
} // namespace JSONIO
namespace HS3 {
struct Distribution;
struct HistFactoryDist;
struct ParameterPoint;
struct ParameterValue;
struct ToolExportState;
struct ToolImportState;
template <class Tag>
struct Ref;
using DistributionRef = Ref<struct DistributionTag>;
void setExportedObject(RooJSONFactoryWSTool &tool, HistFactoryDist dist,
std::vector<DistributionRef> channelConstraints);
} // namespace HS3
} // namespace RooFit
namespace RooStats {
class ModelConfig;
Expand All @@ -39,6 +49,7 @@ class RooRealVar;

class RooJSONFactoryWSTool {
public:
/// Named objects are always stored in lists, as the HS3 standard requires. Kept for backwards compatibility.
static constexpr bool useListsInsteadOfDicts = true;

struct Config {
Expand Down Expand Up @@ -235,44 +246,39 @@ class RooJSONFactoryWSTool {
void exportData(RooAbsData const &data);
RooJSONFactoryWSTool::CombinedData exportCombinedData(RooAbsData const &data);

void importAllNodes(const RooFit::Detail::JSONNode &n);
void importAllNodes(RooFit::Detail::JSONNode &n);
void importDistribution(RooFit::HS3::Distribution const &distribution);

void importVariable(const RooFit::Detail::JSONNode &p);
void checkFixedValue(std::string const &name, const RooFit::Detail::JSONNode &p, std::string const &pointName);
void importVariable(RooFit::HS3::ParameterValue const &p);
void warnIfFreeWithoutDomain(RooRealVar const &var);
void importDependants(const RooFit::Detail::JSONNode &n);

void exportVariable(const RooAbsArg *v, RooFit::Detail::JSONNode &n, bool storeConstant, bool storeBins);
void exportVariables(const RooArgSet &allElems, RooFit::Detail::JSONNode &n, bool storeConstant, bool storeBins);
void exportVariable(const RooAbsArg *v, RooFit::HS3::ParameterPoint &point, bool storeConstant);
void exportVariables(const RooArgSet &allElems, RooFit::HS3::ParameterPoint &point, bool storeConstant);

void exportAllObjects(RooFit::Detail::JSONNode &n);

void exportModelConfig(RooFit::Detail::JSONNode &rootnode, RooStats::ModelConfig const &mc,
void exportModelConfig(RooStats::ModelConfig const &mc,
const std::vector<RooJSONFactoryWSTool::CombinedData> &combined,
const std::vector<RooAbsData *> &single);

void exportSingleModelConfig(RooFit::Detail::JSONNode &rootnode, RooStats::ModelConfig const &mc,
std::string const &analysisName,
void exportSingleModelConfig(RooStats::ModelConfig const &mc, std::string const &analysisName,
std::map<std::string, std::string> const *dataComponents);

friend void RooFit::HS3::setExportedObject(RooJSONFactoryWSTool &tool, RooFit::HS3::HistFactoryDist dist,
std::vector<RooFit::HS3::DistributionRef> channelConstraints);

// member variables
const RooFit::Detail::JSONNode *_rootnodeInput = nullptr;
const RooFit::Detail::JSONNode *_attributesNode = nullptr;
RooFit::Detail::JSONNode *_rootnodeOutput = nullptr;
RooFit::Detail::JSONNode *_varsNode = nullptr;
std::string _hs3VersionInput;
RooWorkspace &_workspace;

// objects to represent intermediate information
std::unique_ptr<RooFit::JSONIO::Detail::Domains> _domains;
std::unique_ptr<RooFit::HS3::ToolImportState> _import;
std::unique_ptr<RooFit::HS3::ToolExportState> _export;
std::vector<RooAbsArg const *> _serversToExport;
std::vector<RooAbsArg const *> _serversToDelete;

// Name-keyed indices over the top-level "functions" and "distributions"
// sequences of the input JSON. Built once at the start of importAllNodes()
// so that requestImpl() lookups become O(1) instead of an O(N) scan over
// every sibling node.
std::unordered_map<std::string, RooFit::Detail::JSONNode const *> _functionsByName;
std::unordered_map<std::string, RooFit::Detail::JSONNode const *> _distributionsByName;
// The objects that are currently being imported, innermost last, to detect circular dependencies.
std::vector<std::string> _importStack;
};
#endif
Loading
Loading