diff --git a/bind/python/iguana_ex_python_00_run_functions.py b/bind/python/iguana_ex_python_00_run_functions.py
index 1f82093a..33996a28 100755
--- a/bind/python/iguana_ex_python_00_run_functions.py
+++ b/bind/python/iguana_ex_python_00_run_functions.py
@@ -42,15 +42,14 @@
seq.Add('clas12::rga::MomentumCorrection') # momentum corrections (a transformer algorithm)
# seq.PrintSequence()
-# set log levels
-# NOTE: this can also be done in a config file
-seq.SetOption('clas12::EventBuilderFilter', 'log', 'info')
-seq.SetOption('clas12::SectorFinder', 'log', 'info')
-seq.SetOption('clas12::rga::MomentumCorrection', 'log', 'info')
-
-# set algorithm options
-# NOTE: this can also be done in a config file, but setting options here OVERRIDES config file settings
-seq.SetOption('clas12::EventBuilderFilter', 'pids', [11, 211, -211])
+# configure algorithms with a custom YAML file
+# - in practice, specify the path(s) to your preferred configuration file(s); see documentation
+# on 'How to Configure Algorithms' for details, and alternative methods for algorithm configuration
+# - in this example, the file is from the source-code path `./config/examples/`, which was copied to
+# the installation subdirectory `etc/iguana/`, within the default configuration-file search path
+seq.SetConfigFileForEachAlgorithm("examples/config_for_examples.yaml")
+# alternatively: use this configuration for the algorithm that needs it
+# seq.Get("clas12::EventBuilderFilter").SetConfigFile("examples/config_for_examples.yaml")
# start the algorithms
seq.Start(banks)
diff --git a/bind/python/iguana_ex_python_01_action_functions.py b/bind/python/iguana_ex_python_01_action_functions.py
index f2624ba9..3baf0163 100755
--- a/bind/python/iguana_ex_python_01_action_functions.py
+++ b/bind/python/iguana_ex_python_01_action_functions.py
@@ -51,13 +51,15 @@
algo_sector_finder = iguana.clas12.SectorFinder() # get the sector for each particle (a creator algorithm)
algo_momentum_correction = iguana.clas12.rga.MomentumCorrection() # momentum corrections (a transformer algorithm)
-# set log levels
-algo_eventbuilder_filter.SetOption('log', 'info')
-algo_sector_finder.SetOption('log', 'info')
-algo_momentum_correction.SetOption('log', 'info')
-
-# set algorithm options
-algo_eventbuilder_filter.SetOption('pids', [11, 211, -211])
+# configure algorithms with a custom YAML file
+# - in practice, specify the path(s) to your preferred configuration file(s); see documentation
+# on 'How to Configure Algorithms' for details, and alternative methods for algorithm configuration
+# - in this example, the file is from the source-code path `./config/examples/`, which was copied to
+# the installation subdirectory `etc/iguana/`, within the default configuration-file search path
+config_file = "examples/config_for_examples.yaml"
+algo_eventbuilder_filter.SetConfigFile(config_file)
+algo_sector_finder.SetConfigFile(config_file)
+algo_momentum_correction.SetConfigFile(config_file)
# start the algorithms
algo_eventbuilder_filter.Start()
diff --git a/bind/python/iguana_ex_python_hipopy.py b/bind/python/iguana_ex_python_hipopy.py
index bcc16abd..a9f86d26 100755
--- a/bind/python/iguana_ex_python_hipopy.py
+++ b/bind/python/iguana_ex_python_hipopy.py
@@ -44,13 +44,11 @@
algo_sector_finder = iguana.clas12.SectorFinder() # get the sector for each particle (a creator algorithm)
algo_momentum_correction = iguana.clas12.rga.MomentumCorrection() # momentum corrections (a transformer algorithm)
-# set log levels
-algo_eventbuilder_filter.SetOption('log', 'info')
-algo_sector_finder.SetOption('log', 'info')
-algo_momentum_correction.SetOption('log', 'info')
-
-# set algorithm options
-algo_eventbuilder_filter.SetOption('pids', [11, 211, -211])
+# configure algorithms with a custom YAML file
+config_file = "examples/config_for_examples.yaml"
+algo_eventbuilder_filter.SetConfigFile(config_file)
+algo_sector_finder.SetConfigFile(config_file)
+algo_momentum_correction.SetConfigFile(config_file)
# start the algorithms
algo_eventbuilder_filter.Start()
diff --git a/doc/doxygen/mainpage.md b/doc/doxygen/mainpage.md
index bbcf3b76..76e598ed 100644
--- a/doc/doxygen/mainpage.md
+++ b/doc/doxygen/mainpage.md
@@ -5,11 +5,12 @@ This documentation shows how to use the Iguana algorithms. For more documentatio
- **Tip:** To toggle between light and dark mode for this webpage, click the button in the top-right corner, next to the search box.
-| Quick Links ||
-| --- | --- |
-| @spacer [List of All Algorithms](#algo) @spacer | @spacer [List of Algorithms Organized by Run Group, etc.](#algo_namespaces) @spacer |
-| @spacer [List of Action Functions](#action) @spacer | @spacer [Configuring Algorithms](#mainpageConfiguring) @spacer |
-| @spacer [Banks Created by Iguana](#created_banks) @spacer | @spacer [Examples of Code](#mainpageExample) @spacer |
+| Quick Links | |
+| --- | --- |
+| @spacer [List of All Algorithms](#algo) @spacer | @spacer [List of Algorithms Organized by Run Group, etc.](#algo_namespaces) @spacer |
+| @spacer [List of Action Functions](#action) @spacer | @spacer [How to Configure Algorithms](#mainpageConfiguring) @spacer |
+| @spacer [Banks Created by Iguana](#created_banks) @spacer | @spacer [How to Run Algorithms](#mainpageRunning) @spacer |
+| | @spacer [Examples of Code](#mainpageExample) @spacer |
@@ -243,7 +244,11 @@ Many algorithms are configurable. An algorithm's configuration parameters and th
Iguana provides a few ways to configure algorithms; in general, you may either:
- use YAML for configuration that gets applied at runtime, _i.e._, no need to recompile
-- use @link iguana::Algorithm::SetOption @endlink to configure an algorithm more directly, which may require recompilation, depending on how you use Iguana algorithms
+ - this is the preferred method for configuration
+- use @link iguana::Algorithm::SetOption @endlink to configure an algorithm more directly, however:
+ - this may require recompilation, depending on how you use Iguana algorithms
+ - some options cannot be set this way, in particular, options that depend on data, such as a run number-dependent vertex cut
+ - using the YAML file is preferred in general (whereas @link iguana::Algorithm::SetOption @endlink is useful for algorithm Validators)
The default configuration YAML files are installed in the `etc/` subdirectory of the Iguana installation. If you have set the Iguana environment variables using, _e.g._ `source this_iguana.sh`, or if you are using the version of Iguana installed on `ifarm`, you will have the environment variable `$IGUANA_CONFIG_PATH` set to include this `etc/` directory.
@@ -276,13 +281,15 @@ physics::AlgorithmB
reptileA: gecko
reptileB: tuatara
```
-Custom YAML file, with some changes such as widening `AlgorithmA`'s `cuts`:
+Custom YAML file, with some changes such as widening `AlgorithmA`'s `cuts`, and controlling the log levels:
```yaml
### custom YAML file
physics::AlgorithmA
+ log: info # set the log level for this algorithm
cuts: [-2, 2]
physics::AlgorithmB
+ log: debug # set the log level for this algorithm
valueA: 5
valueB: 0.14
reptiles:
diff --git a/examples/config/examples/config_for_examples.yaml b/examples/config/examples/config_for_examples.yaml
new file mode 100644
index 00000000..0f0d2f4b
--- /dev/null
+++ b/examples/config/examples/config_for_examples.yaml
@@ -0,0 +1,9 @@
+clas12::EventBuilderFilter:
+ log: info # set the log level
+ pids: [ 11, 211, -211, 22 ] # customize the list of PDGs to filter for
+
+clas12::SectorFinder:
+ log: info
+
+clas12::rga::MomentumCorrection:
+ log: info
diff --git a/examples/config/my_combined_config_file.yaml b/examples/config/examples/my_combined_config_file.yaml
similarity index 100%
rename from examples/config/my_combined_config_file.yaml
rename to examples/config/examples/my_combined_config_file.yaml
diff --git a/examples/config/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml b/examples/config/examples/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml
similarity index 100%
rename from examples/config/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml
rename to examples/config/examples/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml
diff --git a/examples/config/my_z_vertex_cuts.yaml b/examples/config/examples/my_z_vertex_cuts.yaml
similarity index 100%
rename from examples/config/my_z_vertex_cuts.yaml
rename to examples/config/examples/my_z_vertex_cuts.yaml
diff --git a/examples/iguana_ex_cpp_00_run_functions.cc b/examples/iguana_ex_cpp_00_run_functions.cc
index f36156d4..64c4e9df 100644
--- a/examples/iguana_ex_cpp_00_run_functions.cc
+++ b/examples/iguana_ex_cpp_00_run_functions.cc
@@ -47,15 +47,14 @@ int main(int argc, char** argv)
seq.Add("clas12::rga::MomentumCorrection"); // momentum corrections (a transformer algorithm)
// seq.PrintSequence();
- // set log levels
- // NOTE: this can also be done in a config file
- seq.SetOption("clas12::EventBuilderFilter", "log", "info");
- seq.SetOption("clas12::SectorFinder", "log", "info");
- seq.SetOption("clas12::rga::MomentumCorrection", "log", "info");
-
- // set algorithm options
- // NOTE: this can also be done in a config file, but setting options here OVERRIDES config file settings
- seq.SetOption>("clas12::EventBuilderFilter", "pids", {11, 211, -211});
+ // configure algorithms with a custom YAML file
+ // - in practice, specify the path(s) to your preferred configuration file(s); see documentation
+ // on 'How to Configure Algorithms' for details, and alternative methods for algorithm configuration
+ // - in this example, the file is from the source-code path `./config/examples/`, which was copied to
+ // the installation subdirectory `etc/iguana/`, within the default configuration-file search path
+ seq.SetConfigFileForEachAlgorithm("examples/config_for_examples.yaml");
+ // alternatively: use this configuration for the algorithm that needs it
+ // seq.Get("clas12::EventBuilderFilter")->SetConfigFile("examples/config_for_examples.yaml");
// start the algorithms
seq.Start(banks);
diff --git a/examples/iguana_ex_cpp_00_run_functions_with_banks.cc b/examples/iguana_ex_cpp_00_run_functions_with_banks.cc
index bb98f780..755f5096 100644
--- a/examples/iguana_ex_cpp_00_run_functions_with_banks.cc
+++ b/examples/iguana_ex_cpp_00_run_functions_with_banks.cc
@@ -51,15 +51,15 @@ int main(int argc, char** argv)
iguana::clas12::SectorFinder algo_sector_finder; // get the sector for each particle (a creator algorithm)
iguana::clas12::rga::MomentumCorrection algo_momentum_correction; // momentum corrections (a transformer algorithm)
- // set log levels
- // NOTE: this can also be done in a config file
- algo_eventbuilder_filter.SetOption("log", "info");
- algo_sector_finder.SetOption("log", "info");
- algo_momentum_correction.SetOption("log", "info");
-
- // set algorithm options
- // NOTE: this can also be done in a config file, but setting options here OVERRIDES config file settings
- algo_eventbuilder_filter.SetOption>("pids", {11, 211, -211});
+ // configure algorithms with a custom YAML file
+ // - in practice, specify the path(s) to your preferred configuration file(s); see documentation
+ // on 'How to Configure Algorithms' for details, and alternative methods for algorithm configuration
+ // - in this example, the file is from the source-code path `./config/examples/`, which was copied to
+ // the installation subdirectory `etc/iguana/`, within the default configuration-file search path
+ std::string config_file = "examples/config_for_examples.yaml";
+ algo_eventbuilder_filter.SetConfigFile(config_file);
+ algo_sector_finder.SetConfigFile(config_file);
+ algo_momentum_correction.SetConfigFile(config_file);
// start the algorithms
algo_eventbuilder_filter.Start();
diff --git a/examples/iguana_ex_cpp_01_action_functions.cc b/examples/iguana_ex_cpp_01_action_functions.cc
index 11c1aaaa..15de3831 100644
--- a/examples/iguana_ex_cpp_01_action_functions.cc
+++ b/examples/iguana_ex_cpp_01_action_functions.cc
@@ -57,14 +57,15 @@ int main(int argc, char** argv)
iguana::clas12::SectorFinder algo_sector_finder; // get the sector for each particle (a creator algorithm)
iguana::clas12::rga::MomentumCorrection algo_momentum_correction; // momentum corrections (a transformer algorithm)
- // set log levels
- algo_eventbuilder_filter.SetOption("log", "info");
- algo_sector_finder.SetOption("log", "info");
- algo_momentum_correction.SetOption("log", "info");
-
- // set algorithm options
- // NOTE: this can also be done in a config file
- algo_eventbuilder_filter.SetOption>("pids", {11, 211, -211});
+ // configure algorithms with a custom YAML file
+ // - in practice, specify the path(s) to your preferred configuration file(s); see documentation
+ // on 'How to Configure Algorithms' for details, and alternative methods for algorithm configuration
+ // - in this example, the file is from the source-code path `./config/examples/`, which was copied to
+ // the installation subdirectory `etc/iguana/`, within the default configuration-file search path
+ std::string config_file = "examples/config_for_examples.yaml";
+ algo_eventbuilder_filter.SetConfigFile(config_file);
+ algo_sector_finder.SetConfigFile(config_file);
+ algo_momentum_correction.SetConfigFile(config_file);
// start the algorithms
algo_eventbuilder_filter.Start();
diff --git a/examples/iguana_ex_cpp_dataframes.cc b/examples/iguana_ex_cpp_dataframes.cc
index b67ed321..3481899b 100644
--- a/examples/iguana_ex_cpp_dataframes.cc
+++ b/examples/iguana_ex_cpp_dataframes.cc
@@ -33,7 +33,7 @@ int main(int argc, char** argv)
// iguana algorithms
iguana::clas12::EventBuilderFilter algo_eventbuilder_filter;
- algo_eventbuilder_filter.SetOption>("pids", {11, 211, -211});
+ algo_eventbuilder_filter.SetConfigFile("examples/config_for_examples.yaml");
algo_eventbuilder_filter.Start();
// enable interactive mode
diff --git a/examples/meson.build b/examples/meson.build
index 8ba5bb5c..f13e20f3 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -1,6 +1,6 @@
# install config files
example_config_files_prefix = project_etcdir / 'examples'
-install_subdir('config', install_dir: example_config_files_prefix, strip_directory: true)
+install_subdir('config' / 'examples', install_dir: example_config_files_prefix, strip_directory: true)
# example source information
example_sources = {
diff --git a/src/iguana/algorithms/Algorithm.cc b/src/iguana/algorithms/Algorithm.cc
index 3eb3276e..95f4d480 100644
--- a/src/iguana/algorithms/Algorithm.cc
+++ b/src/iguana/algorithms/Algorithm.cc
@@ -31,58 +31,60 @@ namespace iguana {
///////////////////////////////////////////////////////////////////////////////
template
- OPTION_TYPE Algorithm::GetOptionScalar(std::string const& key, YAMLReader::node_path_t node_path) const
+ OPTION_TYPE Algorithm::GetOptionScalar(YAMLReader::node_path_t node_path) const
{
- CompleteOptionNodePath(key, node_path);
+ auto key = YAMLReader::NodePath2String(node_path);
auto opt = GetCachedOption(key);
+ node_path.push_front(m_class_name);
if(!opt.has_value()) {
opt = m_yaml_config->GetScalar(node_path);
}
if(!opt.has_value()) {
- m_log->Error("Failed to `GetOptionScalar` for key {:?}", key);
+ m_log->Error("Failed to `GetOptionScalar` for parameter {:?}", key);
throw std::runtime_error("config file parsing issue");
}
PrintOptionValue(key, opt.value());
return opt.value();
}
- template int Algorithm::GetOptionScalar(std::string const& key, YAMLReader::node_path_t node_path) const;
- template double Algorithm::GetOptionScalar(std::string const& key, YAMLReader::node_path_t node_path) const;
- template std::string Algorithm::GetOptionScalar(std::string const& key, YAMLReader::node_path_t node_path) const;
+ template int Algorithm::GetOptionScalar(YAMLReader::node_path_t node_path) const;
+ template double Algorithm::GetOptionScalar(YAMLReader::node_path_t node_path) const;
+ template std::string Algorithm::GetOptionScalar(YAMLReader::node_path_t node_path) const;
///////////////////////////////////////////////////////////////////////////////
template
- std::vector Algorithm::GetOptionVector(std::string const& key, YAMLReader::node_path_t node_path) const
+ std::vector Algorithm::GetOptionVector(YAMLReader::node_path_t node_path) const
{
- CompleteOptionNodePath(key, node_path);
+ auto key = YAMLReader::NodePath2String(node_path);
auto opt = GetCachedOption>(key);
+ node_path.push_front(m_class_name);
if(!opt.has_value()) {
opt = m_yaml_config->GetVector(node_path);
}
if(!opt.has_value()) {
- m_log->Error("Failed to `GetOptionVector` for key {:?}", key);
+ m_log->Error("Failed to `GetOptionVector` for parameter {:?}", key);
throw std::runtime_error("config file parsing issue");
}
PrintOptionValue(key, opt.value());
return opt.value();
}
- template std::vector Algorithm::GetOptionVector(std::string const& key, YAMLReader::node_path_t node_path) const;
- template std::vector Algorithm::GetOptionVector(std::string const& key, YAMLReader::node_path_t node_path) const;
- template std::vector Algorithm::GetOptionVector(std::string const& key, YAMLReader::node_path_t node_path) const;
+ template std::vector Algorithm::GetOptionVector(YAMLReader::node_path_t node_path) const;
+ template std::vector Algorithm::GetOptionVector(YAMLReader::node_path_t node_path) const;
+ template std::vector Algorithm::GetOptionVector(YAMLReader::node_path_t node_path) const;
///////////////////////////////////////////////////////////////////////////////
template
- std::set Algorithm::GetOptionSet(std::string const& key, YAMLReader::node_path_t node_path) const
+ std::set Algorithm::GetOptionSet(YAMLReader::node_path_t node_path) const
{
- auto val_vec = GetOptionVector(key, node_path);
+ auto val_vec = GetOptionVector(node_path);
std::set val_set;
std::copy(val_vec.begin(), val_vec.end(), std::inserter(val_set, val_set.end()));
return val_set;
}
- template std::set Algorithm::GetOptionSet(std::string const& key, YAMLReader::node_path_t node_path) const;
- template std::set Algorithm::GetOptionSet(std::string const& key, YAMLReader::node_path_t node_path) const;
- template std::set Algorithm::GetOptionSet(std::string const& key, YAMLReader::node_path_t node_path) const;
+ template std::set Algorithm::GetOptionSet(YAMLReader::node_path_t node_path) const;
+ template std::set Algorithm::GetOptionSet(YAMLReader::node_path_t node_path) const;
+ template std::set Algorithm::GetOptionSet(YAMLReader::node_path_t node_path) const;
///////////////////////////////////////////////////////////////////////////////
@@ -430,12 +432,4 @@ namespace iguana {
throw std::runtime_error("algorithm has been renamed");
}
- ///////////////////////////////////////////////////////////////////////////////
-
- void Algorithm::CompleteOptionNodePath(std::string const& key, YAMLReader::node_path_t& node_path) const
- {
- if(node_path.empty())
- node_path.push_front(key);
- node_path.push_front(m_class_name);
- }
}
diff --git a/src/iguana/algorithms/Algorithm.h b/src/iguana/algorithms/Algorithm.h
index f48049a1..b83788fd 100644
--- a/src/iguana/algorithms/Algorithm.h
+++ b/src/iguana/algorithms/Algorithm.h
@@ -8,6 +8,7 @@
#include "AlgorithmBoilerplate.h"
#include "iguana/bankdefs/BankDefs.h"
+#include "iguana/services/Deprecated.h"
#include "iguana/services/RCDBReader.h"
#include "iguana/services/YAMLReader.h"
#include
@@ -101,8 +102,22 @@ namespace iguana {
/// @brief Finalize this algorithm after all events are processed.
virtual void Stop() = 0;
- /// Set an option specified by the user. If the option name is `"log"`, the log level of the `Logger`
- /// owned by this algorithm will be changed to the specified value.
+ /// @brief Set an option specified by the user.
+ ///
+ /// The `key` is the "path" within the YAML configuration file; for example, consider the following YAML file:
+ ///
+ /// ```yaml
+ /// clas12::Example:
+ /// strictness: 1
+ /// forward_tagger:
+ /// radius: [8.5, 15.5]
+ /// ```
+ ///
+ /// - To set `strictness`, use `"strictness"`
+ /// - To set `radius`, which is nested under `forward_tagger`, use `"forward_tagger/radius"`
+ /// - see `YAMLReader::NodePath2String` for details on how a YAML node path is converted to such a string
+ ///
+ /// If the option name is `"log"`, the log level of the `Logger` owned by this algorithm will be changed to the specified value.
/// @param key the name of the option
/// @param val the value to set
/// @returns the value that has been set (if needed, _e.g._, when `val` is an rvalue)
@@ -119,30 +134,30 @@ namespace iguana {
else
m_log->Error("Option '{}' must be a string or a Logger::Level", key);
}
+ // make sure the key hasn't been renamed or deprecated
+ iguana::deprecated::CheckSetOptionKey(m_class_name, key);
+ // add it to the cache
m_option_cache[key] = val;
return val;
}
/// Get the value of a scalar option
- /// @param key the unique key name of this option, for caching; if empty, the option will not be cached
- /// @param node_path the `YAML::Node` identifier path to search for this option in the config files; if empty, it will just use `key`
+ /// @param node_path the `YAML::Node` identifier path to search for this option in the config files
/// @returns the scalar option
template
- OPTION_TYPE GetOptionScalar(std::string const& key, YAMLReader::node_path_t node_path = {}) const;
+ OPTION_TYPE GetOptionScalar(YAMLReader::node_path_t node_path = {}) const;
/// Get the value of a vector option
- /// @param key the unique key name of this option, for caching; if empty, the option will not be cached
- /// @param node_path the `YAML::Node` identifier path to search for this option in the config files; if empty, it will just use `key`
+ /// @param node_path the `YAML::Node` identifier path to search for this option in the config files
/// @returns the vector option
template
- std::vector GetOptionVector(std::string const& key, YAMLReader::node_path_t node_path = {}) const;
+ std::vector GetOptionVector(YAMLReader::node_path_t node_path = {}) const;
/// Get the value of a vector option, and convert it to `std::set`
- /// @param key the unique key name of this option
- /// @param node_path the `YAML::Node` identifier path to search for this option in the config files; if empty, it will just use `key`
+ /// @param node_path the `YAML::Node` identifier path to search for this option in the config files
/// @returns the vector option converted to `std::set`
template
- std::set GetOptionSet(std::string const& key, YAMLReader::node_path_t node_path = {}) const;
+ std::set GetOptionSet(YAMLReader::node_path_t node_path = {}) const;
/// Set the name of this algorithm
/// @param name the new name
@@ -248,12 +263,6 @@ namespace iguana {
/// @param level the log level
void ShowBank(hipo::bank const& bank, std::string_view message = "", Logger::Level const level = Logger::trace) const;
- /// Get an option from the option cache
- /// @param key the key name associated with this option
- /// @returns the option value, if found (using `std::optional`)
- template
- std::optional GetCachedOption(std::string const& key) const;
-
/// Throw a runtime exception since this algorithm has been renamed.
/// Guidance will be printed for the user.
/// @param new_name the new name of the algorithm
@@ -262,10 +271,11 @@ namespace iguana {
private: // methods
- /// Prepend `node_path` with the full algorithm name. If `node_path` is empty, set it to `{key}`.
- /// @param key the key name for this option
- /// @param node_path the `YAMLReader::node_path_t` to prepend
- void CompleteOptionNodePath(std::string const& key, YAMLReader::node_path_t& node_path) const;
+ /// Get an option from the option cache
+ /// @param key the key name associated with this option
+ /// @returns the option value, if found (using `std::optional`)
+ template
+ std::optional GetCachedOption(std::string const& key) const;
// PrintOptionValue: overloaded for different value types
void PrintOptionValue(std::string const& key, int const& val, Logger::Level const level = Logger::debug, std::string_view prefix = "OPTION") const;
diff --git a/src/iguana/algorithms/AlgorithmSequence.h b/src/iguana/algorithms/AlgorithmSequence.h
index d4742540..b22cf501 100644
--- a/src/iguana/algorithms/AlgorithmSequence.h
+++ b/src/iguana/algorithms/AlgorithmSequence.h
@@ -119,6 +119,15 @@ namespace iguana {
Get(algo_instance_name)->SetOption(key, val);
}
+ /// @brief Set an algorithm log level
+ /// @see `Logger::Level` for available levels
+ /// @param algo_instance_name the algorithm instance name
+ /// @param lev the log level name
+ void SetLogLevel(std::string const& algo_instance_name, std::string const& lev)
+ {
+ Get(algo_instance_name)->SetLogLevel(lev);
+ }
+
/// Set the name of this sequence
/// @param name the new name
void SetName(std::string_view name);
diff --git a/src/iguana/algorithms/clas12/EventBuilderFilter/Algorithm.cc b/src/iguana/algorithms/clas12/EventBuilderFilter/Algorithm.cc
index 2ade4e27..a4de4cb9 100644
--- a/src/iguana/algorithms/clas12/EventBuilderFilter/Algorithm.cc
+++ b/src/iguana/algorithms/clas12/EventBuilderFilter/Algorithm.cc
@@ -9,8 +9,8 @@ namespace iguana::clas12 {
// define options, their default values, and cache them
ParseYAMLConfig();
- o_particle_bank = GetOptionScalar("particle_bank");
- o_pids = GetOptionSet("pids");
+ o_particle_bank = GetOptionScalar({"particle_bank"});
+ o_pids = GetOptionSet({"pids"});
// get expected bank indices
b_particle = GetBankIndex(banks, o_particle_bank);
diff --git a/src/iguana/algorithms/clas12/MatchParticleProximity/Algorithm.cc b/src/iguana/algorithms/clas12/MatchParticleProximity/Algorithm.cc
index 7ada847d..615476e0 100644
--- a/src/iguana/algorithms/clas12/MatchParticleProximity/Algorithm.cc
+++ b/src/iguana/algorithms/clas12/MatchParticleProximity/Algorithm.cc
@@ -9,8 +9,8 @@ namespace iguana::clas12 {
{
// parse config file
ParseYAMLConfig();
- o_bank_a = GetOptionScalar("bank_a");
- o_bank_b = GetOptionScalar("bank_b");
+ o_bank_a = GetOptionScalar({"bank_a"});
+ o_bank_b = GetOptionScalar({"bank_b"});
// banklist indices
b_bank_a = GetBankIndex(banks, o_bank_a);
diff --git a/src/iguana/algorithms/clas12/PhotonGBTFilter/Algorithm.cc b/src/iguana/algorithms/clas12/PhotonGBTFilter/Algorithm.cc
index 0af25cd7..2fc572d1 100644
--- a/src/iguana/algorithms/clas12/PhotonGBTFilter/Algorithm.cc
+++ b/src/iguana/algorithms/clas12/PhotonGBTFilter/Algorithm.cc
@@ -39,8 +39,8 @@ namespace iguana::clas12 {
b_calorimeter = GetBankIndex(banks, "REC::Calorimeter");
b_config = GetBankIndex(banks, "RUN::config");
- o_pass = GetOptionScalar("pass");
- o_threshold = GetOptionScalar("threshold");
+ o_pass = GetOptionScalar({"pass"});
+ o_threshold = GetOptionScalar({"threshold"});
}
bool PhotonGBTFilter::Run(hipo::banklist& banks) const
diff --git a/src/iguana/algorithms/clas12/SectorFinder/Algorithm.cc b/src/iguana/algorithms/clas12/SectorFinder/Algorithm.cc
index 3b6be04e..37144984 100644
--- a/src/iguana/algorithms/clas12/SectorFinder/Algorithm.cc
+++ b/src/iguana/algorithms/clas12/SectorFinder/Algorithm.cc
@@ -9,13 +9,13 @@ namespace iguana::clas12 {
// define options, their default values, and cache them
ParseYAMLConfig();
- o_bankname_charged = GetOptionScalar("bank_charged");
+ o_bankname_charged = GetOptionScalar({"bank_charged"});
try {
- o_bankname_neutral = GetOptionScalar("bank_neutral");
+ o_bankname_neutral = GetOptionScalar({"bank_neutral"});
}
catch(std::runtime_error const& ex) {
m_log->Warn("searching instead for configuration parameter named 'bank_uncharged'...");
- o_bankname_neutral = GetOptionScalar("bank_uncharged");
+ o_bankname_neutral = GetOptionScalar({"bank_uncharged"});
m_log->Warn("...found 'bank_uncharged' and using it; note that 'bank_uncharged' has been renamed to 'bank_neutral', please update your configuration");
}
diff --git a/src/iguana/algorithms/clas12/SectorFinder/Validator.cc b/src/iguana/algorithms/clas12/SectorFinder/Validator.cc
index 04cca4d3..a65317be 100644
--- a/src/iguana/algorithms/clas12/SectorFinder/Validator.cc
+++ b/src/iguana/algorithms/clas12/SectorFinder/Validator.cc
@@ -14,7 +14,7 @@ namespace iguana::clas12 {
m_algo_seq->Add("clas12::SectorFinder");
m_algo_seq->SetOption>("clas12::EventBuilderFilter", "pids", u_pdg_list);
m_algo_seq->SetOption("clas12::SectorFinder", "bank_charged", "REC::Track");
- m_algo_seq->SetOption("clas12::SectorFinder", "bank_uncharged", "default");
+ m_algo_seq->SetOption("clas12::SectorFinder", "bank_neutral", "default");
m_algo_seq->Start(banks);
diff --git a/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.cc b/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.cc
index ef147b49..efafece4 100644
--- a/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.cc
+++ b/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.cc
@@ -10,7 +10,7 @@ namespace iguana::clas12 {
// get configuration
ParseYAMLConfig();
- o_particle_bank = GetOptionScalar("particle_bank");
+ o_particle_bank = GetOptionScalar({"particle_bank"});
o_runnum = ConcurrentParamFactory::Create();
o_electron_vz_cuts = ConcurrentParamFactory::Create>();
@@ -71,7 +71,7 @@ namespace iguana::clas12 {
std::lock_guard const lock(m_mutex); // NOTE: be sure to lock successive `ConcurrentParam::Save` calls !!!
m_log->Trace("-> calling Reload({}, {})", runnum, key);
o_runnum->Save(runnum, key);
- o_electron_vz_cuts->Save(GetOptionVector("electron_vz", {"electron", GetConfig()->InRange("runs", runnum), "vz"}), key);
+ o_electron_vz_cuts->Save(GetOptionVector({"electron", GetConfig()->InRange("runs", runnum), "vz"}), key);
}
bool ZVertexFilter::Filter(double const zvertex, int const pid, int const status, concurrent_key_t key) const
diff --git a/src/iguana/algorithms/clas12/ZVertexFilter/Validator.cc b/src/iguana/algorithms/clas12/ZVertexFilter/Validator.cc
index 130a0869..7db4458a 100644
--- a/src/iguana/algorithms/clas12/ZVertexFilter/Validator.cc
+++ b/src/iguana/algorithms/clas12/ZVertexFilter/Validator.cc
@@ -12,8 +12,6 @@ namespace iguana::clas12 {
// define the algorithm sequence
m_algo_seq = std::make_unique();
m_algo_seq->Add("clas12::ZVertexFilter");
- m_algo_seq->SetOption>("clas12::ZVertexFilter", "pids", u_pdgtocut_list);
- m_algo_seq->SetOption>("clas12::ZVertexFilter", "cuts", u_cuts_list);
m_algo_seq->Start(banks);
// get bank indices
diff --git a/src/iguana/algorithms/clas12/ZVertexFilter/Validator.h b/src/iguana/algorithms/clas12/ZVertexFilter/Validator.h
index e3375df3..101be6e1 100644
--- a/src/iguana/algorithms/clas12/ZVertexFilter/Validator.h
+++ b/src/iguana/algorithms/clas12/ZVertexFilter/Validator.h
@@ -33,13 +33,6 @@ namespace iguana::clas12 {
particle::PDG::proton,
particle::PDG::neutron};
- std::vector const u_pdgtocut_list = {
- particle::PDG::electron};
-
- std::vector const u_cuts_list = {
- -5,
- 5};
-
TString m_output_file_basename;
TFile* m_output_file;
mutable std::unordered_map> u_zvertexplots;
diff --git a/src/iguana/algorithms/clas12/rga/FiducialFilterPass1/Algorithm.cc b/src/iguana/algorithms/clas12/rga/FiducialFilterPass1/Algorithm.cc
index f33970d5..f4948b70 100644
--- a/src/iguana/algorithms/clas12/rga/FiducialFilterPass1/Algorithm.cc
+++ b/src/iguana/algorithms/clas12/rga/FiducialFilterPass1/Algorithm.cc
@@ -8,10 +8,10 @@ namespace iguana::clas12::rga {
void FiducialFilterPass1::Start(hipo::banklist& banks)
{
ParseYAMLConfig();
- o_pcal_electron_cut_level = ParseCutLevel(GetOptionScalar("pcal_electron_cut_level"));
- o_pcal_photon_cut_level = ParseCutLevel(GetOptionScalar("pcal_photon_cut_level"));
- o_enable_pcal_cuts = GetOptionScalar("enable_pcal_cuts") == 1;
- o_enable_dc_cuts = GetOptionScalar("enable_dc_cuts") == 1;
+ o_pcal_electron_cut_level = ParseCutLevel(GetOptionScalar({"pcal_electron_cut_level"}));
+ o_pcal_photon_cut_level = ParseCutLevel(GetOptionScalar({"pcal_photon_cut_level"}));
+ o_enable_pcal_cuts = GetOptionScalar({"enable_pcal_cuts"}) == 1;
+ o_enable_dc_cuts = GetOptionScalar({"enable_dc_cuts"}) == 1;
b_particle = GetBankIndex(banks, "REC::Particle");
b_config = GetBankIndex(banks, "RUN::config");
diff --git a/src/iguana/algorithms/clas12/rga/FiducialFilterPass2/Algorithm.cc b/src/iguana/algorithms/clas12/rga/FiducialFilterPass2/Algorithm.cc
index fff78018..12eee662 100644
--- a/src/iguana/algorithms/clas12/rga/FiducialFilterPass2/Algorithm.cc
+++ b/src/iguana/algorithms/clas12/rga/FiducialFilterPass2/Algorithm.cc
@@ -29,13 +29,13 @@ namespace iguana::clas12::rga {
void FiducialFilterPass2::LoadConfig()
{
- m_cal_strictness = GetOptionScalar("calorimeter.strictness", {"calorimeter", "strictness"});
+ m_cal_strictness = GetOptionScalar({"calorimeter", "strictness"});
if(m_cal_strictness < 1 || m_cal_strictness > 3) {
throw std::runtime_error("[RGAFID] 'calorimeter.strictness' must be 1, 2, or 3");
}
{
- auto radius = GetOptionVector("forward_tagger.radius", {"forward_tagger", "radius"});
+ auto radius = GetOptionVector({"forward_tagger", "radius"});
if(radius.size() != 2) {
throw std::runtime_error("[RGAFID] 'forward_tagger.radius' must be [rmin, rmax]");
}
@@ -49,8 +49,7 @@ namespace iguana::clas12::rga {
u_ft_params.holes.clear();
std::vector holes_flat;
try {
- holes_flat = GetOptionVector("forward_tagger.holes_flat",
- {"forward_tagger", "holes_flat"});
+ holes_flat = GetOptionVector({"forward_tagger", "holes_flat"});
}
catch(std::exception const& e) {
std::string const msg = e.what();
@@ -77,16 +76,15 @@ namespace iguana::clas12::rga {
}
{
- m_cvt.edge_layers = GetOptionVector("cvt.edge_layers", {"cvt", "edge_layers"});
+ m_cvt.edge_layers = GetOptionVector({"cvt", "edge_layers"});
if(m_cvt.edge_layers.empty()) {
throw std::runtime_error("[RGAFID] 'cvt.edge_layers' must be non-empty");
}
- m_cvt.edge_min = GetOptionScalar("cvt.edge_min", {"cvt", "edge_min"});
+ m_cvt.edge_min = GetOptionScalar({"cvt", "edge_min"});
m_cvt.phi_forbidden_deg.clear();
try {
- m_cvt.phi_forbidden_deg = GetOptionVector("cvt.phi_forbidden_deg",
- {"cvt", "phi_forbidden_deg"});
+ m_cvt.phi_forbidden_deg = GetOptionVector({"cvt", "phi_forbidden_deg"});
}
catch(std::exception const& e) {
std::string const msg = e.what();
@@ -103,10 +101,10 @@ namespace iguana::clas12::rga {
{
m_dc.theta_small_deg =
- GetOptionScalar("dc.theta_small_deg", {"dc", "theta_small_deg"});
+ GetOptionScalar({"dc", "theta_small_deg"});
auto need3 = [&](char const* key) -> std::array {
- auto v = GetOptionVector(std::string("dc.") + key, {"dc", key});
+ auto v = GetOptionVector({"dc", key});
if(v.size() != 3) {
throw std::runtime_error(std::string("[RGAFID] 'dc.") + key + "' must be [e1,e2,e3]");
}
diff --git a/src/iguana/algorithms/example/ExampleAlgorithm/Algorithm.cc b/src/iguana/algorithms/example/ExampleAlgorithm/Algorithm.cc
index 4217c795..a1198470 100644
--- a/src/iguana/algorithms/example/ExampleAlgorithm/Algorithm.cc
+++ b/src/iguana/algorithms/example/ExampleAlgorithm/Algorithm.cc
@@ -33,8 +33,8 @@ namespace iguana::example {
// # user has specified to use a different configuration file or directory
// ############################################################################
ParseYAMLConfig();
- o_exampleInt = GetOptionScalar("exampleInt");
- o_exampleDouble = GetOptionScalar("exampleDouble");
+ o_exampleInt = GetOptionScalar({"exampleInt"});
+ o_exampleDouble = GetOptionScalar({"exampleDouble"});
// ############################################################################
// # get expected bank indices
// # - here we make sure that parameter `banks` includes the banks that are
diff --git a/src/iguana/algorithms/physics/DihadronKinematics/Algorithm.cc b/src/iguana/algorithms/physics/DihadronKinematics/Algorithm.cc
index 6901892b..2f710946 100644
--- a/src/iguana/algorithms/physics/DihadronKinematics/Algorithm.cc
+++ b/src/iguana/algorithms/physics/DihadronKinematics/Algorithm.cc
@@ -12,11 +12,11 @@ namespace iguana::physics {
{
// parse config file
ParseYAMLConfig();
- o_particle_bank = GetOptionScalar("particle_bank");
- o_hadron_a_pdgs = GetOptionSet("hadron_a_list");
- o_hadron_b_pdgs = GetOptionSet("hadron_b_list");
- o_phi_r_method = GetOptionScalar("phi_r_method");
- o_theta_method = GetOptionScalar("theta_method");
+ o_particle_bank = GetOptionScalar({"particle_bank"});
+ o_hadron_a_pdgs = GetOptionSet({"hadron_a_list"});
+ o_hadron_b_pdgs = GetOptionSet({"hadron_b_list"});
+ o_phi_r_method = GetOptionScalar({"phi_r_method"});
+ o_theta_method = GetOptionScalar({"theta_method"});
// check phiR method
if(o_phi_r_method == "RT_via_covariant_kT")
diff --git a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc
index 858cf86f..ddc74a42 100644
--- a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc
+++ b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc
@@ -13,14 +13,14 @@ namespace iguana::physics {
{
// parse config file
ParseYAMLConfig();
- o_particle_bank = GetOptionScalar("particle_bank");
+ o_particle_bank = GetOptionScalar({"particle_bank"});
o_runnum = ConcurrentParamFactory::Create();
o_target_PxPyPzM = ConcurrentParamFactory::Create>();
o_beam_PxPyPzM = ConcurrentParamFactory::Create>();
- o_theta_between_FD_and_FT = GetOptionScalar("theta_between_FD_and_FT");
+ o_theta_between_FD_and_FT = GetOptionScalar({"theta_between_FD_and_FT"});
// get reconstruction method configuration
- auto method_reconstruction_str = GetOptionScalar("reconstruction", {"method", "reconstruction"});
+ auto method_reconstruction_str = GetOptionScalar({"method", "reconstruction"});
if(method_reconstruction_str == "scattered_lepton") {
o_method_reconstruction = method_reconstruction::scattered_lepton;
}
@@ -30,7 +30,7 @@ namespace iguana::physics {
}
// get scattered lepton finder configuration
- auto method_lepton_finder_str = GetOptionScalar("lepton_finder", {"method", "lepton_finder"});
+ auto method_lepton_finder_str = GetOptionScalar({"method", "lepton_finder"});
if(method_lepton_finder_str == "highest_energy_FD_trigger")
o_method_lepton_finder = method_lepton_finder::highest_energy_FD_trigger;
else if(method_lepton_finder_str == "lund_beam_daughter")
@@ -42,7 +42,7 @@ namespace iguana::physics {
// get beam PDG and mass
o_beam_pdg = 0;
- auto beam_particle = GetOptionScalar("beam_particle", {"method", "beam_particle"});
+ auto beam_particle = GetOptionScalar({"method", "beam_particle"});
for(auto const& [pdg, name] : particle::name) {
if(name == beam_particle) {
o_beam_pdg = pdg;
@@ -76,7 +76,7 @@ namespace iguana::physics {
// instantiate RCDB reader `m_rcdb`
StartRCDBReader();
- o_override_beam_energy = GetOptionScalar("override_beam_energy");
+ o_override_beam_energy = GetOptionScalar({"override_beam_energy"});
if(o_override_beam_energy > 0)
m_rcdb->SetBeamEnergyOverride(o_override_beam_energy);
}
@@ -256,8 +256,8 @@ namespace iguana::physics {
// parse config params
auto beam_energy = user_beam_energy < 0 ? m_rcdb->GetBeamEnergy(runnum) : user_beam_energy;
- auto beam_direction = GetOptionVector("beam_direction", {"initial_state", GetConfig()->InRange("runs", runnum), "beam_direction"});
- auto target_particle = GetOptionScalar("target_particle", {"initial_state", GetConfig()->InRange("runs", runnum), "target_particle"});
+ auto beam_direction = GetOptionVector({"initial_state", GetConfig()->InRange("runs", runnum), "beam_direction"});
+ auto target_particle = GetOptionScalar({"initial_state", GetConfig()->InRange("runs", runnum), "target_particle"});
// get the target mass and momentum
double target_mass = -1;
diff --git a/src/iguana/algorithms/physics/SingleHadronKinematics/Algorithm.cc b/src/iguana/algorithms/physics/SingleHadronKinematics/Algorithm.cc
index bfb18b8a..b0986953 100644
--- a/src/iguana/algorithms/physics/SingleHadronKinematics/Algorithm.cc
+++ b/src/iguana/algorithms/physics/SingleHadronKinematics/Algorithm.cc
@@ -12,8 +12,8 @@ namespace iguana::physics {
{
// parse config file
ParseYAMLConfig();
- o_particle_bank = GetOptionScalar("particle_bank");
- o_hadron_pdgs = GetOptionSet("hadron_list");
+ o_particle_bank = GetOptionScalar({"particle_bank"});
+ o_hadron_pdgs = GetOptionSet({"hadron_list"});
// get bank indices
b_particle = GetBankIndex(banks, o_particle_bank);
diff --git a/src/iguana/services/Deprecated.cc b/src/iguana/services/Deprecated.cc
new file mode 100644
index 00000000..4fd2dffc
--- /dev/null
+++ b/src/iguana/services/Deprecated.cc
@@ -0,0 +1,71 @@
+#include "Deprecated.h"
+
+#include
+#include