Adding parameters from the global configuration to the modules

Hello,

I have several detector modules that require the same parameter. Therefore, I would like to set it only once in the global configuration “[Corryvreckan]” and retrieve it from there. Is this possible?

I have added it to the .config file as follows:


[Corryvreckan]
key = “value”

In the module file, I am attempting to retrieve it in the constructor with:


std::string key = config_.get(“key”)

This is similar to how I handle all other parameters. However, despite my understanding that it should be retrievable from the global configuration, it is not working. Instead, it gives me a fatal error stating that the parameter is not defined for this particular module.

I have also attempted the following:


ConfigManager* conf_manager = getConfigManager();
std::string key = conf_manager->getGlobalConfiguration().get(“key”);

However, I receive an error stating “Cannot access the config manager in constructor or destructor.”

I am now pondering the meaning of section 4.2 in the user manual, which states:

“The global (framework) header sections: These are all zero-length section headers
(including the one at the beginning of the file) and all sections marked with the header
[Corryvreckan] (case-insensitive). These are combined and accessed together as the
global configuration, which contains all parameters of the framework itself as described in
Section 3.3. All key-value pairs defined in this section are also inherited by all individual
configurations as long the key is not defined in the module configuration itself. This is
encouraged for module parameters used in multiple modules.”

I believe I may be overlooking something. Could one of the experts assist me?

Thank you,
Elena