27 #include "cetlib/container_algorithms.h" 28 #include "cetlib/exempt_ptr.h" 29 #include "range/v3/view.hpp" 42 std::string
const indent(2,
' ');
50 create_group(DelayedReader* reader, BranchDescription
const& bd)
52 auto const& class_name = bd.producedClassName();
53 auto gt = Group::grouptype::normal;
56 gt = Group::grouptype::assns;
58 gt = Group::grouptype::assnsWithData;
61 return make_unique<Group>(
62 reader, bd, make_unique<RangeSet>(RangeSet::invalid()), gt);
68 Principal::ctor_create_groups(
69 cet::exempt_ptr<ProductTable const> presentProducts)
71 if (!presentProducts) {
83 assert(pd.branchType() == branchType_);
89 Principal::ctor_read_provenance()
91 for (
auto&& provenance : delayedReader_->readProvenance()) {
92 auto g = getGroupLocal(provenance.productID());
93 if (g.get() ==
nullptr) {
97 g->setProductProvenance(make_unique<ProductProvenance>(provenance));
100 g->setProductProvenance(make_unique<ProductProvenance>(
101 provenance.productID(),
103 provenance.parentage().parents()));
116 std::swap(processHistory_, processHistory);
121 cet::exempt_ptr<ProductTable const> presentProducts,
123 std::unique_ptr<DelayedReader>&&
125 : branchType_{branchType}
144 auto const& found_pd = it->second->productDescription();
148 <<
" was previously used on these products.\n" 149 <<
"Please modify the configuration file to use a " 150 <<
"distinct process name.\n";
153 <<
"The product ID " << pd.
productID() <<
" of the new product:\n" 155 <<
" collides with the product ID of the already-existing product:\n" 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";
180 if (g.get() !=
nullptr) {
206 if (produced.descriptions.empty()) {
242 group->resolveProductIfAvailable();
297 cet::exempt_ptr<ProductProvenance const>
308 cet::exempt_ptr<ProductProvenance const> ret;
310 if (g.get() !=
nullptr) {
311 ret = g->productProvenance();
425 bool expected =
false;
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";
455 auto const phid = processHistory_.id();
480 if (
auto it = pl.find(h.processName()); it != pl.end()) {
495 if (!result.has_value()) {
497 *whyFailed <<
"Found zero products matching all selection criteria\n" 509 string const& productInstanceName,
512 auto const& processName = processTag.
name();
519 std::vector<InputTag>
525 std::vector<InputTag> tags;
527 cet::transform_all(groups, back_inserter(tags), [](
auto const g) {
528 return g->productDescription().inputTag();
533 std::vector<GroupQueryResult>
549 std::vector<cet::exempt_ptr<Group>>
554 std::vector<cet::exempt_ptr<Group>> groups;
569 if (groups.empty()) {
571 if (!groups.empty()) {
575 groups = sp->matchingSequenceFromInputFile(mc, selector);
576 if (!groups.empty()) {
582 if (groups.empty()) {
585 groups = new_sp->matchingSequenceFromInputFile(mc, selector);
586 if (!groups.empty()) {
594 std::vector<cet::exempt_ptr<Group>>
598 std::vector<cet::exempt_ptr<Group>> groups;
618 if (it == lookup.end()) {
621 return findGroups(it->second, mc, selector, groups);
624 std::vector<cet::exempt_ptr<Group>>
630 std::vector<cet::exempt_ptr<Group>> results;
637 if (it != lookup.end()) {
638 ret +=
findGroups(it->second, mc, selector, results);
652 if (sp->findGroupsFromInputFile(mc, wrapped, selector, results)) {
658 auto& new_sp = secondaryPrincipals_.emplace_back(std::move(sp));
659 if (new_sp->findGroupsFromInputFile(mc, wrapped, selector, results)) {
668 std::vector<ProductID>
const& vpid,
674 for (
auto const pid : vpid) {
679 auto const& pd = group->productDescription();
690 if (!sel.
match(pd)) {
694 res.emplace_back(group);
714 unique_ptr<ProductProvenance const>&& pp,
715 unique_ptr<EDProduct>&& edp,
716 unique_ptr<RangeSet>&& rs)
724 group->setProductAndProvenance(
725 std::move(pp), std::move(edp), std::move(rs));
729 if (group->anyProduct() !=
nullptr) {
732 <<
" product: product already put for " << bd.
branchName() <<
'\n';
734 group->setProductAndProvenance(
754 if (g.get() ==
nullptr) {
758 if (!g->resolveProductIfAvailable()) {
762 if (g->anyProduct() ==
nullptr) {
765 if (!g->anyProduct()->isPresent()) {
769 if (!g->anyProduct() && !g->productProvenance()) {
773 &g->productDescription(),
775 g->rangeOfValidity()};
778 cet::exempt_ptr<BranchDescription const>
781 bool const alwaysEnableLookupOfProducedProducts )
const 784 if (alwaysEnableLookupOfProducedProducts ||
799 if (
auto result = sp->getProductDescription(pid)) {
812 std::optional<ProductInserter>
815 return std::make_optional<ProductInserter>(
branchType_, *
this, mc);
825 return pd ==
nullptr ?
false : pd->produced();
835 return pd ==
nullptr ?
false : pd->present();
846 *whyFailed <<
"Principal::getByProductID: no product with branch type: " 851 cet::exempt_ptr<Group>
856 return it !=
groups_.cend() ? it->second.get() :
nullptr;
859 cet::exempt_ptr<Group>
868 if (sp->presentFromSource(pid)) {
869 return sp->getGroupLocal(pid);
874 auto& new_sp = secondaryPrincipals_.emplace_back(std::move(sp));
875 if (new_sp->presentFromSource(pid)) {
876 return new_sp->getGroupLocal(pid);
std::optional< ProductInserter > makeInserter(ModuleContext const &mc)
const_iterator cend() const
std::atomic< bool > processHistoryModified_
size_t findGroups(ProcessLookup const &, ModuleContext const &, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &groups) const
std::map< std::string, std::vector< ProductID >> ProcessLookup
std::atomic< bool > enableLookupOfProducedProducts_
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
auto tryNextSecondaryFile() const
const_iterator end() const
std::vector< InputTag > getInputTags(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
std::string friendlyClassName() const
ProcessHistory processHistory_
bool input_source_search_allowed() const
std::recursive_mutex & get_mutex() const
auto & get(BranchType const bt)
constexpr ProductStatus dummyToPreventDoubleCount() noexcept
void addToProcessHistory()
std::optional< GroupQueryResult > resolve_unique_product(std::vector< cet::exempt_ptr< art::Group >> const &product_groups, art::WrappedTypeID const &wrapped)
std::vector< cet::exempt_ptr< Group > > matchingSequenceFromInputFile(ModuleContext const &, SelectorBase const &) const
size_t findGroupsFromInputFile(ModuleContext const &, WrappedTypeID const &wrapped, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &results) const
void updateSeenRanges(RangeSet const &rs)
std::recursive_mutex groupMutex_
void readImmediate() const
std::string const & processName() const noexcept
ProductProvenance const * productProvenance() const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
GroupQueryResult getBySelector(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
TypeID wrapped_product_type
void createGroupsForProducedProducts(ProductTables const &producedProducts)
std::string print(std::string const &indent) const
bool presentFromSource(ProductID) const
bool current_process_search_allowed() const
RangeSet seenRanges() const
std::atomic< ProductTable const * > producedProducts_
OutputHandle getForOutput(ProductID const &, bool resolveProd) const
cet::exempt_ptr< BranchDescription const > getProductDescription(ProductID const pid, bool const alwaysEnableLookupOfProducedProducts=false) const
constexpr ProductStatus unknown() noexcept
EDProductGetter const * productGetter(ProductID id) const
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::string indent(std::size_t const i)
EDProductGetter const * getEDProductGetter_(ProductID const &) const override
void put(BranchDescription const &, std::unique_ptr< ProductProvenance const > &&, std::unique_ptr< EDProduct > &&, std::unique_ptr< RangeSet > &&)
string name_of_template_arg(string const &template_instance, size_t desired_arg)
std::vector< cet::exempt_ptr< Group > > getMatchingSequence(ModuleContext const &, SelectorBase const &, ProcessTag const &) const
std::atomic< ProductTable const * > presentProducts_
void ctor_fetch_process_history(ProcessHistoryID const &)
std::vector< cet::exempt_ptr< Group > > findGroupsForProduct(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
void ctor_create_groups(cet::exempt_ptr< ProductTable const >)
bool combinable(BranchDescription const &a, BranchDescription const &b)
ProcessHistory const & processHistory() const
cet::exempt_ptr< ProductProvenance const > branchToProductProvenance(ProductID const &) const
void enableLookupOfProducedProducts()
ProcessConfiguration const & processConfiguration() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
bool onSamePathAs(std::string const &module_label) const
auto const & name() const
cet::exempt_ptr< Group > getGroupTryAllFiles(ProductID const) const
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
int nextSecondaryFileIdx_
ProcessConfiguration const & processConfiguration_
static RangeSet invalid()
void ctor_read_provenance()
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
std::vector< GroupQueryResult > getMany(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
bool onTriggerPath() const
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
static OutputHandle invalid()
void fillGroup(BranchDescription const &)
bool match(BranchDescription const &p) const
GroupQueryResult getByLabel(ModuleContext const &mc, WrappedTypeID const &wrapped, std::string const &label, std::string const &productInstanceName, ProcessTag const &processTag) const
std::unique_ptr< DelayedReader > delayedReader_
void markProcessHistoryAsModified()
std::string const & processName() const noexcept
GroupQueryResult getByProductID(ProductID const pid) const
std::vector< std::unique_ptr< Principal > > secondaryPrincipals_
static auto emplace(value_type const &value)
RangeSet const & rangeOfValidity() const
GroupCollection::const_iterator const_iterator
std::string const & branchName() const noexcept
constexpr bool range_sets_supported(BranchType const bt)
bool producedInProcess(ProductID) const
ProductID productID() const noexcept
const_iterator cbegin() const
size_t findGroupsForProcess(std::vector< ProductID > const &vpid, ModuleContext const &mc, SelectorBase const &selector, std::vector< cet::exempt_ptr< Group >> &groups) const
bool is_assns(std::string const &type_name)
const_iterator begin() const
BranchType branchType() const
Provenance provenance(ProductID id) const
std::vector< GroupQueryResult > resolve_products(std::vector< cet::exempt_ptr< art::Group >> const &groups, art::TypeID const &wrapped_type)