artdaq_demo  v3_04_01
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 #include "art/Persistency/Provenance/ProductMetaData.h"
16 
17 #include "canvas/Persistency/Provenance/BranchDescription.h"
18 #include "canvas/Persistency/Provenance/BranchKey.h"
19 #include "canvas/Persistency/Provenance/History.h"
20 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
21 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
22 #include "canvas/Persistency/Provenance/ProcessConfigurationID.h"
23 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
24 #include "canvas/Persistency/Provenance/ProductList.h"
25 #include "canvas/Persistency/Provenance/ProductProvenance.h"
26 #include "canvas/Persistency/Provenance/RunAuxiliary.h"
27 #include "canvas/Persistency/Provenance/SubRunAuxiliary.h"
28 #include "canvas/Utilities/DebugMacros.h"
29 #include "canvas/Utilities/Exception.h"
30 #include "cetlib/column_width.h"
31 #include "cetlib/lpad.h"
32 #include "cetlib/rpad.h"
33 #include <algorithm>
34 # include <iterator>
35 #include "fhiclcpp/ParameterSet.h"
36 #include "fhiclcpp/ParameterSetID.h"
37 #include "fhiclcpp/ParameterSetRegistry.h"
38 
39 #include "artdaq/TransferPlugins/TransferInterface.hh"
40 #include "artdaq/TransferPlugins/MakeTransferPlugin.hh"
41 #include "artdaq-core/Data/detail/ParentageMap.hh"
42 #include "artdaq/DAQdata/Globals.hh"
43 #include "artdaq/DAQdata/NetMonHeader.hh"
44 
45 #include <iomanip>
46 #include <iostream>
47 #include <sstream>
48 #include <string>
49 #include <vector>
50 
51 #include <unistd.h>
52 
53 #include <TClass.h>
54 #include <TMessage.h>
55 
56 namespace art
57 {
58  class EventReporterOutput;
59 }
60 
61 
67 class art::EventReporterOutput : public OutputModule
68 {
69 public:
77  explicit EventReporterOutput(fhicl::ParameterSet const& ps);
78 
83 
84 private:
85  virtual void openFile(FileBlock const&);
86 
87  virtual void closeFile();
88 
89  virtual void respondToCloseInputFile(FileBlock const&);
90 
91  virtual void respondToCloseOutputFiles(FileBlock const&);
92 
93  virtual void endJob();
94 
95  virtual void write(EventPrincipal&);
96 
97  virtual void writeRun(RunPrincipal&);
98 
99  virtual void writeSubRun(SubRunPrincipal&);
100 
101 private:
102 
103 };
104 
106 EventReporterOutput(fhicl::ParameterSet const& ps)
107  : OutputModule(ps)
108 {
109  TLOG(TLVL_DEBUG) << "Begin: EventReporterOutput::EventReporterOutput(ParameterSet const& ps)";
110 }
111 
114 {
115  TLOG(TLVL_DEBUG) << "Begin: EventReporterOutput::~EventReporterOutput()";
116 }
117 
118 void
119 art::EventReporterOutput::
120 openFile(FileBlock const&)
121 {
122  TLOG(TLVL_DEBUG) << "Begin/End: EventReporterOutput::openFile(const FileBlock&)";
123 }
124 
125 void
126 art::EventReporterOutput::
127 closeFile()
128 {
129  TLOG(TLVL_DEBUG) << "Begin/End: EventReporterOutput::closeFile()";
130 }
131 
132 void
133 art::EventReporterOutput::
134 respondToCloseInputFile(FileBlock const&)
135 {
136  TLOG(TLVL_DEBUG) << "Begin/End: EventReporterOutput::respondToCloseOutputFiles(FileBlock const&)";
137 }
138 
139 void
140 art::EventReporterOutput::
141 respondToCloseOutputFiles(FileBlock const&)
142 {
143  TLOG(TLVL_DEBUG) << "Begin/End: EventReporterOutput::respondToCloseOutputFiles(FileBlock const&)";
144 }
145 
146 void
147 art::EventReporterOutput::
148 endJob()
149 {
150  TLOG(TLVL_DEBUG) << "Begin: EventReporterOutput::endJob()";
151 }
152 
153 
154 
155 void
156 art::EventReporterOutput::
157 write(EventPrincipal& ep)
158 {
159  TLOG(TLVL_DEBUG) << " Begin: EventReporterOutput::write(const EventPrincipal& ep)";
160 
161  using RawEvent = artdaq::Fragments;;
162  using RawEvents = std::vector<RawEvent>;
163  using RawEventHandle = art::Handle<RawEvent>;
164  using RawEventHandles = std::vector<RawEventHandle>;
165 
166  auto result_handles = std::vector<art::GroupQueryResult>();
167 
168 #if ART_HEX_VERSION < 0x20906
169  ep.getManyByType(art::TypeID(typeid(RawEvent)), result_handles);
170 #else
171  auto const& wrapped = art::WrappedTypeID::make<RawEvent>();
172  result_handles = ep.getMany(wrapped, art::MatchAllSelector{});
173 #endif
174 
175  for (auto const& result_handle : result_handles)
176  {
177  auto const raw_event_handle = RawEventHandle(result_handle);
178 
179  if (!raw_event_handle.isValid())
180  continue;
181 
182  for (auto const& fragment : *raw_event_handle){
183  TLOG(TLVL_DEBUG) << "EventReporterOutput::write: Event sequenceID=" << fragment.sequenceID() << ", fragmentID=" << fragment.fragmentID();
184  }
185  }
186 
187  return;
188 }
189 
190 void
191 art::EventReporterOutput::
192 writeRun(RunPrincipal& )
193 {
194  TLOG(TLVL_DEBUG) << " EventReporterOutput::writeRun(const RunPrincipal& rp)";
195 }
196 
197 void
198 art::EventReporterOutput::writeSubRun(SubRunPrincipal& )
199 {
200  TLOG(TLVL_DEBUG) << " EventReporterOutput:: writeSubRun(const SubRunPrincipal& srp)";
201 }
202 
203 DEFINE_ART_MODULE(art::EventReporterOutput)
204 
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.