File indexing completed on 2024-04-06 12:21:24
0001 #ifndef L1Trigger_Phase2L1GT_L1GTOptionalParam_h
0002 #define L1Trigger_Phase2L1GT_L1GTOptionalParam_h
0003
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005
0006 #include <string>
0007 #include <optional>
0008 #include <functional>
0009
0010 namespace l1t {
0011
0012 template <typename T, typename K>
0013 inline std::optional<T> getOptionalParam(const std::string& name,
0014 const edm::ParameterSet& config,
0015 std::function<T(K)> conv) {
0016 if (config.exists(name)) {
0017 return std::optional<T>(conv(config.getParameter<K>(name)));
0018 }
0019 return std::optional<T>();
0020 }
0021
0022 template <typename T>
0023 inline std::optional<T> getOptionalParam(const std::string& name, const edm::ParameterSet& config) {
0024 if (config.exists(name)) {
0025 return std::optional<T>(config.getParameter<T>(name));
0026 }
0027 return std::optional<T>();
0028 }
0029 }
0030
0031 #endif