CMS 3D CMS Logo

UniqueStringProducer.cc
Go to the documentation of this file.
7 
8 #include <vector>
9 
10 class UniqueStringProducer : public edm::global::EDProducer<edm::BeginRunProducer> {
11 public:
13  const edm::ParameterSet& strings = iConfig.getParameter<edm::ParameterSet>("strings");
14  for (const std::string& vname : strings.getParameterNamesForType<std::string>()) {
15  strings_.emplace_back(vname, strings.getParameter<std::string>(vname));
16  produces<nanoaod::UniqueString, edm::InRun>(vname);
17  }
18  }
19 
20  ~UniqueStringProducer() override {}
21 
22  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
25  strings.setComment("a parameter set definining the a pair of strings to be added in run flat table");
27  desc.add<edm::ParameterSetDescription>("strings", strings);
28 
29  descriptions.addWithDefaultLabel(desc);
30  }
31  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override {} // do nothing
32 
33  void globalBeginRunProduce(edm::Run& iRun, edm::EventSetup const&) const override {
34  for (const auto& pair : strings_) {
35  iRun.put(std::make_unique<nanoaod::UniqueString>(pair.second), pair.first);
36  }
37  }
38 
39 protected:
40  std::vector<std::pair<std::string, std::string>> strings_;
41 };
42 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< std::pair< std::string, std::string > > strings_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Run.h:109
UniqueStringProducer(edm::ParameterSet const &iConfig)
void globalBeginRunProduce(edm::Run &iRun, edm::EventSetup const &) const override
Definition: Run.h:45