Loading src/core/geometry/GeometryManager.cpp +21 −22 Original line number Diff line number Diff line Loading @@ -60,9 +60,30 @@ void GeometryManager::load(ConfigManager* conf_manager, RandomNumberGenerator& s throw PassiveElementExistsError(geometry_section.getName()); } // Calculate the orientations of passive elements passive_orientations_[geometry_section.getName()] = calculate_orientation(geometry_section); // Check for mandatory but hitherto unused keys: auto check_key = [&](const Configuration& cfg, const std::string& key) { if(!cfg.has(key)) { throw MissingKeyError(key, cfg.getName()); } }; // Check type keyword check_key(geometry_section, "type"); // Check material unless it's a GDML file placement auto type = geometry_section.get<std::string>("type"); std::transform(type.begin(), type.end(), type.begin(), ::tolower); if(type != "gdml") { check_key(geometry_section, "material"); } passive_elements_.push_back(geometry_section); LOG(DEBUG) << "Passive element " << geometry_section.getName() << ", putting aside"; continue; } else if(role != "active") { throw InvalidValueError(geometry_section, "role", "unknown role"); } Loading @@ -81,28 +102,6 @@ void GeometryManager::load(ConfigManager* conf_manager, RandomNumberGenerator& s nonresolved_models_[geometry_section.get<std::string>("type")].emplace_back(geometry_section, detector.get()); } // Calculate the orientations of passive elements for(auto& passive_element : passive_elements_) { passive_orientations_[passive_element.getName()] = calculate_orientation(passive_element); // Check for mandatory but hitherto unused keys: auto check_key = [&](const Configuration& cfg, const std::string& key) { if(!cfg.has(key)) { throw MissingKeyError(key, cfg.getName()); } }; // Check type keyword check_key(passive_element, "type"); // Check material unless it's a GDML file placement auto type = passive_element.get<std::string>("type"); std::transform(type.begin(), type.end(), type.begin(), ::tolower); if(type != "gdml") { check_key(passive_element, "material"); } } // Load the list of standard model paths Configuration& global_config = conf_manager->getGlobalConfiguration(); if(global_config.has("model_paths")) { Loading src/modules/GeometryBuilderGeant4/PassiveMaterialConstructionG4.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,7 @@ void PassiveMaterialConstructionG4::registerVolumes() { LOG(TRACE) << "Registering " << passive_configs.size() << " passive material volume(s)"; for(auto& passive_config : passive_configs) { std::shared_ptr<PassiveMaterialModel> model = PassiveMaterialModel::factory(passive_config.get<std::string>("type"), passive_config, geo_manager_); std::shared_ptr<PassiveMaterialModel> model = PassiveMaterialModel::factory(passive_config, geo_manager_); passive_volumes_.emplace_back(model); } Loading src/modules/GeometryBuilderGeant4/PassiveMaterialModel.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -34,8 +34,9 @@ using namespace allpix; using namespace ROOT::Math; std::shared_ptr<PassiveMaterialModel> allpix::PassiveMaterialModel::factory(const std::string& type, const Configuration& config, GeometryManager* geo_manager) { std::shared_ptr<PassiveMaterialModel> allpix::PassiveMaterialModel::factory(Configuration& config, GeometryManager* geo_manager) { auto type = config.get<std::string>("type"); if(type == "box") { return std::make_shared<BoxModel>(config, geo_manager); } else if(type == "cylinder") { Loading @@ -56,9 +57,8 @@ allpix::PassiveMaterialModel::factory(const std::string& type, const Configurati } } PassiveMaterialModel::PassiveMaterialModel(Configuration config, GeometryManager* geo_manager) PassiveMaterialModel::PassiveMaterialModel(Configuration& config, GeometryManager* geo_manager) : config_(std::move(config)), geo_manager_(geo_manager) { name_ = config_.getName(); mother_volume_ = config_.get<std::string>("mother_volume", ""); Loading Loading @@ -122,6 +122,17 @@ void PassiveMaterialModel::buildVolume(const std::shared_ptr<G4LogicalVolume>& w auto phys_volume = make_shared_no_delete<G4PVPlacement>( transform_phys, log_volume.get(), getName() + "_phys", mother_log_volume, false, 0, true); geo_manager_->setExternalObject(getName(), "passive_material_phys", phys_volume); auto unused_keys = config_.getUnusedKeys(); if(!unused_keys.empty()) { std::stringstream st; st << "Unused configuration keys in passive material definition:"; for(auto& key : unused_keys) { st << std::endl << key; } LOG(WARNING) << st.str(); } LOG(TRACE) << " Constructed passive material " << getName() << " successfully"; } Loading src/modules/GeometryBuilderGeant4/PassiveMaterialModel.hpp +2 −3 Original line number Diff line number Diff line Loading @@ -45,15 +45,14 @@ namespace allpix { * @param geo_manager Pointer to the global geometry manager * @return By param trackModel assigned track model to be used */ static std::shared_ptr<PassiveMaterialModel> factory(const std::string& type, const Configuration& config, GeometryManager* geo_manager); static std::shared_ptr<PassiveMaterialModel> factory(Configuration& config, GeometryManager* geo_manager); /** * @brief Constructs the base passive material model * @param config Configuration with description of the model * @param geo_manager Pointer to the global geometry manager */ PassiveMaterialModel(Configuration config, GeometryManager* geo_manager); PassiveMaterialModel(Configuration& config, GeometryManager* geo_manager); /** * @brief Essential virtual destructor Loading src/modules/GeometryBuilderGeant4/passive_models/BoxModel.hpp +1 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,7 @@ namespace allpix { * @param config Configuration with description of the model * @param geo_manager Pointer to the global geometry manager */ explicit BoxModel(const Configuration& config, GeometryManager* geo_manager) : PassiveMaterialModel(config, geo_manager) { explicit BoxModel(Configuration& config, GeometryManager* geo_manager) : PassiveMaterialModel(config, geo_manager) { // Set the box specifications setOuterSize(config_.get<ROOT::Math::XYZVector>("size")); Loading Loading
src/core/geometry/GeometryManager.cpp +21 −22 Original line number Diff line number Diff line Loading @@ -60,9 +60,30 @@ void GeometryManager::load(ConfigManager* conf_manager, RandomNumberGenerator& s throw PassiveElementExistsError(geometry_section.getName()); } // Calculate the orientations of passive elements passive_orientations_[geometry_section.getName()] = calculate_orientation(geometry_section); // Check for mandatory but hitherto unused keys: auto check_key = [&](const Configuration& cfg, const std::string& key) { if(!cfg.has(key)) { throw MissingKeyError(key, cfg.getName()); } }; // Check type keyword check_key(geometry_section, "type"); // Check material unless it's a GDML file placement auto type = geometry_section.get<std::string>("type"); std::transform(type.begin(), type.end(), type.begin(), ::tolower); if(type != "gdml") { check_key(geometry_section, "material"); } passive_elements_.push_back(geometry_section); LOG(DEBUG) << "Passive element " << geometry_section.getName() << ", putting aside"; continue; } else if(role != "active") { throw InvalidValueError(geometry_section, "role", "unknown role"); } Loading @@ -81,28 +102,6 @@ void GeometryManager::load(ConfigManager* conf_manager, RandomNumberGenerator& s nonresolved_models_[geometry_section.get<std::string>("type")].emplace_back(geometry_section, detector.get()); } // Calculate the orientations of passive elements for(auto& passive_element : passive_elements_) { passive_orientations_[passive_element.getName()] = calculate_orientation(passive_element); // Check for mandatory but hitherto unused keys: auto check_key = [&](const Configuration& cfg, const std::string& key) { if(!cfg.has(key)) { throw MissingKeyError(key, cfg.getName()); } }; // Check type keyword check_key(passive_element, "type"); // Check material unless it's a GDML file placement auto type = passive_element.get<std::string>("type"); std::transform(type.begin(), type.end(), type.begin(), ::tolower); if(type != "gdml") { check_key(passive_element, "material"); } } // Load the list of standard model paths Configuration& global_config = conf_manager->getGlobalConfiguration(); if(global_config.has("model_paths")) { Loading
src/modules/GeometryBuilderGeant4/PassiveMaterialConstructionG4.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,7 @@ void PassiveMaterialConstructionG4::registerVolumes() { LOG(TRACE) << "Registering " << passive_configs.size() << " passive material volume(s)"; for(auto& passive_config : passive_configs) { std::shared_ptr<PassiveMaterialModel> model = PassiveMaterialModel::factory(passive_config.get<std::string>("type"), passive_config, geo_manager_); std::shared_ptr<PassiveMaterialModel> model = PassiveMaterialModel::factory(passive_config, geo_manager_); passive_volumes_.emplace_back(model); } Loading
src/modules/GeometryBuilderGeant4/PassiveMaterialModel.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -34,8 +34,9 @@ using namespace allpix; using namespace ROOT::Math; std::shared_ptr<PassiveMaterialModel> allpix::PassiveMaterialModel::factory(const std::string& type, const Configuration& config, GeometryManager* geo_manager) { std::shared_ptr<PassiveMaterialModel> allpix::PassiveMaterialModel::factory(Configuration& config, GeometryManager* geo_manager) { auto type = config.get<std::string>("type"); if(type == "box") { return std::make_shared<BoxModel>(config, geo_manager); } else if(type == "cylinder") { Loading @@ -56,9 +57,8 @@ allpix::PassiveMaterialModel::factory(const std::string& type, const Configurati } } PassiveMaterialModel::PassiveMaterialModel(Configuration config, GeometryManager* geo_manager) PassiveMaterialModel::PassiveMaterialModel(Configuration& config, GeometryManager* geo_manager) : config_(std::move(config)), geo_manager_(geo_manager) { name_ = config_.getName(); mother_volume_ = config_.get<std::string>("mother_volume", ""); Loading Loading @@ -122,6 +122,17 @@ void PassiveMaterialModel::buildVolume(const std::shared_ptr<G4LogicalVolume>& w auto phys_volume = make_shared_no_delete<G4PVPlacement>( transform_phys, log_volume.get(), getName() + "_phys", mother_log_volume, false, 0, true); geo_manager_->setExternalObject(getName(), "passive_material_phys", phys_volume); auto unused_keys = config_.getUnusedKeys(); if(!unused_keys.empty()) { std::stringstream st; st << "Unused configuration keys in passive material definition:"; for(auto& key : unused_keys) { st << std::endl << key; } LOG(WARNING) << st.str(); } LOG(TRACE) << " Constructed passive material " << getName() << " successfully"; } Loading
src/modules/GeometryBuilderGeant4/PassiveMaterialModel.hpp +2 −3 Original line number Diff line number Diff line Loading @@ -45,15 +45,14 @@ namespace allpix { * @param geo_manager Pointer to the global geometry manager * @return By param trackModel assigned track model to be used */ static std::shared_ptr<PassiveMaterialModel> factory(const std::string& type, const Configuration& config, GeometryManager* geo_manager); static std::shared_ptr<PassiveMaterialModel> factory(Configuration& config, GeometryManager* geo_manager); /** * @brief Constructs the base passive material model * @param config Configuration with description of the model * @param geo_manager Pointer to the global geometry manager */ PassiveMaterialModel(Configuration config, GeometryManager* geo_manager); PassiveMaterialModel(Configuration& config, GeometryManager* geo_manager); /** * @brief Essential virtual destructor Loading
src/modules/GeometryBuilderGeant4/passive_models/BoxModel.hpp +1 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,7 @@ namespace allpix { * @param config Configuration with description of the model * @param geo_manager Pointer to the global geometry manager */ explicit BoxModel(const Configuration& config, GeometryManager* geo_manager) : PassiveMaterialModel(config, geo_manager) { explicit BoxModel(Configuration& config, GeometryManager* geo_manager) : PassiveMaterialModel(config, geo_manager) { // Set the box specifications setOuterSize(config_.get<ROOT::Math::XYZVector>("size")); Loading