artdaq_demo  v3_06_00
EventReporterOutput_module.cc
1 #define TRACE_NAME "EventReporterOutput"
2 
3 #include "art/Framework/Core/ModuleMacros.h"
4 #include "art/Framework/Core/OutputModule.h"
5 #include "art/Framework/Principal/EventPrincipal.h"
6 #include "art/Framework/Principal/OutputHandle.h"
7 #include "art/Framework/Principal/RunPrincipal.h"
8 #include "art/Framework/Principal/SubRunPrincipal.h"
9 #include "art/Framework/Services/Registry/ServiceHandle.h"
10 #if ART_HEX_VERSION < 0x20900
11 #include "art/Persistency/Provenance/BranchIDListRegistry.h"
12 #include "canvas/Persistency/Provenance/BranchIDList.h"
13 #endif
14 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
15 #if ART_HEX_VERSION < 0x30000
16 #include "art/Persistency/Provenance/ProductMetaData.h"
17 #endif
18 
19 #include <algorithm>
20 #include <iterator>
21 #include "canvas/Persistency/Provenance/BranchDescription.h"
22 #include "canvas/Persistency/Provenance/BranchKey.h"
23 #include "canvas/Persistency/Provenance/History.h"
24 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
25 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
26 #include "canvas/Persistency/Provenance/ProcessConfigurationID.h"
27 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
28 #include "canvas/Persistency/Provenance/ProductList.h"
29 #include "canvas/Persistency/Provenance/ProductProvenance.h"
30 #include "canvas/Persistency/Provenance/RunAuxiliary.h"
31 #include "canvas/Persistency/Provenance/SubRunAuxiliary.h"
32 #include "canvas/Utilities/DebugMacros.h"
33 #include "canvas/Utilities/Exception.h"
34 #include "cetlib/column_width.h"
35 #include "cetlib/lpad.h"
36 #include "cetlib/rpad.h"
37 #include "fhiclcpp/ParameterSet.h"
38 #include "fhiclcpp/ParameterSetID.h"
39 #include "fhiclcpp/ParameterSetRegistry.h"
40 
41 #include "artdaq-core/Data/detail/ParentageMap.hh"
42 #include "artdaq/DAQdata/Globals.hh"
43 #include "artdaq/DAQdata/NetMonHeader.hh"
44 #include "artdaq/TransferPlugins/MakeTransferPlugin.hh"
45 #include "artdaq/TransferPlugins/TransferInterface.hh"
46 
47 #include <iomanip>
48 #include <iostream>
49 #include <sstream>
50 #include <string>
51 #include <vector>
52 
53 #include <unistd.h>
54 
55 #include <TClass.h>
56 #include <TMessage.h>
57 
58 namespace art {
59 class EventReporterOutput;
60 }
61 
67 class art::EventReporterOutput : public OutputModule {
68  public:
76  explicit EventReporterOutput(fhicl::ParameterSet const& ps);
77 
82 
83  private:
84  virtual void openFile(FileBlock const&);
85 
86  virtual void closeFile();
87 
88  virtual void respondToCloseInputFile(FileBlock const&);
89 
90  virtual void respondToCloseOutputFiles(FileBlock const&);
91 
92  virtual void endJob();
93 
94  virtual void write(EventPrincipal&);
95 
96  virtual void writeRun(RunPrincipal&);
97 
98  virtual void writeSubRun(SubRunPrincipal&);
99 
100  private:
101 };
102 
103 art::EventReporterOutput::EventReporterOutput(fhicl::ParameterSet const& ps) : OutputModule(ps) {
104  TLOG(TLVL_DEBUG) << "Begin: EventReporterOutput::EventReporterOutput(ParameterSet const& ps)";
105 }
106 
108  TLOG(TLVL_DEBUG) << "Begin: EventReporterOutput::~EventReporterOutput()";
109 }
110 
111 void art::EventReporterOutput::openFile(FileBlock const&) {
112  TLOG(TLVL_DEBUG) << "Begin/End: EventReporterOutput::openFile(const FileBlock&)";
113 }
114 
115 void art::EventReporterOutput::closeFile() { TLOG(TLVL_DEBUG) << "Begin/End: EventReporterOutput::closeFile()"; }
116 
117 void art::EventReporterOutput::respondToCloseInputFile(FileBlock const&) {
118  TLOG(TLVL_DEBUG) << "Begin/End: EventReporterOutput::respondToCloseOutputFiles(FileBlock const&)";
119 }
120 
121 void art::EventReporterOutput::respondToCloseOutputFiles(FileBlock const&) {
122  TLOG(TLVL_DEBUG) << "Begin/End: EventReporterOutput::respondToCloseOutputFiles(FileBlock const&)";
123 }
124 
125 void art::EventReporterOutput::endJob() { TLOG(TLVL_DEBUG) << "Begin: EventReporterOutput::endJob()"; }
126 
127 void art::EventReporterOutput::write(EventPrincipal& ep) {
128  TLOG(TLVL_DEBUG) << " Begin: EventReporterOutput::write(const EventPrincipal& ep)";
129 
130  using RawEvent = artdaq::Fragments;
131  ;
132  using RawEvents = std::vector<RawEvent>;
133  using RawEventHandle = art::Handle<RawEvent>;
134  using RawEventHandles = std::vector<RawEventHandle>;
135 
136  auto result_handles = std::vector<art::GroupQueryResult>();
137 
138 #if ART_HEX_VERSION < 0x30000
139  auto const& wrapped = art::WrappedTypeID::make<RawEvent>();
140  result_handles = ep.getMany(wrapped, art::MatchAllSelector{});
141 #else
142  auto const& wrapped = art::WrappedTypeID::make<RawEvent>();
143  ModuleContext const mc{moduleDescription()};
144  ProcessTag const processTag{"", mc.moduleDescription().processName()};
145 
146  result_handles = ep.getMany(mc, wrapped, art::MatchAllSelector{}, processTag);
147 #endif
148 
149  for (auto const& result_handle : result_handles) {
150  auto const raw_event_handle = RawEventHandle(result_handle);
151 
152  if (!raw_event_handle.isValid()) continue;
153 
154  for (auto const& fragment : *raw_event_handle) {
155  TLOG(TLVL_DEBUG) << "EventReporterOutput::write: Event sequenceID=" << fragment.sequenceID()
156  << ", fragmentID=" << fragment.fragmentID();
157  }
158  }
159 
160  return;
161 }
162 
163 void art::EventReporterOutput::writeRun(RunPrincipal&) {
164  TLOG(TLVL_DEBUG) << " EventReporterOutput::writeRun(const RunPrincipal& rp)";
165 }
166 
167 void art::EventReporterOutput::writeSubRun(SubRunPrincipal&) {
168  TLOG(TLVL_DEBUG) << " EventReporterOutput:: writeSubRun(const SubRunPrincipal& srp)";
169 }
170 
171 DEFINE_ART_MODULE(art::EventReporterOutput)
An art::OutputModule which does nothing, but reports seen events and their fragments. This module is designed for debugging purposes, where writing events into ROOT files or sending events down stream is not necessary.
EventReporterOutput(fhicl::ParameterSet const &ps)
EventReporterOutput Constructor.
~EventReporterOutput()
EventReporterOutput Destructor.