AssembleProducts_module.cc
Go to the documentation of this file.
7 
8 #include <atomic>
9 
10 using art::InputTag;
11 using fhicl::Name;
12 using fhicl::TupleAs;
13 using std::string;
14 
15 namespace {
16 
17  struct Config {
18  TupleAs<InputTag(string)> particlesTag{Name("particlesTag")};
19  };
20 
21  class AssembleProducts : public art::EDProducer {
22  public:
23  using Parameters = EDProducer::Table<Config>;
24  explicit AssembleProducts(Parameters const& config)
25  : EDProducer{config}, particlesTag_{config().particlesTag()}
26  {
27  produces<unsigned, art::InSubRun>("seenParticles");
28  }
29 
30  private:
31  void
32  produce(art::Event& e) override
33  {
34  auto const& particles =
35  e.getValidHandle<std::vector<double>>(particlesTag_);
36  seenParticles_ += particles->size();
37  }
38 
39  void
40  endSubRun(art::SubRun& sr) override
41  {
42  sr.put(std::make_unique<unsigned>(seenParticles_),
43  "seenParticles",
45  seenParticles_ = 0u;
46  }
47 
48  InputTag const particlesTag_;
49  std::atomic<unsigned> seenParticles_{};
50 
51  }; // AssembleProducts
52 } // namespace
53 
54 DEFINE_ART_MODULE(AssembleProducts)
std::string string
Definition: nybbler.cc:12
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:480
constexpr auto subRunFragment()
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
static const double sr
Definition: Units.h:167
AdcRoiViewer::Name Name