Loading etc/unittests/test_core/test_05-3_overwrite_detector_module.conf 0 → 100644 +30 −0 Original line number Diff line number Diff line # SPDX-FileCopyrightText: 2022 CERN and the Allpix Squared authors # SPDX-License-Identifier: MIT #DESC tests whether two detector modules with different priorities are handled correctly. [AllPix] log_level = "WARNING" log_format = "SHORT" number_of_events = 0 detectors_file = "two_detectors.conf" random_seed_core = 0 multithreading = false [ElectricFieldReader] log_level = "INFO" model="linear" bias_voltage=150V depletion_voltage=100V [ElectricFieldReader] log_level = "INFO" model="linear" bias_voltage=50V depletion_voltage=200V name = "mydetector2" #FAIL [I:ElectricFieldReader:mydetector] Setting linear electric field from 50V bias voltage and 200V depletion voltage #FAIL [I:ElectricFieldReader:mydetector2] Setting linear electric field from 150V bias voltage and 100V depletion voltage #LABEL coverage etc/unittests/test_core/test_05-4_overwrite_detector_module_reverse.conf 0 → 100644 +30 −0 Original line number Diff line number Diff line # SPDX-FileCopyrightText: 2022 CERN and the Allpix Squared authors # SPDX-License-Identifier: MIT #DESC tests whether two detector modules with different priorities are handled correctly (reverse order). [AllPix] log_level = "WARNING" log_format = "SHORT" number_of_events = 0 detectors_file = "two_detectors.conf" random_seed_core = 0 multithreading = false [ElectricFieldReader] log_level = "INFO" model="linear" bias_voltage=50V depletion_voltage=200V name = "mydetector2" [ElectricFieldReader] log_level = "INFO" model="linear" bias_voltage=150V depletion_voltage=100V #FAIL [I:ElectricFieldReader:mydetector] Setting linear electric field from 50V bias voltage and 200V depletion voltage #FAIL [I:ElectricFieldReader:mydetector2] Setting linear electric field from 150V bias voltage and 100V depletion voltage #LABEL coverage etc/unittests/test_core/test_05-5_overwrite_module_allow_io.conf 0 → 100644 +63 −0 Original line number Diff line number Diff line # SPDX-FileCopyrightText: 2022 CERN and the Allpix Squared authors # SPDX-License-Identifier: MIT #DESC tests different input / output configurations with module overwriting. [AllPix] log_level = "WARNING" log_format = "SHORT" number_of_events = 0 detectors_file = "two_detectors.conf" random_seed_core = 0 multithreading = false [GeometryBuilderGeant4] [DepositionGeant4] physics_list = FTFP_BERT particle_type = "pi+" source_energy = 120GeV source_position = 0mm 0mm 0mm beam_size = 0 beam_direction = 0 0 1 number_of_particles = 1 [GenericPropagation] [SimpleTransfer] output = "st1" [SimpleTransfer] output = "st2" [DefaultDigitizer] input = "st1" output = "low_noise" electronics_noise = 100e name = "mydetector2" [DefaultDigitizer] input = "st1" output = "low_noise" electronics_noise = 110e [DefaultDigitizer] input = "st2" output = "high_noise" electronics_noise = 500e [DefaultDigitizer] input = "st2" output = "high_noise" electronics_noise = 550e name = "mydetector" [DetectorHistogrammer] input = "low_noise" [DetectorHistogrammer] input = "high_noise" #PASS Executed 16 instantiations #LABEL coverage src/core/config/ConfigManager.cpp +21 −7 Original line number Diff line number Diff line Loading @@ -159,26 +159,25 @@ std::list<Configuration>& ConfigManager::getDetectorConfigurations() { /** * @warning A previously stored configuration is directly invalidated if the same unique name is used again * * An instance configuration is a specialized configuration for a particular module instance. If an unique name already * exists the previous record is deleted and a new configuration record corresponding to the replaced instance is added. * An instance configuration is a specialized configuration for a particular module instance. If a ModuleIdentifier already * exists an error is thrown. */ Configuration& ConfigManager::addInstanceConfiguration(const ModuleIdentifier& identifier, const Configuration& config) { std::string unique_name = identifier.getUniqueName(); // Check uniqueness if(instance_name_to_config_.find(unique_name) != instance_name_to_config_.end()) { instance_configs_.erase(instance_name_to_config_[unique_name]); if(instance_identifier_to_config_.find(identifier) != instance_identifier_to_config_.end()) { throw ModuleIdentifierAlreadyAddedError(identifier); } // Add configuration instance_configs_.push_back(config); Configuration& ret_config = instance_configs_.back(); instance_name_to_config_[unique_name] = --instance_configs_.end(); instance_identifier_to_config_[identifier] = --instance_configs_.end(); // Add identifier key to config ret_config.set<std::string>("identifier", identifier.getIdentifier()); // Apply instance options module_option_parser_.applyOptions(unique_name, ret_config); module_option_parser_.applyOptions(identifier.getUniqueName(), ret_config); return ret_config; } Loading @@ -189,3 +188,18 @@ Configuration& ConfigManager::addInstanceConfiguration(const ModuleIdentifier& i std::list<Configuration>& ConfigManager::getInstanceConfigurations() { return instance_configs_; } /** * An instance configuration might be dropped when not used (e.g. it is overwritten by another module instance afterwards) * We need to remove it from the instance configuration list to ensure dumping the config actually dumps only the instance * configurations that were used. */ void ConfigManager::dropInstanceConfiguration(const ModuleIdentifier& identifier) { // Remove config from instance configs and from instance identifier map if(instance_identifier_to_config_.find(identifier) != instance_identifier_to_config_.end()) { instance_configs_.erase(instance_identifier_to_config_[identifier]); instance_identifier_to_config_.erase(identifier); } else { throw ModuleIdentifierNotFoundError(identifier); } } src/core/config/ConfigManager.hpp +7 −1 Original line number Diff line number Diff line Loading @@ -89,6 +89,12 @@ namespace allpix { */ std::list<Configuration>& getInstanceConfigurations(); /** * @brief Drops an instance configuration from instance configuration storage * @param identifier Identifier of the module instance to drop */ void dropInstanceConfiguration(const ModuleIdentifier& identifier); /** * @brief Load module options and directly apply them to the global configuration and the module configurations * @param options List of options to load and apply Loading Loading @@ -124,7 +130,7 @@ namespace allpix { std::list<Configuration> detector_configs_; std::list<Configuration> instance_configs_; std::map<std::string, std::list<Configuration>::iterator> instance_name_to_config_; std::map<ModuleIdentifier, std::list<Configuration>::iterator> instance_identifier_to_config_; }; } // namespace allpix Loading Loading
etc/unittests/test_core/test_05-3_overwrite_detector_module.conf 0 → 100644 +30 −0 Original line number Diff line number Diff line # SPDX-FileCopyrightText: 2022 CERN and the Allpix Squared authors # SPDX-License-Identifier: MIT #DESC tests whether two detector modules with different priorities are handled correctly. [AllPix] log_level = "WARNING" log_format = "SHORT" number_of_events = 0 detectors_file = "two_detectors.conf" random_seed_core = 0 multithreading = false [ElectricFieldReader] log_level = "INFO" model="linear" bias_voltage=150V depletion_voltage=100V [ElectricFieldReader] log_level = "INFO" model="linear" bias_voltage=50V depletion_voltage=200V name = "mydetector2" #FAIL [I:ElectricFieldReader:mydetector] Setting linear electric field from 50V bias voltage and 200V depletion voltage #FAIL [I:ElectricFieldReader:mydetector2] Setting linear electric field from 150V bias voltage and 100V depletion voltage #LABEL coverage
etc/unittests/test_core/test_05-4_overwrite_detector_module_reverse.conf 0 → 100644 +30 −0 Original line number Diff line number Diff line # SPDX-FileCopyrightText: 2022 CERN and the Allpix Squared authors # SPDX-License-Identifier: MIT #DESC tests whether two detector modules with different priorities are handled correctly (reverse order). [AllPix] log_level = "WARNING" log_format = "SHORT" number_of_events = 0 detectors_file = "two_detectors.conf" random_seed_core = 0 multithreading = false [ElectricFieldReader] log_level = "INFO" model="linear" bias_voltage=50V depletion_voltage=200V name = "mydetector2" [ElectricFieldReader] log_level = "INFO" model="linear" bias_voltage=150V depletion_voltage=100V #FAIL [I:ElectricFieldReader:mydetector] Setting linear electric field from 50V bias voltage and 200V depletion voltage #FAIL [I:ElectricFieldReader:mydetector2] Setting linear electric field from 150V bias voltage and 100V depletion voltage #LABEL coverage
etc/unittests/test_core/test_05-5_overwrite_module_allow_io.conf 0 → 100644 +63 −0 Original line number Diff line number Diff line # SPDX-FileCopyrightText: 2022 CERN and the Allpix Squared authors # SPDX-License-Identifier: MIT #DESC tests different input / output configurations with module overwriting. [AllPix] log_level = "WARNING" log_format = "SHORT" number_of_events = 0 detectors_file = "two_detectors.conf" random_seed_core = 0 multithreading = false [GeometryBuilderGeant4] [DepositionGeant4] physics_list = FTFP_BERT particle_type = "pi+" source_energy = 120GeV source_position = 0mm 0mm 0mm beam_size = 0 beam_direction = 0 0 1 number_of_particles = 1 [GenericPropagation] [SimpleTransfer] output = "st1" [SimpleTransfer] output = "st2" [DefaultDigitizer] input = "st1" output = "low_noise" electronics_noise = 100e name = "mydetector2" [DefaultDigitizer] input = "st1" output = "low_noise" electronics_noise = 110e [DefaultDigitizer] input = "st2" output = "high_noise" electronics_noise = 500e [DefaultDigitizer] input = "st2" output = "high_noise" electronics_noise = 550e name = "mydetector" [DetectorHistogrammer] input = "low_noise" [DetectorHistogrammer] input = "high_noise" #PASS Executed 16 instantiations #LABEL coverage
src/core/config/ConfigManager.cpp +21 −7 Original line number Diff line number Diff line Loading @@ -159,26 +159,25 @@ std::list<Configuration>& ConfigManager::getDetectorConfigurations() { /** * @warning A previously stored configuration is directly invalidated if the same unique name is used again * * An instance configuration is a specialized configuration for a particular module instance. If an unique name already * exists the previous record is deleted and a new configuration record corresponding to the replaced instance is added. * An instance configuration is a specialized configuration for a particular module instance. If a ModuleIdentifier already * exists an error is thrown. */ Configuration& ConfigManager::addInstanceConfiguration(const ModuleIdentifier& identifier, const Configuration& config) { std::string unique_name = identifier.getUniqueName(); // Check uniqueness if(instance_name_to_config_.find(unique_name) != instance_name_to_config_.end()) { instance_configs_.erase(instance_name_to_config_[unique_name]); if(instance_identifier_to_config_.find(identifier) != instance_identifier_to_config_.end()) { throw ModuleIdentifierAlreadyAddedError(identifier); } // Add configuration instance_configs_.push_back(config); Configuration& ret_config = instance_configs_.back(); instance_name_to_config_[unique_name] = --instance_configs_.end(); instance_identifier_to_config_[identifier] = --instance_configs_.end(); // Add identifier key to config ret_config.set<std::string>("identifier", identifier.getIdentifier()); // Apply instance options module_option_parser_.applyOptions(unique_name, ret_config); module_option_parser_.applyOptions(identifier.getUniqueName(), ret_config); return ret_config; } Loading @@ -189,3 +188,18 @@ Configuration& ConfigManager::addInstanceConfiguration(const ModuleIdentifier& i std::list<Configuration>& ConfigManager::getInstanceConfigurations() { return instance_configs_; } /** * An instance configuration might be dropped when not used (e.g. it is overwritten by another module instance afterwards) * We need to remove it from the instance configuration list to ensure dumping the config actually dumps only the instance * configurations that were used. */ void ConfigManager::dropInstanceConfiguration(const ModuleIdentifier& identifier) { // Remove config from instance configs and from instance identifier map if(instance_identifier_to_config_.find(identifier) != instance_identifier_to_config_.end()) { instance_configs_.erase(instance_identifier_to_config_[identifier]); instance_identifier_to_config_.erase(identifier); } else { throw ModuleIdentifierNotFoundError(identifier); } }
src/core/config/ConfigManager.hpp +7 −1 Original line number Diff line number Diff line Loading @@ -89,6 +89,12 @@ namespace allpix { */ std::list<Configuration>& getInstanceConfigurations(); /** * @brief Drops an instance configuration from instance configuration storage * @param identifier Identifier of the module instance to drop */ void dropInstanceConfiguration(const ModuleIdentifier& identifier); /** * @brief Load module options and directly apply them to the global configuration and the module configurations * @param options List of options to load and apply Loading Loading @@ -124,7 +130,7 @@ namespace allpix { std::list<Configuration> detector_configs_; std::list<Configuration> instance_configs_; std::map<std::string, std::list<Configuration>::iterator> instance_name_to_config_; std::map<ModuleIdentifier, std::list<Configuration>::iterator> instance_identifier_to_config_; }; } // namespace allpix Loading