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 #if ART_HEX_VERSION < 0x20900
14 #include "art/Persistency/Provenance/BranchIDListRegistry.h"
15 #include "canvas/Persistency/Provenance/BranchIDList.h"
17 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
18 #include "art/Persistency/Provenance/ProductMetaData.h"
20 #include "canvas/Persistency/Provenance/BranchDescription.h"
21 #include "canvas/Persistency/Provenance/BranchKey.h"
22 #include "canvas/Persistency/Provenance/History.h"
23 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
24 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
25 #include "canvas/Persistency/Provenance/ProcessConfigurationID.h"
26 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
27 #include "canvas/Persistency/Provenance/ProductList.h"
28 #include "canvas/Persistency/Provenance/ProductProvenance.h"
29 #include "canvas/Persistency/Provenance/RunAuxiliary.h"
30 #include "canvas/Persistency/Provenance/SubRunAuxiliary.h"
31 #include "canvas/Utilities/DebugMacros.h"
32 #include "canvas/Utilities/Exception.h"
33 #include "cetlib/column_width.h"
34 #include "cetlib/lpad.h"
35 #include "cetlib/rpad.h"
37 #include "fhiclcpp/ParameterSet.h"
38 #include "fhiclcpp/ParameterSetID.h"
39 #include "fhiclcpp/ParameterSetRegistry.h"
41 #define TRACE_NAME "RootNetOutput"
43 #define TLVL_OPENFILE 5
44 #define TLVL_CLOSEFILE 6
45 #define TLVL_RESPONDTOCLOSEINPUTFILE 7
46 #define TLVL_RESPONDTOCLOSEOUTPUTFILE 8
48 #define TLVL_SENDINIT 10
49 #define TLVL_SENDINIT_VERBOSE1 32
50 #define TLVL_SENDINIT_VERBOSE2 33
51 #define TLVL_WRITEDATAPRODUCTS 11
52 #define TLVL_WRITEDATAPRODUCTS_VERBOSE 34
54 #define TLVL_WRITERUN 13
55 #define TLVL_WRITESUBRUN 14
56 #define TLVL_WRITESUBRUN_VERBOSE 35
59 #include "artdaq/DAQdata/Globals.hh"
60 #include "artdaq/ArtModules/NetMonTransportService.h"
61 #include "artdaq-core/Data/detail/ParentageMap.hh"
62 #include "artdaq/DAQdata/NetMonHeader.hh"
106 virtual void openFile(FileBlock
const&);
108 virtual void closeFile();
110 virtual void respondToCloseInputFile(FileBlock
const&);
112 virtual void respondToCloseOutputFiles(FileBlock
const&);
114 virtual void endJob();
116 virtual void write(EventPrincipal CONST_WRITE&);
118 virtual void writeRun(RunPrincipal CONST_WRITE&);
120 virtual void writeSubRun(SubRunPrincipal CONST_WRITE&);
122 void writeDataProducts(TBufferFile&,
const Principal&,
123 std::vector<BranchKey*>&);
132 , initMsgSent_(false)
134 TLOG(TLVL_DEBUG) <<
"Begin: RootNetOutput::RootNetOutput(ParameterSet const& ps)" ;
135 ServiceHandle<NetMonTransportService> transport;
136 transport->connect();
137 TLOG(TLVL_DEBUG) <<
"End: RootNetOutput::RootNetOutput(ParameterSet const& ps)" ;
143 TLOG(TLVL_DEBUG) <<
"Begin: RootNetOutput::~RootNetOutput()" ;
144 ServiceHandle<NetMonTransportService> transport;
145 transport->disconnect();
146 TLOG(TLVL_DEBUG) <<
"End: RootNetOutput::~RootNetOutput()" ;
151 openFile(FileBlock
const&)
153 TLOG(TLVL_OPENFILE) <<
"Begin/End: RootNetOutput::openFile(const FileBlock&)" ;
160 TLOG(TLVL_CLOSEFILE) <<
"Begin/End: RootNetOutput::closeFile()" ;
165 respondToCloseInputFile(FileBlock
const&)
167 TLOG(TLVL_RESPONDTOCLOSEINPUTFILE) <<
"Begin/End: RootNetOutput::"
168 "respondToCloseOutputFiles(FileBlock const&)" ;
173 respondToCloseOutputFiles(FileBlock
const&)
175 TLOG(TLVL_RESPONDTOCLOSEOUTPUTFILE) <<
"Begin/End: RootNetOutput::"
176 "respondToCloseOutputFiles(FileBlock const&)" ;
181 send_shutdown_message()
193 TLOG(TLVL_ENDJOB) <<
"Begin: RootNetOutput::endJob()" ;
194 send_shutdown_message();
195 TLOG(TLVL_ENDJOB) <<
"End: RootNetOutput::endJob()" ;
204 TLOG(TLVL_SENDINIT) <<
"Begin: RootNetOutput static send_init_message()" ;
214 static TClass* product_list_class = TClass::GetClass(
215 "std::map<art::BranchKey,art::BranchDescription>");
216 if (product_list_class ==
nullptr)
218 throw art::Exception(art::errors::DictionaryNotFound) <<
219 "RootNetOutput static send_init_message(): "
220 "Could not get TClass for "
221 "map<art::BranchKey,art::BranchDescription>!";
227 static TClass* process_history_map_class = TClass::GetClass(
228 "std::map<const art::Hash<2>,art::ProcessHistory>");
229 if (process_history_map_class ==
nullptr)
231 throw art::Exception(art::errors::DictionaryNotFound) <<
232 "RootNetOutput static send_init_message(): "
233 "Could not get class for "
234 "std::map<const art::Hash<2>,art::ProcessHistory>!";
239 static TClass* parentage_map_class = TClass::GetClass(
"art::ParentageMap");
240 if (parentage_map_class ==
nullptr)
242 throw art::Exception(art::errors::DictionaryNotFound) <<
243 "RootNetOutput static send_init_message(): "
244 "Could not get class for ParentageMap.";
246 TLOG(TLVL_SENDINIT) <<
"parentage_map_class: " << (
void*)parentage_map_class ;
251 TBufferFile msg(TBuffer::kWrite);
256 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Streaming message type code ..." ;
258 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Finished streaming message type code." ;
263 unsigned long ps_cnt = fhicl::ParameterSetRegistry::size();
264 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): parameter set count: " + std::to_string(ps_cnt) ;
265 msg.WriteULong(ps_cnt);
266 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Streaming parameter sets ..." ;
268 #
if ART_HEX_VERSION >= 0x20703
269 auto I = std::begin(fhicl::ParameterSetRegistry::get()),
270 E = std::end(fhicl::ParameterSetRegistry::get());
272 auto I = fhicl::ParameterSetRegistry::begin(),
273 E = fhicl::ParameterSetRegistry::end();
277 std::string pset_str = I->second.to_string();
279 msg.WriteStdString(pset_str);
281 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Finished streaming parameter sets." ;
286 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Streaming MasterProductRegistry ..." ;
287 art::ProductList productList(
288 art::ProductMetaData::instance().productList());
289 msg.WriteObjectAny(&productList, product_list_class);
290 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Finished streaming MasterProductRegistry." ;
292 #if ART_HEX_VERSION < 0x20900
296 # if ART_HEX_VERSION >= 0x20703
297 art::BranchIDLists
const * bilr =
298 &art::BranchIDListRegistry::instance().data();
300 art::BranchIDLists* bilr =
301 &art::BranchIDListRegistry::instance()->data();
303 TLOG(TLVL_SENDINIT_VERBOSE1) <<
"RootNetOutput static send_init_message(): Content of BranchIDLists" ;
304 int max_bli = bilr->size();
305 TLOG(TLVL_SENDINIT_VERBOSE1) <<
"RootNetOutput static send_init_message(): max_bli: " << max_bli ;
306 for (
int i = 0; i < max_bli; ++i)
308 int max_prdidx = (*bilr)[i].size();
309 TLOG(TLVL_SENDINIT_VERBOSE1) <<
"RootNetOutput static send_init_message(): max_prdidx: " << max_prdidx ;
310 for (
int j = 0; j < max_prdidx; ++j)
312 TLOG(TLVL_SENDINIT_VERBOSE1) <<
"RootNetOutput static send_init_message(): bli: " << i <<
" prdidx: " << j <<
" bid: 0x" << std::hex << static_cast<unsigned long>((*bilr)[i][j]) << std::dec ;
317 # if ART_HEX_VERSION >= 0x20703
318 art::ProcessHistoryMap phr;
319 for (
auto const& pr : art::ProcessHistoryRegistry::get()) {
326 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"RootNetOutput static send_init_message(): Dumping ProcessHistoryRegistry ..." ;
329 # if ART_HEX_VERSION < 0x20703
330 art::ProcessHistoryMap
const& phr = art::ProcessHistoryRegistry::get();
332 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"RootNetOutput static send_init_message(): phr: size: " << std::to_string(phr.size()) ;
333 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
335 std::ostringstream OS;
337 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"RootNetOutput static send_init_message(): phr: id: '" << OS.str() <<
"'" ;
342 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Streaming ProcessHistoryRegistry ..." ;
345 # if ART_HEX_VERSION >= 0x20703
346 const art::ProcessHistoryMap& phm = phr;
348 const art::ProcessHistoryMap& phm = art::ProcessHistoryRegistry::get();
350 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): phm: size: " << std::to_string(phm.size()) ;
351 msg.WriteObjectAny(&phm, process_history_map_class);
352 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Finished streaming ProcessHistoryRegistry." ;
357 TLOG(TLVL_SENDINIT) <<
"static send_init_message(): Streaming ParentageRegistry ..."
358 << (
void*)parentage_map_class ;
359 # if ART_HEX_VERSION >= 0x20703
360 art::ParentageMap parentageMap{};
361 for (
auto const& pr : art::ParentageRegistry::get()) {
362 parentageMap.emplace(pr.first, pr.second);
365 const art::ParentageMap& parentageMap = art::ParentageRegistry::get();
368 msg.WriteObjectAny(&parentageMap, parentage_map_class);
370 TLOG(TLVL_SENDINIT) <<
"static send_init_message(): Finished streaming ParentageRegistry." ;
376 art::ServiceHandle<NetMonTransportService> transport;
377 if (!transport.get())
379 TLOG(TLVL_ERROR) <<
"Could not get handle to NetMonTransportService!" ;
382 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Sending the init message to " << std::to_string(transport->dataReceiverCount()) <<
" data receivers ..." ;
383 for (
size_t idx = 0; idx < transport->dataReceiverCount(); ++idx)
385 transport->sendMessage(idx, artdaq::Fragment::InitFragmentType, msg);
387 TLOG(TLVL_SENDINIT) <<
"RootNetOutput static send_init_message(): Init message(s) sent." ;
389 TLOG(TLVL_SENDINIT) <<
"End: RootNetOutput static send_init_message()" ;
396 writeDataProducts(TBufferFile& msg,
const Principal& principal,
397 std::vector<BranchKey*>& bkv)
399 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"Begin: RootNetOutput::writeDataProducts(...)" ;
404 static TClass* branch_key_class = TClass::GetClass(
"art::BranchKey");
405 if (branch_key_class ==
nullptr)
407 throw art::Exception(art::errors::DictionaryNotFound) <<
408 "RootNetOutput::writeDataProducts(...): "
409 "Could not get TClass for art::BranchKey!";
411 static TClass* prdprov_class = TClass::GetClass(
"art::ProductProvenance");
412 if (prdprov_class ==
nullptr)
414 throw art::Exception(art::errors::DictionaryNotFound) <<
415 "RootNetOutput::writeDataProducts(...): "
416 "Could not get TClass for art::ProductProvenance!";
422 unsigned long prd_cnt = 0;
424 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
426 #if ART_HEX_VERSION > 0x20800
427 auto const& productDescription = I->second->productDescription();
428 auto const& refs = keptProducts()[productDescription.branchType()];
430 for (
auto const& ref : refs)
432 if (*ref == productDescription) {
437 if (I->second->productUnavailable() || !found)
442 if (I->second->productUnavailable() || !selected(I->second->productDescription()))
453 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"RootNetOutput::writeDataProducts(...): Streaming product count: " + std::to_string(prd_cnt) ;
454 msg.WriteULong(prd_cnt);
455 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"RootNetOutput::writeDataProducts(...): Finished streaming product count." ;
467 bkv.reserve(prd_cnt);
469 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
471 #if ART_HEX_VERSION > 0x20800
472 auto const& productDescription = I->second->productDescription();
473 auto const& refs = keptProducts()[productDescription.branchType()];
475 for (
auto const& ref : refs)
477 if (*ref == productDescription) {
482 if (I->second->productUnavailable() || !found)
487 if (I->second->productUnavailable() || !selected(I->second->productDescription()))
493 const BranchDescription& bd(I->second->productDescription());
494 bkv.push_back(
new BranchKey(bd));
495 TLOG(TLVL_WRITEDATAPRODUCTS_VERBOSE) <<
"RootNetOutput::writeDataProducts(...): Dumping branch key of class: '"
496 << bkv.back()->friendlyClassName_
498 << bkv.back()->moduleLabel_
500 << bkv.back()->productInstanceName_
502 << bkv.back()->processName_
504 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"RootNetOutput::writeDataProducts(...): "
505 "Streaming branch key of class: '"
506 << bd.producedClassName()
510 << bd.productInstanceName()
514 msg.WriteObjectAny(bkv.back(), branch_key_class);
515 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"RootNetOutput::writeDataProducts(...): "
516 "Streaming product of class: '"
517 << bd.producedClassName()
521 << bd.productInstanceName()
525 #if ART_HEX_VERSION > 0x20800
526 OutputHandle oh = principal.getForOutput(bd.productID(),
true);
528 OutputHandle oh = principal.getForOutput(bd.branchID(),
true);
530 const EDProduct* prd = oh.wrapper();
531 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"Class for branch " << bd.wrappedName() <<
" is " << (
void*)TClass::GetClass(bd.wrappedName().c_str());
532 msg.WriteObjectAny(prd, TClass::GetClass(bd.wrappedName().c_str()));
533 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"RootNetOutput::writeDataProducts(...): "
534 "Streaming product provenance of class: '"
535 << bd.producedClassName()
539 << bd.productInstanceName()
543 const ProductProvenance* prdprov = I->second->productProvenancePtr().get();
544 msg.WriteObjectAny(prdprov, prdprov_class);
546 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"End: RootNetOutput::writeDataProducts(...)" ;
551 write(CONST_WRITE EventPrincipal& ep)
556 TLOG(TLVL_WRITE) <<
"Begin: RootNetOutput::write(const EventPrincipal& ep)" ;
565 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
566 if (run_aux_class ==
nullptr)
568 throw art::Exception(art::errors::DictionaryNotFound) <<
569 "RootNetOutput::write(const EventPrincipal& ep): "
570 "Could not get TClass for art::RunAuxiliary!";
572 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
573 if (subrun_aux_class ==
nullptr)
575 throw art::Exception(art::errors::DictionaryNotFound) <<
576 "RootNetOutput::write(const EventPrincipal& ep): "
577 "Could not get TClass for art::SubRunAuxiliary!";
579 static TClass* event_aux_class = TClass::GetClass(
"art::EventAuxiliary");
580 if (event_aux_class ==
nullptr)
582 throw art::Exception(art::errors::DictionaryNotFound) <<
583 "RootNetOutput::write(const EventPrincipal& ep): "
584 "Could not get TClass for art::EventAuxiliary!";
586 static TClass* history_class = TClass::GetClass(
"art::History");
587 if (history_class ==
nullptr)
589 throw art::Exception(art::errors::DictionaryNotFound) <<
590 "RootNetOutput::write(const EventPrincipal& ep): "
591 "Could not get TClass for art::History!";
596 TBufferFile msg(TBuffer::kWrite);
601 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Streaming message type code ..." ;
603 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Finished streaming message type code." ;
608 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Streaming RunAuxiliary ..." ;
609 msg.WriteObjectAny(&ep.subRunPrincipal().runPrincipal().aux(),
611 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Finished streaming RunAuxiliary." ;
616 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Streaming SubRunAuxiliary ..." ;
617 msg.WriteObjectAny(&ep.subRunPrincipal().aux(),
619 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Finished streaming SubRunAuxiliary." ;
625 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Streaming EventAuxiliary ..." ;
626 msg.WriteObjectAny(&ep.aux(), event_aux_class);
627 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Finished streaming EventAuxiliary." ;
633 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Streaming History ..." ;
634 msg.WriteObjectAny(&ep.history(), history_class);
635 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Finished streaming History." ;
640 std::vector<BranchKey*> bkv;
641 writeDataProducts(msg, ep, bkv);
646 ServiceHandle<NetMonTransportService> transport;
647 if (!transport.get())
649 TLOG(TLVL_ERROR) <<
"Could not get handle to NetMonTransportService!" ;
652 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Sending a message ..." ;
653 transport->sendMessage(ep.id().event(), artdaq::Fragment::DataFragmentType, msg);
654 TLOG(TLVL_WRITE) <<
"RootNetOutput::write(const EventPrincipal& ep): Message sent." ;
659 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
664 TLOG(TLVL_WRITE) <<
"End: RootNetOutput::write(const EventPrincipal& ep)" ;
669 writeRun(CONST_WRITE RunPrincipal& rp)
674 TLOG(TLVL_WRITERUN) <<
"Begin: RootNetOutput::writeRun(const RunPrincipal& rp)" ;
686 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
687 assert(run_aux_class !=
nullptr &&
"writeRun: Could not get TClass for art::RunAuxiliary!");
691 TBufferFile msg(TBuffer::kWrite);
697 TLOG(TLVL_WRITERUN) <<
"writeRun: streaming message type code ..." ;
699 TLOG(TLVL_WRITERUN) <<
"writeRun: finished streaming message type code." ;
705 TLOG(TLVL_WRITERUN) <<
"writeRun: streaming RunAuxiliary ..." ;
706 TLOG(TLVL_WRITERUN_VERBOSE) <<
"writeRun: dumping ProcessHistoryRegistry ..." ;
709 art::ProcessHistoryMap
const& phr =
710 art::ProcessHistoryRegistry::get();
711 TLOG(TLVL_WRITERUN_VERBOSE) <<
"writeRun: phr: size: " << phr.size() ;
712 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I) {
713 std::ostringstream OS;
715 TLOG(TLVL_WRITERUN_VERBOSE) <<
"writeRun: phr: id: '" << OS.str() <<
"'" ;
717 TLOG(TLVL_WRITERUN_VERBOSE) <<
"writeRun: phr: data.size(): " << I->second.data().size() ;
718 if (I->second.data().size()) {
719 I->second.data().back().id().print(OS);
720 TLOG(TLVL_WRITERUN_VERBOSE) <<
"writeRun: phr: data.back().id(): '" << OS.str() <<
"'" ;
723 if (!rp.aux().processHistoryID().isValid()) {
724 TLOG(TLVL_WRITERUN_VERBOSE) <<
"writeRun: ProcessHistoryID: 'INVALID'" ;
727 std::ostringstream OS;
728 rp.aux().processHistoryID().print(OS);
729 TLOG(TLVL_WRITERUN_VERBOSE) <<
"writeRun: ProcessHistoryID: '" << OS.str() <<
"'" ;
731 const ProcessHistory& processHistory =
732 ProcessHistoryRegistry::get(rp.aux().processHistoryID());
733 if (processHistory.data().size()) {
735 processHistory.data().back().id().print(OS);
736 TLOG(TLVL_WRITERUN_VERBOSE) <<
"writeRun: ProcessConfigurationID: '" << OS.str() <<
"'" ;
738 TLOG(TLVL_WRITERUN_VERBOSE) <<
"writeRun: ProcessConfiguration: '" << processHistory.data().back() ;
741 msg.WriteObjectAny(&rp.aux(), run_aux_class);
742 TLOG(TLVL_WRITERUN) <<
"writeRun: streamed RunAuxiliary." ;
747 std::vector<BranchKey*> bkv;
748 writeDataProducts(msg, rp, bkv);
753 ServiceHandle<NetMonTransportService> transport;
754 if (!transport.get())
756 TLOG(TLVL_ERROR) <<
"Could not get handle to NetMonTransportService!" ;
759 TLOG(TLVL_WRITERUN) <<
"writeRun: sending a message ..." ;
760 transport->sendMessage(0, artdaq::Fragment::EndOfRunFragmentType, msg);
761 TLOG(TLVL_WRITERUN) <<
"writeRun: message sent." ;
766 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I) {
771 TLOG(TLVL_WRITERUN) <<
"End: RootNetOutput::writeRun(const RunPrincipal& rp)" ;
775 art::RootNetOutput::writeSubRun(CONST_WRITE SubRunPrincipal& srp)
780 TLOG(TLVL_WRITESUBRUN) <<
"Begin: RootNetOutput::writeSubRun(const SubRunPrincipal& srp)" ;
790 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
791 if (subrun_aux_class ==
nullptr)
793 throw art::Exception(art::errors::DictionaryNotFound) <<
794 "RootNetOutput::writeSubRun: "
795 "Could not get TClass for art::SubRunAuxiliary!";
800 TBufferFile msg(TBuffer::kWrite);
806 TLOG(TLVL_WRITESUBRUN) <<
"RootNetOutput::writeSubRun: streaming message type code ..." ;
808 TLOG(TLVL_WRITESUBRUN) <<
"RootNetOutput::writeSubRun: finished streaming message type code." ;
814 TLOG(TLVL_WRITESUBRUN) <<
"RootNetOutput::writeSubRun: streaming SubRunAuxiliary ..." ;
816 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"RootNetOutput::writeSubRun: dumping ProcessHistoryRegistry ..." ;
819 # if ART_HEX_VERSION >= 0x20703
820 for (
auto I = std::begin(art::ProcessHistoryRegistry::get())
821 , E = std::end(art::ProcessHistoryRegistry::get()); I != E; ++I)
823 art::ProcessHistoryMap
const& phr =
824 art::ProcessHistoryRegistry::get();
825 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"RootNetOutput::writeSubRun: phr: size: " << std::to_string(phr.size()) ;
826 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
829 std::ostringstream OS;
831 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"RootNetOutput::writeSubRun: phr: id: '" << OS.str() <<
"'" ;
833 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"RootNetOutput::writeSubRun: phr: data.size(): " << std::to_string(I->second.data().size()) ;
834 if (I->second.data().size())
836 I->second.data().back().id().print(OS);
837 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"RootNetOutput::writeSubRun: phr: data.back().id(): '" << OS.str() <<
"'" ;
840 if (!srp.aux().processHistoryID().isValid())
842 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"RootNetOutput::writeSubRun: ProcessHistoryID: 'INVALID'" ;
846 std::ostringstream OS;
847 srp.aux().processHistoryID().print(OS);
848 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"RootNetOutput::writeSubRun: ProcessHistoryID: '" << OS.str() <<
"'" ;
850 # if ART_HEX_VERSION >= 0x20703
851 ProcessHistory processHistory;
852 ProcessHistoryRegistry::get(srp.aux().processHistoryID(), processHistory);
854 const ProcessHistory& processHistory =
855 ProcessHistoryRegistry::get(srp.aux().processHistoryID());
857 if (processHistory.data().size())
860 processHistory.data().back().id().print(OS);
861 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"RootNetOutput::writeSubRun: ProcessConfigurationID: '" << OS.str() <<
"'" ;
863 OS << processHistory.data().back();
864 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"RootNetOutput::writeSubRun: ProcessConfiguration: '" << OS.str() ;
867 msg.WriteObjectAny(&srp.aux(), subrun_aux_class);
868 TLOG(TLVL_WRITESUBRUN) <<
"RootNetOutput::writeSubRun: streamed SubRunAuxiliary." ;
873 std::vector<BranchKey*> bkv;
874 writeDataProducts(msg, srp, bkv);
878 ServiceHandle<NetMonTransportService> transport;
879 if (!transport.get())
881 TLOG(TLVL_ERROR) <<
"Could not get handle to NetMonTransportService!" ;
884 TLOG(TLVL_WRITESUBRUN) <<
"RootNetOutput::writeSubRun: Sending the EndOfSubrun message to " << std::to_string(transport->dataReceiverCount()) <<
" data receivers ..." ;
885 for (
size_t idx = 0; idx < transport->dataReceiverCount(); ++idx)
887 transport->sendMessage(idx, artdaq::Fragment::EndOfSubrunFragmentType, msg);
889 TLOG(TLVL_WRITESUBRUN) <<
"RootNetOutput::writeSubRun: EndOfSubrun message(s) sent." ;
898 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
903 TLOG(TLVL_WRITESUBRUN) <<
"End: RootNetOutput::writeSubRun(const SubRunPrincipal& srp)" ;
~RootNetOutput()
RootNetOutput Destructor.
An art::OutputModule which sends events using DataSenderManager. This module is designed for transpor...
RootNetOutput(fhicl::ParameterSet const &ps)
RootNetOutput Constructor.