CMS 3D CMS Logo

AcquireIntStreamProducer.cc
Go to the documentation of this file.
2 #include "DataFormats/TestObjects/interface/ToyProducts.h"
7 #include "WaitingService.h"
12 
13 #include <memory>
14 #include <vector>
15 
16 namespace edm {
17  class EventSetup;
18 }
19 
20 namespace edmtest {
21 
22  class AcquireIntStreamProducer : public edm::stream::EDProducer<edm::ExternalWork> {
23  public:
25  ~AcquireIntStreamProducer() override;
27  void produce(edm::Event&, edm::EventSetup const&) override;
28 
29  private:
30  std::vector<edm::EDGetTokenT<IntProduct>> m_getTokens;
33  };
34 
37  for (auto const& tag : pset.getParameter<std::vector<edm::InputTag>>("tags")) {
38  m_getTokens.emplace_back(consumes<IntProduct>(tag));
39  }
40  m_tokenForProduce = consumes<IntProduct>(pset.getParameter<edm::InputTag>("produceTag"));
41  produces<IntProduct>();
42  }
43 
45 
47  edm::EventSetup const&,
50  cache->retrieved().clear();
51  cache->processed().clear();
52 
53  for (auto const& token : m_getTokens) {
54  cache->retrieved().push_back(event.get(token).value);
55  }
56 
57  edm::Service<test_acquire::WaitingService>()->requestValuesAsync(
58  m_token, &cache->retrieved(), &cache->processed(), holder);
59  }
60 
62  int sum = 0;
64  for (auto v : cache->processed()) {
65  sum += v;
66  }
67  event.put(std::make_unique<IntProduct>(sum));
68 
69  // This part is here only for the Parentage test.
71  }
72 } // namespace edmtest
void produce(edm::Event &, edm::EventSetup const &) override
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
std::vector< edm::EDGetTokenT< IntProduct > > m_getTokens
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< IntProduct > m_tokenForProduce
AcquireIntStreamProducer(edm::ParameterSet const &pset)
HLT enums.
def cache(function)
Definition: utilities.py:3
Definition: event.py:1
def getToken(db, tag, since)