All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DaqDecoderICARUSTrigger_module.cc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////
2 ///// Class: DaqDecoderICARUSTrigger
3 ///// Plugin Type: producer
4 ///// File: DaqDecoderICARUSTrigger.cc
5 //////////////////////////////////////////////////////
6 
7 #include "art/Framework/Core/EDProducer.h"
8 #include "art/Framework/Core/ModuleMacros.h"
9 #include "art/Utilities/make_tool.h"
10 #include "art/Framework/Services/Registry/ServiceHandle.h"
11 #include "art/Framework/Principal/Event.h"
12 #include "art/Framework/Principal/Handle.h"
13 
14 #include "canvas/Utilities/InputTag.h"
15 #include "fhiclcpp/ParameterSet.h"
16 #include "messagefacility/MessageLogger/MessageLogger.h"
17 
18 #include "artdaq-core/Data/Fragment.hh"
19 
21 
22 #include <iostream>
23 #include <cstdlib>
24 #include <vector>
25 
26 namespace daq
27 {
28  class DaqDecoderICARUSTrigger: public art::EDProducer
29  {
30  public:
31  explicit DaqDecoderICARUSTrigger(fhicl::ParameterSet const & p);
36 
37  void beginRun(art::Run& run) override;
38  void produce(art::Event & e) override;
39 
40  private:
41  std::unique_ptr<IDecoder> fDecoderTool;
42  art::InputTag fInputTag;
43 
44  };
45 
46  DEFINE_ART_MODULE(DaqDecoderICARUSTrigger)
47 
48  DaqDecoderICARUSTrigger::DaqDecoderICARUSTrigger(fhicl::ParameterSet const & params): art::EDProducer{params}, fInputTag(params.get<std::string>("FragmentsLabel", "daq:ICARUSTriggerUDP"))
49  {
50  consumes<artdaq::Fragments>(fInputTag);
51 
52  fDecoderTool = art::make_tool<IDecoder>(params.get<fhicl::ParameterSet>("DecoderTool"));
53  fDecoderTool->produces(producesCollector());
54 
55  return;
56  }
57 
59  {
60  fDecoderTool->setupRun(run);
61  }
62 
63 
64  void DaqDecoderICARUSTrigger::produce(art::Event & event)
65  {
66  fDecoderTool->initializeDataProducts();
67  auto const & daq_handle = event.getValidHandle<artdaq::Fragments>(fInputTag);
68  if(daq_handle.isValid() && daq_handle->size() > 0)
69  {
70  for (auto const & rawFrag: *daq_handle) fDecoderTool->process_fragment(rawFrag);
71  }
72  else
73  std::cout << "No Trigger Fragment Information Found!" << std::endl;
74 
75  fDecoderTool->outputDataProducts(event);
76  return;
77 
78  }
79 
80 } //end namespace
DaqDecoderICARUSTrigger & operator=(DaqDecoderICARUSTrigger const &)=delete
This provides an art tool interface definition for tools which &quot;decode&quot; artdaq fragments into LArSoft...
pdgs p
Definition: selectors.fcl:22
DaqDecoderICARUSTrigger(fhicl::ParameterSet const &p)
do i e
std::unique_ptr< IDecoder > fDecoderTool
BEGIN_PROLOG could also be cout