HMRunProdProducer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: HMRunProdProducer
3 // Module Type: producer
4 // File: HMRunProdProducer_module.cc
5 //
6 // Generated at Tue Apr 15 13:28:33 2014 by Christopher Green using artmod
7 // from cetpkgsupport v1_05_03.
8 ////////////////////////////////////////////////////////////////////////
9 
18 #include "fhiclcpp/ParameterSet.h"
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 namespace arttest {
25  class HMRunProdProducer;
26 }
27 
29 public:
30  explicit HMRunProdProducer(fhicl::ParameterSet const& p);
31 
32 private:
33  void produce(art::Event&) override{};
34  void endSubRun(art::SubRun& sr) override;
35  void endRun(art::Run& r) override;
36 
38  std::vector<std::unique_ptr<HMLargeData>> data_;
39 };
40 
42  : EDProducer{p}
43  , inputLabel_(p.get<std::string>("inputLabel"))
44  , data_(N_BLOCKS)
45 {
46  for (unsigned short i = 0; i < N_BLOCKS; ++i) {
47  std::string const instance_name = "block" + std::to_string(i);
48  produces<HMLargeData, art::InRun>(instance_name);
49  consumes<HMLargeData, art::InSubRun>(
50  art::InputTag{inputLabel_, instance_name});
51  }
52 }
53 
54 void
56 {
57  for (unsigned short i = 0; i < N_BLOCKS; ++i) {
60  inputLabel_, std::string("block") + std::to_string(i), h);
61  if (data_[i]) {
62  *data_[i] += *h;
63  } else {
64  data_[i] = std::make_unique<HMLargeData>(*h);
65  }
66  assert(sr.removeCachedProduct(h)); // Save the space.
67  }
68 }
69 
70 void
72 {
73  for (unsigned short i = 0; i < N_BLOCKS; ++i) {
74  r.put(std::move(data_[i]),
75  std::string("block") + std::to_string(i),
77  }
78 }
79 
void produce(art::Event &) override
void endSubRun(art::SubRun &sr) override
std::string string
Definition: nybbler.cc:12
EDProducer()=default
std::vector< std::unique_ptr< HMLargeData > > data_
Definition: Run.h:21
constexpr auto runFragment()
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:435
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
constexpr unsigned short N_BLOCKS
Definition: HMLargeData.h:12
bool removeCachedProduct(Handle< PROD > &) const
Definition: DataViewImpl.h:951
p
Definition: test.py:228
void endRun(art::Run &r) override
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
static const double sr
Definition: Units.h:167
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
HMRunProdProducer(fhicl::ParameterSet const &p)
h
training ###############################
Definition: train_cnn.py:186