File indexing completed on 2024-04-06 12:13:00
0001 #ifndef FWCore_PyBind11ParameterSet_Python11ParameterSet_h
0002 #define FWCore_PyBind11ParameterSet_Python11ParameterSet_h
0003 #include <pybind11/pybind11.h>
0004
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/PythonParameterSet/interface/PyBind11Wrapper.h"
0007
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 #include "FWCore/Utilities/interface/ESInputTag.h"
0010 #include "DataFormats/Provenance/interface/EventRange.h"
0011 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
0012 #include "DataFormats/Provenance/interface/LuminosityBlockRange.h"
0013 #include "DataFormats/Provenance/interface/EventID.h"
0014 #include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
0015
0016 #include <string>
0017 #include <vector>
0018
0019 class Python11ParameterSet {
0020 public:
0021 Python11ParameterSet();
0022
0023 Python11ParameterSet(edm::ParameterSet const& p) : theParameterSet(p) {}
0024
0025 template <typename T>
0026 T getParameter(bool tracked, std::string const& name) const {
0027 T result;
0028 if (tracked) {
0029 result = theParameterSet.template getParameter<T>(name);
0030 } else {
0031 result = theParameterSet.template getUntrackedParameter<T>(name);
0032 }
0033 return result;
0034 }
0035
0036 template <typename T>
0037 void addParameter(bool tracked, std::string const& name, T const& value) {
0038 if (tracked) {
0039 theParameterSet.template addParameter<T>(name, value);
0040 } else {
0041 theParameterSet.template addUntrackedParameter<T>(name, value);
0042 }
0043 }
0044
0045
0046 template <typename T>
0047 pybind11::list getParameters(bool tracked, std::string const& name) const {
0048 std::vector<T> v = getParameter<std::vector<T> >(tracked, name);
0049 return edm::toPython11List(v);
0050 }
0051
0052
0053 template <typename T>
0054 void addParameters(bool tracked, std::string const& name, pybind11::list value) {
0055 std::vector<T> v = edm::toVector<T>(value);
0056 addParameter(tracked, name, v);
0057 }
0058
0059
0060
0061
0062 void addPSet(bool tracked, std::string const& name, Python11ParameterSet const& ppset) {
0063 addParameter(tracked, name, ppset.theParameterSet);
0064 }
0065
0066 Python11ParameterSet getPSet(bool tracked, std::string const& name) const {
0067 return Python11ParameterSet(getParameter<edm::ParameterSet>(tracked, name));
0068 }
0069
0070 void addVPSet(bool tracked, std::string const& name, pybind11::list value);
0071
0072 pybind11::list getVPSet(bool tracked, std::string const& name);
0073
0074
0075 edm::InputTag newInputTag(std::string const& label, std::string const& instance, std::string const& process) {
0076 return edm::InputTag(label, instance, process);
0077 }
0078
0079 edm::ESInputTag newESInputTag(std::string const& module, std::string const& data) {
0080 return edm::ESInputTag(module, data);
0081 }
0082
0083 edm::EventID newEventID(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event) {
0084 return edm::EventID(run, lumi, event);
0085 }
0086
0087 edm::LuminosityBlockID newLuminosityBlockID(unsigned int run, unsigned int lumi) {
0088 return edm::LuminosityBlockID(run, lumi);
0089 }
0090
0091 edm::LuminosityBlockRange newLuminosityBlockRange(unsigned int start,
0092 unsigned int startSub,
0093 unsigned int end,
0094 unsigned int endSub) {
0095 return edm::LuminosityBlockRange(start, startSub, end, endSub);
0096 }
0097
0098 edm::EventRange newEventRange(edm::RunNumber_t start,
0099 edm::LuminosityBlockNumber_t startLumi,
0100 edm::EventNumber_t startSub,
0101 edm::RunNumber_t end,
0102 edm::LuminosityBlockNumber_t endLumi,
0103 edm::EventNumber_t endSub) {
0104 return edm::EventRange(start, startLumi, startSub, end, endLumi, endSub);
0105 }
0106
0107 void addNewFileInPath(bool tracked, std::string const& name, std::string const& value);
0108
0109 Python11ParameterSet newPSet() const { return Python11ParameterSet(); }
0110
0111 edm::ParameterSet& pset() { return theParameterSet; }
0112
0113 edm::ParameterSet const& pset() const { return theParameterSet; }
0114
0115 std::string dump() const { return theParameterSet.dump(); }
0116
0117 private:
0118 edm::ParameterSet theParameterSet;
0119 };
0120
0121 #endif