LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::EventPrincipal Class Referencefinal

#include "EventPrincipal.h"

Inheritance diagram for art::EventPrincipal:
art::Principal art::PrincipalBase

Public Types

using Auxiliary = EventAuxiliary
 
enum  allowed_processes { allowed_processes::current_process, allowed_processes::input_source, allowed_processes::all }
 
using GroupCollection = std::map< ProductID, std::unique_ptr< Group >>
 
using const_iterator = GroupCollection::const_iterator
 

Public Member Functions

 ~EventPrincipal ()
 
 EventPrincipal (EventAuxiliary const &aux, ProcessConfiguration const &pc, cet::exempt_ptr< ProductTable const > presentProducts, std::unique_ptr< DelayedReader > &&rtrv=std::make_unique< NoDelayedReader >(), bool lastInSubRun=false)
 
Event makeEvent (ModuleContext const &mc)
 
Event makeEvent (ModuleContext const &mc) const
 
EventAuxiliary const & eventAux () const
 
EventID const & eventID () const
 
EventNumber_t event () const
 
SubRunNumber_t subRun () const
 
RunNumber_t run () const
 
Timestamp const & time () const
 
SubRunPrincipal const & subRunPrincipal () const
 
void setSubRunPrincipal (cet::exempt_ptr< SubRunPrincipal const > srp)
 
EventAuxiliary::ExperimentType ExperimentType () const
 
bool isReal () const
 
bool isLastInSubRun () const
 
void createGroupsForProducedProducts (ProductTables const &producedProducts)
 
void refreshProcessHistoryID ()
 
GroupQueryResult getByProductID (ProductID const pid) const
 
GroupQueryResult getBySelector (ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
 
GroupQueryResult getByLabel (ModuleContext const &mc, WrappedTypeID const &wrapped, std::string const &label, std::string const &productInstanceName, ProcessTag const &processTag) const
 
std::vector< GroupQueryResultgetMany (ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
 
std::vector< InputTaggetInputTags (ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
 
std::vector< cet::exempt_ptr< Group > > getMatchingSequence (ModuleContext const &, SelectorBase const &, ProcessTag const &) const
 
EDProductGetter const * productGetter (ProductID id) const
 
Provenance provenance (ProductID id) const
 
ProcessHistory const & processHistory () const
 
OutputHandle getForOutput (ProductID const &, bool resolveProd) const
 
cet::exempt_ptr< BranchDescription const > getProductDescription (ProductID const pid, bool const alwaysEnableLookupOfProducedProducts=false) const
 
void enableLookupOfProducedProducts ()
 
void markProcessHistoryAsModified ()
 
void readImmediate () const
 
ProcessConfiguration const & processConfiguration () const
 
ProcessHistoryID const & processHistoryID () const
 
cet::exempt_ptr< ProductProvenance const > branchToProductProvenance (ProductID const &) const
 
size_t size () const
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator end () const
 
const_iterator cend () const
 
void addToProcessHistory ()
 
BranchType branchType () const
 
RangeSet seenRanges () const
 
void put (BranchDescription const &, std::unique_ptr< ProductProvenance const > &&, std::unique_ptr< EDProduct > &&, std::unique_ptr< RangeSet > &&)
 
EDProductGetter const * getEDProductGetter (ProductID const &pid) const
 

Static Public Attributes

static constexpr BranchType branch_type = Auxiliary::branch_type
 

Protected Member Functions

std::optional< ProductInsertermakeInserter (ModuleContext const &mc)
 
void fillGroup (BranchDescription const &)
 
void setProcessHistoryIDcombined (ProcessHistoryID const &)
 
void updateSeenRanges (RangeSet const &rs)
 

Private Attributes

cet::exempt_ptr< SubRunPrincipal const > subRunPrincipal_ {nullptr}
 
EventAuxiliary aux_
 
bool lastInSubRun_
 

Detailed Description

Definition at line 17 of file EventPrincipal.h.

Member Typedef Documentation

using art::Principal::const_iterator = GroupCollection::const_iterator
inherited

Definition at line 52 of file Principal.h.

using art::Principal::GroupCollection = std::map<ProductID, std::unique_ptr<Group>>
inherited

Definition at line 51 of file Principal.h.

Member Enumeration Documentation

enum art::Principal::allowed_processes
stronginherited
Enumerator
current_process 
input_source 
all 

Definition at line 53 of file Principal.h.

53 { current_process, input_source, all };

Constructor & Destructor Documentation

art::EventPrincipal::~EventPrincipal ( )
default
art::EventPrincipal::EventPrincipal ( EventAuxiliary const &  aux,
ProcessConfiguration const &  pc,
cet::exempt_ptr< ProductTable const >  presentProducts,
std::unique_ptr< DelayedReader > &&  rtrv = std::make_unique<NoDelayedReader>(),
bool  lastInSubRun = false 
)

Definition at line 10 of file EventPrincipal.cc.

References aux_, art::InEvent, lastInSubRun_, and art::EventAuxiliary::processHistoryID().

18  pc,
19  presentProducts,
20  aux.processHistoryID(),
21  std::move(reader)}
22  , aux_{aux}
23  , lastInSubRun_{lastInSubRun}
24  {}
EventAuxiliary aux_
Principal(BranchType, ProcessConfiguration const &, cet::exempt_ptr< ProductTable const > presentProducts, ProcessHistoryID const &id, std::unique_ptr< DelayedReader > &&reader=std::make_unique< NoDelayedReader >())
Definition: Principal.cc:119

Member Function Documentation

void art::Principal::addToProcessHistory ( )
inherited

Definition at line 423 of file Principal.cc.

References art::errors::Configuration, art::thread_safe_registry_via_id< K, M >::emplace(), art::ProcessHistory::get_mutex(), art::Principal::processConfiguration_, art::Principal::processHistory_, art::Principal::processHistoryModified_, and art::ProcessConfiguration::processName().

Referenced by art::Principal::createGroupsForProducedProducts(), and art::Principal::processHistoryID().

424  {
425  bool expected = false;
426  if (processHistoryModified_.compare_exchange_strong(expected, true)) {
427  // MT note: We have now locked out any other task trying to
428  // modify the process history. Now we have to block
429  // tasks that already have a pointer to the process
430  // history from accessing its internals while we update
431  // it. We do not protect the iteration interface, the
432  // begin(), end(), and size() are all separate calls
433  // and we cannot lock in each one because there is no
434  // way to automatically unlock.
435  std::lock_guard sentry{processHistory_.get_mutex()};
436  string const& processName = processConfiguration_.processName();
437  for (auto const& val : processHistory_) {
438  if (processName == val.processName()) {
440  << "The process name " << processName
441  << " was previously used on these products.\n"
442  << "Please modify the configuration file to use a "
443  << "distinct process name.\n";
444  }
445  }
446  processHistory_.push_back(processConfiguration_);
447  // Optimization note: As of 0_9_0_pre3 For very simple Sources
448  // (e.g. EmptyEvent) this routine takes up nearly 50% of the
449  // time per event, and 96% of the time for this routine is spent
450  // in computing the ProcessHistory id which happens because we
451  // are reconstructing the ProcessHistory for each event. It
452  // would probably be better to move the ProcessHistory
453  // construction out to somewhere which persists for longer than
454  // one Event.
455  auto const phid = processHistory_.id();
456  ProcessHistoryRegistry::emplace(phid, processHistory_);
457  }
458  }
std::atomic< bool > processHistoryModified_
Definition: Principal.h:232
ProcessHistory processHistory_
Definition: Principal.h:231
std::recursive_mutex & get_mutex() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ProcessConfiguration const & processConfiguration_
Definition: Principal.h:233
std::string const & processName() const noexcept
static auto emplace(value_type const &value)
Principal::const_iterator art::Principal::begin ( ) const
inherited

Definition at line 270 of file Principal.cc.

References art::Principal::groupMutex_, and art::Principal::groups_.

Referenced by art::Principal::processHistoryID().

271  {
272  std::lock_guard sentry{groupMutex_};
273  return groups_.begin();
274  }
GroupCollection groups_
Definition: Principal.h:246
std::recursive_mutex groupMutex_
Definition: Principal.h:241
cet::exempt_ptr< ProductProvenance const > art::Principal::branchToProductProvenance ( ProductID const &  pid) const
inherited

Definition at line 298 of file Principal.cc.

References art::Principal::getGroupLocal().

Referenced by art::markAncestors(), and art::Principal::processHistoryID().

299  {
300  // Note: The input source lock will be held when this routine is called.
301  //
302  // MT-TODO: For right now ignore the delay reading option for
303  // product provenance. If we do the delay reading then we
304  // must use a lock to interlock all fetches of provenance
305  // because the delay read fills the pp_by_pid_ one entry
306  // at a time, and we do not want other threads to find
307  // the info only partly there.
308  cet::exempt_ptr<ProductProvenance const> ret;
309  auto g = getGroupLocal(pid);
310  if (g.get() != nullptr) {
311  ret = g->productProvenance();
312  }
313  return ret;
314  }
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
Definition: Principal.cc:852
BranchType art::Principal::branchType ( ) const
inherited

Definition at line 807 of file Principal.cc.

References art::Principal::branchType_.

Referenced by art::SourceHelper::makePtr(), and art::Principal::processHistoryID().

808  {
809  return branchType_;
810  }
BranchType branchType_
Definition: Principal.h:230
Principal::const_iterator art::Principal::cbegin ( ) const
inherited

Definition at line 277 of file Principal.cc.

References art::Principal::groupMutex_, and art::Principal::groups_.

Referenced by art::Principal::processHistoryID().

278  {
279  std::lock_guard sentry{groupMutex_};
280  return groups_.cbegin();
281  }
GroupCollection groups_
Definition: Principal.h:246
std::recursive_mutex groupMutex_
Definition: Principal.h:241
Principal::const_iterator art::Principal::cend ( ) const
inherited

Definition at line 291 of file Principal.cc.

References art::Principal::groupMutex_, and art::Principal::groups_.

Referenced by art::Principal::processHistoryID().

292  {
293  std::lock_guard sentry{groupMutex_};
294  return groups_.cend();
295  }
GroupCollection groups_
Definition: Principal.h:246
std::recursive_mutex groupMutex_
Definition: Principal.h:241
void art::EventPrincipal::createGroupsForProducedProducts ( ProductTables const &  producedProducts)

Definition at line 115 of file EventPrincipal.cc.

References art::Principal::createGroupsForProducedProducts(), and refreshProcessHistoryID().

117  {
120  }
void createGroupsForProducedProducts(ProductTables const &producedProducts)
Definition: Principal.cc:201
void art::Principal::enableLookupOfProducedProducts ( )
inherited

Definition at line 220 of file Principal.cc.

References art::Principal::enableLookupOfProducedProducts_.

221  {
223  }
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:238
Principal::const_iterator art::Principal::end ( void  ) const
inherited

Definition at line 284 of file Principal.cc.

References art::Principal::groupMutex_, and art::Principal::groups_.

Referenced by art::Principal::processHistoryID().

285  {
286  std::lock_guard sentry{groupMutex_};
287  return groups_.end();
288  }
GroupCollection groups_
Definition: Principal.h:246
std::recursive_mutex groupMutex_
Definition: Principal.h:241
EventNumber_t art::EventPrincipal::event ( ) const

Definition at line 51 of file EventPrincipal.cc.

References aux_, art::EventID::event(), and art::EventAuxiliary::id().

52  {
53  return aux_.id().event();
54  }
EventAuxiliary aux_
EventNumber_t event() const
Definition: EventID.h:116
EventID const & id() const noexcept
EventAuxiliary const & art::EventPrincipal::eventAux ( ) const

Definition at line 39 of file EventPrincipal.cc.

References aux_.

40  {
41  return aux_;
42  }
EventAuxiliary aux_
EventID const & art::EventPrincipal::eventID ( ) const

Definition at line 45 of file EventPrincipal.cc.

References aux_, and art::EventAuxiliary::id().

Referenced by art::OutputModule::doWriteEvent(), art::Event::id(), art::Source< T >::throwIfInsane_(), and art::EndPathExecutor::writeEvent().

46  {
47  return aux_.id();
48  }
EventAuxiliary aux_
EventID const & id() const noexcept
EventAuxiliary::ExperimentType art::EventPrincipal::ExperimentType ( ) const

Definition at line 81 of file EventPrincipal.cc.

References aux_, and art::EventAuxiliary::experimentType().

Referenced by art::Event::experimentType().

82  {
83  return aux_.experimentType();
84  }
EventAuxiliary aux_
EventAuxiliary::ExperimentType experimentType() const noexcept
void art::Principal::fillGroup ( BranchDescription const &  pd)
protectedinherited

Definition at line 137 of file Principal.cc.

References util::cend(), art::combinable(), art::errors::Configuration, art::Principal::delayedReader_, art::Principal::groupMutex_, art::Principal::groups_, art::BranchDescription::processName(), art::BranchDescription::productID(), and art::errors::ProductRegistrationFailure.

Referenced by art::Principal::createGroupsForProducedProducts(), and art::Principal::processHistoryID().

138  {
139  std::lock_guard sentry{groupMutex_};
140  auto it = groups_.find(pd.productID());
141  if (it != std::cend(groups_)) {
142  // The 'combinable' call does not require that the processing
143  // history be the same, which is not what we are checking for here.
144  auto const& found_pd = it->second->productDescription();
145  if (combinable(found_pd, pd)) {
147  << "The process name " << pd.processName()
148  << " was previously used on these products.\n"
149  << "Please modify the configuration file to use a "
150  << "distinct process name.\n";
151  }
153  << "The product ID " << pd.productID() << " of the new product:\n"
154  << pd
155  << " collides with the product ID of the already-existing product:\n"
156  << found_pd
157  << "Please modify the instance name of the new product so as to avoid "
158  "the product ID collision.\n"
159  << "In addition, please notify artists@fnal.gov of this error.\n";
160  }
161 
162  groups_[pd.productID()] = create_group(delayedReader_.get(), pd);
163  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
GroupCollection groups_
Definition: Principal.h:246
std::recursive_mutex groupMutex_
Definition: Principal.h:241
bool combinable(BranchDescription const &a, BranchDescription const &b)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr< DelayedReader > delayedReader_
Definition: Principal.h:250
GroupQueryResult art::Principal::getByLabel ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
std::string const &  label,
std::string const &  productInstanceName,
ProcessTag const &  processTag 
) const
inherited

Definition at line 506 of file Principal.cc.

References art::Principal::getBySelector(), and art::ProcessTag::name().

Referenced by art::ProductRetriever::getByLabel_().

511  {
512  auto const& processName = processTag.name();
513  Selector const sel{ModuleLabelSelector{label} &&
514  ProductInstanceNameSelector{productInstanceName} &&
515  ProcessNameSelector{processName}};
516  return getBySelector(mc, wrapped, sel, processTag);
517  }
GroupQueryResult getBySelector(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
Definition: Principal.cc:488
GroupQueryResult art::Principal::getByProductID ( ProductID const  pid) const
inherited

Definition at line 839 of file Principal.cc.

References art::Principal::branchType_, art::Principal::getGroupTryAllFiles(), and art::errors::ProductNotFound.

Referenced by art::ProductRetriever::getByProductID_(), and art::ProductRetriever::getProductProvenance().

840  {
841  if (auto g = getGroupTryAllFiles(pid)) {
842  return GroupQueryResult{g};
843  }
844  auto whyFailed =
845  make_shared<Exception>(errors::ProductNotFound, "InvalidID");
846  *whyFailed << "Principal::getByProductID: no product with branch type: "
847  << branchType_ << " product id: " << pid << '\n';
848  return GroupQueryResult{whyFailed};
849  }
BranchType branchType_
Definition: Principal.h:230
cet::exempt_ptr< Group > getGroupTryAllFiles(ProductID const) const
Definition: Principal.cc:860
GroupQueryResult art::Principal::getBySelector ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
SelectorBase const &  sel,
ProcessTag const &  processTag 
) const
inherited

Definition at line 488 of file Principal.cc.

References art::Principal::findGroupsForProduct(), art::detail::indent(), art::SelectorBase::print(), art::WrappedTypeID::product_type, art::errors::ProductNotFound, and art::resolve_unique_product().

Referenced by art::Principal::getByLabel(), and art::ProductRetriever::getBySelector_().

492  {
493  auto const groups = findGroupsForProduct(mc, wrapped, sel, processTag);
494  auto const result = resolve_unique_product(groups, wrapped);
495  if (!result.has_value()) {
496  auto whyFailed = std::make_shared<Exception>(errors::ProductNotFound);
497  *whyFailed << "Found zero products matching all selection criteria\n"
498  << indent << "C++ type: " << wrapped.product_type << '\n'
499  << sel.print(indent) << '\n';
500  return GroupQueryResult{whyFailed};
501  }
502  return *result;
503  }
std::optional< GroupQueryResult > resolve_unique_product(std::vector< cet::exempt_ptr< art::Group >> const &product_groups, art::WrappedTypeID const &wrapped)
Definition: Group.cc:387
std::string indent(std::size_t const i)
std::vector< cet::exempt_ptr< Group > > findGroupsForProduct(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
Definition: Principal.cc:625
EDProductGetter const * art::PrincipalBase::getEDProductGetter ( ProductID const &  pid) const
inherited

Definition at line 12 of file PrincipalBase.cc.

References art::PrincipalBase::getEDProductGetter_().

13  {
14  return getEDProductGetter_(pid);
15  }
virtual EDProductGetter const * getEDProductGetter_(ProductID const &) const =0
OutputHandle art::Principal::getForOutput ( ProductID const &  pid,
bool  resolveProd 
) const
inherited

Definition at line 750 of file Principal.cc.

References art::Principal::getGroupTryAllFiles(), art::OutputHandle::invalid(), art::OutputHandle::productProvenance(), and art::OutputHandle::rangeOfValidity().

751  {
752  // MT-FIXME: Uses of group!
753  auto g = getGroupTryAllFiles(pid);
754  if (g.get() == nullptr) {
755  return OutputHandle::invalid();
756  }
757  if (resolveProd) {
758  if (!g->resolveProductIfAvailable()) {
759  // Behavior is the same as if the group wasn't there.
760  return OutputHandle::invalid();
761  }
762  if (g->anyProduct() == nullptr) {
763  return OutputHandle::invalid();
764  }
765  if (!g->anyProduct()->isPresent()) {
766  return OutputHandle::invalid();
767  }
768  }
769  if (!g->anyProduct() && !g->productProvenance()) {
770  return OutputHandle{g->rangeOfValidity()};
771  }
772  return OutputHandle{g->anyProduct(),
773  &g->productDescription(),
774  g->productProvenance(),
775  g->rangeOfValidity()};
776  }
cet::exempt_ptr< Group > getGroupTryAllFiles(ProductID const) const
Definition: Principal.cc:860
static OutputHandle invalid()
Definition: OutputHandle.h:44
std::vector< InputTag > art::Principal::getInputTags ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
SelectorBase const &  sel,
ProcessTag const &  processTag 
) const
inherited

Definition at line 520 of file Principal.cc.

References art::Principal::findGroupsForProduct().

Referenced by art::ProductRetriever::getInputTags_().

524  {
525  std::vector<InputTag> tags;
526  auto const groups = findGroupsForProduct(mc, wrapped, sel, processTag);
527  cet::transform_all(groups, back_inserter(tags), [](auto const g) {
528  return g->productDescription().inputTag();
529  });
530  return tags;
531  }
std::vector< cet::exempt_ptr< Group > > findGroupsForProduct(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
Definition: Principal.cc:625
std::vector< GroupQueryResult > art::Principal::getMany ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
SelectorBase const &  sel,
ProcessTag const &  processTag 
) const
inherited

Definition at line 534 of file Principal.cc.

References art::Principal::findGroupsForProduct(), art::resolve_products(), and art::WrappedTypeID::wrapped_product_type.

Referenced by art::ProductRetriever::getMany_().

538  {
539  auto const groups = findGroupsForProduct(mc, wrapped, sel, processTag);
540  return resolve_products(groups, wrapped.wrapped_product_type);
541  }
std::vector< cet::exempt_ptr< Group > > findGroupsForProduct(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
Definition: Principal.cc:625
std::vector< GroupQueryResult > resolve_products(std::vector< cet::exempt_ptr< art::Group >> const &groups, art::TypeID const &wrapped_type)
Definition: Group.cc:428
std::vector< cet::exempt_ptr< Group > > art::Principal::getMatchingSequence ( ModuleContext const &  mc,
SelectorBase const &  selector,
ProcessTag const &  processTag 
) const
inherited

Definition at line 550 of file Principal.cc.

References art::ProcessTag::current_process_search_allowed(), art::Principal::enableLookupOfProducedProducts_, art::Principal::findGroups(), art::ProcessTag::input_source_search_allowed(), art::Principal::matchingSequenceFromInputFile(), art::Principal::producedProducts_, art::Principal::secondaryPrincipals_, and art::Principal::tryNextSecondaryFile().

Referenced by art::ProductRetriever::getContainerForView_().

553  {
554  std::vector<cet::exempt_ptr<Group>> groups;
555  // Find groups from current process
556  if (processTag.current_process_search_allowed() &&
558  if (findGroups(
559  producedProducts_.load()->viewLookup, mc, selector, groups) != 0) {
560  return groups;
561  }
562  }
563 
564  if (!processTag.input_source_search_allowed()) {
565  return groups;
566  }
567 
568  // Look through currently opened input files
569  if (groups.empty()) {
570  groups = matchingSequenceFromInputFile(mc, selector);
571  if (!groups.empty()) {
572  return groups;
573  }
574  for (auto const& sp : secondaryPrincipals_) {
575  groups = sp->matchingSequenceFromInputFile(mc, selector);
576  if (!groups.empty()) {
577  return groups;
578  }
579  }
580  }
581  // Open more secondary files if necessary
582  if (groups.empty()) {
583  while (auto sp = tryNextSecondaryFile()) {
584  auto& new_sp = secondaryPrincipals_.emplace_back(std::move(sp));
585  groups = new_sp->matchingSequenceFromInputFile(mc, selector);
586  if (!groups.empty()) {
587  return groups;
588  }
589  }
590  }
591  return groups;
592  }
size_t findGroups(ProcessLookup const &, ModuleContext const &, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &groups) const
Definition: Principal.cc:461
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:238
auto tryNextSecondaryFile() const
Definition: Principal.cc:544
std::vector< cet::exempt_ptr< Group > > matchingSequenceFromInputFile(ModuleContext const &, SelectorBase const &) const
Definition: Principal.cc:595
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:237
std::vector< std::unique_ptr< Principal > > secondaryPrincipals_
Definition: Principal.h:260
cet::exempt_ptr< BranchDescription const > art::Principal::getProductDescription ( ProductID const  pid,
bool const  alwaysEnableLookupOfProducedProducts = false 
) const
inherited

Definition at line 779 of file Principal.cc.

References art::Principal::enableLookupOfProducedProducts_, art::Principal::presentProducts_, art::Principal::producedProducts_, and art::Principal::secondaryPrincipals_.

Referenced by art::ProductRetriever::getProductDescription(), art::ProductInserter::getProductDescription_(), and art::ProductRetriever::getProductID_().

782  {
783  // Find groups from current process
784  if (alwaysEnableLookupOfProducedProducts ||
786  if (producedProducts_.load() != nullptr) {
787  if (auto result = producedProducts_.load()->description(pid)) {
788  return result;
789  }
790  }
791  }
792  if (presentProducts_.load()) {
793  // Look through currently opened input files
794  if (auto result = presentProducts_.load()->description(pid)) {
795  return result;
796  }
797  }
798  for (auto const& sp : secondaryPrincipals_) {
799  if (auto result = sp->getProductDescription(pid)) {
800  return result;
801  }
802  }
803  return nullptr;
804  }
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:238
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:237
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:236
std::vector< std::unique_ptr< Principal > > secondaryPrincipals_
Definition: Principal.h:260
bool art::EventPrincipal::isLastInSubRun ( ) const

Definition at line 87 of file EventPrincipal.cc.

References lastInSubRun_.

Referenced by art::EndPathExecutor::writeEvent().

88  {
89  return lastInSubRun_;
90  }
bool art::EventPrincipal::isReal ( ) const

Definition at line 75 of file EventPrincipal.cc.

References aux_, and art::EventAuxiliary::isRealData().

Referenced by art::Event::isRealData().

76  {
77  return aux_.isRealData();
78  }
EventAuxiliary aux_
bool isRealData() const noexcept
Event art::EventPrincipal::makeEvent ( ModuleContext const &  mc)
Event art::EventPrincipal::makeEvent ( ModuleContext const &  mc) const

Definition at line 33 of file EventPrincipal.cc.

34  {
35  return Event{*this, mc};
36  }
std::optional< ProductInserter > art::Principal::makeInserter ( ModuleContext const &  mc)
protectedinherited

Definition at line 813 of file Principal.cc.

References art::Principal::branchType_.

Referenced by makeEvent(), art::ResultsPrincipal::makeResults(), art::RunPrincipal::makeRun(), art::SubRunPrincipal::makeSubRun(), and art::Principal::processHistoryID().

814  {
815  return std::make_optional<ProductInserter>(branchType_, *this, mc);
816  }
BranchType branchType_
Definition: Principal.h:230
void art::Principal::markProcessHistoryAsModified ( )
inherited

Definition at line 170 of file Principal.cc.

References art::Principal::processHistoryModified_.

171  {
173  }
std::atomic< bool > processHistoryModified_
Definition: Principal.h:232
ProcessConfiguration const & art::Principal::processConfiguration ( ) const
inherited

Definition at line 257 of file Principal.cc.

References art::Principal::processConfiguration_.

258  {
259  return processConfiguration_;
260  }
ProcessConfiguration const & processConfiguration_
Definition: Principal.h:233
ProcessHistory const & art::Principal::processHistory ( ) const
inherited

Definition at line 247 of file Principal.cc.

References art::Principal::processHistory_.

Referenced by art::ProductRetriever::getProcessParameterSet(), art::Event::processHistory(), art::Run::processHistory(), and art::SubRun::processHistory().

248  {
249  // MT note: We make no attempt to protect callers who use this
250  // call to get access to the iteration interface of the
251  // process history. See the threading notes there and
252  // here for the reasons why.
253  return processHistory_;
254  }
ProcessHistory processHistory_
Definition: Principal.h:231
ProcessHistoryID const& art::Principal::processHistoryID ( ) const
inlineinherited

Definition at line 148 of file Principal.h.

References art::Principal::addToProcessHistory(), art::Principal::begin(), art::Principal::branchToProductProvenance(), art::Principal::branchType(), art::Principal::cbegin(), art::Principal::cend(), art::Principal::ctor_create_groups(), art::Principal::ctor_fetch_process_history(), art::Principal::ctor_read_provenance(), art::Principal::end(), art::Principal::fillGroup(), art::Principal::findGroups(), art::Principal::findGroupsForProcess(), art::Principal::findGroupsForProduct(), art::Principal::findGroupsFromInputFile(), art::Principal::getEDProductGetter_(), art::Principal::getGroupLocal(), art::Principal::getGroupTryAllFiles(), art::ProcessHistory::id(), art::Principal::makeInserter(), art::Principal::matchingSequenceFromInputFile(), art::Principal::presentFromSource(), art::Principal::processHistory_, art::Principal::producedInProcess(), art::Principal::put(), art::Principal::seenRanges(), art::Principal::setProcessHistoryIDcombined(), art::Principal::size(), art::Principal::tryNextSecondaryFile(), art::Principal::updateSeenRanges(), and lar::dump::vector().

Referenced by art::RunPrincipal::createGroupsForProducedProducts(), art::ResultsPrincipal::createGroupsForProducedProducts(), art::SubRunPrincipal::createGroupsForProducedProducts(), art::Event::processHistoryID(), and refreshProcessHistoryID().

149  {
150  return processHistory_.id();
151  }
ProcessHistory processHistory_
Definition: Principal.h:231
ProcessHistoryID const & id() const
EDProductGetter const * art::Principal::productGetter ( ProductID  id) const
inherited

Definition at line 177 of file Principal.cc.

References art::Principal::getGroupTryAllFiles().

Referenced by art::Principal::getEDProductGetter_(), art::SourceHelper::makePtr(), art::ProductRetriever::productGetter(), and art::ProductInserter::productGetter_().

178  {
179  auto g = getGroupTryAllFiles(pid);
180  if (g.get() != nullptr) {
181  // Note: All produced products should be found.
182  return g.get();
183  }
184  return nullptr;
185  }
cet::exempt_ptr< Group > getGroupTryAllFiles(ProductID const) const
Definition: Principal.cc:860
Provenance art::Principal::provenance ( ProductID  id) const
inherited

Definition at line 189 of file Principal.cc.

References art::Principal::getGroupLocal().

Referenced by art::ProductInserter::provenance_().

190  {
191  return Provenance{getGroupLocal(pid)};
192  }
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
Definition: Principal.cc:852
void art::Principal::put ( BranchDescription const &  bd,
std::unique_ptr< ProductProvenance const > &&  pp,
std::unique_ptr< EDProduct > &&  edp,
std::unique_ptr< RangeSet > &&  rs 
)
inherited

Definition at line 713 of file Principal.cc.

References art::BranchDescription::branchName(), art::Principal::branchType_, art::Principal::getGroupLocal(), art::RangeSet::invalid(), art::BranchDescription::productID(), art::errors::ProductRegistrationFailure, and art::detail::range_sets_supported().

Referenced by art::ProductInserter::commitProducts(), and art::Principal::processHistoryID().

717  {
718  assert(edp);
720  // Note: We intentionally allow group and provenance replacement
721  // for run and subrun products.
722  auto group = getGroupLocal(bd.productID());
723  assert(group);
724  group->setProductAndProvenance(
725  std::move(pp), std::move(edp), std::move(rs));
726  } else {
727  auto group = getGroupLocal(bd.productID());
728  assert(group);
729  if (group->anyProduct() != nullptr) {
730  throw Exception(errors::ProductRegistrationFailure, "Principal::put:")
731  << "Problem found during put of " << branchType_
732  << " product: product already put for " << bd.branchName() << '\n';
733  }
734  group->setProductAndProvenance(
735  std::move(pp),
736  std::move(edp),
737  make_unique<RangeSet>(RangeSet::invalid()));
738  }
739  }
BranchType branchType_
Definition: Principal.h:230
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
static RangeSet invalid()
Definition: RangeSet.cc:45
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
Definition: Principal.cc:852
constexpr bool range_sets_supported(BranchType const bt)
void art::Principal::readImmediate ( ) const
inherited

Definition at line 226 of file Principal.cc.

References art::Principal::groupMutex_, art::Principal::groups_, and util::values().

227  {
228  // Read all data products and provenance immediately, if
229  // available. Used only by RootInputFile to implement the
230  // delayedRead*Products config options.
231  //
232  // Note: The input source lock will be held when this routine is called.
233  //
234  // MT-TODO: For right now ignore the delay reading option for
235  // product provenance. If we do the delay reading then we
236  // must use a lock to interlock all fetches of provenance
237  // because the delay read fills the pp_by_pid_ one entry
238  // at a time, and we do not want other threads to find
239  // the info only partly there.
240  std::lock_guard sentry{groupMutex_};
241  for (auto const& group : groups_ | ::ranges::views::values) {
242  group->resolveProductIfAvailable();
243  }
244  }
GroupCollection groups_
Definition: Principal.h:246
std::recursive_mutex groupMutex_
Definition: Principal.h:241
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
void art::EventPrincipal::refreshProcessHistoryID ( )

Definition at line 109 of file EventPrincipal.cc.

References aux_, art::Principal::processHistoryID(), and art::EventAuxiliary::setProcessHistoryID().

Referenced by createGroupsForProducedProducts().

110  {
112  }
void setProcessHistoryID(ProcessHistoryID const &)
EventAuxiliary aux_
ProcessHistoryID const & processHistoryID() const
Definition: Principal.h:148
RunNumber_t art::EventPrincipal::run ( ) const

Definition at line 63 of file EventPrincipal.cc.

References aux_, art::EventAuxiliary::id(), and art::EventID::run().

64  {
65  return aux_.id().run();
66  }
EventAuxiliary aux_
RunNumber_t run() const
Definition: EventID.h:98
EventID const & id() const noexcept
RangeSet art::Principal::seenRanges ( ) const
inherited
void art::Principal::setProcessHistoryIDcombined ( ProcessHistoryID const &  )
protectedinherited
void art::EventPrincipal::setSubRunPrincipal ( cet::exempt_ptr< SubRunPrincipal const >  srp)

Definition at line 103 of file EventPrincipal.cc.

References subRunPrincipal_.

104  {
105  subRunPrincipal_ = srp;
106  }
cet::exempt_ptr< SubRunPrincipal const > subRunPrincipal_
size_t art::Principal::size ( void  ) const
inherited

Definition at line 263 of file Principal.cc.

References art::Principal::groupMutex_, and art::Principal::groups_.

Referenced by art::Principal::processHistoryID().

264  {
265  std::lock_guard sentry{groupMutex_};
266  return groups_.size();
267  }
GroupCollection groups_
Definition: Principal.h:246
std::recursive_mutex groupMutex_
Definition: Principal.h:241
SubRunNumber_t art::EventPrincipal::subRun ( ) const

Definition at line 57 of file EventPrincipal.cc.

References aux_, art::EventAuxiliary::id(), and art::EventID::subRun().

58  {
59  return aux_.id().subRun();
60  }
EventAuxiliary aux_
SubRunNumber_t subRun() const
Definition: EventID.h:110
EventID const & id() const noexcept
SubRunPrincipal const & art::EventPrincipal::subRunPrincipal ( ) const

Definition at line 93 of file EventPrincipal.cc.

References art::errors::NullPointerError, and subRunPrincipal_.

94  {
95  if (subRunPrincipal_.get() == nullptr) {
97  << "Tried to obtain a NULL subRunPrincipal.\n";
98  }
99  return *subRunPrincipal_;
100  }
cet::exempt_ptr< SubRunPrincipal const > subRunPrincipal_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Timestamp const & art::EventPrincipal::time ( ) const

Definition at line 69 of file EventPrincipal.cc.

References aux_, and art::EventAuxiliary::time().

Referenced by art::Event::time().

70  {
71  return aux_.time();
72  }
EventAuxiliary aux_
Timestamp const & time() const noexcept
void art::Principal::updateSeenRanges ( RangeSet const &  rs)
protectedinherited

Definition at line 707 of file Principal.cc.

References art::Principal::rangeSet_.

Referenced by art::Principal::processHistoryID().

708  {
709  rangeSet_ = rs;
710  }
RangeSet rangeSet_
Definition: Principal.h:266

Member Data Documentation

EventAuxiliary art::EventPrincipal::aux_
private
constexpr BranchType art::EventPrincipal::branch_type = Auxiliary::branch_type
static

Definition at line 20 of file EventPrincipal.h.

bool art::EventPrincipal::lastInSubRun_
private

Definition at line 53 of file EventPrincipal.h.

Referenced by EventPrincipal(), and isLastInSubRun().

cet::exempt_ptr<SubRunPrincipal const> art::EventPrincipal::subRunPrincipal_ {nullptr}
private

Definition at line 51 of file EventPrincipal.h.

Referenced by setSubRunPrincipal(), and subRunPrincipal().


The documentation for this class was generated from the following files: