AddIntsProducer_module.cc
Go to the documentation of this file.
8 
9 using namespace fhicl;
10 
11 namespace {
12 
13  class AddIntsProducer : public art::EDProducer {
14  public:
15  struct Config {
16  DelegatedParameter tool_table{Name("addIntsImpl")};
18  };
19  using Parameters = art::EDProducer::Table<Config>;
20 
21  explicit AddIntsProducer(Parameters const& p)
22  : EDProducer{p}
23  , labels_{p().labels()}
24  , addInts_{art::make_tool<void(int&, int)>(
25  p().tool_table.get<fhicl::ParameterSet>(),
26  "addInts")}
27  {
28  produces<arttest::IntProduct>();
29  }
30 
31  private:
32  void produce(art::Event& e) override;
33 
34  std::vector<std::string> const labels_;
35  // Test tool invocation from within module.
36  std::function<void(int&, int)> addInts_;
37  };
38 
39  void
40  AddIntsProducer::produce(art::Event& e)
41  {
42  int value{};
43  for (auto const& label : labels_) {
44  auto const newVal = e.getValidHandle<arttest::IntProduct>(label)->value;
45  addInts_(value, newVal);
46  }
47  e.put(std::make_unique<arttest::IntProduct>(value));
48  }
49 
50 } // namespace
51 
52 DEFINE_ART_MODULE(AddIntsProducer)
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
parameter set interface
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:480
p
Definition: test.py:228
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
AdcRoiViewer::Name Name