@@ -127,32 +127,13 @@ std::vector<std::string> valsToStringVec(JSONNode const &node)
127127 return out;
128128}
129129
130- /* *
131- * @brief Check if the number of components in CombinedData matches the number of categories in the RooSimultaneous PDF.
132- *
133- * This function checks whether the number of components in the provided CombinedData 'data' matches the number of
134- * categories in the provided RooSimultaneous PDF 'pdf'.
135- *
136- * @param data The reference to the CombinedData to be checked.
137- * @param pdf The pointer to the RooSimultaneous PDF for comparison.
138- * @return bool Returns true if the number of components in 'data' matches the number of categories in 'pdf'; otherwise,
139- * returns false.
140- */
130+ // True if the number of components in `data` matches the number of categories in `pdf`.
141131bool matches (const RooJSONFactoryWSTool::CombinedData &data, const RooSimultaneous *pdf)
142132{
143133 return data.components .size () == pdf->indexCat ().size ();
144134}
145135
146- /* *
147- * @brief Check if a string represents a valid number.
148- *
149- * This function checks whether the provided string 'str' represents a valid number.
150- * The function returns true if the entire string can be parsed as a number (integer or floating-point); otherwise, it
151- * returns false.
152- *
153- * @param str The string to be checked.
154- * @return bool Returns true if the string 'str' represents a valid number; otherwise, returns false.
155- */
136+ // True if the entire string parses as a number (integer or floating-point).
156137bool isNumber (const std::string &str)
157138{
158139 // Parse with the same mechanism as toDouble() and require that the whole string is consumed, so that isNumber(s) is
@@ -163,20 +144,7 @@ bool isNumber(const std::string &str)
163144 return (stream >> value) && stream.eof ();
164145}
165146
166- /* *
167- * @brief Configure a RooRealVar based on information from a JSONNode.
168- *
169- * This function configures the provided RooRealVar 'v' based on the information provided in the JSONNode 'p'.
170- * The JSONNode 'p' contains information about various properties of the RooRealVar, such as its value, error, number of
171- * bins, etc. The function reads these properties from the JSONNode and sets the corresponding properties of the
172- * RooRealVar accordingly.
173- *
174- * @param domains The reference to the RooFit::JSONIO::Detail::Domains containing domain information for variables (not
175- * used in this function).
176- * @param p The JSONNode containing information about the properties of the RooRealVar 'v'.
177- * @param v The reference to the RooRealVar to be configured.
178- * @return void
179- */
147+ // Configure `v` (value, error, binning, constness) from the JSON node `p`.
180148void configureVariable (RooFit::JSONIO ::Detail::Domains &domains, const JSONNode &p, RooRealVar &v)
181149{
182150 if (!p.has_child (" name" )) {
@@ -241,16 +209,7 @@ void genIndicesHelper(std::vector<std::vector<int>> &combinations, std::vector<i
241209 }
242210}
243211
244- /* *
245- * @brief Import attributes from a JSONNode into a RooAbsArg.
246- *
247- * This function imports attributes, represented by the provided JSONNode 'node', into the provided RooAbsArg 'arg'.
248- * The attributes are read from the JSONNode and applied to the RooAbsArg.
249- *
250- * @param arg The pointer to the RooAbsArg to which the attributes will be imported.
251- * @param node The JSONNode containing information about the attributes to be imported.
252- * @return void
253- */
212+ // Import string attributes ("dict") and boolean tags ("tags") from `node` onto `arg`.
254213void importAttributes (RooAbsArg *arg, JSONNode const &node)
255214{
256215 if (auto seq = node.find (" dict" )) {
@@ -408,16 +367,7 @@ std::string generate(const RooFit::JSONIO::ImportExpression &ex, const JSONNode
408367 return expression.str ();
409368}
410369
411- /* *
412- * @brief Generate bin indices for a set of RooRealVars.
413- *
414- * This function generates all possible combinations of bin indices for the provided RooArgSet 'vars' containing
415- * RooRealVars. Each bin index represents a possible bin selection for the corresponding RooRealVar. The bin indices are
416- * stored in a vector of vectors, where each inner vector represents a combination of bin indices for all RooRealVars.
417- *
418- * @param vars The RooArgSet containing the RooRealVars for which bin indices will be generated.
419- * @return std::vector<std::vector<int>> A vector of vectors containing all possible combinations of bin indices.
420- */
370+ // Generate all combinations of bin indices for the RooRealVars in `vars`.
421371std::vector<std::vector<int >> generateBinIndices (const RooArgSet &vars)
422372{
423373 std::vector<std::vector<int >> combinations;
@@ -437,30 +387,14 @@ JSONNode const *findRooFitInternal(JSONNode const &node, Keys_t const &...keys)
437387 return node.find (" misc" , " ROOT_internal" , keys...);
438388}
439389
440- /* *
441- * @brief Check if a RooAbsArg is a literal constant variable.
442- *
443- * This function checks whether the provided RooAbsArg 'arg' is a literal constant variable.
444- * A literal constant variable is a RooConstVar with a numeric value as a name.
445- *
446- * @param arg The reference to the RooAbsArg to be checked.
447- * @return bool Returns true if 'arg' is a literal constant variable; otherwise, returns false.
448- */
390+ // True if `arg` is a RooConstVar whose name is a plain number (i.e. a literal constant).
449391bool isLiteralConstVar (RooAbsArg const &arg)
450392{
451393 bool isRooConstVar = dynamic_cast <RooConstVar const *>(&arg);
452394 return isRooConstVar && isNumber (arg.GetName ());
453395}
454396
455- /* *
456- * @brief Export attributes of a RooAbsArg to a JSONNode.
457- *
458- * This function exports the attributes of the provided RooAbsArg 'arg' to the JSONNode 'rootnode'.
459- *
460- * @param arg The pointer to the RooAbsArg from which attributes will be exported.
461- * @param rootnode The JSONNode to which the attributes will be exported.
462- * @return void
463- */
397+ // Export the string attributes and tags of `arg` into the ROOT-internal attributes node.
464398void exportAttributes (const RooAbsArg *arg, JSONNode &rootnode)
465399{
466400 // If this RooConst is a literal number, we don't need to export the attributes.
@@ -502,19 +436,7 @@ void exportAttributes(const RooAbsArg *arg, JSONNode &rootnode)
502436 }
503437}
504438
505- /* *
506- * @brief Create several observables in the workspace.
507- *
508- * This function obtains a list of observables from the provided
509- * RooWorkspace 'ws' based on their names given in the 'axes" field of
510- * the JSONNode 'node'. The observables are added to the RooArgSet
511- * 'out'.
512- *
513- * @param ws The RooWorkspace in which the observables will be created.
514- * @param node The JSONNode containing information about the observables to be created.
515- * @param out The RooAbsCollection to which the created observables will be added.
516- * @return void
517- */
439+ // Collect the observables named in the "axes" field of `node` from the workspace into `out`.
518440void getObservables (RooWorkspace const &ws, const JSONNode &node, RooAbsCollection &out)
519441{
520442 for (const auto &p : node[" axes" ].children ()) {
@@ -529,17 +451,7 @@ void getObservables(RooWorkspace const &ws, const JSONNode &node, RooAbsCollecti
529451 }
530452}
531453
532- /* *
533- * @brief Import data from the JSONNode into the workspace.
534- *
535- * This function imports data, represented by the provided JSONNode 'p', into the workspace represented by the provided
536- * RooWorkspace. The data information is read from the JSONNode and added to the workspace.
537- *
538- * @param p The JSONNode representing the data to be imported.
539- * @param workspace The RooWorkspace to which the data will be imported.
540- * @return std::unique_ptr<RooAbsData> A unique pointer to the RooAbsData object representing the imported data.
541- * The caller is responsible for managing the memory of the returned object.
542- */
454+ // Create a RooAbsData (binned or unbinned) from the JSON node `p`.
543455std::unique_ptr<RooAbsData> loadData (const JSONNode &p, RooWorkspace &workspace)
544456{
545457 std::string name (RooJSONFactoryWSTool::name (p));
@@ -602,21 +514,7 @@ std::unique_ptr<RooAbsData> loadData(const JSONNode &p, RooWorkspace &workspace)
602514 return nullptr ;
603515}
604516
605- /* *
606- * @brief Import an analysis from the JSONNode into the workspace.
607- *
608- * This function imports an analysis, represented by the provided JSONNodes 'analysisNode' and 'likelihoodsNode',
609- * into the workspace represented by the provided RooWorkspace. The analysis information is read from the JSONNodes
610- * and added to the workspace as one or more RooFit::ModelConfig objects.
611- *
612- * @param rootnode The root JSONNode representing the entire JSON file.
613- * @param analysisNode The JSONNode representing the analysis to be imported.
614- * @param likelihoodsNode The JSONNode containing information about likelihoods associated with the analysis.
615- * @param domainsNode The JSONNode containing information about domains associated with the analysis.
616- * @param workspace The RooWorkspace to which the analysis will be imported.
617- * @param datasets A vector of unique pointers to RooAbsData objects representing the data associated with the analysis.
618- * @return void
619- */
517+ // Import an analysis (likelihood + domains) as one or more ModelConfig objects into the workspace.
620518void importAnalysis (const JSONNode &rootnode, const JSONNode &analysisNode, const JSONNode &likelihoodsNode,
621519 const JSONNode &domainsNode, RooWorkspace &workspace,
622520 const std::vector<std::unique_ptr<RooAbsData>> &datasets)
@@ -996,16 +894,7 @@ RooAbsReal *RooJSONFactoryWSTool::requestImpl<RooAbsReal>(const std::string &obj
996894 return nullptr ;
997895}
998896
999- /* *
1000- * @brief Export a variable from the workspace to a JSONNode.
1001- *
1002- * This function exports a variable, represented by the provided RooAbsArg pointer 'v', from the workspace to a
1003- * JSONNode. The variable's information is added to the JSONNode as key-value pairs.
1004- *
1005- * @param v The pointer to the RooAbsArg representing the variable to be exported.
1006- * @param node The JSONNode to which the variable will be exported.
1007- * @return void
1008- */
897+ // Export a single variable (RooRealVar or RooConstVar) `v` as a named child of `node`.
1009898void RooJSONFactoryWSTool::exportVariable (const RooAbsArg *v, JSONNode &node, bool storeConstant, bool storeBins)
1010899{
1011900 auto *cv = dynamic_cast <const RooConstVar *>(v);
@@ -1038,16 +927,7 @@ void RooJSONFactoryWSTool::exportVariable(const RooAbsArg *v, JSONNode &node, bo
1038927 }
1039928}
1040929
1041- /* *
1042- * @brief Export variables from the workspace to a JSONNode.
1043- *
1044- * This function exports variables, represented by the provided RooArgSet, from the workspace to a JSONNode.
1045- * The variables' information is added to the JSONNode as key-value pairs.
1046- *
1047- * @param allElems The RooArgSet representing the variables to be exported.
1048- * @param n The JSONNode to which the variables will be exported.
1049- * @return void
1050- */
930+ // Export all variables in `allElems` as a sequence under `n`.
1051931void RooJSONFactoryWSTool::exportVariables (const RooArgSet &allElems, JSONNode &n, bool storeConstant, bool storeBins)
1052932{
1053933 // export a list of RooRealVar objects
@@ -1068,17 +948,8 @@ std::string RooJSONFactoryWSTool::exportTransformed(const RooAbsReal *original,
1068948 return newname;
1069949}
1070950
1071- /* *
1072- * @brief Export an object from the workspace to a JSONNode.
1073- *
1074- * This function exports an object, represented by the provided RooAbsArg, from the workspace to a JSONNode.
1075- * The object's information is added to the JSONNode as key-value pairs.
1076- *
1077- * @param func The RooAbsArg representing the object to be exported.
1078- * @param exportedObjectNames A set of strings containing names of previously exported objects to avoid duplicates.
1079- * This set is updated with the name of the newly exported object.
1080- * @return void
1081- */
951+ // Export a single object `func` (pdf, function, variable or category) to the output JSON, recording its name in
952+ // `exportedObjectNames` to avoid exporting it twice.
1082953void RooJSONFactoryWSTool::exportObject (RooAbsArg const &func, std::set<std::string> &exportedObjectNames)
1083954{
1084955 std::string name = func.GetName ();
@@ -1423,16 +1294,6 @@ void RooJSONFactoryWSTool::exportArray(std::size_t n, double const *contents, JS
14231294 }
14241295}
14251296
1426- /* *
1427- * @brief Export a RooAbsCategory object to a JSONNode.
1428- *
1429- * This function exports a RooAbsCategory object, represented by the provided categories and indices,
1430- * to a JSONNode. The category labels and corresponding indices are added to the JSONNode as key-value pairs.
1431- *
1432- * @param cat The RooAbsCategory object to be exported.
1433- * @param node The JSONNode to which the category data will be exported.
1434- * @return void
1435- */
14361297namespace {
14371298
14381299// Turn an arbitrary string into a valid variable name, but refuse to change the
@@ -1451,6 +1312,16 @@ std::string makeValidNameOrError(std::string const &in)
14511312
14521313} // namespace
14531314
1315+ /* *
1316+ * @brief Export a RooAbsCategory object to a JSONNode.
1317+ *
1318+ * This function exports a RooAbsCategory object, represented by the provided categories and indices,
1319+ * to a JSONNode. The category labels and corresponding indices are added to the JSONNode as key-value pairs.
1320+ *
1321+ * @param cat The RooAbsCategory object to be exported.
1322+ * @param node The JSONNode to which the category data will be exported.
1323+ * @return void
1324+ */
14541325void RooJSONFactoryWSTool::exportCategory (RooAbsCategory const &cat, JSONNode &node)
14551326{
14561327 auto &labels = node[" labels" ].set_seq ();
@@ -1462,16 +1333,8 @@ void RooJSONFactoryWSTool::exportCategory(RooAbsCategory const &cat, JSONNode &n
14621333 }
14631334}
14641335
1465- /* *
1466- * @brief Export combined data from the workspace to a custom struct.
1467- *
1468- * This function exports combined data from the workspace, represented by the provided RooAbsData object,
1469- * to a CombinedData struct. The struct contains information such as variables, categories,
1470- * and bin contents of the combined data.
1471- *
1472- * @param data The RooAbsData object representing the combined data to be exported.
1473- * @return CombinedData A custom struct containing the exported combined data.
1474- */
1336+ // Split `data` by its index category into per-channel datasets and export each, returning the resulting
1337+ // component-name map.
14751338RooJSONFactoryWSTool::CombinedData RooJSONFactoryWSTool::exportCombinedData (RooAbsData const &data)
14761339{
14771340 // find category observables
@@ -1527,15 +1390,7 @@ RooJSONFactoryWSTool::CombinedData RooJSONFactoryWSTool::exportCombinedData(RooA
15271390 return datamap;
15281391}
15291392
1530- /* *
1531- * @brief Export data from the workspace to a JSONNode.
1532- *
1533- * This function exports data represented by the provided RooAbsData object,
1534- * to a JSONNode. The data's information is added as key-value pairs to the JSONNode.
1535- *
1536- * @param data The RooAbsData object representing the data to be exported.
1537- * @return void
1538- */
1393+ // Export a single dataset `data` (binned or unbinned) to the output JSON.
15391394void RooJSONFactoryWSTool::exportData (RooAbsData const &data)
15401395{
15411396 // find category observables
@@ -1721,15 +1576,7 @@ RooJSONFactoryWSTool::readBinnedData(const JSONNode &n, const std::string &name,
17211576 return dh;
17221577}
17231578
1724- /* *
1725- * @brief Import a variable from the JSONNode into the workspace.
1726- *
1727- * This function imports a variable from the given JSONNode into the workspace.
1728- * The variable's information is read from the JSONNode and added to the workspace.
1729- *
1730- * @param p The JSONNode representing the variable to be imported.
1731- * @return void
1732- */
1579+ // Import a single variable (RooRealVar or RooConstVar) from the JSON node `p` into the workspace.
17331580void RooJSONFactoryWSTool::importVariable (const JSONNode &p)
17341581{
17351582 // import a RooRealVar object
@@ -1754,15 +1601,7 @@ void RooJSONFactoryWSTool::importVariable(const JSONNode &p)
17541601 configureVariable (*_domains, p, wsEmplace<RooRealVar>(name, 1 .));
17551602}
17561603
1757- /* *
1758- * @brief Import all dependants (servers) of a node into the workspace.
1759- *
1760- * This function imports all the dependants (servers) of the given JSONNode into the workspace.
1761- * The dependants' information is read from the JSONNode and added to the workspace.
1762- *
1763- * @param n The JSONNode representing the node whose dependants are to be imported.
1764- * @return void
1765- */
1604+ // Import all dependants (variables, functions and distributions) of node `n` into the workspace.
17661605void RooJSONFactoryWSTool::importDependants (const JSONNode &n)
17671606{
17681607 // import all the dependants of an object
@@ -1899,15 +1738,7 @@ void RooJSONFactoryWSTool::exportSingleModelConfig(JSONNode &rootnode, RooFit::M
18991738 modelConfigAux[" mcName" ] << mc.GetName ();
19001739}
19011740
1902- /* *
1903- * @brief Export all objects in the workspace to a JSONNode.
1904- *
1905- * This function exports all the objects in the workspace to the provided JSONNode.
1906- * The objects' information is added as key-value pairs to the JSONNode.
1907- *
1908- * @param n The JSONNode to which the objects will be exported.
1909- * @return void
1910- */
1741+ // Export all top-level pdfs, functions, datasets and ModelConfigs of the workspace into `n`.
19111742void RooJSONFactoryWSTool::exportAllObjects (JSONNode &n)
19121743{
19131744 _domains = std::make_unique<RooFit::JSONIO ::Detail::Domains>();
@@ -2127,12 +1958,7 @@ void RooJSONFactoryWSTool::setStringAttribute(const std::string &obj, const std:
21271958 dict[attrib] << value;
21281959}
21291960
2130- /* *
2131- * @brief Imports all nodes of the JSON data and adds them to the workspace.
2132- *
2133- * @param n The JSONNode representing the root node of the JSON data.
2134- * @return void
2135- */
1961+ // Import all nodes of the JSON document rooted at `n` into the workspace.
21361962void RooJSONFactoryWSTool::importAllNodes (const JSONNode &n)
21371963{
21381964 // Per HS3 standard, the hs3_version in the metadata is required. So we
0 commit comments