1 #ifndef ARTDAQ_ARTDAQ_ARTMODULES_ARTDAQOUTPUT_HH_
2 #define ARTDAQ_ARTDAQ_ARTMODULES_ARTDAQOUTPUT_HH_
4 #include "TRACE/tracemf.h"
5 #include "artdaq-core/Data/Fragment.hh"
7 #include "artdaq-core/Data/RawEvent.hh"
8 #include "artdaq-core/Data/detail/ParentageMap.hh"
9 #include "artdaq/DAQdata/Globals.hh"
10 #include "artdaq/DAQdata/NetMonHeader.hh"
12 #include "art/Framework/Core/OutputModule.h"
13 #include "art/Framework/Principal/EventPrincipal.h"
14 #include "art/Framework/Principal/OutputHandle.h"
15 #include "art/Framework/Principal/RunPrincipal.h"
16 #include "art/Framework/Principal/SubRunPrincipal.h"
17 #include "art/Persistency/Provenance/ModuleContext.h"
18 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
19 #include "art_root_io/setup.h"
21 #include "canvas/Persistency/Common/WrappedTypeID.h"
22 #include "canvas/Persistency/Provenance/BranchDescription.h"
23 #include "canvas/Persistency/Provenance/BranchKey.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/Exception.h"
33 #include "fhiclcpp/ParameterSet.h"
34 #include "fhiclcpp/ParameterSetRegistry.h"
36 #include <TBufferFile.h>
39 #include <TStreamerInfo.h>
51 #define TLVL_OPENFILE 34
52 #define TLVL_CLOSEFILE 35
53 #define TLVL_RESPONDTOCLOSEINPUTFILE 36
54 #define TLVL_RESPONDTOCLOSEOUTPUTFILE 37
55 #define TLVL_ENDJOB 38
56 #define TLVL_SENDINIT 39
57 #define TLVL_SENDINIT_VERBOSE1 40
58 #define TLVL_SENDINIT_VERBOSE2 41
59 #define TLVL_WRITEDATAPRODUCTS 42
60 #define TLVL_WRITEDATAPRODUCTS_VERBOSE 43
62 #define TLVL_WRITERUN 45
63 #define TLVL_WRITERUN_VERBOSE 46
64 #define TLVL_WRITESUBRUN 47
65 #define TLVL_WRITESUBRUN_VERBOSE 48
66 #define TLVL_EXTRACTPRODUCTS 49
67 #define TLVL_EXTRACTPRODUCTS_VERBOSE 50
73 static artdaq::FragmentPtr outputFrag =
nullptr;
74 inline char* Fragment_ReAllocChar(
char* dataPtr,
size_t size,
size_t )
76 if (outputFrag !=
nullptr && dataPtr == reinterpret_cast<char*>(outputFrag->dataBegin()))
78 outputFrag->resizeBytes(size);
80 return reinterpret_cast<char*
>(outputFrag->dataBegin());
96 : OutputModule(ps), productList_(), raw_data_label_(ps.get<std::string>(
"raw_data_label",
"daq"))
112 TLOG(TLVL_OPENFILE) <<
"Begin/End: ArtdaqOutput::openFile(const FileBlock&)";
118 virtual void closeFile() { TLOG(TLVL_CLOSEFILE) <<
"Begin/End: ArtdaqOutput::closeFile()"; }
125 TLOG(TLVL_RESPONDTOCLOSEINPUTFILE) <<
"Begin/End: ArtdaqOutput::"
126 "respondToCloseOutputFiles(FileBlock const&)";
134 TLOG(TLVL_RESPONDTOCLOSEOUTPUTFILE) <<
"Begin/End: ArtdaqOutput::"
135 "respondToCloseOutputFiles(FileBlock const&)";
143 TLOG(TLVL_ENDJOB) <<
"Begin/End: ArtdaqOutput::endJob()";
178 void event(EventPrincipal
const& ep)
final
186 virtual void event_(EventPrincipal
const&) {}
192 void write(EventPrincipal& ep)
final;
198 void writeRun(RunPrincipal& rp)
final;
212 void writeDataProducts(std::unique_ptr<TBufferFile>& msg,
const Principal& principal, std::vector<BranchKey*>& bkv);
229 virtual void SendMessage(artdaq::FragmentPtr& msg) = 0;
237 bool initMsgSent_{
false};
238 ProductList productList_;
239 size_t last_fragment_size_{10};
240 artdaq::Fragment::sequence_id_t last_sequence_id_{0};
241 artdaq::Fragment::timestamp_t last_timestamp_{0};
242 std::string raw_data_label_;
244 std::unique_ptr<TBufferFile> prepareMessage(artdaq::Fragment::sequence_id_t seqID, artdaq::Fragment::timestamp_t ts, artdaq::Fragment::type_t type)
247 outputFrag = std::make_unique<artdaq::Fragment>(last_fragment_size_, seqID, my_rank, type, hdr, ts);
248 auto msg = std::make_unique<TBufferFile>(TBuffer::kWrite, last_fragment_size_ *
sizeof(artdaq::RawDataType), outputFrag->dataBegin(), kFALSE, &Fragment_ReAllocChar);
251 if (seqID > last_sequence_id_) last_sequence_id_ = seqID;
252 if (ts > last_timestamp_) last_timestamp_ = ts;
257 void sendMessage(std::unique_ptr<TBufferFile>& msg)
260 hdr.
data_length =
static_cast<uint64_t
>(msg->Length());
261 outputFrag->updateMetadata(hdr);
262 outputFrag->resizeBytes(hdr.data_length);
263 last_fragment_size_ = std::ceil(msg->Length() /
static_cast<double>(
sizeof(artdaq::RawDataType)));
270 TLOG(TLVL_SENDINIT) <<
"Begin: ArtdaqOutput::send_init_message()";
280 static TClass* product_list_class = TClass::GetClass(
"std::map<art::BranchKey,art::BranchDescription>");
281 if (product_list_class ==
nullptr)
283 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
284 "Could not get TClass for "
285 "map<art::BranchKey,art::BranchDescription>!";
291 static TClass* process_history_map_class = TClass::GetClass(
"std::map<const art::Hash<2>,art::ProcessHistory>");
292 if (process_history_map_class ==
nullptr)
294 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
295 "Could not get class for "
296 "std::map<const art::Hash<2>,art::ProcessHistory>!";
300 static TClass* parentage_map_class = TClass::GetClass(
"art::ParentageMap");
301 if (parentage_map_class ==
nullptr)
303 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message(): "
304 "Could not get class for ParentageMap.";
306 TLOG(TLVL_SENDINIT) <<
"parentage_map_class: " <<
static_cast<void*
>(parentage_map_class);
311 auto msg = prepareMessage(0, 0, artdaq::Fragment::InitFragmentType);
315 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming message type code ...";
317 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming message type code.";
324 std::vector<std::string> classNames{
"std::map<art::BranchKey,art::BranchDescription>",
"std::map<const art::Hash<2>,art::ProcessHistory>",
"art::ParentageMap",
325 "art::BranchKey",
"art::ProductProvenance",
"art::RunAuxiliary",
"art::SubRunAuxiliary",
"art::EventAuxiliary"};
326 for (
auto& className : classNames)
328 TClass* class_ptr = TClass::GetClass(className.c_str());
329 if (class_ptr ==
nullptr)
331 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::send_init_message: Could not get TClass for " << className <<
"!";
333 infos.Add(class_ptr->GetStreamerInfo());
335 msg->WriteObject(&infos);
340 ULong_t ps_cnt = fhicl::ParameterSetRegistry::size();
341 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): parameter set count: " << ps_cnt;
342 msg->WriteULong(ps_cnt);
343 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming parameter sets ...";
344 for (
auto I = std::begin(fhicl::ParameterSetRegistry::get()), E = std::end(fhicl::ParameterSetRegistry::get());
347 TLOG(TLVL_SENDINIT) <<
"Pset ID " << I->first <<
": " << I->second.to_string();
348 std::string pset_str = I->second.to_string();
350 msg->WriteStdString(pset_str);
352 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming parameter sets.";
357 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming Product List sz=" << productList_.size() <<
"...";
358 msg->WriteObjectAny(&productList_, product_list_class);
359 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming Product List.";
361 art::ProcessHistoryMap phr;
362 for (
auto const& pr : art::ProcessHistoryRegistry::get())
369 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"ArtdaqOutput::send_init_message(): Dumping ProcessHistoryRegistry ...";
372 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"ArtdaqOutput::send_init_message(): phr: size: " << phr.size();
373 for (
auto I = phr.begin(), E = phr.end(); I != E; ++I)
375 std::ostringstream OS;
377 TLOG(TLVL_SENDINIT_VERBOSE2) <<
"ArtdaqOutput::send_init_message(): phr: id: '" << OS.str() <<
"'";
382 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming ProcessHistoryRegistry ...";
385 const art::ProcessHistoryMap& phm = phr;
386 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): phm: size: " << phm.size();
387 msg->WriteObjectAny(&phm, process_history_map_class);
388 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming ProcessHistoryRegistry.";
393 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Streaming ParentageRegistry ..." <<
static_cast<void*
>(parentage_map_class);
394 art::ParentageMap parentageMap{};
395 for (
auto const& pr : art::ParentageRegistry::get())
397 parentageMap.emplace(pr.first, pr.second);
400 msg->WriteObjectAny(&parentageMap, parentage_map_class);
402 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Finished streaming ParentageRegistry.";
404 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Sending init message";
406 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): Done sending init message";
408 TLOG(TLVL_SENDINIT) <<
"ArtdaqOutput::send_init_message(): END";
413 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"Begin: ArtdaqOutput::writeDataProducts(...)";
418 static TClass* branch_key_class = TClass::GetClass(
"art::BranchKey");
419 if (branch_key_class ==
nullptr)
421 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::writeDataProducts(...): "
422 "Could not get TClass for art::BranchKey!";
424 static TClass* prdprov_class = TClass::GetClass(
"art::ProductProvenance");
425 if (prdprov_class ==
nullptr)
427 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::writeDataProducts(...): "
428 "Could not get TClass for art::ProductProvenance!";
436 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
438 auto const& productDescription = I->second->productDescription();
439 auto const& refs = keptProducts()[productDescription.branchType()];
441 for (
auto const& ref : refs)
443 if (ref.second == productDescription)
449 if (!I->second->productAvailable() || !found)
458 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): Streaming product count: " +
459 std::to_string(prd_cnt);
460 msg->WriteULong(prd_cnt);
461 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): Finished streaming product count.";
473 bkv.reserve(prd_cnt);
475 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
477 auto const& productDescription = I->second->productDescription();
478 auto const& refs = keptProducts()[productDescription.branchType()];
480 for (
auto const& ref : refs)
482 if (ref.second == productDescription)
488 if (!I->second->productAvailable() || !found)
492 const BranchDescription& bd(I->second->productDescription());
493 bkv.push_back(
new BranchKey(bd));
494 TLOG(TLVL_WRITEDATAPRODUCTS_VERBOSE)
495 <<
"ArtdaqOutput::writeDataProducts(...): Dumping branch key of class: '"
496 << bkv.back()->friendlyClassName_ <<
"' modlbl: '" << bkv.back()->moduleLabel_ <<
"' instnm: '"
497 << bkv.back()->productInstanceName_ <<
"' procnm: '" << bkv.back()->processName_ <<
"'";
498 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): "
499 "Streaming branch key of class: '"
500 << bd.producedClassName() <<
"' modlbl: '" << bd.moduleLabel() <<
"' instnm: '"
501 << bd.productInstanceName() <<
"' procnm: '" << bd.processName() <<
"'";
502 msg->WriteObjectAny(bkv.back(), branch_key_class);
504 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): "
505 "Streaming product of class: '"
506 << bd.producedClassName() <<
"' modlbl: '" << bd.moduleLabel() <<
"' instnm: '"
507 << bd.productInstanceName() <<
"' procnm: '" << bd.processName() <<
"'";
509 OutputHandle oh = principal.getForOutput(bd.productID(),
true);
510 const EDProduct* prd = oh.wrapper();
511 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"Class for branch " << bd.wrappedName() <<
" is "
512 <<
static_cast<void*
>(TClass::GetClass(bd.wrappedName().c_str()));
513 msg->WriteObjectAny(prd, TClass::GetClass(bd.wrappedName().c_str()));
514 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"ArtdaqOutput::writeDataProducts(...): "
515 "Streaming product provenance of class: '"
516 << bd.producedClassName() <<
"' modlbl: '" << bd.moduleLabel() <<
"' instnm: '"
517 << bd.productInstanceName() <<
"' procnm: '" << bd.processName() <<
"'";
519 const ProductProvenance* prdprov = I->second->productProvenance().get();
521 msg->WriteObjectAny(prdprov, prdprov_class);
523 TLOG(TLVL_WRITEDATAPRODUCTS) <<
"End: ArtdaqOutput::writeDataProducts(...)";
531 TLOG(TLVL_WRITE) <<
"Begin: ArtdaqOutput::write(const EventPrincipal& ep)";
540 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
541 if (run_aux_class ==
nullptr)
543 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
544 "Could not get TClass for art::RunAuxiliary!";
546 static TClass* subrun_aux_class = TClass::GetClass(
"art::SubRunAuxiliary");
547 if (subrun_aux_class ==
nullptr)
549 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
550 "Could not get TClass for art::SubRunAuxiliary!";
552 static TClass* event_aux_class = TClass::GetClass(
"art::EventAuxiliary");
553 if (event_aux_class ==
nullptr)
555 throw art::Exception(art::errors::DictionaryNotFound) <<
"ArtdaqOutput::write(const EventPrincipal& ep): "
556 "Could not get TClass for art::EventAuxiliary!";
560 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Setting Output Fragment Header Fields";
561 auto seqID = (
static_cast<uint64_t
>(ep.eventID().subRun() - 1) << 32) + ep.eventID().event();
563 art::ProcessTag tag(
"", processName());
564 auto res = ep.getMany(art::ModuleContext::invalid(), art::WrappedTypeID::make<artdaq::detail::RawEventHeader>(), art::MatchAllSelector(), tag);
566 artdaq::Fragment::timestamp_t ts = 0;
568 for (
auto const& qr : res)
570 Handle<artdaq::detail::RawEventHeader> handle{qr};
571 if (handle.isValid())
573 if (handle->timestamp > ts) ts = handle->timestamp;
576 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Data Fragment Header Fields: SeqID: " << seqID <<
", timestamp: " << ts;
581 auto msg = prepareMessage(seqID, ts, artdaq::Fragment::DataFragmentType);
585 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming message type code ...";
587 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming message type code.";
592 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming RunAuxiliary ...";
593 msg->WriteObjectAny(&ep.subRunPrincipal().runPrincipal().runAux(), run_aux_class);
594 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming RunAuxiliary.";
599 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming SubRunAuxiliary ...";
600 msg->WriteObjectAny(&ep.subRunPrincipal().subRunAux(), subrun_aux_class);
601 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming SubRunAuxiliary.";
607 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Streaming EventAuxiliary ...";
608 msg->WriteObjectAny(&ep.eventAux(), event_aux_class);
609 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write(const EventPrincipal& ep): Finished streaming EventAuxiliary.";
615 std::vector<BranchKey*> bkv;
616 writeDataProducts(msg, ep, bkv);
618 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write: Sending message";
620 TLOG(TLVL_WRITE) <<
"ArtdaqOutput::write: Done sending message";
625 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
630 TLOG(TLVL_WRITE) <<
"End: ArtdaqOutput::write(const EventPrincipal& ep)";
637 TLOG(TLVL_WRITERUN) <<
"Begin: ArtdaqOutput::writeRun(const RunPrincipal& rp)";
649 static TClass* run_aux_class = TClass::GetClass(
"art::RunAuxiliary");
650 assert(run_aux_class !=
nullptr &&
"writeRun: Could not get TClass for art::RunAuxiliary!");
654 auto msg = prepareMessage(last_sequence_id_ + 1,rp.run() + 1, artdaq::Fragment::EndOfRunFragmentType);
659 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: streaming message type code ...";
661 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: finished streaming message type code.";
667 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: streaming RunAuxiliary ...";
668 msg->WriteObjectAny(&rp.runAux(), run_aux_class);
669 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: streamed RunAuxiliary.";
674 std::vector<BranchKey*> bkv;
675 writeDataProducts(msg, rp, bkv);
677 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: Sending message";
679 TLOG(TLVL_WRITERUN) <<
"ArtdaqOutput::writeRun: Done sending message";
681 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
687 TLOG(TLVL_WRITERUN) <<
"End: ArtdaqOutput::writeRun(RunPrincipal& rp)";
693 TLOG(TLVL_WRITESUBRUN) <<
"Begin: ArtdaqOutput::writeSubRun(const SubRunPrincipal& srp)";
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 auto msg = prepareMessage(last_sequence_id_ + 1, srp.subRun() + 1, artdaq::Fragment::EndOfSubrunFragmentType);
717 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: streaming message type code ...";
719 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: finished streaming message type code.";
725 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: streaming SubRunAuxiliary ...";
727 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: dumping ProcessHistoryRegistry ...";
730 for (
auto I = std::begin(art::ProcessHistoryRegistry::get()), E = std::end(art::ProcessHistoryRegistry::get());
733 std::ostringstream OS;
735 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: phr: id: '" << OS.str() <<
"'";
737 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: phr: data.size(): " << I->second.data().size();
738 if (!I->second.data().empty())
740 I->second.data().back().id().print(OS);
741 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: phr: data.back().id(): '" << OS.str() <<
"'";
744 if (!srp.subRunAux().processHistoryID().isValid())
746 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessHistoryID: 'INVALID'";
750 std::ostringstream OS;
751 srp.subRunAux().processHistoryID().print(OS);
752 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessHistoryID: '" << OS.str() <<
"'";
754 ProcessHistory processHistory;
755 ProcessHistoryRegistry::get(srp.subRunAux().processHistoryID(), processHistory);
756 if (!processHistory.data().empty())
759 processHistory.data().back().id().print(OS);
760 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessConfigurationID: '" << OS.str() <<
"'";
762 OS << processHistory.data().back();
763 TLOG(TLVL_WRITESUBRUN_VERBOSE) <<
"ArtdaqOutput::writeSubRun: ProcessConfiguration: '" << OS.str();
766 msg->WriteObjectAny(&srp.subRunAux(), subrun_aux_class);
767 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: streamed SubRunAuxiliary.";
772 std::vector<BranchKey*> bkv;
773 writeDataProducts(msg, srp, bkv);
775 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: Sending message";
777 TLOG(TLVL_WRITESUBRUN) <<
"ArtdaqOutput::writeSubRun: Done sending message";
782 for (
auto I = bkv.begin(), E = bkv.end(); I != E; ++I)
787 TLOG(TLVL_WRITESUBRUN) <<
"End: ArtdaqOutput::writeSubRun(const SubRunPrincipal& srp)";
792 TLOG(TLVL_EXTRACTPRODUCTS) <<
"Begin: ArtdaqOutput::extractProducts_(Principal const& principal) sz=" << principal.size();
794 for (
auto I = principal.begin(), E = principal.end(); I != E; ++I)
796 auto const& productDescription = I->second->productDescription();
797 auto const& branchKey = BranchKey(productDescription);
799 if (!productList_.count(branchKey))
801 TLOG(TLVL_EXTRACTPRODUCTS_VERBOSE) <<
"ArtdaqOutput::extractProducts_:"
802 <<
"Adding branch key to productList of class: '"
803 << branchKey.friendlyClassName_ <<
"' modlbl: '" << branchKey.moduleLabel_ <<
"' instnm: '"
804 << branchKey.productInstanceName_ <<
"' procnm: '" << branchKey.processName_ <<
"'"
805 <<
", description: " << productDescription.wrappedName();
807 productList_[branchKey] = productDescription;
811 TLOG(TLVL_EXTRACTPRODUCTS) <<
"End: ArtdaqOutput::extractProducts_(Principal const& principal) Product list sz=" << productList_.size();
814 #endif // ARTDAQ_ARTDAQ_ARTMODULES_ARTDAQOUTPUT_HH_
void writeRun(RunPrincipal &rp) final
Write a RunPrincipal to TBufferFile and send
virtual void event_(EventPrincipal const &)
Perform actions for each event. No-op, but derived classes may override
void extractProducts_(Principal const &principal)
Extract the list of Products from the given Principal
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
void event(EventPrincipal const &ep) final
Perform actions for each event. Derived classes should implement event_ instead.
void send_init_message()
Send an init message downstream.
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 SendMessage(artdaq::FragmentPtr &msg)=0
Send the serialized art Event downstream. Artdaq output modules should define this function...
void beginRun(RunPrincipal const &rp) final
Perform Begin Run actions. Derived classes should implement beginRun_ instead.
void beginSubRun(SubRunPrincipal const &srp) final
Perform Begin SubRun actions. Derived classes should implement beginSubRun_ instead.
virtual void closeFile()
Perform actions necessary for closing files. No-op, but derived classes may override ...
ArtdaqOutput(fhicl::ParameterSet const &ps)
ArtdaqOutput Constructor
virtual void respondToCloseOutputFiles(FileBlock const &)
Perform actions necessary after closing the output file(s). No-op, but derived classes may override ...
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
void write(EventPrincipal &ep) final
Write an EventPrincipal to TBufferFile and send
void writeDataProducts(std::unique_ptr< TBufferFile > &msg, const Principal &principal, std::vector< BranchKey * > &bkv)
Extract the data products from a Principal and write them to the TBufferFile