IntVectorProducer_module.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Produces an IntProduct instance.
4 //
5 // ======================================================================
6 
10 #include "fhiclcpp/ParameterSet.h"
11 
12 #include <iostream>
13 #include <memory>
14 #include <vector>
15 
16 namespace arttest {
17  class IntVectorProducer;
18 }
19 
21 
22 // ----------------------------------------------------------------------
23 
25  using intvector_t = std::vector<int>;
26 
27 public:
28  struct Config {
30  };
32  explicit IntVectorProducer(Parameters const& p)
33  : EDProducer{p}, nvalues_{p().nvalues()}
34  {
35  produces<intvector_t>();
36  }
37 
38 private:
39  void
40  produce(art::Event& e) override
41  {
42  auto const value = e.id().event();
43  auto p = std::make_unique<intvector_t>();
44  for (unsigned k = 0; k != nvalues_; ++k)
45  p->push_back(value + k);
46  e.put(move(p));
47  }
48 
49  unsigned const nvalues_;
50 
51 }; // IntVectorProducer
52 
53 // ----------------------------------------------------------------------
54 
56 
57 // ======================================================================
EDProducer()=default
IntVectorProducer(Parameters const &p)
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
p
Definition: test.py:228
EventNumber_t event() const
Definition: EventID.h:117
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
void produce(art::Event &e) override
EventID id() const
Definition: Event.cc:37