Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches

When using RooFit, statistical models can be conveniently handled and stored as a RooWorkspace.

However, for the sake of interoperability with other statistical frameworks, and also ease of manipulation, it may be useful to store statistical models in text form.

The RooJSONFactoryWSTool is a helper class to achieve exactly this, exporting to and importing from JSON.

In order to import a workspace from a JSON file, you can do

ws = ROOT.RooWorkspace("ws")
tool = ROOT.RooJSONFactoryWSTool(ws)
tool.importJSON("myjson.json")

Similarly, in order to export a workspace to a JSON file, you can do

tool = ROOT.RooJSONFactoryWSTool(ws)
tool.exportJSON("myjson.json")

Analogously, in C++, you can do

// ...
RooWorkspace ws("ws");
tool.importJSON("myjson.json");
When using RooFit, statistical models can be conveniently handled and stored as a RooWorkspace.
Persistable container for RooFit projects.

and

// ...
tool.exportJSON("myjson.json");

For more details, consult the tutorial rf515_hfJSON.

The RooJSONFactoryWSTool only knows about a limited set of classes for import and export. If import or export of a class you're interested in fails, you might need to add your own importer or exporter. Please consult the relevant section in the RooFit Developer Documentation to learn how to do that (Implement JSON I/O for a RooFit class with RooFit HS3).

You can always get a list of all the available importers and exporters by calling the following functions:

ROOT.RooFit.JSONIO.printImporters()
ROOT.RooFit.JSONIO.printExporters()

Alternatively, you can generate a LaTeX version of the available importers and exporters by calling

tool = ROOT.RooJSONFactoryWSTool(ws)
tool.writedoc("hs3.tex")

Definition at line 53 of file RooJSONFactoryWSTool.h.

Classes

struct  CombinedData
 
struct  Config
 
class  DependencyMissingError
 

Public Member Functions

 RooJSONFactoryWSTool (RooWorkspace &ws)
 
 ~RooJSONFactoryWSTool ()
 
std::string const * constraintObservable (std::string const &pdfName) const
 
std::string exportAsArrayComponent (RooAbsPdf const &pdf, std::string const &arrayName)
 
bool exportJSON (std::ostream &os)
 Export the workspace to JSON format and write to the output stream.
 
bool exportJSON (std::string const &fileName)
 Export the workspace to JSON format and write to the specified file.
 
std::string exportJSONtoString ()
 Export the workspace to a JSON string.
 
std::string const & exportRootName () const
 The name of the top-level object whose export is in progress (the root of the current export recursion).
 
std::string exportTransformed (const RooAbsReal *original, const std::string &suffix, const std::string &formula)
 
std::string getStringAttribute (const std::string &obj, const std::string &attrib)
 
bool hasAttribute (const std::string &obj, const std::string &attrib)
 
std::string const & hs3VersionInput () const
 The "hs3_version" of the document that is currently being imported, or an empty string outside of an import.
 
void importFunction (const RooFit::Detail::JSONNode &p, bool importAllDependants)
 Import a function from the JSONNode into the workspace.
 
void importFunction (const std::string &jsonString, bool importAllDependants)
 Import a function from a JSON string into the workspace.
 
bool importJSON (std::istream &os)
 Imports a JSON file from the given input stream to the workspace.
 
bool importJSON (std::string const &filename)
 Imports a JSON file from the given filename to the workspace.
 
void importJSONElement (const std::string &name, const std::string &jsonString)
 
bool importJSONfromString (const std::string &s)
 Import the workspace from a JSON string.
 
void importVariableElement (const RooFit::Detail::JSONNode &n)
 
void queueExport (RooAbsArg const &arg)
 
void queueExportTemporary (RooAbsArg *arg)
 
void recordConstraintTerms (std::string const &pdfName, std::vector< std::string > const &terms)
 
template<class T >
T * request (const std::string &objname, const std::string &requestAuthor)
 The object objname from the workspace, imported from the document first if needed.
 
template<class T >
T * requestArg (const RooFit::Detail::JSONNode &node, const std::string &key)
 
template<class T >
RooArgList requestArgList (const RooFit::Detail::JSONNode &node, const std::string &seqName)
 
template<class T >
RooArgSet requestArgSet (const RooFit::Detail::JSONNode &node, const std::string &seqName)
 
template<class T , class Coll_t >
Coll_t requestCollection (const RooFit::Detail::JSONNode &node, const std::string &seqName)
 
void setAttribute (const std::string &obj, const std::string &attrib)
 
void setConstraintObservable (RooAbsPdf const &pdf, std::string const &observable)
 Record that observable is the observable of the constraint term pdf (the side that is not the constrained parameter).
 
void setStringAttribute (const std::string &obj, const std::string &attrib, const std::string &value)
 
template<class T >
T * tryRequest (const std::string &objname)
 Like request(), but returns nullptr if neither the workspace nor the document has the object.
 
RooWorkspace * workspace ()
 
template<class Obj_t , typename... Args_t>
Obj_t & wsEmplace (RooStringView name, Args_t &&...args)
 
template<class Obj_t >
Obj_t & wsImport (Obj_t const &obj)
 

Static Public Member Functions

static RooFit::Detail::JSONNode & appendNamedChild (RooFit::Detail::JSONNode &node, std::string const &name)
 
static RooWorkspace cleanWS (const RooWorkspace &ws, bool onlyModelConfig=false)
 
static Config & config ()
 
static std::unique_ptr< RooFit::Detail::JSONTree > createNewJSONTree ()
 Create a new JSON tree with version information.
 
static void error (const char *s)
 Writes an error message to the RooFit message service and throws a runtime_error.
 
static void error (const std::string &s)
 
static void exportArray (std::size_t n, double const *contents, RooFit::Detail::JSONNode &output)
 Export an array of doubles to a JSONNode.
 
static void exportAxis (RooFit::Detail::JSONNode &obsNode, RooRealVar const &var)
 
static void exportCategoricalAxis (RooFit::Detail::JSONNode &obsNode, RooCategory const &cat)
 Export the name and binning of a RooRealVar to a JSONNode.
 
static void exportHisto (RooArgSet const &vars, std::size_t n, double const *contents, RooFit::Detail::JSONNode &output)
 Export histogram data to a JSONNode.
 
static void fillSeq (RooFit::Detail::JSONNode &node, RooAbsCollection const &coll, size_t nMax=-1)
 
static RooFit::Detail::JSONNode const * findNamedChild (RooFit::Detail::JSONNode const &node, std::string const &name)
 
template<typename... Keys_t>
static RooFit::Detail::JSONNode & getRooFitInternal (RooFit::Detail::JSONNode &node, Keys_t const &...keys)
 
static bool isValidName (const std::string &str)
 Check if a string is a valid name.
 
static RooFit::Detail::JSONNode & makeVariablesNode (RooFit::Detail::JSONNode &rootNode)
 
static std::string name (const RooFit::Detail::JSONNode &n)
 
static RooArgSet readAxes (const RooFit::Detail::JSONNode &node)
 Read axes from the JSONNode and create a RooArgSet representing them.
 
static std::unique_ptr< RooDataHist > readBinnedData (const RooFit::Detail::JSONNode &n, const std::string &namecomp, RooArgSet const &vars)
 Read binned data from the JSONNode and create a RooDataHist object.
 
static void rebuildModelConfigInWorkspace (RooStats::ModelConfig *mc, RooWorkspace &ws)
 
static std::string sanitizeName (const std::string str)
 Cleans up names to the HS3 standard.
 
static RooWorkspace sanitizeWS (const RooWorkspace &ws)
 
static bool testValidName (const std::string &str, bool forcError)
 
static std::ostream & warning (const std::string &s)
 Writes a warning message to the RooFit message service.
 

Static Public Attributes

static constexpr bool useListsInsteadOfDicts = true
 Named objects are always stored in lists, as the HS3 standard requires. Kept for backwards compatibility.
 

Private Member Functions

void exportAllObjects (RooFit::Detail::JSONNode &n)
 
void exportArrayDists ()
 
RooJSONFactoryWSTool::CombinedData exportCombinedData (RooAbsData const &data)
 Export a data set with category observables as a "combined" data set.
 
bool exportConstraintData (std::string const &term, RooArgSet const *globalObservables)
 
void exportData (RooAbsData const &data)
 
void exportModelConfig (RooStats::ModelConfig const &mc, const std::vector< RooJSONFactoryWSTool::CombinedData > &combined, const std::vector< RooAbsData * > &single)
 
void exportObject (RooAbsArg const &func)
 
template<class T >
void exportObjects (T const &args)
 
void exportSimultaneous (RooSimultaneous const &simPdf)
 Export a RooSimultaneous as a "combined_dist".
 
void exportSingleModelConfig (RooStats::ModelConfig const &mc, std::string const &analysisName, std::string const *dataName)
 
void exportVariable (const RooAbsArg *v, RooFit::HS3::ParameterPoint &point, bool storeConstant)
 
void exportVariables (const RooArgSet &allElems, RooFit::HS3::ParameterPoint &point, bool storeConstant)
 
void importAllNodes (RooFit::Detail::JSONNode &n)
 
void importDependants (const RooFit::Detail::JSONNode &n)
 
void importDistribution (RooFit::HS3::Distribution const &distribution)
 
void importVariable (RooFit::HS3::ParameterValue const &p)
 
void prepareCombinedObservableRenaming ()
 
void recordCategory (RooAbsCategory const &cat)
 
template<class T >
T * requestImpl (const std::string &objname)
 
template<>
RooRealVar * requestImpl (const std::string &objname)
 
template<>
RooAbsPdf * requestImpl (const std::string &objname)
 
template<>
RooAbsReal * requestImpl (const std::string &objname)
 
void warnIfFreeWithoutDomain (RooRealVar const &var)
 

Private Attributes

std::map< std::string, std::map< std::string, std::map< std::string, std::string > > > _combinedObservableRenames
 
std::unique_ptr< RooFit::HS3::ToolExportState > _export
 
std::string _hs3VersionInput
 
std::unique_ptr< RooFit::HS3::ToolImportState > _import
 
std::vector< std::string > _importStack
 
std::map< std::string, std::map< std::string, RooAbsPdf const * > > _renamedComponents
 
std::vector< std::unique_ptr< RooAbsArg > > _renamedObjects
 
std::vector< RooAbsArg const * > _serversToDelete
 
std::vector< RooAbsArg const * > _serversToExport
 
RooWorkspace & _workspace
 

Friends

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

#include <RooFitHS3/RooJSONFactoryWSTool.h>

Constructor & Destructor Documentation

◆ RooJSONFactoryWSTool()

RooJSONFactoryWSTool::RooJSONFactoryWSTool ( RooWorkspace & ws)

Definition at line 2006 of file RooJSONFactoryWSTool.cxx.

◆ ~RooJSONFactoryWSTool()

RooJSONFactoryWSTool::~RooJSONFactoryWSTool ( )
default

Member Function Documentation

◆ appendNamedChild()

JSONNode & RooJSONFactoryWSTool::appendNamedChild ( RooFit::Detail::JSONNode & node,
std::string const & name )
static

Definition at line 2026 of file RooJSONFactoryWSTool.cxx.

◆ cleanWS()

RooWorkspace RooJSONFactoryWSTool::cleanWS ( const RooWorkspace & ws,
bool onlyModelConfig = false )
static

Definition at line 4147 of file RooJSONFactoryWSTool.cxx.

◆ config()

RooJSONFactoryWSTool::Config & RooJSONFactoryWSTool::config ( )
static

Definition at line 4196 of file RooJSONFactoryWSTool.cxx.

◆ constraintObservable()

std::string const * RooJSONFactoryWSTool::constraintObservable ( std::string const & pdfName) const

Definition at line 2473 of file RooJSONFactoryWSTool.cxx.

◆ createNewJSONTree()

std::unique_ptr< JSONTree > RooJSONFactoryWSTool::createNewJSONTree ( )
static

Create a new JSON tree with version information.

Returns
std::unique_ptr<JSONTree> A unique pointer to the created JSON tree.

Definition at line 3726 of file RooJSONFactoryWSTool.cxx.

◆ error() [1/2]

void RooJSONFactoryWSTool::error ( const char * s)
static

Writes an error message to the RooFit message service and throws a runtime_error.

Parameters
sThe error message to be logged and thrown.
Returns
void

Definition at line 4108 of file RooJSONFactoryWSTool.cxx.

◆ error() [2/2]

static void RooJSONFactoryWSTool::error ( const std::string & s)
inlinestatic

Definition at line 186 of file RooJSONFactoryWSTool.h.

◆ exportAllObjects()

void RooJSONFactoryWSTool::exportAllObjects ( RooFit::Detail::JSONNode & n)
private

Definition at line 3536 of file RooJSONFactoryWSTool.cxx.

◆ exportArray()

void RooJSONFactoryWSTool::exportArray ( std::size_t n,
double const * contents,
RooFit::Detail::JSONNode & output )
static

Export an array of doubles to a JSONNode.

This function exports an array of doubles, represented by the provided size and contents, to a JSONNode. The array elements are added to the JSONNode as a sequence of values.

Parameters
nThe size of the array.
contentsA pointer to the array containing the double values.
outputThe JSONNode to which the array will be exported.
Returns
void

Definition at line 2809 of file RooJSONFactoryWSTool.cxx.

◆ exportArrayDists()

void RooJSONFactoryWSTool::exportArrayDists ( )
private

Definition at line 2445 of file RooJSONFactoryWSTool.cxx.

◆ exportAsArrayComponent()

std::string RooJSONFactoryWSTool::exportAsArrayComponent ( RooAbsPdf const & pdf,
std::string const & arrayName )

Definition at line 2416 of file RooJSONFactoryWSTool.cxx.

◆ exportAxis()

void RooJSONFactoryWSTool::exportAxis ( RooFit::Detail::JSONNode & obsNode,
RooRealVar const & var )
static

Definition at line 2762 of file RooJSONFactoryWSTool.cxx.

◆ exportCategoricalAxis()

void RooJSONFactoryWSTool::exportCategoricalAxis ( RooFit::Detail::JSONNode & obsNode,
RooCategory const & cat )
static

Export the name and binning of a RooRealVar to a JSONNode.

Parameters
obsNodeThe JSONNode to which the axis information will be exported.
varThe RooRealVar representing the axis to be exported.
Returns
void

Definition at line 2752 of file RooJSONFactoryWSTool.cxx.

◆ exportCombinedData()

RooJSONFactoryWSTool::CombinedData RooJSONFactoryWSTool::exportCombinedData ( RooAbsData const & data)
private

Export a data set with category observables as a "combined" data set.

The categories are the columns, sorted by name, and are declared as categorical axes of the default domain. There is one sub-data set per key, i.e. per combination of states, written like any other data set and named after the data set and the labels of the key. A key is written also without entries: RooFit treats a channel without entries as present and empty. If the workspace has a RooSimultaneous with the same columns, each sub-data set only carries the observables of the corresponding component, and keys without entries for which it has no component are left out; otherwise, every sub-data set carries all observables.

Definition at line 2914 of file RooJSONFactoryWSTool.cxx.

◆ exportConstraintData()

bool RooJSONFactoryWSTool::exportConstraintData ( std::string const & term,
RooArgSet const * globalObservables )
private

Definition at line 2495 of file RooJSONFactoryWSTool.cxx.

◆ exportData()

void RooJSONFactoryWSTool::exportData ( RooAbsData const & data)
private

Definition at line 2980 of file RooJSONFactoryWSTool.cxx.

◆ exportHisto()

void RooJSONFactoryWSTool::exportHisto ( RooArgSet const & vars,
std::size_t n,
double const * contents,
RooFit::Detail::JSONNode & output )
static

Export histogram data to a JSONNode.

This function exports histogram data, represented by the provided variables and contents, to a JSONNode. The histogram's axes information and bin contents are added as key-value pairs to the JSONNode.

Parameters
varsThe RooArgSet representing the variables associated with the histogram.
nThe number of bins in the histogram.
contentsA pointer to the array containing the bin contents of the histogram.
outputThe JSONNode to which the histogram data will be exported.
Returns
void

Definition at line 2783 of file RooJSONFactoryWSTool.cxx.

◆ exportJSON() [1/2]

bool RooJSONFactoryWSTool::exportJSON ( std::ostream & os)

Export the workspace to JSON format and write to the output stream.

Parameters
osThe output stream to write the JSON data to.
Returns
bool Returns true on successful export, false otherwise.

Definition at line 3747 of file RooJSONFactoryWSTool.cxx.

◆ exportJSON() [2/2]

bool RooJSONFactoryWSTool::exportJSON ( std::string const & filename)

Export the workspace to JSON format and write to the specified file.

Parameters
filenameThe name of the JSON file to create and write the data to.
Returns
bool Returns true on successful export, false otherwise.

Definition at line 3762 of file RooJSONFactoryWSTool.cxx.

◆ exportJSONtoString()

std::string RooJSONFactoryWSTool::exportJSONtoString ( )

Export the workspace to a JSON string.

Returns
std::string The JSON string representing the exported workspace.

Definition at line 3714 of file RooJSONFactoryWSTool.cxx.

◆ exportModelConfig()

void RooJSONFactoryWSTool::exportModelConfig ( RooStats::ModelConfig const & mc,
const std::vector< RooJSONFactoryWSTool::CombinedData > & combined,
const std::vector< RooAbsData * > & single )
private

Definition at line 3204 of file RooJSONFactoryWSTool.cxx.

◆ exportObject()

void RooJSONFactoryWSTool::exportObject ( RooAbsArg const & func)
private

Definition at line 2299 of file RooJSONFactoryWSTool.cxx.

◆ exportObjects()

template<class T >
void RooJSONFactoryWSTool::exportObjects ( T const & args)
inlineprivate

Definition at line 273 of file RooJSONFactoryWSTool.h.

◆ exportRootName()

std::string const & RooJSONFactoryWSTool::exportRootName ( ) const

The name of the top-level object whose export is in progress (the root of the current export recursion).

Definition at line 2411 of file RooJSONFactoryWSTool.cxx.

◆ exportSimultaneous()

void RooJSONFactoryWSTool::exportSimultaneous ( RooSimultaneous const & simPdf)
private

Export a RooSimultaneous as a "combined_dist".

The components are selected by a key with one label per column. The columns are the index category of the RooSimultaneous or, for a RooSuperCategory index, its input categories, sorted by name. They are declared as categorical axes of the default domain. States without a pdf are not written: HS3 does not require a component for every key.

Definition at line 2556 of file RooJSONFactoryWSTool.cxx.

◆ exportSingleModelConfig()

void RooJSONFactoryWSTool::exportSingleModelConfig ( RooStats::ModelConfig const & mc,
std::string const & analysisName,
std::string const * dataName )
private

Definition at line 3327 of file RooJSONFactoryWSTool.cxx.

◆ exportTransformed()

std::string RooJSONFactoryWSTool::exportTransformed ( const RooAbsReal * original,
const std::string & suffix,
const std::string & formula )

Definition at line 2202 of file RooJSONFactoryWSTool.cxx.

◆ exportVariable()

void RooJSONFactoryWSTool::exportVariable ( const RooAbsArg * v,
RooFit::HS3::ParameterPoint & point,
bool storeConstant )
private

Definition at line 2164 of file RooJSONFactoryWSTool.cxx.

◆ exportVariables()

void RooJSONFactoryWSTool::exportVariables ( const RooArgSet & allElems,
RooFit::HS3::ParameterPoint & point,
bool storeConstant )
private

Definition at line 2195 of file RooJSONFactoryWSTool.cxx.

◆ fillSeq()

void RooJSONFactoryWSTool::fillSeq ( RooFit::Detail::JSONNode & node,
RooAbsCollection const & coll,
size_t nMax = -1 )
static

Definition at line 2010 of file RooJSONFactoryWSTool.cxx.

◆ findNamedChild()

JSONNode const * RooJSONFactoryWSTool::findNamedChild ( RooFit::Detail::JSONNode const & node,
std::string const & name )
static

Definition at line 2033 of file RooJSONFactoryWSTool.cxx.

◆ getRooFitInternal()

template<typename... Keys_t>
static RooFit::Detail::JSONNode & RooJSONFactoryWSTool::getRooFitInternal ( RooFit::Detail::JSONNode & node,
Keys_t const &... keys )
inlinestatic

Definition at line 228 of file RooJSONFactoryWSTool.h.

◆ getStringAttribute()

std::string RooJSONFactoryWSTool::getStringAttribute ( const std::string & obj,
const std::string & attrib )

Definition at line 3786 of file RooJSONFactoryWSTool.cxx.

◆ hasAttribute()

bool RooJSONFactoryWSTool::hasAttribute ( const std::string & obj,
const std::string & attrib )

Definition at line 3770 of file RooJSONFactoryWSTool.cxx.

◆ hs3VersionInput()

std::string const & RooJSONFactoryWSTool::hs3VersionInput ( ) const
inline

The "hs3_version" of the document that is currently being imported, or an empty string outside of an import.

Definition at line 264 of file RooJSONFactoryWSTool.h.

◆ importAllNodes()

void RooJSONFactoryWSTool::importAllNodes ( RooFit::Detail::JSONNode & n)
private

Definition at line 3804 of file RooJSONFactoryWSTool.cxx.

◆ importDependants()

void RooJSONFactoryWSTool::importDependants ( const RooFit::Detail::JSONNode & n)
private

Definition at line 3193 of file RooJSONFactoryWSTool.cxx.

◆ importDistribution()

void RooJSONFactoryWSTool::importDistribution ( RooFit::HS3::Distribution const & distribution)
private

Definition at line 2707 of file RooJSONFactoryWSTool.cxx.

◆ importFunction() [1/2]

void RooJSONFactoryWSTool::importFunction ( const RooFit::Detail::JSONNode & p,
bool importAllDependants )

Import a function from the JSONNode into the workspace.

This function imports a function from the given JSONNode into the workspace. The function's information is read from the JSONNode and added to the workspace.

Parameters
pThe JSONNode representing the function to be imported.
importAllDependantsA boolean flag indicating whether to import all dependants (servers) of the function.
Returns
void

Definition at line 2634 of file RooJSONFactoryWSTool.cxx.

◆ importFunction() [2/2]

void RooJSONFactoryWSTool::importFunction ( const std::string & jsonString,
bool importAllDependants )

Import a function from a JSON string into the workspace.

This function imports a function from the provided JSON string into the workspace. The function's information is read from the JSON string and added to the workspace.

Parameters
jsonStringThe JSON string containing the function information.
importAllDependantsA boolean flag indicating whether to import all dependants (servers) of the function.
Returns
void

Definition at line 2738 of file RooJSONFactoryWSTool.cxx.

◆ importJSON() [1/2]

bool RooJSONFactoryWSTool::importJSON ( std::istream & is)

Imports a JSON file from the given input stream to the workspace.

Parameters
isThe input stream containing the JSON data.
Returns
bool Returns true on successful import, false otherwise.

Definition at line 3986 of file RooJSONFactoryWSTool.cxx.

◆ importJSON() [2/2]

bool RooJSONFactoryWSTool::importJSON ( std::string const & filename)

Imports a JSON file from the given filename to the workspace.

Parameters
filenameThe name of the JSON file to import.
Returns
bool Returns true on successful import, false otherwise.

Definition at line 4000 of file RooJSONFactoryWSTool.cxx.

◆ importJSONElement()

void RooJSONFactoryWSTool::importJSONElement ( const std::string & name,
const std::string & jsonString )

Definition at line 4009 of file RooJSONFactoryWSTool.cxx.

◆ importJSONfromString()

bool RooJSONFactoryWSTool::importJSONfromString ( const std::string & s)

Import the workspace from a JSON string.

Parameters
sThe JSON string containing the workspace data.
Returns
bool Returns true on successful import, false otherwise.

Definition at line 3703 of file RooJSONFactoryWSTool.cxx.

◆ importVariable()

void RooJSONFactoryWSTool::importVariable ( RooFit::HS3::ParameterValue const & p)
private

Definition at line 3155 of file RooJSONFactoryWSTool.cxx.

◆ importVariableElement()

void RooJSONFactoryWSTool::importVariableElement ( const RooFit::Detail::JSONNode & n)

Definition at line 4056 of file RooJSONFactoryWSTool.cxx.

◆ isValidName()

bool RooJSONFactoryWSTool::isValidName ( const std::string & str)
static

Check if a string is a valid name.

A valid name should start with a letter or an underscore, followed by letters, digits, or underscores. Only characters from the ASCII character set are allowed.

Parameters
strThe string to be checked.
Returns
bool Returns true if the string is a valid name; otherwise, returns false.

Definition at line 2054 of file RooJSONFactoryWSTool.cxx.

◆ makeVariablesNode()

JSONNode & RooJSONFactoryWSTool::makeVariablesNode ( RooFit::Detail::JSONNode & rootNode)
static

Definition at line 2094 of file RooJSONFactoryWSTool.cxx.

◆ name()

std::string RooJSONFactoryWSTool::name ( const RooFit::Detail::JSONNode & n)
static

Definition at line 2089 of file RooJSONFactoryWSTool.cxx.

◆ prepareCombinedObservableRenaming()

void RooJSONFactoryWSTool::prepareCombinedObservableRenaming ( )
private

Definition at line 2827 of file RooJSONFactoryWSTool.cxx.

◆ queueExport()

void RooJSONFactoryWSTool::queueExport ( RooAbsArg const & arg)
inline

Definition at line 241 of file RooJSONFactoryWSTool.h.

◆ queueExportTemporary()

void RooJSONFactoryWSTool::queueExportTemporary ( RooAbsArg * arg)
inline

Definition at line 242 of file RooJSONFactoryWSTool.h.

◆ readAxes()

RooArgSet RooJSONFactoryWSTool::readAxes ( const RooFit::Detail::JSONNode & node)
static

Read axes from the JSONNode and create a RooArgSet representing them.

This function reads axes information from the given JSONNode and creates a RooArgSet with variables representing these axes.

Parameters
topNodeThe JSONNode containing the axes information to be read.
Returns
RooArgSet A RooArgSet containing the variables created from the JSONNode.

Definition at line 3111 of file RooJSONFactoryWSTool.cxx.

◆ readBinnedData()

std::unique_ptr< RooDataHist > RooJSONFactoryWSTool::readBinnedData ( const RooFit::Detail::JSONNode & n,
const std::string & name,
RooArgSet const & vars )
static

Read binned data from the JSONNode and create a RooDataHist object.

This function reads binned data from the given JSONNode and creates a RooDataHist object. The binned data is associated with the specified name and variables (RooArgSet) in the workspace.

Parameters
nThe JSONNode representing the binned data to be read.
nameThe name to be associated with the created RooDataHist object.
varsThe RooArgSet representing the variables associated with the binned data.
Returns
std::unique_ptr<RooDataHist> A unique pointer to the created RooDataHist object.

Definition at line 3131 of file RooJSONFactoryWSTool.cxx.

◆ rebuildModelConfigInWorkspace()

static void RooJSONFactoryWSTool::rebuildModelConfigInWorkspace ( RooStats::ModelConfig * mc,
RooWorkspace & ws )
static

◆ recordCategory()

void RooJSONFactoryWSTool::recordCategory ( RooAbsCategory const & cat)
private

Definition at line 2609 of file RooJSONFactoryWSTool.cxx.

◆ recordConstraintTerms()

void RooJSONFactoryWSTool::recordConstraintTerms ( std::string const & pdfName,
std::vector< std::string > const & terms )

Definition at line 2482 of file RooJSONFactoryWSTool.cxx.

◆ request()

template<class T >
T * RooJSONFactoryWSTool::request ( const std::string & objname,
const std::string & requestAuthor )
inline

The object objname from the workspace, imported from the document first if needed.

Throws a DependencyMissingError if neither has it.

Definition at line 115 of file RooJSONFactoryWSTool.h.

◆ requestArg()

template<class T >
T * RooJSONFactoryWSTool::requestArg ( const RooFit::Detail::JSONNode & node,
const std::string & key )
inline

Definition at line 131 of file RooJSONFactoryWSTool.h.

◆ requestArgList()

template<class T >
RooArgList RooJSONFactoryWSTool::requestArgList ( const RooFit::Detail::JSONNode & node,
const std::string & seqName )
inline

Definition at line 165 of file RooJSONFactoryWSTool.h.

◆ requestArgSet()

template<class T >
RooArgSet RooJSONFactoryWSTool::requestArgSet ( const RooFit::Detail::JSONNode & node,
const std::string & seqName )
inline

Definition at line 159 of file RooJSONFactoryWSTool.h.

◆ requestCollection()

template<class T , class Coll_t >
Coll_t RooJSONFactoryWSTool::requestCollection ( const RooFit::Detail::JSONNode & node,
const std::string & seqName )
inline

Definition at line 141 of file RooJSONFactoryWSTool.h.

◆ requestImpl() [1/4]

template<class T >
T * RooJSONFactoryWSTool::requestImpl ( const std::string & objname)
private

◆ requestImpl() [2/4]

template<>
RooRealVar * RooJSONFactoryWSTool::requestImpl ( const std::string & objname)
private

Definition at line 2100 of file RooJSONFactoryWSTool.cxx.

◆ requestImpl() [3/4]

template<>
RooAbsPdf * RooJSONFactoryWSTool::requestImpl ( const std::string & objname)
private

Definition at line 2116 of file RooJSONFactoryWSTool.cxx.

◆ requestImpl() [4/4]

template<>
RooAbsReal * RooJSONFactoryWSTool::requestImpl ( const std::string & objname)
private

Definition at line 2139 of file RooJSONFactoryWSTool.cxx.

◆ sanitizeName()

std::string RooJSONFactoryWSTool::sanitizeName ( const std::string str)
static

Cleans up names to the HS3 standard.

Parameters
strThe string to be sanitized.
Returns
std::string

Definition at line 4120 of file RooJSONFactoryWSTool.cxx.

◆ sanitizeWS()

RooWorkspace RooJSONFactoryWSTool::sanitizeWS ( const RooWorkspace & ws)
static

Definition at line 4203 of file RooJSONFactoryWSTool.cxx.

◆ setAttribute()

void RooJSONFactoryWSTool::setAttribute ( const std::string & obj,
const std::string & attrib )

Definition at line 3781 of file RooJSONFactoryWSTool.cxx.

◆ setConstraintObservable()

void RooJSONFactoryWSTool::setConstraintObservable ( RooAbsPdf const & pdf,
std::string const & observable )

Record that observable is the observable of the constraint term pdf (the side that is not the constrained parameter).

A Gaussian whose mean it is gets written with x and mean swapped, so that the observable is x.

Definition at line 2468 of file RooJSONFactoryWSTool.cxx.

◆ setStringAttribute()

void RooJSONFactoryWSTool::setStringAttribute ( const std::string & obj,
const std::string & attrib,
const std::string & value )

Definition at line 3797 of file RooJSONFactoryWSTool.cxx.

◆ testValidName()

bool RooJSONFactoryWSTool::testValidName ( const std::string & str,
bool forcError )
static

Definition at line 2073 of file RooJSONFactoryWSTool.cxx.

◆ tryRequest()

template<class T >
T * RooJSONFactoryWSTool::tryRequest ( const std::string & objname)
inline

Like request(), but returns nullptr if neither the workspace nor the document has the object.

Definition at line 125 of file RooJSONFactoryWSTool.h.

◆ warnIfFreeWithoutDomain()

void RooJSONFactoryWSTool::warnIfFreeWithoutDomain ( RooRealVar const & var)
private

Definition at line 3183 of file RooJSONFactoryWSTool.cxx.

◆ warning()

std::ostream & RooJSONFactoryWSTool::warning ( const std::string & s)
static

Writes a warning message to the RooFit message service.

Parameters
strThe warning message to be logged.
Returns
std::ostream& A reference to the output stream.

Definition at line 4097 of file RooJSONFactoryWSTool.cxx.

◆ workspace()

RooWorkspace * RooJSONFactoryWSTool::workspace ( )
inline

Definition at line 170 of file RooJSONFactoryWSTool.h.

◆ wsEmplace()

template<class Obj_t , typename... Args_t>
Obj_t & RooJSONFactoryWSTool::wsEmplace ( RooStringView name,
Args_t &&... args )
inline

Definition at line 180 of file RooJSONFactoryWSTool.h.

◆ wsImport()

template<class Obj_t >
Obj_t & RooJSONFactoryWSTool::wsImport ( Obj_t const & obj)
inline

Definition at line 173 of file RooJSONFactoryWSTool.h.

Friends And Related Symbol Documentation

◆ RooFit::HS3::setExportedObject

Member Data Documentation

◆ _combinedObservableRenames

std::map<std::string, std::map<std::string, std::map<std::string, std::string> > > RooJSONFactoryWSTool::_combinedObservableRenames
private

Definition at line 326 of file RooJSONFactoryWSTool.h.

◆ _export

std::unique_ptr<RooFit::HS3::ToolExportState> RooJSONFactoryWSTool::_export
private

Definition at line 320 of file RooJSONFactoryWSTool.h.

◆ _hs3VersionInput

std::string RooJSONFactoryWSTool::_hs3VersionInput
private

Definition at line 315 of file RooJSONFactoryWSTool.h.

◆ _import

std::unique_ptr<RooFit::HS3::ToolImportState> RooJSONFactoryWSTool::_import
private

Definition at line 319 of file RooJSONFactoryWSTool.h.

◆ _importStack

std::vector<std::string> RooJSONFactoryWSTool::_importStack
private

Definition at line 332 of file RooJSONFactoryWSTool.h.

◆ _renamedComponents

std::map<std::string, std::map<std::string, RooAbsPdf const *> > RooJSONFactoryWSTool::_renamedComponents
private

Definition at line 327 of file RooJSONFactoryWSTool.h.

◆ _renamedObjects

std::vector<std::unique_ptr<RooAbsArg> > RooJSONFactoryWSTool::_renamedObjects
private

Definition at line 328 of file RooJSONFactoryWSTool.h.

◆ _serversToDelete

std::vector<RooAbsArg const *> RooJSONFactoryWSTool::_serversToDelete
private

Definition at line 322 of file RooJSONFactoryWSTool.h.

◆ _serversToExport

std::vector<RooAbsArg const *> RooJSONFactoryWSTool::_serversToExport
private

Definition at line 321 of file RooJSONFactoryWSTool.h.

◆ _workspace

RooWorkspace& RooJSONFactoryWSTool::_workspace
private

Definition at line 316 of file RooJSONFactoryWSTool.h.

◆ useListsInsteadOfDicts

constexpr bool RooJSONFactoryWSTool::useListsInsteadOfDicts = true
staticconstexpr

Named objects are always stored in lists, as the HS3 standard requires. Kept for backwards compatibility.

Definition at line 56 of file RooJSONFactoryWSTool.h.

Libraries for RooJSONFactoryWSTool:

The documentation for this class was generated from the following files: