ParameterSet Creation¶
This page is under construction
Creating a ParameterSet
from only a FHiCL document¶
A ParameterSet
object can be obtained directly from a FHiCL document by calling a function, make_ParameterSet
. The call takes one of two forms, depending on how the document is represented.
- Given a FHiCL document represented by a variable
doc
of typestd::string
:#include "fhiclcpp/make_ParameterSet.h" ... fhicl::ParameterSet pset; fhicl::make_ParameterSet(doc, pset);
- Given a FHiCL document contained in an external text file, there is the slight complication of finding the correct file. This is handled by appealing to functionality found in the external
cetlib
library. Given (a) the file's name as a variablefname
of typestd::string
and (b) a variablemaker
of static typecet::filepath_maker
:#include "fhiclcpp/make_ParameterSet.h" ... fhicl::ParameterSet pset; fhicl::make_ParameterSet(fname, maker, pset);
In either case, the resulting ParameterSet
will contain precisely those name-value pairs specified by the FHiCL document, taking into account any FHiCL (a) #include
directives, (b) name overrides, and (c) references in the documents. The ParameterSet
does not track the origin of any resulting pair.
Making a ParameterSet
from multiple sources¶
In practice, it is often the case that a FHiCL document is not the sole source for obtaining a ParameterSet
. Additional information may come from command-line arguments, for example, and may be used to augment or otherwise adjust a ParameterSet
before it is considered finalized.
While it is possible to update a ParameterSet
directly (e.g., via its put
and erase
member functions), such an approach is not generally recommended, as the design of the ParameterSet
class is strongly biased in favor of inspection and retrieval operations and against modifications. This is the reason for the earlier recommendation that a ParameterSet
be generally treated as immutable.
For this reason, the fhiclcpp
library provides a type, intermediate_table
, that can capture information presented by a FHiCL document, can be readily updated, and can be used to obtain a ParameterSet
. As detailed below, an intermediate_table
has some characteristics reminiscent of a ParameterSet
, some characteristics reminiscent of a FHiCL document, and some characteristics of its own. We first discuss two other types, value_tag
and extended_value
, that provide support for intermediate_table
.
The value_tag
type¶
The type fhicl::value_tag
consists of the enumerated values NIL
, BOOL
, NUMBER
, COMPLEX
, STRING
, SEQUENCE
, TABLE
, TABLEID
and UNKNOWN
. These are used as a classification scheme roughly corresponding to FHiCL's value categories; each extended_value
is accompanied by one of these enumerations. While some values can be self-classified, others can't be classified without outside help. For example, it is unclear whether the std::string
whose value is nil
is intended to be the FHiCL nil
value or just a FHiCL string value.
Because a value_tag
always accompanies an extended_value
, both these types are declared in the "fhiclcpp/extended_value.h"
header.