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 
15 namespace arttest {
16  class IntVectorProducer;
17 }
18 
20 
21 // ----------------------------------------------------------------------
22 
24  : public art::EDProducer
25 {
26 public:
27  typedef std::vector<int> intvector_t;
28 
30  : EDProducer{p}, nvalues_( p.get<int>("nvalues") )
31  {
32  produces<intvector_t>();
33  }
34 
35  void produce( art::Event & e ) override
36  {
37  std::cerr << "IntVectorProducer::produce is running!\n";
38  int value_ = e.id().event();
39  std::unique_ptr<intvector_t> p(new intvector_t);
40  for( int k = 0; k != nvalues_; ++k ) {
41  p->push_back(value_ * k);
42  }
43  e.put(std::move(p));
44  }
45 
46 private:
47  int nvalues_;
48 
49 }; // IntVectorProducer
50 
51 // ----------------------------------------------------------------------
52 
54 
55 // ======================================================================
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
IntVectorProducer(fhicl::ParameterSet const &p)
EventNumber_t event() const
Definition: EventID.h:116
void produce(art::Event &e) override
EventID id() const
Definition: Event.cc:34