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"
8 #include "art/Framework/Core/ModuleMacros.h"
9 #include "art/Framework/Services/Registry/ServiceHandle.h"
10 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
11 #if ART_HEX_VERSION < 0x30000
12 #include "art/Persistency/Provenance/ProductMetaData.h"
14 #if ART_HEX_VERSION >= 0x30200
15 #include "art_root_io/setup.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"
36 #include "fhiclcpp/ParameterSet.h"
37 #include "fhiclcpp/ParameterSetID.h"
38 #include "fhiclcpp/ParameterSetRegistry.h"
40 #include "artdaq/DAQdata/Globals.hh"
42 #include "artdaq-core/Data/Fragment.hh"
43 #include "artdaq-core/Data/detail/ParentageMap.hh"
53 #include <TBufferFile.h>
56 #include <TStreamerInfo.h>
58 #define TLVL_OPENFILE 5
59 #define TLVL_CLOSEFILE 6
60 #define TLVL_RESPONDTOCLOSEINPUTFILE 7
61 #define TLVL_RESPONDTOCLOSEOUTPUTFILE 8
63 #define TLVL_SENDINIT 10
64 #define TLVL_SENDINIT_VERBOSE1 32
65 #define TLVL_SENDINIT_VERBOSE2 33
66 #define TLVL_WRITEDATAPRODUCTS 11
67 #define TLVL_WRITEDATAPRODUCTS_VERBOSE 34
69 #define TLVL_WRITERUN 13
70 #define TLVL_WRITERUN_VERBOSE 37
71 #define TLVL_WRITESUBRUN 14
72 #define TLVL_WRITESUBRUN_VERBOSE 35
73 #define TLVL_EXTRACTPRODUCTS 15
74 #define TLVL_EXTRACTPRODUCTS_VERBOSE 36
76 #if ART_HEX_VERSION < 0x30000
78 #define SUBRUN_AUX aux
84 #define RUN_AUX runAux
85 #define SUBRUN_AUX subRunAux
86 #define EVENT_AUX eventAux
88 #define SUBRUN_ID subRunID
89 #define EVENT_ID eventID
107 : OutputModule(ps), initMsgSent_(false), productList_()
109 #if ART_HEX_VERSION >= 0x30200
125 TLOG(TLVL_OPENFILE) <<
"Begin/End: ArtdaqOutput::openFile(const FileBlock&)";
131 virtual void closeFile() { TLOG(TLVL_CLOSEFILE) <<
"Begin/End: ArtdaqOutput::closeFile()"; }
138 TLOG(TLVL_RESPONDTOCLOSEINPUTFILE) <<
"Begin/End: ArtdaqOutput::"
139 "respondToCloseOutputFiles(FileBlock const&)";
147 TLOG(TLVL_RESPONDTOCLOSEOUTPUTFILE) <<
"Begin/End: ArtdaqOutput::"
148 "respondToCloseOutputFiles(FileBlock const&)";
156 TLOG(TLVL_ENDJOB) <<
"Begin/End: ArtdaqOutput::endJob()";
163 virtual void beginRun(RunPrincipal
const& rp)
final
191 virtual void event(EventPrincipal
const& ep)
final
199 virtual void event_(EventPrincipal
const&) {}
205 virtual void write(EventPrincipal& ep)
final;
211 virtual void writeRun(RunPrincipal& rp)
final;
217 virtual void writeSubRun(SubRunPrincipal& srp)
final;
225 void writeDataProducts(TBufferFile& msg,
const Principal& principal, std::vector<BranchKey*>& bkv);
245 virtual void SendMessage(artdaq::Fragment::sequence_id_t sequenceId, artdaq::Fragment::type_t messageType, TBufferFile& msg) = 0;
249 ProductList productList_;
254 TLOG(TLVL_SENDINIT) <<
"Begin: ArtdaqOutput::send_init_message()";
264 static TClass* product_list_class = TClass::GetClass(
"std::map<art::BranchKey,art::BranchDescription>");
265 if (product_list_class ==
nullptr)
267 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
268 "Could not get TClass for "
269 "map<art::BranchKey,art::BranchDescription>!";
275 static TClass* process_history_map_class = TClass::GetClass(
"std::map<const art::Hash<2>,art::ProcessHistory>");
276 if (process_history_map_class ==
nullptr)
278 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
279 "Could not get class for "
280 "std::map<const art::Hash<2>,art::ProcessHistory>!";
284 static TClass* parentage_map_class = TClass::GetClass(
"art::ParentageMap");
285 if (parentage_map_class ==
nullptr)
287 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
288 "Could not get class for ParentageMap.";
290 TLOG(TLVL_SENDINIT) <<
"parentage_map_class: " << (
void*)parentage_map_class;
292 static TClass* history_class = TClass::GetClass(
"art::History");
293 if (history_class ==
nullptr)
295 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
296 "Could not get TClass for art::History!";
302 TBufferFile msg(TBuffer::kWrite);
307 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming message type code ...";
309 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming message type code.";
316 std::vector<std::string> classNames{
"std::map<art::BranchKey,art::BranchDescription>",
"std::map<const art::Hash<2>,art::ProcessHistory>",
"art::ParentageMap",
317 "art::History",
"art::BranchKey",
"art::ProductProvenance",
"art::RunAuxiliary",
"art::SubRunAuxiliary",
"art::EventAuxiliary"};
318 for (
auto& className : classNames)
320 TClass* class_ptr = TClass::GetClass(className.c_str());
321 if (class_ptr ==
nullptr)
323 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message: Could not get TClass for " << className <<
"!";
325 infos.Add(class_ptr->GetStreamerInfo());
327 msg.WriteObject(&infos);
332 unsigned long ps_cnt = fhicl::ParameterSetRegistry::size();
333 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): parameter set count: " << ps_cnt;
334 msg.WriteULong(ps_cnt);
335 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming parameter sets ...";
336 for (
auto I = std::begin(fhicl::ParameterSetRegistry::get()), E = std::end(fhicl::ParameterSetRegistry::get());
339 TLOG(TLVL_SENDINIT) <<
"Pset ID " << I->first <<
": " << I->second.to_string();
340 std::string pset_str = I->second.to_string();
342 msg.WriteStdString(pset_str);
344 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming parameter sets.";
349 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming Product List sz=" << productList_.size() <<
"...";
350 msg.WriteObjectAny(&productList_, product_list_class);
351 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming Product List.";
353 art::ProcessHistoryMap phr;
354 for (
auto const& pr : art::ProcessHistoryRegistry::get())
361 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"ArtdaqOutput::send_init_message(): Dumping ProcessHistoryRegistry ...";
364 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"ArtdaqOutput::send_init_message(): phr: size: " << phr.size();
365 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
367 std::ostringstream OS;
369 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"ArtdaqOutput::send_init_message(): phr: id: '" << OS.str() <<
"'";
374 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming ProcessHistoryRegistry ...";
377 const art::ProcessHistoryMap& phm = phr;
378 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): phm: size: " << phm.size();
379 msg.WriteObjectAny(&phm, process_history_map_class);
380 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming ProcessHistoryRegistry.";
385 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming ParentageRegistry ..." << (
void*)parentage_map_class;
386 art::ParentageMap parentageMap{};
387 for (
auto const& pr : art::ParentageRegistry::get())
389 parentageMap.emplace(pr.first, pr.second);
392 msg.WriteObjectAny(&parentageMap, parentage_map_class);
394 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming ParentageRegistry.";
396 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming History";
397 msg.WriteObjectAny(&history, history_class);
398 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Done streaming History";
400 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Sending init message";
401 SendMessage(0, artdaq::Fragment::InitFragmentType, msg);
402 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Done sending init message";
404 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): END";
409 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"Begin: ArtdaqOutput::writeDataProducts(...)";
414 static TClass* branch_key_class = TClass::GetClass(
"art::BranchKey");
415 if (branch_key_class ==
nullptr)
417 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::writeDataProducts(...): "
418 "Could not get TClass for art::BranchKey!";
420 static TClass* prdprov_class = TClass::GetClass(
"art::ProductProvenance");
421 if (prdprov_class ==
nullptr)
423 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::writeDataProducts(...): "
424 "Could not get TClass for art::ProductProvenance!";
430 unsigned long prd_cnt = 0;
432 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
434 auto const& productDescription = I->second->productDescription();
435 auto const& refs = keptProducts()[productDescription.branchType()];
437 for (
auto const& ref : refs)
439 #if ART_HEX_VERSION < 0x30000
440 if (*ref == productDescription)
443 if (ref.second == productDescription)
450 #if ART_HEX_VERSION < 0x30000
451 if (I->second->productUnavailable() || !found)
453 if (!I->second->productAvailable() || !found)
463 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): Streaming product count: " +
464 std::to_string(prd_cnt);
465 msg.WriteULong(prd_cnt);
466 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): Finished streaming product count.";
478 bkv.reserve(prd_cnt);
480 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
482 auto const& productDescription = I->second->productDescription();
483 auto const& refs = keptProducts()[productDescription.branchType()];
485 for (
auto const& ref : refs)
487 #if ART_HEX_VERSION < 0x30000
488 if (*ref == productDescription)
491 if (ref.second == productDescription)
498 #if ART_HEX_VERSION < 0x30000
499 if (I->second->productUnavailable() || !found)
501 if (!I->second->productAvailable() || !found)
506 const BranchDescription& bd(I->second->productDescription());
507 bkv.push_back(
new BranchKey(bd));
508 TLOG(TLVL_WRITEDATAPRODUCTS_VERBOSE)
509 <<
"ArtdaqOutput::writeDataProducts(...): Dumping branch key of class: '"
510 << bkv.back()->friendlyClassName_ <<
"' modlbl: '" << bkv.back()->moduleLabel_ <<
"' instnm: '"
511 << bkv.back()->productInstanceName_ <<
"' procnm: '" << bkv.back()->processName_ <<
"'";
512 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): "
513 "Streaming branch key of class: '"
514 << bd.producedClassName() <<
"' modlbl: '" << bd.moduleLabel() <<
"' instnm: '"
515 << bd.productInstanceName() <<
"' procnm: '" << bd.processName() <<
"'";
516 msg.WriteObjectAny(bkv.back(), branch_key_class);
518 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): "
519 "Streaming product of class: '"
520 << bd.producedClassName() <<
"' modlbl: '" << bd.moduleLabel() <<
"' instnm: '"
521 << bd.productInstanceName() <<
"' procnm: '" << bd.processName() <<
"'";
523 OutputHandle oh = principal.getForOutput(bd.productID(),
true);
524 const EDProduct* prd = oh.wrapper();
525 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"Class for branch " << bd.wrappedName() <<
" is "
526 << (
void*)TClass::GetClass(bd.wrappedName().c_str());
527 msg.WriteObjectAny(prd, TClass::GetClass(bd.wrappedName().c_str()));
528 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): "
529 "Streaming product provenance of class: '"
530 << bd.producedClassName() <<
"' modlbl: '" << bd.moduleLabel() <<
"' instnm: '"
531 << bd.productInstanceName() <<
"' procnm: '" << bd.processName() <<
"'";
532 #if ART_HEX_VERSION < 0x30000
533 const ProductProvenance* prdprov = I->second->productProvenancePtr().get();
535 const ProductProvenance* prdprov = I->second->productProvenance().get();
537 msg.WriteObjectAny(prdprov, prdprov_class);
539 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"End: ArtdaqOutput::writeDataProducts(...)";
547 TLOG(TLVL_WRITE) <<
"Begin: ArtdaqOutput::write(const EventPrincipal& ep)";
550 send_init_message(ep.history());
556 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
557 if (run_aux_class ==
nullptr)
559 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
560 "Could not get TClass for art::RunAuxiliary!";
562 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
563 if (subrun_aux_class ==
nullptr)
565 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
566 "Could not get TClass for art::SubRunAuxiliary!";
568 static TClass* event_aux_class = TClass::GetClass(
"art::EventAuxiliary");
569 if (event_aux_class ==
nullptr)
571 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
572 "Could not get TClass for art::EventAuxiliary!";
574 static TClass* history_class = TClass::GetClass(
"art::History");
575 if (history_class ==
nullptr)
577 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
578 "Could not get TClass for art::History!";
583 TBufferFile msg(TBuffer::kWrite);
588 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming message type code ...";
590 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming message type code.";
595 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming RunAuxiliary ...";
596 msg.WriteObjectAny(&ep.subRunPrincipal().runPrincipal().RUN_AUX(), run_aux_class);
597 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming RunAuxiliary.";
602 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming SubRunAuxiliary ...";
603 msg.WriteObjectAny(&ep.subRunPrincipal().SUBRUN_AUX(), subrun_aux_class);
604 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming SubRunAuxiliary.";
610 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming EventAuxiliary ...";
611 msg.WriteObjectAny(&ep.EVENT_AUX(), event_aux_class);
612 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming EventAuxiliary.";
618 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming History ...";
619 msg.WriteObjectAny(&ep.history(), history_class);
620 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming History.";
625 std::vector<BranchKey*> bkv;
626 writeDataProducts(msg, ep, bkv);
628 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write: Sending message";
629 SendMessage(ep.EVENT_ID().event(), artdaq::Fragment::DataFragmentType, msg);
630 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write: Done sending message";
635 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
640 TLOG(TLVL_WRITE) <<
"End: ArtdaqOutput::write(const EventPrincipal& ep)";
647 TLOG(TLVL_WRITERUN) <<
"Begin: ArtdaqOutput::writeRun(const RunPrincipal& rp)";
651 #if ART_HEX_VERSION < 0x30000
652 send_init_message(art::History());
654 send_init_message(rp.history());
663 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
664 assert(run_aux_class !=
nullptr &&
"writeRun: Could not get TClass for art::RunAuxiliary!");
668 TBufferFile msg(TBuffer::kWrite);
674 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: streaming message type code ...";
676 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: finished streaming message type code.";
682 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: streaming RunAuxiliary ...";
683 msg.WriteObjectAny(&rp.RUN_AUX(), run_aux_class);
684 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: streamed RunAuxiliary.";
689 std::vector<BranchKey*> bkv;
690 writeDataProducts(msg, rp, bkv);
692 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: Sending message";
693 SendMessage(0, artdaq::Fragment::EndOfRunFragmentType, msg);
694 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: Done sending message";
696 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
702 TLOG(TLVL_WRITERUN) <<
"End: ArtdaqOutput::writeRun(RunPrincipal& rp)";
708 TLOG(TLVL_WRITESUBRUN) <<
"Begin: ArtdaqOutput::writeSubRun(const SubRunPrincipal& srp)";
711 #if ART_HEX_VERSION < 0x30000
712 send_init_message(art::History());
714 send_init_message(srp.history());
722 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
723 if (subrun_aux_class ==
nullptr)
725 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::writeSubRun: "
726 "Could not get TClass for art::SubRunAuxiliary!";
731 TBufferFile msg(TBuffer::kWrite);
737 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: streaming message type code ...";
739 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: finished streaming message type code.";
745 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: streaming SubRunAuxiliary ...";
747 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: dumping ProcessHistoryRegistry ...";
750 for (
auto I = std::begin(art::ProcessHistoryRegistry::get()), E = std::end(art::ProcessHistoryRegistry::get());
753 std::ostringstream OS;
755 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: phr: id: '" << OS.str() <<
"'";
757 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: phr: data.size(): " << I->second.data().size();
758 if (I->second.data().size())
760 I->second.data().back().id().print(OS);
761 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: phr: data.back().id(): '" << OS.str() <<
"'";
764 if (!srp.SUBRUN_AUX().processHistoryID().isValid())
766 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessHistoryID: 'INVALID'";
770 std::ostringstream OS;
771 srp.SUBRUN_AUX().processHistoryID().print(OS);
772 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessHistoryID: '" << OS.str() <<
"'";
774 ProcessHistory processHistory;
775 ProcessHistoryRegistry::get(srp.SUBRUN_AUX().processHistoryID(), processHistory);
776 if (processHistory.data().size())
779 processHistory.data().back().id().print(OS);
780 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessConfigurationID: '" << OS.str() <<
"'";
782 OS << processHistory.data().back();
783 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessConfiguration: '" << OS.str();
786 msg.WriteObjectAny(&srp.SUBRUN_AUX(), subrun_aux_class);
787 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: streamed SubRunAuxiliary.";
792 std::vector<BranchKey*> bkv;
793 writeDataProducts(msg, srp, bkv);
795 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: Sending message";
796 SendMessage(0, artdaq::Fragment::EndOfSubrunFragmentType, msg);
797 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: Done sending message";
802 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
807 TLOG(TLVL_WRITESUBRUN) <<
"End: ArtdaqOutput::writeSubRun(const SubRunPrincipal& srp)";
812 TLOG(TLVL_EXTRACTPRODUCTS) <<
"Begin: ArtdaqOutput::extractProducts_(Principal const& principal) sz=" << principal.size();
813 #if ART_HEX_VERSION < 0x30000
814 productList_ = art::ProductMetaData::instance().productList();
817 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
819 auto const& productDescription = I->second->productDescription();
820 auto const& branchKey = BranchKey(productDescription);
822 if (!productList_.count(branchKey))
824 TLOG(TLVL_EXTRACTPRODUCTS_VERBOSE) <<
"ArtdaqOutput::extractProducts_:"
825 <<
"Adding branch key to productList of class: '"
826 << branchKey.friendlyClassName_ <<
"' modlbl: '" << branchKey.moduleLabel_ <<
"' instnm: '"
827 << branchKey.productInstanceName_ <<
"' procnm: '" << branchKey.processName_ <<
"'"
828 <<
", description: " << productDescription.wrappedName();
830 productList_[branchKey] = productDescription;
835 TLOG(TLVL_EXTRACTPRODUCTS) <<
"End: ArtdaqOutput::extractProducts_(Principal const& principal) Product list sz=" << productList_.size();
virtual void writeRun(RunPrincipal &rp) final
Write a RunPrincipal to TBufferFile and send
virtual void event(EventPrincipal const &ep) final
Perform actions for each event. Derived classes should implement event_ instead.
virtual void event_(EventPrincipal const &)
Perform actions for each event. No-op, but derived classes may override
void send_init_message(History const &history)
Send an init message downstream. Use the given History for initializing downstream art processes...
void extractProducts_(Principal const &principal)
Extract the list of Products from the given Principal
virtual void beginSubRun(SubRunPrincipal const &srp) final
Perform Begin SubRun actions. Derived classes should implement beginSubRun_ instead.
This is the base class for artdaq OutputModules, providing the serialization interface for art Events...
virtual void beginSubRun_(SubRunPrincipal const &)
Perform Begin SubRun actions. No-op, but derived classes may override
virtual ~ArtdaqOutput()=default
Destructor
virtual void beginRun(RunPrincipal const &rp) final
Perform Begin Run actions. Derived classes should implement beginRun_ instead.
virtual void SendMessage(artdaq::Fragment::sequence_id_t sequenceId, artdaq::Fragment::type_t messageType, TBufferFile &msg)=0
Send the serialized art Event downstream. Artdaq output modules should define this function...
virtual void openFile(FileBlock const &)
Perform actions necessary for opening files. No-op, but derived classes may override ...
virtual void endJob()
Perform End-of-Job actions. No-op, but derived classes may override
virtual void closeFile()
Perform actions necessary for closing files. No-op, but derived classes may override ...
ArtdaqOutput(fhicl::ParameterSet const &ps)
ArtdaqOutput Constructor
void writeDataProducts(TBufferFile &msg, const Principal &principal, std::vector< BranchKey * > &bkv)
Extract the data products from a Principal and write them to the TBufferFile
virtual void respondToCloseOutputFiles(FileBlock const &)
Perform actions necessary after closing the output file(s). No-op, but derived classes may override ...
virtual void writeSubRun(SubRunPrincipal &srp) final
Write a SubRunPrincipal to TBufferFile and send
virtual void respondToCloseInputFile(FileBlock const &)
Perform actions nesessary after closing the input file. No-op, but derived classes may override ...
virtual void beginRun_(RunPrincipal const &)
Perform Begin Run actions. No-op, but derived classes may override
virtual void write(EventPrincipal &ep) final
Write an EventPrincipal to TBufferFile and send