LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
OutputWorker.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
11 
12 namespace art {
13 
14  OutputWorker::~OutputWorker() = default;
15 
16  // This is called directly by the make_worker function created
17  // by the DEFINE_ART_MODULE macro.
19  : Worker{module->moduleDescription(), wp}
20  , module_{module}
21  , actReg_{wp.actReg_}
22  {
23  if (wp.scheduleID_ == ScheduleID::first()) {
24  // We only want to register the products (and any shared
25  // resources) once, not once for every schedule)
26  module_->registerProducts(wp.producedProducts_);
27  wp.resources_.registerSharedResources(module_->sharedResources());
28  }
29  ci_->outputModuleInitiated(
30  label(),
31  fhicl::ParameterSetRegistry::get(description().parameterSetID()));
32  }
33 
34  hep::concurrency::SerialTaskQueueChain*
36  {
37  return module_->serialTaskQueueChain();
38  }
39 
40  void
42  {
43  module_->doBeginJob(resources);
44  }
45 
46  void
48  {
49  module_->doEndJob();
50  }
51 
52  void
54  {
55  module_->doRespondToOpenInputFile(fb);
56  }
57 
58  void
60  {
61  module_->doRespondToCloseInputFile(fb);
62  }
63 
64  void
66  {
67  module_->doRespondToOpenOutputFiles(fb);
68  }
69 
70  void
72  {
73  module_->doRespondToCloseOutputFiles(fb);
74  }
75 
76  void
78  {
79  module_->doBeginRun(rp, mc);
80  }
81 
82  void
84  {
85  module_->doEndRun(rp, mc);
86  }
87 
88  void
90  {
91  module_->doBeginSubRun(srp, mc);
92  }
93 
94  void
96  {
97  module_->doEndSubRun(srp, mc);
98  }
99 
100  bool
102  {
103  // Note, only filters ever return false, and when they do it means
104  // they have rejected.
105  return module_->doEvent(
107  }
108 
109  std::string const&
111  {
112  return module_->lastClosedFileName();
113  }
114 
115  void
117  {
119  if (module_->doCloseFile()) {
120  ci_->outputFileClosed(label(), lastClosedFileName());
121  }
124  }
125 
126  void
128  {
129  return module_->incrementInputFileNumber();
130  }
131 
132  bool
134  {
135  return module_->requestsToCloseFile();
136  }
137 
138  void
140  {
141  if (module_->doOpenFile(fb)) {
142  ci_->outputFileOpened(label());
144  }
145  }
146 
147  void
149  {
150  module_->doWriteRun(rp);
151  }
152 
153  void
155  {
156  module_->doWriteSubRun(srp);
157  }
158 
159  void
161  {
162  ModuleContext const mc{pc, description()};
163  actReg_.sPreWriteEvent.invoke(mc);
164  module_->doWriteEvent(ep, mc);
165  actReg_.sPostWriteEvent.invoke(mc);
166  }
167 
168  void
170  {
171  module_->doSetRunAuxiliaryRangeSetID(rs);
172  }
173 
174  void
176  {
177  module_->doSetSubRunAuxiliaryRangeSetID(rs);
178  }
179 
180  bool
182  {
183  return module_->fileIsOpen();
184  }
185 
186  void
188  {
189  return module_->setFileStatus(ofs);
190  }
191 
192  void
194  {
195  module_->selectProducts(tables);
196  }
197 
200  {
201  return module_->fileGranularity();
202  }
203 
204 } // namespace art
bool doProcess(EventPrincipal &, ModuleContext const &) override
void setRunAuxiliaryRangeSetID(RangeSet const &)
void doRespondToOpenInputFile(FileBlock const &) override
Definition: OutputWorker.cc:53
void doRespondToCloseOutputFiles(FileBlock const &) override
Definition: OutputWorker.cc:71
GlobalSignal< detail::SignalResponseType::LIFO, void(std::string const &)> sPostOpenOutputFile
void openFile(FileBlock const &fb)
static collection_type const & get() noexcept
std::string const & label() const
Definition: Worker.cc:127
std::string const & lastClosedFileName() const
void selectProducts(ProductTables const &)
static constexpr ScheduleID first()
Definition: ScheduleID.h:50
virtual ~OutputWorker()
void setFileStatus(OutputFileStatus)
bool fileIsOpen() const
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleContext const &)> sPreWriteEvent
OutputFileStatus
void setSubRunAuxiliaryRangeSetID(RangeSet const &)
hep::concurrency::SerialTaskQueueChain * doSerialTaskQueueChain() const override
Definition: OutputWorker.cc:35
void doBegin(RunPrincipal &, ModuleContext const &) override
Definition: OutputWorker.cc:77
cet::exempt_ptr< OutputModule > module_
Definition: OutputWorker.h:63
ActivityRegistry const & actReg_
Definition: OutputWorker.h:65
void doBeginJob(detail::SharedResources const &) override
Definition: OutputWorker.cc:41
void doEndJob() override
Definition: OutputWorker.cc:47
bool requestsToCloseFile() const
void doEnd(RunPrincipal &, ModuleContext const &) override
Definition: OutputWorker.cc:83
TFile fb("Li6.root")
std::atomic< std::size_t > counts_run_
Definition: Worker.h:99
ModuleDescription const & description() const
Definition: Worker.cc:121
std::atomic< std::size_t > counts_passed_
Definition: Worker.h:100
std::atomic< std::size_t > counts_failed_
Definition: Worker.h:101
GlobalSignal< detail::SignalResponseType::FIFO, void(std::string const &)> sPreCloseOutputFile
GlobalSignal< detail::SignalResponseType::LIFO, void(OutputFileInfo const &)> sPostCloseOutputFile
Definition: MVAAlg.h:12
void incrementInputFileNumber()
OutputWorker(OutputModule *mod, WorkerParams const &)
Definition: OutputWorker.cc:18
void doRespondToCloseInputFile(FileBlock const &) override
Definition: OutputWorker.cc:59
void doRespondToOpenOutputFiles(FileBlock const &) override
Definition: OutputWorker.cc:65
void writeEvent(EventPrincipal &ep, PathContext const &pc)
void writeSubRun(SubRunPrincipal &srp)
ServiceHandle< CatalogInterface > ci_
Definition: OutputWorker.h:64
GlobalSignal< detail::SignalResponseType::LIFO, void(ModuleContext const &)> sPostWriteEvent
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void writeRun(RunPrincipal &rp)
Granularity fileGranularity() const