Skip to content

Commit 2fa4d91

Browse files
authored
fix!: standardize config param names for Algorithm::SetOption (#425)
1 parent a364d0a commit 2fa4d91

File tree

39 files changed

+327
-203
lines changed

39 files changed

+327
-203
lines changed

bind/python/iguana_ex_python_00_run_functions.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,14 @@
4242
seq.Add('clas12::rga::MomentumCorrection') # momentum corrections (a transformer algorithm)
4343
# seq.PrintSequence()
4444

45-
# set log levels
46-
# NOTE: this can also be done in a config file
47-
seq.SetOption('clas12::EventBuilderFilter', 'log', 'info')
48-
seq.SetOption('clas12::SectorFinder', 'log', 'info')
49-
seq.SetOption('clas12::rga::MomentumCorrection', 'log', 'info')
50-
51-
# set algorithm options
52-
# NOTE: this can also be done in a config file, but setting options here OVERRIDES config file settings
53-
seq.SetOption('clas12::EventBuilderFilter', 'pids', [11, 211, -211])
45+
# configure algorithms with a custom YAML file
46+
# - in practice, specify the path(s) to your preferred configuration file(s); see documentation
47+
# on 'How to Configure Algorithms' for details, and alternative methods for algorithm configuration
48+
# - in this example, the file is from the source-code path `./config/examples/`, which was copied to
49+
# the installation subdirectory `etc/iguana/`, within the default configuration-file search path
50+
seq.SetConfigFileForEachAlgorithm("examples/config_for_examples.yaml")
51+
# alternatively: use this configuration for the algorithm that needs it
52+
# seq.Get("clas12::EventBuilderFilter").SetConfigFile("examples/config_for_examples.yaml")
5453

5554
# start the algorithms
5655
seq.Start(banks)

bind/python/iguana_ex_python_01_action_functions.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@
5151
algo_sector_finder = iguana.clas12.SectorFinder() # get the sector for each particle (a creator algorithm)
5252
algo_momentum_correction = iguana.clas12.rga.MomentumCorrection() # momentum corrections (a transformer algorithm)
5353

54-
# set log levels
55-
algo_eventbuilder_filter.SetOption('log', 'info')
56-
algo_sector_finder.SetOption('log', 'info')
57-
algo_momentum_correction.SetOption('log', 'info')
58-
59-
# set algorithm options
60-
algo_eventbuilder_filter.SetOption('pids', [11, 211, -211])
54+
# configure algorithms with a custom YAML file
55+
# - in practice, specify the path(s) to your preferred configuration file(s); see documentation
56+
# on 'How to Configure Algorithms' for details, and alternative methods for algorithm configuration
57+
# - in this example, the file is from the source-code path `./config/examples/`, which was copied to
58+
# the installation subdirectory `etc/iguana/`, within the default configuration-file search path
59+
config_file = "examples/config_for_examples.yaml"
60+
algo_eventbuilder_filter.SetConfigFile(config_file)
61+
algo_sector_finder.SetConfigFile(config_file)
62+
algo_momentum_correction.SetConfigFile(config_file)
6163

6264
# start the algorithms
6365
algo_eventbuilder_filter.Start()

bind/python/iguana_ex_python_hipopy.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@
4444
algo_sector_finder = iguana.clas12.SectorFinder() # get the sector for each particle (a creator algorithm)
4545
algo_momentum_correction = iguana.clas12.rga.MomentumCorrection() # momentum corrections (a transformer algorithm)
4646

47-
# set log levels
48-
algo_eventbuilder_filter.SetOption('log', 'info')
49-
algo_sector_finder.SetOption('log', 'info')
50-
algo_momentum_correction.SetOption('log', 'info')
51-
52-
# set algorithm options
53-
algo_eventbuilder_filter.SetOption('pids', [11, 211, -211])
47+
# configure algorithms with a custom YAML file
48+
config_file = "examples/config_for_examples.yaml"
49+
algo_eventbuilder_filter.SetConfigFile(config_file)
50+
algo_sector_finder.SetConfigFile(config_file)
51+
algo_momentum_correction.SetConfigFile(config_file)
5452

5553
# start the algorithms
5654
algo_eventbuilder_filter.Start()

doc/doxygen/mainpage.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ This documentation shows how to use the Iguana algorithms. For more documentatio
55

66
- **Tip:** To toggle between light and dark mode for this webpage, click the button in the top-right corner, next to the search box.
77

8-
| Quick Links ||
9-
| --- | --- |
10-
| @spacer [List of All Algorithms](#algo) @spacer | @spacer [List of Algorithms Organized by Run Group, <i>etc</i>.](#algo_namespaces) @spacer |
11-
| @spacer [List of Action Functions](#action) @spacer | @spacer [Configuring Algorithms](#mainpageConfiguring) @spacer |
12-
| @spacer [Banks Created by Iguana](#created_banks) @spacer | @spacer [Examples of Code](#mainpageExample) @spacer |
8+
| Quick Links | |
9+
| --- | --- |
10+
| @spacer [List of All Algorithms](#algo) @spacer | @spacer [List of Algorithms Organized by Run Group, <i>etc</i>.](#algo_namespaces) @spacer |
11+
| @spacer [List of Action Functions](#action) @spacer | @spacer [How to Configure Algorithms](#mainpageConfiguring) @spacer |
12+
| @spacer [Banks Created by Iguana](#created_banks) @spacer | @spacer [How to Run Algorithms](#mainpageRunning) @spacer |
13+
| | @spacer [Examples of Code](#mainpageExample) @spacer |
1314

1415
<br><hr>
1516

@@ -243,7 +244,11 @@ Many algorithms are configurable. An algorithm's configuration parameters and th
243244

244245
Iguana provides a few ways to configure algorithms; in general, you may either:
245246
- use YAML for configuration that gets applied at runtime, _i.e._, no need to recompile
246-
- use @link iguana::Algorithm::SetOption @endlink to configure an algorithm more directly, which may require recompilation, depending on how you use Iguana algorithms
247+
- this is the preferred method for configuration
248+
- use @link iguana::Algorithm::SetOption @endlink to configure an algorithm more directly, however:
249+
- this may require recompilation, depending on how you use Iguana algorithms
250+
- some options cannot be set this way, in particular, options that depend on data, such as a run number-dependent vertex cut
251+
- using the YAML file is preferred in general (whereas @link iguana::Algorithm::SetOption @endlink is useful for algorithm Validators)
247252

248253
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.
249254

@@ -276,13 +281,15 @@ physics::AlgorithmB
276281
reptileA: gecko
277282
reptileB: tuatara
278283
```
279-
Custom YAML file, with some changes such as widening `AlgorithmA`'s `cuts`:
284+
Custom YAML file, with some changes such as widening `AlgorithmA`'s `cuts`, and controlling the log levels:
280285
```yaml
281286
### custom YAML file
282287
physics::AlgorithmA
288+
log: info # set the log level for this algorithm
283289
cuts: [-2, 2]
284290
285291
physics::AlgorithmB
292+
log: debug # set the log level for this algorithm
286293
valueA: 5
287294
valueB: 0.14
288295
reptiles:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
clas12::EventBuilderFilter:
2+
log: info # set the log level
3+
pids: [ 11, 211, -211, 22 ] # customize the list of PDGs to filter for
4+
5+
clas12::SectorFinder:
6+
log: info
7+
8+
clas12::rga::MomentumCorrection:
9+
log: info
File renamed without changes.

examples/config/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml renamed to examples/config/examples/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml

File renamed without changes.
File renamed without changes.

examples/iguana_ex_cpp_00_run_functions.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@ int main(int argc, char** argv)
4747
seq.Add("clas12::rga::MomentumCorrection"); // momentum corrections (a transformer algorithm)
4848
// seq.PrintSequence();
4949

50-
// set log levels
51-
// NOTE: this can also be done in a config file
52-
seq.SetOption("clas12::EventBuilderFilter", "log", "info");
53-
seq.SetOption("clas12::SectorFinder", "log", "info");
54-
seq.SetOption("clas12::rga::MomentumCorrection", "log", "info");
55-
56-
// set algorithm options
57-
// NOTE: this can also be done in a config file, but setting options here OVERRIDES config file settings
58-
seq.SetOption<std::vector<int>>("clas12::EventBuilderFilter", "pids", {11, 211, -211});
50+
// configure algorithms with a custom YAML file
51+
// - in practice, specify the path(s) to your preferred configuration file(s); see documentation
52+
// on 'How to Configure Algorithms' for details, and alternative methods for algorithm configuration
53+
// - in this example, the file is from the source-code path `./config/examples/`, which was copied to
54+
// the installation subdirectory `etc/iguana/`, within the default configuration-file search path
55+
seq.SetConfigFileForEachAlgorithm("examples/config_for_examples.yaml");
56+
// alternatively: use this configuration for the algorithm that needs it
57+
// seq.Get("clas12::EventBuilderFilter")->SetConfigFile("examples/config_for_examples.yaml");
5958

6059
// start the algorithms
6160
seq.Start(banks);

examples/iguana_ex_cpp_00_run_functions_with_banks.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ int main(int argc, char** argv)
5151
iguana::clas12::SectorFinder algo_sector_finder; // get the sector for each particle (a creator algorithm)
5252
iguana::clas12::rga::MomentumCorrection algo_momentum_correction; // momentum corrections (a transformer algorithm)
5353

54-
// set log levels
55-
// NOTE: this can also be done in a config file
56-
algo_eventbuilder_filter.SetOption("log", "info");
57-
algo_sector_finder.SetOption("log", "info");
58-
algo_momentum_correction.SetOption("log", "info");
59-
60-
// set algorithm options
61-
// NOTE: this can also be done in a config file, but setting options here OVERRIDES config file settings
62-
algo_eventbuilder_filter.SetOption<std::vector<int>>("pids", {11, 211, -211});
54+
// configure algorithms with a custom YAML file
55+
// - in practice, specify the path(s) to your preferred configuration file(s); see documentation
56+
// on 'How to Configure Algorithms' for details, and alternative methods for algorithm configuration
57+
// - in this example, the file is from the source-code path `./config/examples/`, which was copied to
58+
// the installation subdirectory `etc/iguana/`, within the default configuration-file search path
59+
std::string config_file = "examples/config_for_examples.yaml";
60+
algo_eventbuilder_filter.SetConfigFile(config_file);
61+
algo_sector_finder.SetConfigFile(config_file);
62+
algo_momentum_correction.SetConfigFile(config_file);
6363

6464
// start the algorithms
6565
algo_eventbuilder_filter.Start();

0 commit comments

Comments
 (0)