DerivedPtrVectorProducer_module.cc
Go to the documentation of this file.
1 // ======================================================================
2 // Produces a PtrVector instance.
3 // ======================================================================
4 
12 #include "fhiclcpp/types/Atom.h"
13 
14 #include <iostream>
15 #include <memory>
16 #include <vector>
17 
18 namespace arttest {
20 }
21 
23 
24 // ----------------------------------------------------------------------
25 
27 public:
28  using input_t = std::vector<arttest::SimpleDerived>;
31 
32  struct Config {
34  };
37  : EDProducer{p}
38  , inputToken_{
39  consumes<input_t>(art::InputTag{p().input_label(), "derived"})}
40  {
41  produces<derived_t>();
42  produces<base_t>();
43  }
44 
45 private:
46  void produce(art::Event& e) override;
47 
49 }; // DerivedPtrVectorProducer
50 
51 // ----------------------------------------------------------------------
52 
53 void
55 {
56  auto const& h = e.getValidHandle(inputToken_);
57 
58  auto prod = std::make_unique<derived_t>();
59  for (std::size_t k = 0; k != 16; ++k) {
61  prod->push_back(p);
62  }
63  auto base_prod = std::make_unique<base_t>(*prod);
64  e.put(move(prod));
65  e.put(move(base_prod));
66 }
67 
EDProducer()=default
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:480
std::vector< arttest::SimpleDerived > input_t
p
Definition: test.py:228
art::ProductToken< input_t > const inputToken_
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
Definition: fwd.h:26
h
training ###############################
Definition: train_cnn.py:186