CMS 3D CMS Logo

UniqueStringProducer.cc
Go to the documentation of this file.
5 
6 #include <vector>
7 
8 class UniqueStringProducer : public edm::global::EDProducer<edm::BeginRunProducer> {
9  public:
11  const edm::ParameterSet & strings = iConfig.getParameter<edm::ParameterSet>("strings");
12  for (const std::string & vname : strings.getParameterNamesForType<std::string>()) {
13  strings_.emplace_back(vname, strings.getParameter<std::string>(vname));
14  produces<nanoaod::UniqueString,edm::InRun>(vname);
15  }
16  }
17 
18  ~UniqueStringProducer() override {}
19 
20  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override {} // do nothing
21 
22  void globalBeginRunProduce(edm::Run& iRun, edm::EventSetup const&) const override {
23  for (const auto & pair : strings_) {
24  iRun.put(std::make_unique<nanoaod::UniqueString>(pair.second), pair.first);
25  }
26  }
27 
28  protected:
29  std::vector<std::pair<std::string,std::string>> strings_;
30 };
31 
34 
T getParameter(std::string const &) const
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
std::vector< std::pair< std::string, std::string > > strings_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:169
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void globalBeginRunProduce(edm::Run &iRun, edm::EventSetup const &) const override
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Run.h:108
UniqueStringProducer(edm::ParameterSet const &iConfig)
Definition: Run.h:45