MockClusterListProducer_module.cc
Go to the documentation of this file.
1 // Produces a MockClusterList starting from a vector<SimpleDerived>
2 
11 #include "fhiclcpp/ParameterSet.h"
12 
13 #include <iostream>
14 #include <memory>
15 #include <vector>
16 
17 namespace arttest {
19 }
20 
22 
23 // ----------------------------------------------------------------------
24 
26 public:
27  using input_t = std::vector<arttest::SimpleDerived>;
29 
31  : EDProducer{p}
32  , input_label_(p.get<std::string>("input_label"))
33  , nvalues_(p.get<int>("nvalues"))
34  {
35  produces<product_t>();
36  }
37 
38 private:
39  void produce(art::Event& e) override;
40 
42  unsigned const nvalues_;
43 }; // MockClusterListProducer
44 
45 // ----------------------------------------------------------------------
46 
47 void
49 {
51  e.getByLabel(input_label_, "derived", h);
52 
53  std::unique_ptr<product_t> prod(new product_t);
55  c1.skew = 1;
56  for (unsigned k = 0; k < (nvalues_ / 2); ++k) {
58  c1.cells.push_back(p);
59  }
60  c1.eNum = e.id().event();
61  prod->push_back(c1);
62 
64  c2.skew = 2;
65  for (unsigned k = nvalues_ / 2; k < nvalues_; ++k) {
67  c2.cells.push_back(p);
68  }
69  c2.eNum = e.id().event() + 1;
70  prod->push_back(c2);
71 
72  e.put(std::move(prod));
73 }
74 
std::string string
Definition: nybbler.cc:12
EDProducer()=default
std::vector< arttest::MockCluster > MockClusterList
Definition: MockCluster.h:26
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:435
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
MockClusterListProducer(fhicl::ParameterSet const &p)
p
Definition: test.py:228
art::EventNumber_t eNum
Definition: MockCluster.h:22
EventNumber_t event() const
Definition: EventID.h:117
std::vector< arttest::SimpleDerived > input_t
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
Definition: fwd.h:26
EventID id() const
Definition: Event.cc:37
h
training ###############################
Definition: train_cnn.py:186