CMS 3D CMS Logo

ManyProductProducer.cc
Go to the documentation of this file.
1 /* This was written to benchmark some changes to
2 the getByLabel function and supporting code. It makes
3 a lot of getByLabel calls although it is not particularly
4 realistic ... */
5 
9 #include "DataFormats/TestObjects/interface/ToyProducts.h"
13 
14 #include <memory>
15 #include <vector>
16 
17 namespace edmtest {
18 
20  public:
21  explicit ManyProductProducer(edm::ParameterSet const& iConfig);
22 
23  void produce(edm::StreamID, edm::Event& e, edm::EventSetup const& c) const final;
24 
25  private:
26  unsigned int nProducts_;
27  std::vector<std::string> instanceNames_;
28  };
29 
31  : nProducts_(iConfig.getUntrackedParameter<unsigned int>("nProducts", 1)) {
32  for (unsigned int i = 0; i < nProducts_; ++i) {
33  std::stringstream instanceName;
34  instanceName << "i" << i;
35  instanceNames_.push_back(instanceName.str());
36  produces<IntProduct>(instanceName.str());
37  }
38  }
39 
40  // Functions that gets called by framework every event
42  for (unsigned int i = 0; i < nProducts_; ++i) {
43  e.put(std::make_unique<IntProduct>(1), instanceNames_[i]);
44  }
45  }
46 
48  public:
49  explicit ManyProductAnalyzer(edm::ParameterSet const& iConfig);
50 
51  void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const final;
52 
53  private:
54  unsigned int nProducts_;
55  std::vector<edm::InputTag> tags_;
56  };
57 
59  : nProducts_(iConfig.getUntrackedParameter<unsigned int>("nProducts", 1)) {
60  for (unsigned int i = 0; i < nProducts_; ++i) {
61  std::stringstream instanceName;
62  instanceName << "i" << i;
63  edm::InputTag tag("produceInts", instanceName.str());
64  tags_.push_back(tag);
65  }
66  }
67 
70  for (auto const& tag : tags_) {
71  e.getByLabel(tag, h);
72  if (!h.isValid()) {
73  abort();
74  }
75  }
76  }
77 } // namespace edmtest
78 
81 
void produce(edm::StreamID, edm::Event &e, edm::EventSetup const &c) const final
std::vector< edm::InputTag > tags_
ManyProductAnalyzer(edm::ParameterSet const &iConfig)
ManyProductProducer(edm::ParameterSet const &iConfig)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const final
std::vector< std::string > instanceNames_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4