1 #include "art/Framework/Core/ModuleMacros.h"
2 #include "art/Framework/Core/OutputModule.h"
3 #include "art/Framework/Principal/EventPrincipal.h"
4 #include "art/Framework/Principal/OutputHandle.h"
5 #include "art/Framework/Principal/RunPrincipal.h"
6 #include "art/Framework/Principal/SubRunPrincipal.h"
7 #include "art/Framework/Services/Registry/ServiceHandle.h"
8 #if ART_HEX_VERSION >= 0x20703
11 # include "art/Persistency/Provenance/BranchIDListHelper.h"
13 #include "art/Persistency/Provenance/BranchIDListRegistry.h"
14 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
15 #include "art/Persistency/Provenance/ProductMetaData.h"
17 #include "canvas/Persistency/Provenance/BranchDescription.h"
18 #include "canvas/Persistency/Provenance/BranchIDList.h"
19 #include "canvas/Persistency/Provenance/BranchKey.h"
20 #include "canvas/Persistency/Provenance/History.h"
21 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
22 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
23 #include "canvas/Persistency/Provenance/ProcessConfigurationID.h"
24 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
25 #include "canvas/Persistency/Provenance/ProductList.h"
26 #include "canvas/Persistency/Provenance/ProductProvenance.h"
27 #include "canvas/Persistency/Provenance/RunAuxiliary.h"
28 #include "canvas/Persistency/Provenance/SubRunAuxiliary.h"
29 #include "canvas/Utilities/DebugMacros.h"
30 #include "canvas/Utilities/Exception.h"
31 #include "cetlib/column_width.h"
32 #include "cetlib/lpad.h"
33 #include "cetlib/rpad.h"
35 #include "fhiclcpp/ParameterSet.h"
36 #include "fhiclcpp/ParameterSetID.h"
37 #include "fhiclcpp/ParameterSetRegistry.h"
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"
85 virtual void openFile(FileBlock
const&);
87 virtual void closeFile();
89 virtual void respondToCloseInputFile(FileBlock
const&);
91 virtual void respondToCloseOutputFiles(FileBlock
const&);
93 virtual void endJob();
95 virtual void write(EventPrincipal&);
97 virtual void writeRun(RunPrincipal&);
99 virtual void writeSubRun(SubRunPrincipal&);
101 void writeDataProducts(TBufferFile&,
const Principal&,
102 std::vector<BranchKey*>&);
106 std::unique_ptr<artdaq::TransferInterface> transfer_;
108 void sendMessage_(uint64_t sequenceId, uint8_t messageType, TBufferFile& msg);
109 void send_init_message();
116 , initMsgSent_(false)
118 TLOG_DEBUG(
"TransferOutput") <<
"Begin: TransferOutput::TransferOutput(ParameterSet const& ps)" << TLOG_ENDL;
120 TLOG_DEBUG(
"TransferOutput") <<
"END: TransferOutput::TransferOutput" << TLOG_ENDL;
126 TLOG_DEBUG(
"TransferOutput") <<
"Begin: TransferOutput::~TransferOutput()" << TLOG_ENDL;
128 auto sts = transfer_->moveFragment(std::move(*artdaq::Fragment::eodFrag(0)));
130 transfer_.reset(
nullptr);
134 art::TransferOutput::
135 openFile(FileBlock
const&)
137 TLOG_TRACE(
"TransferOutput") <<
"Begin/End: TransferOutput::openFile(const FileBlock&)" << TLOG_ENDL;
141 art::TransferOutput::
144 TLOG_TRACE(
"TransferOutput") <<
"Begin/End: TransferOutput::closeFile()" << TLOG_ENDL;
148 art::TransferOutput::
149 respondToCloseInputFile(FileBlock
const&)
151 TLOG_TRACE(
"TransferOutput") <<
"Begin/End: TransferOutput::" <<
152 "respondToCloseOutputFiles(FileBlock const&)" << TLOG_ENDL;
156 art::TransferOutput::
157 respondToCloseOutputFiles(FileBlock
const&)
159 TLOG_TRACE(
"TransferOutput") <<
"Begin/End: TransferOutput::" <<
160 "respondToCloseOutputFiles(FileBlock const&)" << TLOG_ENDL;
164 art::TransferOutput::
167 TLOG_TRACE(
"TransferOutput") <<
"Begin: TransferOutput::endJob()" << TLOG_ENDL;
173 art::TransferOutput::
176 TLOG_TRACE(
"TransferOutput") <<
"Begin: TransferOutput static send_init_message()" << TLOG_ENDL;
186 static TClass* product_list_class = TClass::GetClass(
187 "std::map<art::BranchKey,art::BranchDescription>");
188 if (product_list_class ==
nullptr)
190 throw art::Exception(art::errors::DictionaryNotFound) <<
191 "TransferOutput static send_init_message(): "
192 "Could not get TClass for "
193 "map<art::BranchKey,art::BranchDescription>!";
199 static TClass* process_history_map_class = TClass::GetClass(
200 "std::map<const art::Hash<2>,art::ProcessHistory>");
201 if (process_history_map_class ==
nullptr)
203 throw art::Exception(art::errors::DictionaryNotFound) <<
204 "TransferOutput static send_init_message(): "
205 "Could not get class for "
206 "std::map<const art::Hash<2>,art::ProcessHistory>!";
211 static TClass* parentage_map_class = TClass::GetClass(
"art::ParentageMap");
212 if (parentage_map_class ==
nullptr)
214 throw art::Exception(art::errors::DictionaryNotFound) <<
215 "TransferOutput static send_init_message(): "
216 "Could not get class for ParentageMap";
221 TBufferFile msg(TBuffer::kWrite);
226 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): "
227 "Streaming message type code ..." << TLOG_ENDL;
229 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): "
230 "Finished streaming message type code." << TLOG_ENDL;
235 unsigned long ps_cnt = fhicl::ParameterSetRegistry::size();
236 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): parameter set count: " << std::to_string(ps_cnt) << TLOG_ENDL;
237 msg.WriteULong(ps_cnt);
238 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): Streaming parameter sets ..." << TLOG_ENDL;
240 #
if ART_HEX_VERSION >= 0x20703
241 auto I = std::begin(fhicl::ParameterSetRegistry::get()),
242 E = std::end(fhicl::ParameterSetRegistry::get());
244 auto I = fhicl::ParameterSetRegistry::begin(),
245 E = fhicl::ParameterSetRegistry::end();
249 std::string pset_str = I->second.to_string();
251 msg.WriteStdString(pset_str);
253 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): Finished streaming parameter sets." << TLOG_ENDL;
258 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): Streaming MasterProductRegistry ..." << TLOG_ENDL;;
259 art::ProductList productList(art::ProductMetaData::instance().productList());
260 msg.WriteObjectAny(&productList, product_list_class);
261 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): Finished streaming MasterProductRegistry." << TLOG_ENDL;
266 if (art::debugit() >= 2)
271 # if ART_HEX_VERSION >= 0x20703
272 art::BranchIDLists
const * bilr =
273 &art::BranchIDListRegistry::instance().data();
275 art::BranchIDLists* bilr =
276 &art::BranchIDListRegistry::instance()->data();
278 TLOG_TRACE(
"TransferOutput") <<
"TransferOutput static send_init_message(): " <<
"Content of BranchIDLists" << TLOG_ENDL;
279 int max_bli = bilr->size();
280 TLOG_TRACE(
"TransferOutput") <<
"TransferOutput static send_init_message(): " <<
281 "max_bli: " << max_bli << TLOG_ENDL;
282 for (
int i = 0; i < max_bli; ++i)
284 int max_prdidx = (*bilr)[i].size();
285 TLOG_TRACE(
"TransferOutput") <<
"TransferOutput static send_init_message(): " <<
286 "max_prdidx: " << max_prdidx << TLOG_ENDL;
287 for (
int j = 0; j < max_prdidx; ++j)
289 TLOG_TRACE(
"TransferOutput") <<
"TransferOutput static send_init_message(): " <<
292 <<
" bid: 0x" << std::hex
293 <<
static_cast<unsigned long>((*bilr)[i][j])
294 << std::dec << TLOG_ENDL;
299 # if ART_HEX_VERSION >= 0x20703
300 art::ProcessHistoryMap phr;
301 for (
auto const& pr : art::ProcessHistoryRegistry::get())
309 if (art::debugit() >= 1)
311 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): "
312 "Dumping ProcessHistoryRegistry ..." << TLOG_ENDL;
315 # if ART_HEX_VERSION < 0x20703
316 art::ProcessHistoryMap
const& phr = art::ProcessHistoryRegistry::get();
318 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): " <<
319 "phr: size: " + std::to_string(phr.size()) << TLOG_ENDL;
320 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
322 std::ostringstream OS;
324 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): " <<
325 "phr: id: '" + OS.str() +
"'" << TLOG_ENDL;
332 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): " <<
333 "Streaming ProcessHistoryRegistry ..." << TLOG_ENDL;
336 # if ART_HEX_VERSION >= 0x20703
337 const art::ProcessHistoryMap& phm = phr;
339 const art::ProcessHistoryMap& phm = art::ProcessHistoryRegistry::get();
341 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): " <<
342 "phm: size: " << std::to_string(phm.size()) << TLOG_ENDL;
343 msg.WriteObjectAny(&phm, process_history_map_class);
344 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): " <<
345 "Finished streaming ProcessHistoryRegistry." << TLOG_ENDL;
351 TLOG_DEBUG(
"TransferOutput") <<
"TransferOutput static send_init_message(): " <<
352 "Streaming ParentageRegistry ... sz=" << std::to_string(msg.Length()) << TLOG_ENDL;
354 # if ART_HEX_VERSION >= 0x20703
355 art::ParentageMap parentageMap{};
356 for (
auto const& pr : art::ParentageRegistry::get())
358 parentageMap.emplace(pr.first, pr.second);
361 const art::ParentageMap& parentageMap = art::ParentageRegistry::get();
364 TLOG_TRACE(
"TransferOutput") <<
"Before WriteObjectAny ParentageMap" << TLOG_ENDL;
368 msg.WriteObjectAny(&parentageMap, parentage_map_class);
369 TLOG_TRACE(
"RootMPIOuptut") <<
"After WriteObjectAny ParentageMap" << TLOG_ENDL;
371 TLOG_DEBUG(
"TransferOutput") <<
"TransferOutput: TransferOutput static send_init_message(): " <<
372 "Finished streaming ParentageRegistry." <<
" sts=" << sts <<
", sz=" << std::to_string(msg.Length()) << TLOG_ENDL;
379 TLOG_DEBUG(
"TransferOutput") <<
"TransferOutput: TransferOutput static send_init_message(): " <<
"Sending the init message." << TLOG_ENDL;
380 sendMessage_(artdaq::Fragment::InvalidSequenceID - 1, artdaq::Fragment::InitFragmentType, msg);
381 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput static send_init_message(): "
382 "Init message(s) sent." << TLOG_ENDL;
384 TLOG_TRACE(
"TransferOutput") <<
" End: TransferOutput static send_init_message()" << TLOG_ENDL;
387 #//pragma GCC pop_options
390 art::TransferOutput::
391 writeDataProducts(TBufferFile& msg,
const Principal& principal,
392 std::vector<BranchKey*>& bkv)
394 TLOG_TRACE(
"TransferOutput") <<
" Begin: TransferOutput::writeDataProducts(...)" << TLOG_ENDL;
399 static TClass* branch_key_class = TClass::GetClass(
"art::BranchKey");
400 if (branch_key_class ==
nullptr)
402 throw art::Exception(art::errors::DictionaryNotFound) <<
403 "TransferOutput::writeDataProducts(...): "
404 "Could not get TClass for art::BranchKey!";
406 static TClass* prdprov_class = TClass::GetClass(
"art::ProductProvenance");
407 if (prdprov_class ==
nullptr)
409 throw art::Exception(art::errors::DictionaryNotFound) <<
410 "TransferOutput::writeDataProducts(...): "
411 "Could not get TClass for art::ProductProvenance!";
416 unsigned long prd_cnt = 0;
418 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
420 if (I->second->productUnavailable() || !selected(I->second->productDescription()))
430 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeDataProducts(...): "
431 "Streaming product count: " << std::to_string(prd_cnt) << TLOG_ENDL;
432 msg.WriteULong(prd_cnt);
433 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeDataProducts(...): "
434 "Finished streaming product count." << TLOG_ENDL;
446 bkv.reserve(prd_cnt);
448 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
450 if (I->second->productUnavailable() || !selected(I->second->productDescription()))
454 const BranchDescription& bd(I->second->productDescription());
455 bkv.push_back(
new BranchKey(bd));
456 if (art::debugit() >= 2)
458 TLOG_TRACE(
"TransferOutput") <<
"TransferOutput::writeDataProducts(...): "
459 "Dumping branch key of class: '"
460 << bkv.back()->friendlyClassName_
462 << bkv.back()->moduleLabel_
464 << bkv.back()->productInstanceName_
466 << bkv.back()->processName_
470 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeDataProducts(...): "
471 "Streaming branch key of class: '"
472 + bd.producedClassName()
476 + bd.productInstanceName()
480 msg.WriteObjectAny(bkv.back(), branch_key_class);
483 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeDataProducts(...): "
484 "Streaming product of class: '"
485 + bd.producedClassName()
489 + bd.productInstanceName()
493 OutputHandle oh = principal.getForOutput(bd.branchID(),
true);
494 const EDProduct* prd = oh.wrapper();
495 msg.WriteObjectAny(prd, TClass::GetClass(bd.wrappedName().c_str()));
498 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeDataProducts(...): "
499 "Streaming product provenance of class: '"
500 + bd.producedClassName()
504 + bd.productInstanceName()
508 const ProductProvenance* prdprov =
509 I->second->productProvenancePtr().get();
510 msg.WriteObjectAny(prdprov, prdprov_class);
513 TLOG_TRACE(
"TransferOutput") <<
" End: TransferOutput::writeDataProducts(...)" << TLOG_ENDL;
517 art::TransferOutput::
518 write(EventPrincipal& ep)
523 TLOG_TRACE(
"TransferOutput") <<
" Begin: TransferOutput::"
524 "write(const EventPrincipal& ep)" << TLOG_ENDL;
533 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
534 if (run_aux_class ==
nullptr)
536 throw art::Exception(art::errors::DictionaryNotFound) <<
537 "TransferOutput::write(const EventPrincipal& ep): "
538 "Could not get TClass for art::RunAuxiliary!";
540 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
541 if (subrun_aux_class ==
nullptr)
543 throw art::Exception(art::errors::DictionaryNotFound) <<
544 "TransferOutput::write(const EventPrincipal& ep): "
545 "Could not get TClass for art::SubRunAuxiliary!";
547 static TClass* event_aux_class = TClass::GetClass(
"art::EventAuxiliary");
548 if (event_aux_class ==
nullptr)
550 throw art::Exception(art::errors::DictionaryNotFound) <<
551 "TransferOutput::write(const EventPrincipal& ep): "
552 "Could not get TClass for art::EventAuxiliary!";
554 static TClass* history_class = TClass::GetClass(
"art::History");
555 if (history_class ==
nullptr)
557 throw art::Exception(art::errors::DictionaryNotFound) <<
558 "TransferOutput::write(const EventPrincipal& ep): "
559 "Could not get TClass for art::History!";
564 TBufferFile msg(TBuffer::kWrite);
570 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
571 "Streaming message type code ..." << TLOG_ENDL;
573 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
574 "Finished streaming message type code." << TLOG_ENDL;
580 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
581 "Streaming RunAuxiliary ..." << TLOG_ENDL;
582 msg.WriteObjectAny(&ep.subRunPrincipal().runPrincipal().aux(),
584 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
585 "Finished streaming RunAuxiliary." << TLOG_ENDL;
591 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
592 "Streaming SubRunAuxiliary ..." << TLOG_ENDL;
593 msg.WriteObjectAny(&ep.subRunPrincipal().aux(),
595 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
596 "Finished streaming SubRunAuxiliary." << TLOG_ENDL;
602 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
603 "Streaming EventAuxiliary ..." << TLOG_ENDL;
604 msg.WriteObjectAny(&ep.aux(), event_aux_class);
605 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
606 "Finished streaming EventAuxiliary." << TLOG_ENDL;
612 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
613 "Streaming History ..." << TLOG_ENDL;
614 msg.WriteObjectAny(&ep.history(), history_class);
615 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
616 "Finished streaming History." << TLOG_ENDL;
621 std::vector<BranchKey*> bkv;
622 writeDataProducts(msg, ep, bkv);
627 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
628 "Sending a message ..." << TLOG_ENDL;
629 sendMessage_(ep.id().event(), artdaq::Fragment::DataFragmentType, msg);
630 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::write(const EventPrincipal& ep): "
631 "Message sent." << TLOG_ENDL;
636 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
641 TLOG_TRACE(
"TransferOutput") <<
" End: TransferOutput::write(const EventPrincipal& ep)" << TLOG_ENDL;
645 art::TransferOutput::
646 writeRun(RunPrincipal& rp)
651 TLOG_TRACE(
"TransferOutput") <<
" Begin: TransferOutput::writeRun(const RunPrincipal& rp)" << TLOG_ENDL;
663 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
664 assert(run_aux_class !=
nullptr &&
"writeRun: Could not get TClass for "
665 "art::RunAuxiliary!");
669 TBufferFile msg(TBuffer::kWrite);
675 TLOG_TRACE(
"TransferOutput") <<
" writeRun: streaming message type code ...");
677 TLOG_TRACE(
"TransferOutput") <<
" writeRun: finished streaming message type code.");
683 TLOG_TRACE(
"TransferOutput") <<
" writeRun: streaming RunAuxiliary ...");
684 if (art::debugit() >= 1)
686 TLOG_TRACE(
"TransferOutput") <<
" writeRun: dumping ProcessHistoryRegistry ...");
689 art::ProcessHistoryMap
const& phr =
690 art::ProcessHistoryRegistry::get();
691 TLOG_TRACE(
"TransferOutput") <<
" writeRun: phr: size: " << phr.size() <<
'\n';
692 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
694 std::ostringstream OS;
696 TLOG_TRACE(
"TransferOutput") <<
" writeRun: phr: id: '" << OS.str() <<
"'");
698 TLOG_TRACE(
"TransferOutput") <<
" writeRun: phr: data.size(): "
699 << I->second.data().size() <<
'\n';
700 if (I->second.data().size())
702 I->second.data().back().id().print(OS);
703 TLOG_TRACE(
"TransferOutput") <<
" writeRun: phr: data.back().id(): '"
707 if (!rp.aux().processHistoryID().isValid())
709 TLOG_TRACE(
"TransferOutput") <<
" writeRun: ProcessHistoryID: 'INVALID'");
713 std::ostringstream OS;
714 rp.aux().processHistoryID().print(OS);
715 TLOG_TRACE(
"TransferOutput") <<
" writeRun: ProcessHistoryID: '"
718 const ProcessHistory& processHistory =
719 ProcessHistoryRegistry::get(rp.aux().processHistoryID());
720 if (processHistory.data().size())
723 processHistory.data().back().id().print(OS);
724 TLOG_TRACE(
"TransferOutput") <<
" writeRun: ProcessConfigurationID: '"
727 TLOG_TRACE(
"TransferOutput") <<
" writeRun: ProcessConfiguration: '"
728 << processHistory.data().back() <<
'\n';
732 msg.WriteObjectAny(&rp.aux(), run_aux_class);
733 TLOG_TRACE(
"TransferOutput") <<
" writeRun: streamed RunAuxiliary.");
738 std::vector<BranchKey*> bkv;
739 writeDataProducts(msg, rp, bkv);
744 TLOG_TRACE(
"TransferOutput") <<
" writeRun: sending a message ...");
745 sendMessage_(0, artdaq::Fragment::EndOfRunFragmentType, msg);
746 TLOG_TRACE(
"TransferOutput") <<
" writeRun: message sent.");
751 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
757 TLOG_TRACE(
"TransferOutput") <<
" End: TransferOutput::writeRun(const RunPrincipal& rp)" << TLOG_ENDL;
761 art::TransferOutput::writeSubRun(SubRunPrincipal& srp)
766 TLOG_TRACE(
"TransferOutput") <<
" Begin: TransferOutput::"
767 "writeSubRun(const SubRunPrincipal& srp)" << TLOG_ENDL;
777 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
778 if (subrun_aux_class ==
nullptr)
780 throw art::Exception(art::errors::DictionaryNotFound) <<
781 "TransferOutput::writeSubRun: "
782 "Could not get TClass for art::SubRunAuxiliary!";
787 TBufferFile msg(TBuffer::kWrite);
793 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
794 "streaming message type code ..." << TLOG_ENDL;
796 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
797 "finished streaming message type code." << TLOG_ENDL;
803 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
804 "streaming SubRunAuxiliary ..." << TLOG_ENDL;
805 if (art::debugit() >= 1)
807 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
808 "dumping ProcessHistoryRegistry ..." << TLOG_ENDL;
811 # if ART_HEX_VERSION >= 0x20703
812 for (
auto I = std::begin(art::ProcessHistoryRegistry::get())
813 , E = std::end(art::ProcessHistoryRegistry::get()); I != E; ++I)
815 art::ProcessHistoryMap
const& phr =
816 art::ProcessHistoryRegistry::get();
817 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
818 "phr: size: " << std::to_string(phr.size()) << TLOG_ENDL;
819 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
822 std::ostringstream OS;
824 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
825 "phr: id: '" + OS.str() +
"'" << TLOG_ENDL;
827 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
828 "phr: data.size(): " << std::to_string(I->second.data().size()) << TLOG_ENDL;
829 if (I->second.data().size())
831 I->second.data().back().id().print(OS);
832 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
833 "phr: data.back().id(): '"
834 + OS.str() +
"'" << TLOG_ENDL;
837 if (!srp.aux().processHistoryID().isValid())
839 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
840 "ProcessHistoryID: 'INVALID'" << TLOG_ENDL;;
844 std::ostringstream OS;
845 srp.aux().processHistoryID().print(OS);
846 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: ProcessHistoryID: '"
847 + OS.str() +
"'" << TLOG_ENDL;
849 # if ART_HEX_VERSION >= 0x20703
850 ProcessHistory processHistory;
851 ProcessHistoryRegistry::get(srp.aux().processHistoryID(), processHistory);
853 const ProcessHistory& processHistory =
854 ProcessHistoryRegistry::get(srp.aux().processHistoryID());
856 if (processHistory.data().size())
859 processHistory.data().back().id().print(OS);
860 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
861 "ProcessConfigurationID: '"
862 + OS.str() +
"'" << TLOG_ENDL;
864 OS << processHistory.data().back();
865 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
866 "ProcessConfiguration: '"
867 + OS.str() << TLOG_ENDL;
871 msg.WriteObjectAny(&srp.aux(), subrun_aux_class);
872 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: streamed SubRunAuxiliary." << TLOG_ENDL;
877 std::vector<BranchKey*> bkv;
878 writeDataProducts(msg, srp, bkv);
883 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
884 "Sending the EndOfSubrun message." << TLOG_ENDL;
885 sendMessage_(0, artdaq::Fragment::EndOfSubrunFragmentType, msg);
886 TLOG_TRACE(
"TransferOutput") <<
" TransferOutput::writeSubRun: "
887 "EndOfSubrun message(s) sent." << TLOG_ENDL;
893 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
898 TLOG_TRACE(
"TransferOutput") <<
" End: TransferOutput::writeSubRun(const SubRunPrincipal& srp)" << TLOG_ENDL;
903 art::TransferOutput::sendMessage_(uint64_t sequenceId, uint8_t messageType, TBufferFile& msg)
905 TLOG_DEBUG(
"TransferOutput") <<
"Sending message with sequenceID=" << std::to_string(sequenceId) <<
", type=" << std::to_string(messageType) <<
", length=" << std::to_string(msg.Length()) << TLOG_ENDL;
907 header.
data_length =
static_cast<uint64_t
>(msg.Length());
909 fragment(std::ceil(msg.Length() /
910 static_cast<double>(
sizeof(artdaq::RawDataType))),
911 sequenceId, 0, messageType, header);
913 memcpy(&*fragment.dataBegin(), msg.Buffer(), msg.Length());
917 sts = transfer_->copyFragment(fragment);
921 if (messageType == artdaq::Fragment::InitFragmentType)
923 std::fstream ostream(
"sendInitMessage_TransferOutput.bin", std::ios::out | std::ios::binary);
924 ostream.write(msg.Buffer(), msg.Length());
~TransferOutput()
TransferOutput Destructor.
std::unique_ptr< artdaq::TransferInterface > MakeTransferPlugin(const fhicl::ParameterSet &pset, std::string plugin_label, TransferInterface::Role role)
Load a TransferInterface plugin.
TransferOutput(fhicl::ParameterSet const &ps)
TransferOutput Constructor.
An art::OutputModule which sends events using DataSenderManager. This module is designed for transpor...
This TransferInterface is a Sender.
Some error occurred, but no exception was thrown.
The send operation completed successfully.