1 #define TRACE_NAME "TransferOutput"
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 >= 0x20703
13 # include "art/Persistency/Provenance/BranchIDListHelper.h"
15 #if ART_HEX_VERSION < 0x20900
16 #include "art/Persistency/Provenance/BranchIDListRegistry.h"
17 #include "canvas/Persistency/Provenance/BranchIDList.h"
19 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
20 #include "art/Persistency/Provenance/ProductMetaData.h"
22 #include "canvas/Persistency/Provenance/BranchDescription.h"
23 #include "canvas/Persistency/Provenance/BranchKey.h"
24 #include "canvas/Persistency/Provenance/History.h"
25 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
26 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
27 #include "canvas/Persistency/Provenance/ProcessConfigurationID.h"
28 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
29 #include "canvas/Persistency/Provenance/ProductList.h"
30 #include "canvas/Persistency/Provenance/ProductProvenance.h"
31 #include "canvas/Persistency/Provenance/RunAuxiliary.h"
32 #include "canvas/Persistency/Provenance/SubRunAuxiliary.h"
33 #include "canvas/Utilities/DebugMacros.h"
34 #include "canvas/Utilities/Exception.h"
35 #include "cetlib/column_width.h"
36 #include "cetlib/lpad.h"
37 #include "cetlib/rpad.h"
39 #include "fhiclcpp/ParameterSet.h"
40 #include "fhiclcpp/ParameterSetID.h"
41 #include "fhiclcpp/ParameterSetRegistry.h"
43 #include "artdaq/TransferPlugins/TransferInterface.hh"
44 #include "artdaq/TransferPlugins/MakeTransferPlugin.hh"
45 #include "artdaq-core/Data/detail/ParentageMap.hh"
46 #include "artdaq/DAQdata/Globals.hh"
47 #include "artdaq/DAQdata/NetMonHeader.hh"
89 virtual void openFile(FileBlock
const&);
91 virtual void closeFile();
93 virtual void respondToCloseInputFile(FileBlock
const&);
95 virtual void respondToCloseOutputFiles(FileBlock
const&);
97 virtual void endJob();
99 virtual void write(EventPrincipal&);
101 virtual void writeRun(RunPrincipal&);
103 virtual void writeSubRun(SubRunPrincipal&);
105 void writeDataProducts(TBufferFile&,
const Principal&,
106 std::vector<BranchKey*>&);
110 size_t send_timeout_us_;
111 size_t send_retry_count_;
112 std::unique_ptr<artdaq::TransferInterface> transfer_;
114 void sendMessage_(uint64_t sequenceId, uint8_t messageType, TBufferFile& msg);
115 void send_init_message();
122 , initMsgSent_(false)
123 , send_timeout_us_(ps.get<size_t>(
"send_timeout_us", 5000000))
124 , send_retry_count_(ps.get<size_t>(
"send_retry_count", 5))
126 TLOG(TLVL_DEBUG) <<
"Begin: TransferOutput::TransferOutput(ParameterSet const& ps)" ;
128 TLOG(TLVL_DEBUG) <<
"END: TransferOutput::TransferOutput" ;
134 TLOG(TLVL_DEBUG) <<
"Begin: TransferOutput::~TransferOutput()" ;
136 auto sts = transfer_->moveFragment(std::move(*artdaq::Fragment::eodFrag(0)));
138 transfer_.reset(
nullptr);
139 TLOG(TLVL_DEBUG) <<
"End: TransferOutput::~TransferOutput()";
143 art::TransferOutput::
144 openFile(FileBlock
const&)
146 TLOG(TLVL_TRACE) <<
"Begin/End: TransferOutput::openFile(const FileBlock&)" ;
150 art::TransferOutput::
153 TLOG(TLVL_TRACE) <<
"Begin/End: TransferOutput::closeFile()" ;
157 art::TransferOutput::
158 respondToCloseInputFile(FileBlock
const&)
160 TLOG(TLVL_TRACE) <<
"Begin/End: TransferOutput::" <<
161 "respondToCloseOutputFiles(FileBlock const&)" ;
165 art::TransferOutput::
166 respondToCloseOutputFiles(FileBlock
const&)
168 TLOG(TLVL_TRACE) <<
"Begin/End: TransferOutput::" <<
169 "respondToCloseOutputFiles(FileBlock const&)" ;
173 art::TransferOutput::
176 TLOG(TLVL_TRACE) <<
"Begin: TransferOutput::endJob()" ;
182 art::TransferOutput::
185 TLOG(TLVL_TRACE) <<
"Begin: TransferOutput static send_init_message()" ;
195 static TClass* product_list_class = TClass::GetClass(
196 "std::map<art::BranchKey,art::BranchDescription>");
197 if (product_list_class ==
nullptr)
199 throw art::Exception(art::errors::DictionaryNotFound) <<
200 "TransferOutput static send_init_message(): "
201 "Could not get TClass for "
202 "map<art::BranchKey,art::BranchDescription>!";
208 static TClass* process_history_map_class = TClass::GetClass(
209 "std::map<const art::Hash<2>,art::ProcessHistory>");
210 if (process_history_map_class ==
nullptr)
212 throw art::Exception(art::errors::DictionaryNotFound) <<
213 "TransferOutput static send_init_message(): "
214 "Could not get class for "
215 "std::map<const art::Hash<2>,art::ProcessHistory>!";
220 static TClass* parentage_map_class = TClass::GetClass(
"art::ParentageMap");
221 if (parentage_map_class ==
nullptr)
223 throw art::Exception(art::errors::DictionaryNotFound) <<
224 "TransferOutput static send_init_message(): "
225 "Could not get class for ParentageMap";
230 TBufferFile msg(TBuffer::kWrite);
235 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): "
236 "Streaming message type code ..." ;
238 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): "
239 "Finished streaming message type code." ;
244 unsigned long ps_cnt = fhicl::ParameterSetRegistry::size();
245 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): parameter set count: " << std::to_string(ps_cnt) ;
246 msg.WriteULong(ps_cnt);
247 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): Streaming parameter sets ..." ;
249 #
if ART_HEX_VERSION >= 0x20703
250 auto I = std::begin(fhicl::ParameterSetRegistry::get()),
251 E = std::end(fhicl::ParameterSetRegistry::get());
253 auto I = fhicl::ParameterSetRegistry::begin(),
254 E = fhicl::ParameterSetRegistry::end();
258 std::string pset_str = I->second.to_string();
260 msg.WriteStdString(pset_str);
262 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): Finished streaming parameter sets." ;
267 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): Streaming MasterProductRegistry ..." ;;
268 art::ProductList productList(art::ProductMetaData::instance().productList());
269 msg.WriteObjectAny(&productList, product_list_class);
270 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): Finished streaming MasterProductRegistry." ;
272 #if ART_HEX_VERSION < 0x20900
276 if (art::debugit() >= 2)
281 # if ART_HEX_VERSION >= 0x20703
282 art::BranchIDLists
const * bilr =
283 &art::BranchIDListRegistry::instance().data();
285 art::BranchIDLists* bilr =
286 &art::BranchIDListRegistry::instance()->data();
288 TLOG(TLVL_TRACE) <<
"TransferOutput static send_init_message(): " <<
"Content of BranchIDLists" ;
289 int max_bli = bilr->size();
290 TLOG(TLVL_TRACE) <<
"TransferOutput static send_init_message(): " <<
291 "max_bli: " << max_bli ;
292 for (
int i = 0; i < max_bli; ++i)
294 int max_prdidx = (*bilr)[i].size();
295 TLOG(TLVL_TRACE) <<
"TransferOutput static send_init_message(): " <<
296 "max_prdidx: " << max_prdidx ;
297 for (
int j = 0; j < max_prdidx; ++j)
299 TLOG(TLVL_TRACE) <<
"TransferOutput static send_init_message(): " <<
302 <<
" bid: 0x" << std::hex
303 <<
static_cast<unsigned long>((*bilr)[i][j])
310 # if ART_HEX_VERSION >= 0x20703
311 art::ProcessHistoryMap phr;
312 for (
auto const& pr : art::ProcessHistoryRegistry::get())
320 if (art::debugit() >= 1)
322 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): "
323 "Dumping ProcessHistoryRegistry ..." ;
326 # if ART_HEX_VERSION < 0x20703
327 art::ProcessHistoryMap
const& phr = art::ProcessHistoryRegistry::get();
329 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): " <<
330 "phr: size: " + std::to_string(phr.size()) ;
331 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
333 std::ostringstream OS;
335 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): " <<
336 "phr: id: '" + OS.str() +
"'" ;
343 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): " <<
344 "Streaming ProcessHistoryRegistry ..." ;
347 # if ART_HEX_VERSION >= 0x20703
348 const art::ProcessHistoryMap& phm = phr;
350 const art::ProcessHistoryMap& phm = art::ProcessHistoryRegistry::get();
352 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): " <<
353 "phm: size: " << std::to_string(phm.size()) ;
354 msg.WriteObjectAny(&phm, process_history_map_class);
355 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): " <<
356 "Finished streaming ProcessHistoryRegistry." ;
362 TLOG(TLVL_DEBUG) <<
"TransferOutput static send_init_message(): " <<
363 "Streaming ParentageRegistry ... sz=" << std::to_string(msg.Length()) ;
365 # if ART_HEX_VERSION >= 0x20703
366 art::ParentageMap parentageMap{};
367 for (
auto const& pr : art::ParentageRegistry::get())
369 parentageMap.emplace(pr.first, pr.second);
372 const art::ParentageMap& parentageMap = art::ParentageRegistry::get();
375 TLOG(TLVL_TRACE) <<
"Before WriteObjectAny ParentageMap" ;
379 msg.WriteObjectAny(&parentageMap, parentage_map_class);
380 TLOG(TLVL_TRACE) <<
"After WriteObjectAny ParentageMap" ;
382 TLOG(TLVL_DEBUG) <<
"TransferOutput: TransferOutput static send_init_message(): " <<
383 "Finished streaming ParentageRegistry." <<
" sts=" << sts <<
", sz=" << std::to_string(msg.Length()) ;
390 TLOG(TLVL_DEBUG) <<
"TransferOutput: TransferOutput static send_init_message(): " <<
"Sending the init message." ;
391 sendMessage_(artdaq::Fragment::InvalidSequenceID - 1, artdaq::Fragment::InitFragmentType, msg);
392 TLOG(TLVL_TRACE) <<
" TransferOutput static send_init_message(): "
393 "Init message(s) sent." ;
395 TLOG(TLVL_TRACE) <<
" End: TransferOutput static send_init_message()" ;
398 #//pragma GCC pop_options
401 art::TransferOutput::
402 writeDataProducts(TBufferFile& msg,
const Principal& principal,
403 std::vector<BranchKey*>& bkv)
405 TLOG(TLVL_TRACE) <<
" Begin: TransferOutput::writeDataProducts(...)" ;
410 static TClass* branch_key_class = TClass::GetClass(
"art::BranchKey");
411 if (branch_key_class ==
nullptr)
413 throw art::Exception(art::errors::DictionaryNotFound) <<
414 "TransferOutput::writeDataProducts(...): "
415 "Could not get TClass for art::BranchKey!";
417 static TClass* prdprov_class = TClass::GetClass(
"art::ProductProvenance");
418 if (prdprov_class ==
nullptr)
420 throw art::Exception(art::errors::DictionaryNotFound) <<
421 "TransferOutput::writeDataProducts(...): "
422 "Could not get TClass for art::ProductProvenance!";
427 unsigned long prd_cnt = 0;
429 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
431 #if ART_HEX_VERSION > 0x20800
432 auto const& productDescription = I->second->productDescription();
433 auto const& refs = keptProducts()[productDescription.branchType()];
435 for (
auto const& ref : refs)
437 if (*ref == productDescription) {
442 if (I->second->productUnavailable() || !found)
447 if (I->second->productUnavailable() || !selected(I->second->productDescription()))
459 TLOG(TLVL_TRACE) <<
" TransferOutput::writeDataProducts(...): "
460 "Streaming product count: " << std::to_string(prd_cnt) ;
461 msg.WriteULong(prd_cnt);
462 TLOG(TLVL_TRACE) <<
" TransferOutput::writeDataProducts(...): "
463 "Finished streaming product count." ;
475 bkv.reserve(prd_cnt);
477 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
479 #if ART_HEX_VERSION > 0x20800
480 auto const& productDescription = I->second->productDescription();
481 auto const& refs = keptProducts()[productDescription.branchType()];
483 for (
auto const& ref : refs)
485 if (*ref == productDescription) {
490 if (I->second->productUnavailable() || !found)
495 if (I->second->productUnavailable() || !selected(I->second->productDescription()))
501 const BranchDescription& bd(I->second->productDescription());
502 bkv.push_back(
new BranchKey(bd));
503 if (art::debugit() >= 2)
505 TLOG(TLVL_TRACE) <<
"TransferOutput::writeDataProducts(...): "
506 "Dumping branch key of class: '"
507 << bkv.back()->friendlyClassName_
509 << bkv.back()->moduleLabel_
511 << bkv.back()->productInstanceName_
513 << bkv.back()->processName_
517 TLOG(TLVL_TRACE) <<
" TransferOutput::writeDataProducts(...): "
518 "Streaming branch key of class: '"
519 + bd.producedClassName()
523 + bd.productInstanceName()
527 msg.WriteObjectAny(bkv.back(), branch_key_class);
530 TLOG(TLVL_TRACE) <<
" TransferOutput::writeDataProducts(...): "
531 "Streaming product of class: '"
532 + bd.producedClassName()
536 + bd.productInstanceName()
540 #if ART_HEX_VERSION > 0x20800
541 OutputHandle oh = principal.getForOutput(bd.productID(),
true);
543 OutputHandle oh = principal.getForOutput(bd.branchID(),
true);
545 const EDProduct* prd = oh.wrapper();
546 msg.WriteObjectAny(prd, TClass::GetClass(bd.wrappedName().c_str()));
549 TLOG(TLVL_TRACE) <<
" TransferOutput::writeDataProducts(...): "
550 "Streaming product provenance of class: '"
551 + bd.producedClassName()
555 + bd.productInstanceName()
559 const ProductProvenance* prdprov =
560 I->second->productProvenancePtr().get();
561 msg.WriteObjectAny(prdprov, prdprov_class);
564 TLOG(TLVL_TRACE) <<
" End: TransferOutput::writeDataProducts(...)" ;
568 art::TransferOutput::
569 write(EventPrincipal& ep)
574 TLOG(TLVL_TRACE) <<
" Begin: TransferOutput::"
575 "write(const EventPrincipal& ep)" ;
584 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
585 if (run_aux_class ==
nullptr)
587 throw art::Exception(art::errors::DictionaryNotFound) <<
588 "TransferOutput::write(const EventPrincipal& ep): "
589 "Could not get TClass for art::RunAuxiliary!";
591 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
592 if (subrun_aux_class ==
nullptr)
594 throw art::Exception(art::errors::DictionaryNotFound) <<
595 "TransferOutput::write(const EventPrincipal& ep): "
596 "Could not get TClass for art::SubRunAuxiliary!";
598 static TClass* event_aux_class = TClass::GetClass(
"art::EventAuxiliary");
599 if (event_aux_class ==
nullptr)
601 throw art::Exception(art::errors::DictionaryNotFound) <<
602 "TransferOutput::write(const EventPrincipal& ep): "
603 "Could not get TClass for art::EventAuxiliary!";
605 static TClass* history_class = TClass::GetClass(
"art::History");
606 if (history_class ==
nullptr)
608 throw art::Exception(art::errors::DictionaryNotFound) <<
609 "TransferOutput::write(const EventPrincipal& ep): "
610 "Could not get TClass for art::History!";
615 TBufferFile msg(TBuffer::kWrite);
621 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
622 "Streaming message type code ..." ;
624 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
625 "Finished streaming message type code." ;
631 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
632 "Streaming RunAuxiliary ..." ;
633 msg.WriteObjectAny(&ep.subRunPrincipal().runPrincipal().aux(),
635 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
636 "Finished streaming RunAuxiliary." ;
642 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
643 "Streaming SubRunAuxiliary ..." ;
644 msg.WriteObjectAny(&ep.subRunPrincipal().aux(),
646 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
647 "Finished streaming SubRunAuxiliary." ;
653 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
654 "Streaming EventAuxiliary ..." ;
655 msg.WriteObjectAny(&ep.aux(), event_aux_class);
656 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
657 "Finished streaming EventAuxiliary." ;
663 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
664 "Streaming History ..." ;
665 msg.WriteObjectAny(&ep.history(), history_class);
666 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
667 "Finished streaming History." ;
672 std::vector<BranchKey*> bkv;
673 writeDataProducts(msg, ep, bkv);
678 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
679 "Sending a message ..." ;
680 sendMessage_(ep.id().event(), artdaq::Fragment::DataFragmentType, msg);
681 TLOG(TLVL_TRACE) <<
" TransferOutput::write(const EventPrincipal& ep): "
687 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
692 TLOG(TLVL_TRACE) <<
" End: TransferOutput::write(const EventPrincipal& ep)" ;
696 art::TransferOutput::
697 writeRun(RunPrincipal& rp)
702 TLOG(TLVL_TRACE) <<
" Begin: TransferOutput::writeRun(const RunPrincipal& rp)" ;
714 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
715 assert(run_aux_class !=
nullptr &&
"writeRun: Could not get TClass for "
716 "art::RunAuxiliary!");
720 TBufferFile msg(TBuffer::kWrite);
726 TLOG(TLVL_TRACE) <<
" writeRun: streaming message type code ...");
728 TLOG(TLVL_TRACE) <<
" writeRun: finished streaming message type code.");
734 TLOG(TLVL_TRACE) <<
" writeRun: streaming RunAuxiliary ...");
735 if (art::debugit() >= 1)
737 TLOG(TLVL_TRACE) <<
" writeRun: dumping ProcessHistoryRegistry ...");
740 art::ProcessHistoryMap
const& phr =
741 art::ProcessHistoryRegistry::get();
742 TLOG(TLVL_TRACE) <<
" writeRun: phr: size: " << phr.size() <<
'\n';
743 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
745 std::ostringstream OS;
747 TLOG(TLVL_TRACE) <<
" writeRun: phr: id: '" << OS.str() <<
"'");
749 TLOG(TLVL_TRACE) <<
" writeRun: phr: data.size(): "
750 << I->second.data().size() <<
'\n';
751 if (I->second.data().size())
753 I->second.data().back().id().print(OS);
754 TLOG(TLVL_TRACE) <<
" writeRun: phr: data.back().id(): '"
758 if (!rp.aux().processHistoryID().isValid())
760 TLOG(TLVL_TRACE) <<
" writeRun: ProcessHistoryID: 'INVALID'");
764 std::ostringstream OS;
765 rp.aux().processHistoryID().print(OS);
766 TLOG(TLVL_TRACE) <<
" writeRun: ProcessHistoryID: '"
769 const ProcessHistory& processHistory =
770 ProcessHistoryRegistry::get(rp.aux().processHistoryID());
771 if (processHistory.data().size())
774 processHistory.data().back().id().print(OS);
775 TLOG(TLVL_TRACE) <<
" writeRun: ProcessConfigurationID: '"
778 TLOG(TLVL_TRACE) <<
" writeRun: ProcessConfiguration: '"
779 << processHistory.data().back() <<
'\n';
783 msg.WriteObjectAny(&rp.aux(), run_aux_class);
784 TLOG(TLVL_TRACE) <<
" writeRun: streamed RunAuxiliary.");
789 std::vector<BranchKey*> bkv;
790 writeDataProducts(msg, rp, bkv);
795 TLOG(TLVL_TRACE) <<
" writeRun: sending a message ...");
796 sendMessage_(0, artdaq::Fragment::EndOfRunFragmentType, msg);
797 TLOG(TLVL_TRACE) <<
" writeRun: message sent.");
802 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
808 TLOG(TLVL_TRACE) <<
" End: TransferOutput::writeRun(const RunPrincipal& rp)" ;
812 art::TransferOutput::writeSubRun(SubRunPrincipal& srp)
817 TLOG(TLVL_TRACE) <<
" Begin: TransferOutput::"
818 "writeSubRun(const SubRunPrincipal& srp)" ;
828 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
829 if (subrun_aux_class ==
nullptr)
831 throw art::Exception(art::errors::DictionaryNotFound) <<
832 "TransferOutput::writeSubRun: "
833 "Could not get TClass for art::SubRunAuxiliary!";
838 TBufferFile msg(TBuffer::kWrite);
844 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
845 "streaming message type code ..." ;
847 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
848 "finished streaming message type code." ;
854 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
855 "streaming SubRunAuxiliary ..." ;
856 if (art::debugit() >= 1)
858 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
859 "dumping ProcessHistoryRegistry ..." ;
862 # if ART_HEX_VERSION >= 0x20703
863 for (
auto I = std::begin(art::ProcessHistoryRegistry::get())
864 , E = std::end(art::ProcessHistoryRegistry::get()); I != E; ++I)
866 art::ProcessHistoryMap
const& phr =
867 art::ProcessHistoryRegistry::get();
868 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
869 "phr: size: " << std::to_string(phr.size()) ;
870 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
873 std::ostringstream OS;
875 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
876 "phr: id: '" + OS.str() +
"'" ;
878 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
879 "phr: data.size(): " << std::to_string(I->second.data().size()) ;
880 if (I->second.data().size())
882 I->second.data().back().id().print(OS);
883 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
884 "phr: data.back().id(): '"
888 if (!srp.aux().processHistoryID().isValid())
890 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
891 "ProcessHistoryID: 'INVALID'" ;;
895 std::ostringstream OS;
896 srp.aux().processHistoryID().print(OS);
897 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: ProcessHistoryID: '"
900 # if ART_HEX_VERSION >= 0x20703
901 ProcessHistory processHistory;
902 ProcessHistoryRegistry::get(srp.aux().processHistoryID(), processHistory);
904 const ProcessHistory& processHistory =
905 ProcessHistoryRegistry::get(srp.aux().processHistoryID());
907 if (processHistory.data().size())
910 processHistory.data().back().id().print(OS);
911 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
912 "ProcessConfigurationID: '"
915 OS << processHistory.data().back();
916 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
917 "ProcessConfiguration: '"
922 msg.WriteObjectAny(&srp.aux(), subrun_aux_class);
923 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: streamed SubRunAuxiliary." ;
928 std::vector<BranchKey*> bkv;
929 writeDataProducts(msg, srp, bkv);
934 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
935 "Sending the EndOfSubrun message." ;
936 sendMessage_(0, artdaq::Fragment::EndOfSubrunFragmentType, msg);
937 TLOG(TLVL_TRACE) <<
" TransferOutput::writeSubRun: "
938 "EndOfSubrun message(s) sent." ;
944 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
949 TLOG(TLVL_TRACE) <<
" End: TransferOutput::writeSubRun(const SubRunPrincipal& srp)" ;
954 art::TransferOutput::sendMessage_(uint64_t sequenceId, uint8_t messageType, TBufferFile& msg)
956 TLOG(TLVL_DEBUG) <<
"Sending message with sequenceID=" << std::to_string(sequenceId) <<
", type=" << std::to_string(messageType) <<
", length=" << std::to_string(msg.Length()) ;
958 header.
data_length =
static_cast<uint64_t
>(msg.Length());
960 fragment(std::ceil(msg.Length() /
961 static_cast<double>(
sizeof(artdaq::RawDataType))),
962 sequenceId, 0, messageType, header);
964 memcpy(&*fragment.dataBegin(), msg.Buffer(), msg.Length());
969 sts = transfer_->copyFragment(fragment, send_timeout_us_);
974 if (messageType == artdaq::Fragment::InitFragmentType)
976 std::fstream ostream(
"sendInitMessage_TransferOutput.bin", std::ios::out | std::ios::binary);
977 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.