2 #include <TBufferFile.h>
3 #include "art/Framework/Core/OutputModule.h"
4 #include "art/Framework/Principal/EventPrincipal.h"
5 #include "art/Framework/Principal/OutputHandle.h"
6 #include "art/Framework/Principal/RunPrincipal.h"
7 #include "art/Framework/Principal/SubRunPrincipal.h"
9 #include "art/Framework/Core/ModuleMacros.h"
10 #include "art/Framework/Services/Registry/ServiceHandle.h"
11 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
12 #if ART_HEX_VERSION < 0x30000
13 #include "art/Persistency/Provenance/ProductMetaData.h"
15 #if ART_HEX_VERSION >= 0x30200
16 #include "art_root_io/setup.h"
21 #include "canvas/Persistency/Provenance/BranchDescription.h"
22 #include "canvas/Persistency/Provenance/BranchKey.h"
23 #include "canvas/Persistency/Provenance/History.h"
24 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
25 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
26 #include "canvas/Persistency/Provenance/ProcessConfigurationID.h"
27 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
28 #include "canvas/Persistency/Provenance/ProductList.h"
29 #include "canvas/Persistency/Provenance/ProductProvenance.h"
30 #include "canvas/Persistency/Provenance/RunAuxiliary.h"
31 #include "canvas/Persistency/Provenance/SubRunAuxiliary.h"
32 #include "canvas/Utilities/DebugMacros.h"
33 #include "canvas/Utilities/Exception.h"
34 #include "cetlib/column_width.h"
35 #include "cetlib/lpad.h"
36 #include "cetlib/rpad.h"
37 #include "fhiclcpp/ParameterSet.h"
38 #include "fhiclcpp/ParameterSetID.h"
39 #include "fhiclcpp/ParameterSetRegistry.h"
41 #include "artdaq/DAQdata/Globals.hh"
43 #include "artdaq-core/Data/Fragment.hh"
44 #include "artdaq-core/Data/detail/ParentageMap.hh"
54 #include <TBufferFile.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_() {
108 #if ART_HEX_VERSION >= 0x30200
124 TLOG(TLVL_OPENFILE) <<
"Begin/End: ArtdaqOutput::openFile(const FileBlock&)";
130 virtual void closeFile() { TLOG(TLVL_CLOSEFILE) <<
"Begin/End: ArtdaqOutput::closeFile()"; }
137 TLOG(TLVL_RESPONDTOCLOSEINPUTFILE) <<
"Begin/End: ArtdaqOutput::"
138 "respondToCloseOutputFiles(FileBlock const&)";
146 TLOG(TLVL_RESPONDTOCLOSEOUTPUTFILE) <<
"Begin/End: ArtdaqOutput::"
147 "respondToCloseOutputFiles(FileBlock const&)";
155 TLOG(TLVL_ENDJOB) <<
"Begin/End: ArtdaqOutput::endJob()";
162 virtual void beginRun(RunPrincipal
const& rp)
final
190 virtual void event(EventPrincipal
const& ep)
final
198 virtual void event_(EventPrincipal
const& ) {}
204 virtual void write(EventPrincipal& ep)
final;
210 virtual void writeRun(RunPrincipal& rp)
final;
216 virtual void writeSubRun(SubRunPrincipal& srp)
final;
224 void writeDataProducts(TBufferFile& msg,
const Principal& principal, std::vector<BranchKey*>& bkv);
244 virtual void SendMessage(artdaq::Fragment::sequence_id_t sequenceId, artdaq::Fragment::type_t messageType, TBufferFile& msg) = 0;
248 ProductList productList_;
253 TLOG(TLVL_SENDINIT) <<
"Begin: ArtdaqOutput::send_init_message()";
263 static TClass* product_list_class = TClass::GetClass(
"std::map<art::BranchKey,art::BranchDescription>");
264 if (product_list_class ==
nullptr)
266 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
267 "Could not get TClass for "
268 "map<art::BranchKey,art::BranchDescription>!";
274 static TClass* process_history_map_class = TClass::GetClass(
"std::map<const art::Hash<2>,art::ProcessHistory>");
275 if (process_history_map_class ==
nullptr)
277 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
278 "Could not get class for "
279 "std::map<const art::Hash<2>,art::ProcessHistory>!";
283 static TClass* parentage_map_class = TClass::GetClass(
"art::ParentageMap");
284 if (parentage_map_class ==
nullptr)
286 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
287 "Could not get class for ParentageMap.";
289 TLOG(TLVL_SENDINIT) <<
"parentage_map_class: " << (
void*)parentage_map_class;
291 static TClass* history_class = TClass::GetClass(
"art::History");
292 if (history_class ==
nullptr)
294 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
295 "Could not get TClass for art::History!";
301 TBufferFile msg(TBuffer::kWrite);
306 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming message type code ...";
308 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming message type code.";
313 unsigned long ps_cnt = fhicl::ParameterSetRegistry::size();
314 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): parameter set count: " << ps_cnt;
315 msg.WriteULong(ps_cnt);
316 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming parameter sets ...";
317 for (
auto I = std::begin(fhicl::ParameterSetRegistry::get()), E = std::end(fhicl::ParameterSetRegistry::get());
320 TLOG(TLVL_SENDINIT) <<
"Pset ID " << I->first <<
": " << I->second.to_string();
321 std::string pset_str = I->second.to_string();
323 msg.WriteStdString(pset_str);
325 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming parameter sets.";
330 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming Product List sz=" << productList_.size() <<
"...";
331 msg.WriteObjectAny(&productList_, product_list_class);
332 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming Product List.";
334 art::ProcessHistoryMap phr;
335 for (
auto const& pr : art::ProcessHistoryRegistry::get())
342 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"ArtdaqOutput::send_init_message(): Dumping ProcessHistoryRegistry ...";
345 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"ArtdaqOutput::send_init_message(): phr: size: " << phr.size();
346 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
348 std::ostringstream OS;
350 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"ArtdaqOutput::send_init_message(): phr: id: '" << OS.str() <<
"'";
355 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming ProcessHistoryRegistry ...";
358 const art::ProcessHistoryMap& phm = phr;
359 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): phm: size: " << phm.size();
360 msg.WriteObjectAny(&phm, process_history_map_class);
361 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming ProcessHistoryRegistry.";
366 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming ParentageRegistry ..." << (
void*)parentage_map_class;
367 art::ParentageMap parentageMap{};
368 for (
auto const& pr : art::ParentageRegistry::get())
370 parentageMap.emplace(pr.first, pr.second);
373 msg.WriteObjectAny(&parentageMap, parentage_map_class);
375 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming ParentageRegistry.";
377 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming History";
378 msg.WriteObjectAny(&history, history_class);
379 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Done streaming History";
381 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Sending init message";
382 SendMessage(0, artdaq::Fragment::InitFragmentType, msg);
383 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Done sending init message";
385 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): END";
390 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"Begin: ArtdaqOutput::writeDataProducts(...)";
395 static TClass* branch_key_class = TClass::GetClass(
"art::BranchKey");
396 if (branch_key_class ==
nullptr)
398 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::writeDataProducts(...): "
399 "Could not get TClass for art::BranchKey!";
401 static TClass* prdprov_class = TClass::GetClass(
"art::ProductProvenance");
402 if (prdprov_class ==
nullptr)
404 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::writeDataProducts(...): "
405 "Could not get TClass for art::ProductProvenance!";
411 unsigned long prd_cnt = 0;
413 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
415 auto const& productDescription = I->second->productDescription();
416 auto const& refs = keptProducts()[productDescription.branchType()];
418 for (
auto const& ref : refs)
420 #if ART_HEX_VERSION < 0x30000
421 if (*ref == productDescription)
424 if (ref.second == productDescription)
431 #if ART_HEX_VERSION < 0x30000
432 if (I->second->productUnavailable() || !found)
434 if (!I->second->productAvailable() || !found)
444 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): Streaming product count: " +
445 std::to_string(prd_cnt);
446 msg.WriteULong(prd_cnt);
447 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): Finished streaming product count.";
459 bkv.reserve(prd_cnt);
461 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
463 auto const& productDescription = I->second->productDescription();
464 auto const& refs = keptProducts()[productDescription.branchType()];
466 for (
auto const& ref : refs)
468 #if ART_HEX_VERSION < 0x30000
469 if (*ref == productDescription)
472 if (ref.second == productDescription)
479 #if ART_HEX_VERSION < 0x30000
480 if (I->second->productUnavailable() || !found)
482 if (!I->second->productAvailable() || !found)
487 const BranchDescription& bd(I->second->productDescription());
488 bkv.push_back(
new BranchKey(bd));
489 TLOG(TLVL_WRITEDATAPRODUCTS_VERBOSE)
490 <<
"ArtdaqOutput::writeDataProducts(...): Dumping branch key of class: '"
491 << bkv.back()->friendlyClassName_ <<
"' modlbl: '" << bkv.back()->moduleLabel_ <<
"' instnm: '"
492 << bkv.back()->productInstanceName_ <<
"' procnm: '" << bkv.back()->processName_ <<
"'";
493 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): "
494 "Streaming branch key of class: '"
495 << bd.producedClassName() <<
"' modlbl: '" << bd.moduleLabel() <<
"' instnm: '"
496 << bd.productInstanceName() <<
"' procnm: '" << bd.processName() <<
"'";
497 msg.WriteObjectAny(bkv.back(), branch_key_class);
499 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): "
500 "Streaming product of class: '"
501 << bd.producedClassName() <<
"' modlbl: '" << bd.moduleLabel() <<
"' instnm: '"
502 << bd.productInstanceName() <<
"' procnm: '" << bd.processName() <<
"'";
504 OutputHandle oh = principal.getForOutput(bd.productID(),
true);
505 const EDProduct* prd = oh.wrapper();
506 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"Class for branch " << bd.wrappedName() <<
" is "
507 << (
void*)TClass::GetClass(bd.wrappedName().c_str());
508 msg.WriteObjectAny(prd, TClass::GetClass(bd.wrappedName().c_str()));
509 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): "
510 "Streaming product provenance of class: '"
511 << bd.producedClassName() <<
"' modlbl: '" << bd.moduleLabel() <<
"' instnm: '"
512 << bd.productInstanceName() <<
"' procnm: '" << bd.processName() <<
"'";
513 #if ART_HEX_VERSION < 0x30000
514 const ProductProvenance* prdprov = I->second->productProvenancePtr().get();
516 const ProductProvenance* prdprov = I->second->productProvenance().get();
518 msg.WriteObjectAny(prdprov, prdprov_class);
520 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"End: ArtdaqOutput::writeDataProducts(...)";
528 TLOG(TLVL_WRITE) <<
"Begin: ArtdaqOutput::write(const EventPrincipal& ep)";
531 send_init_message(ep.history());
537 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
538 if (run_aux_class ==
nullptr)
540 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
541 "Could not get TClass for art::RunAuxiliary!";
543 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
544 if (subrun_aux_class ==
nullptr)
546 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
547 "Could not get TClass for art::SubRunAuxiliary!";
549 static TClass* event_aux_class = TClass::GetClass(
"art::EventAuxiliary");
550 if (event_aux_class ==
nullptr)
552 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
553 "Could not get TClass for art::EventAuxiliary!";
555 static TClass* history_class = TClass::GetClass(
"art::History");
556 if (history_class ==
nullptr)
558 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
559 "Could not get TClass for art::History!";
564 TBufferFile msg(TBuffer::kWrite);
569 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming message type code ...";
571 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming message type code.";
576 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming RunAuxiliary ...";
577 msg.WriteObjectAny(&ep.subRunPrincipal().runPrincipal().RUN_AUX(), run_aux_class);
578 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming RunAuxiliary.";
583 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming SubRunAuxiliary ...";
584 msg.WriteObjectAny(&ep.subRunPrincipal().SUBRUN_AUX(), subrun_aux_class);
585 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming SubRunAuxiliary.";
591 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming EventAuxiliary ...";
592 msg.WriteObjectAny(&ep.EVENT_AUX(), event_aux_class);
593 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming EventAuxiliary.";
599 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming History ...";
600 msg.WriteObjectAny(&ep.history(), history_class);
601 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming History.";
606 std::vector<BranchKey*> bkv;
607 writeDataProducts(msg, ep, bkv);
609 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write: Sending message";
610 SendMessage(ep.EVENT_ID().event(), artdaq::Fragment::DataFragmentType, msg);
611 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write: Done sending message";
616 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
621 TLOG(TLVL_WRITE) <<
"End: ArtdaqOutput::write(const EventPrincipal& ep)";
628 TLOG(TLVL_WRITERUN) <<
"Begin: ArtdaqOutput::writeRun(const RunPrincipal& rp)";
632 #if ART_HEX_VERSION < 0x30000
633 send_init_message(art::History());
635 send_init_message(rp.history());
644 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
645 assert(run_aux_class !=
nullptr &&
"writeRun: Could not get TClass for art::RunAuxiliary!");
649 TBufferFile msg(TBuffer::kWrite);
655 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: streaming message type code ...";
657 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: finished streaming message type code.";
663 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: streaming RunAuxiliary ...";
664 msg.WriteObjectAny(&rp.RUN_AUX(), run_aux_class);
665 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: streamed RunAuxiliary.";
670 std::vector<BranchKey*> bkv;
671 writeDataProducts(msg, rp, bkv);
673 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: Sending message";
674 SendMessage(0, artdaq::Fragment::EndOfRunFragmentType, msg);
675 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: Done sending message";
677 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
683 TLOG(TLVL_WRITERUN) <<
"End: ArtdaqOutput::writeRun(RunPrincipal& rp)";
689 TLOG(TLVL_WRITESUBRUN) <<
"Begin: ArtdaqOutput::writeSubRun(const SubRunPrincipal& srp)";
692 #if ART_HEX_VERSION < 0x30000
693 send_init_message(art::History());
695 send_init_message(srp.history());
703 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
704 if (subrun_aux_class ==
nullptr)
706 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::writeSubRun: "
707 "Could not get TClass for art::SubRunAuxiliary!";
712 TBufferFile msg(TBuffer::kWrite);
718 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: streaming message type code ...";
720 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: finished streaming message type code.";
726 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: streaming SubRunAuxiliary ...";
728 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: dumping ProcessHistoryRegistry ...";
731 for (
auto I = std::begin(art::ProcessHistoryRegistry::get()), E = std::end(art::ProcessHistoryRegistry::get());
734 std::ostringstream OS;
736 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: phr: id: '" << OS.str() <<
"'";
738 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: phr: data.size(): " << I->second.data().size();
739 if (I->second.data().size())
741 I->second.data().back().id().print(OS);
742 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: phr: data.back().id(): '" << OS.str() <<
"'";
745 if (!srp.SUBRUN_AUX().processHistoryID().isValid())
747 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessHistoryID: 'INVALID'";
751 std::ostringstream OS;
752 srp.SUBRUN_AUX().processHistoryID().print(OS);
753 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessHistoryID: '" << OS.str() <<
"'";
755 ProcessHistory processHistory;
756 ProcessHistoryRegistry::get(srp.SUBRUN_AUX().processHistoryID(), processHistory);
757 if (processHistory.data().size())
760 processHistory.data().back().id().print(OS);
761 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessConfigurationID: '" << OS.str() <<
"'";
763 OS << processHistory.data().back();
764 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessConfiguration: '" << OS.str();
767 msg.WriteObjectAny(&srp.SUBRUN_AUX(), subrun_aux_class);
768 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: streamed SubRunAuxiliary.";
773 std::vector<BranchKey*> bkv;
774 writeDataProducts(msg, srp, bkv);
776 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: Sending message";
777 SendMessage(0, artdaq::Fragment::EndOfSubrunFragmentType, msg);
778 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: Done sending message";
783 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
788 TLOG(TLVL_WRITESUBRUN) <<
"End: ArtdaqOutput::writeSubRun(const SubRunPrincipal& srp)";
793 TLOG(TLVL_EXTRACTPRODUCTS) <<
"Begin: ArtdaqOutput::extractProducts_(Principal const& principal) sz=" << principal.size();
794 #if ART_HEX_VERSION < 0x30000
795 productList_ = art::ProductMetaData::instance().productList();
798 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
800 auto const& productDescription = I->second->productDescription();
801 auto const& branchKey = BranchKey(productDescription);
803 if (!productList_.count(branchKey))
805 TLOG(TLVL_EXTRACTPRODUCTS_VERBOSE) <<
"ArtdaqOutput::extractProducts_:"
806 <<
"Adding branch key to productList of class: '"
807 << branchKey.friendlyClassName_ <<
"' modlbl: '" << branchKey.moduleLabel_ <<
"' instnm: '"
808 << branchKey.productInstanceName_ <<
"' procnm: '" << branchKey.processName_ <<
"'"
809 <<
", description: " << productDescription.wrappedName();
811 productList_[branchKey] = productDescription;
816 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