41 returnValue += currentProcess;
45 return processFromInputTag;
49 throw Exception(
error,
"InvalidID") <<
"Principal::" << where <<
": no product with given branch id: " << bid
62 <<
": Found zero products matching all criteria\nLooking for type: " << productType <<
"\n" 63 <<
"Looking for module label: " <<
label <<
"\n" 64 <<
"Looking for productInstanceName: " <<
instance <<
"\n" 65 << (
process.empty() ?
"" :
"Looking for process: ") <<
process <<
"\n";
68 <<
": Found zero products matching all criteria\nLooking for a container with elements of type: " 69 << productType <<
"\n" 70 <<
"Looking for module label: " <<
label <<
"\n" 71 <<
"Looking for productInstanceName: " <<
instance <<
"\n" 72 << (
process.empty() ?
"" :
"Looking for process: ") <<
process <<
"\n";
84 <<
": More than 1 product matches all criteria\nLooking for type: " << productType <<
"\n" 85 <<
"Looking for module label: " <<
label <<
"\n" 86 <<
"Looking for productInstanceName: " <<
instance <<
"\n" 87 << (
process.empty() ?
"" :
"Looking for process: ") <<
process <<
"\n" 88 <<
"This can only occur with get function calls using a Handle<View> argument.\n" 89 <<
"Try a get not using a View or change the instance name of one of the products";
94 void failedToRegisterConsumes(
KindOfType kindOfType,
95 TypeID
const& productType,
100 exception <<
"::getByLabel without corresponding call to consumes or mayConsumes for this module.\n" 101 << (kindOfType ==
PRODUCT_TYPE ?
" type: " :
" type: edm::View<") << productType
103 <<
"\n product instance name: '" << productInstanceName <<
"'\n process name: '" <<
processName 116 std::shared_ptr<ProductResolverIndexHelper const> productLookup,
120 bool isForPrimaryProcess)
122 processHistoryPtr_(),
124 processHistoryIDBeforeConfig_(),
125 processConfiguration_(&pc),
128 productLookup_(productLookup),
129 lookupProcessOrder_(productLookup->lookupProcessNames().
size(), 0),
132 historyAppender_(historyAppender),
141 bool hasAliases =
false;
142 bool hasSwitchAliases =
false;
143 for (
auto const&
prod : prodsList) {
150 hasSwitchAliases =
true;
152 auto cbd = std::make_shared<BranchDescription const>(bd);
176 auto cbd = std::make_shared<BranchDescription const>(bd);
183 for (
auto const&
prod : prodsList) {
191 if (hasSwitchAliases) {
192 for (
auto const&
prod : prodsList) {
196 auto cbd = std::make_shared<BranchDescription const>(bd);
214 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
216 std::vector<bool> ambiguous(lookupProcessNames.size(),
false);
218 std::vector<TypeID>
const& sortedTypeIDs =
productLookup_->sortedTypeIDs();
220 std::vector<ProductResolverIndexHelper::IndexAndNames>
const& indexAndNames =
productLookup_->indexAndNames();
221 std::vector<char>
const& processNamesCharArray =
productLookup_->processNames();
223 unsigned int numberOfMatches = 0;
225 if (!sortedTypeIDs.empty()) {
227 for (
unsigned int k = 0, kEnd = sortedTypeIDs.size();
k < kEnd; ++
k) {
236 std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
238 bool productMadeAtEnd =
false;
240 for (
unsigned int j = 0;
j < matchingHolders.size(); ++
j) {
242 productResolvers_[matchingHolders[
j]]->branchDescription().availableOnlyAtEndTransition()) {
243 productMadeAtEnd =
true;
247 std::shared_ptr<ProductResolverBase> newHolder =
248 std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
252 ambiguous.assign(lookupProcessNames.size(),
false);
256 productResolverIndex = product.
index();
259 auto iter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(),
process);
260 assert(iter != lookupProcessNames.end());
262 lastMatchIndex = iMatchingIndex;
267 ambiguous.at(iter - lookupProcessNames.begin()) =
true;
269 matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
278 std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
280 bool productMadeAtEnd =
false;
281 for (
unsigned int i = 0;
i < matchingHolders.size(); ++
i) {
283 productResolvers_[matchingHolders[
i]]->branchDescription().availableOnlyAtEndTransition()) {
284 productMadeAtEnd =
true;
288 std::shared_ptr<ProductResolverBase> newHolder =
289 std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
302 for (
auto const&
prod : *
this) {
303 if (
prod->singleProduct() &&
304 !
prod->productUnavailable() && !
prod->unscheduledWasNotRun() && !
prod->branchDescription().dropped()) {
314 for (
auto const&
prod : prodsList) {
317 auto cbd = std::make_shared<BranchDescription const>(bd);
319 if (phb ==
nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
329 auto phb = std::make_unique<PuttableProductResolver>(
std::move(bd));
334 auto phb = std::make_unique<PuttableProductResolver>(
std::move(bd));
388 for (
auto&
prod : *
this) {
389 prod->resetProductData();
396 phb->unsafe_deleteProduct();
424 std::shared_ptr<ProcessHistory const> inputProcessHistory;
426 if (
hist.isValid()) {
428 auto noDel = [](
void const*) {};
429 inputProcessHistory = std::shared_ptr<ProcessHistory const>(
processHistory, noDel);
430 if (inputProcessHistory.get() ==
nullptr) {
432 <<
"Input ProcessHistory not found in registry\n" 433 <<
"Contact a Framework developer\n";
437 inputProcessHistory = std::shared_ptr<ProcessHistory const>(&
s_emptyProcessHistory, [](
void const*) {});
448 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
461 auto nameIterCurrentProcess =
463 if (nameIterCurrentProcess != lookupProcessNames.end()) {
477 auto nameIter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
478 if (nameIter == lookupProcessNames.end()) {
492 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
495 auto iter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(), processNameOfBlock);
496 if (iter != lookupProcessNames.end()) {
519 <<
"Principal::getExistingProduct\n" 520 <<
" Branch " << newProduct.
branchName() <<
" has same branch ID as branch " <<
existing.branchName()
522 <<
"Workaround: change process name or product instance name of " << newProduct.
branchName() <<
"\n";
545 if (phb !=
nullptr) {
548 <<
"addProductOrThrow: Problem found while adding product, " 617 bool skipCurrentProcess,
623 assert(
nullptr != productResolver.get());
624 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
632 if (productData ==
nullptr) {
637 return BasicHandle(productData->wrapper(), &(productData->provenance()));
642 bool skipCurrentProcess,
646 assert(
nullptr != productResolver.get());
647 productResolver->prefetchAsync(
task, *
this, skipCurrentProcess,
token,
nullptr, mcc);
656 bool skipCurrentProcess =
inputTag.willSkipCurrentProcess();
662 if (skipCurrentProcess) {
679 for (
auto const&
item :
preg_->productList()) {
680 auto const& bd =
item.second;
681 if (bd.present() and bd.unwrappedTypeID() == typeID and bd.moduleLabel() ==
inputTag.label() and
682 bd.productInstanceName() ==
inputTag.instance()) {
685 (skipCurrentProcess and not inCurrentProcess)
or 687 failedToRegisterConsumes(
701 failedToRegisterConsumes(kindOfType,
710 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
736 for (
auto const&
item :
preg_->productList()) {
737 auto const& bd =
item.second;
738 if (bd.present() and bd.unwrappedTypeID() == typeID and bd.moduleLabel() ==
label and
739 bd.productInstanceName() ==
instance) {
754 auto resolution = productResolver->resolveProduct(*
this,
false, sra, mcc);
773 if (phb ==
nullptr) {
777 if (phb->unscheduledWasNotRun()) {
779 <<
"Requesting provenance from unrun EDProducer. The requested branch ID was: " << bid;
781 return *phb->provenance();
786 if (phb ==
nullptr) {
790 return *phb->stableProvenance();
798 for (
auto const& productResolver : *
this) {
799 if (productResolver->singleProduct() && productResolver->provenanceAvailable() &&
800 !productResolver->branchDescription().isAnyAlias()) {
803 if (productResolver->provenance()->branchDescription().present()) {
804 provenances.push_back(productResolver->provenance());
815 for (
auto const& productResolver : *
this) {
816 if (productResolver->singleProduct() && !productResolver->branchDescription().isAnyAlias()) {
817 if (productResolver->stableProvenance()->branchDescription().present()) {
818 provenances.push_back(productResolver->stableProvenance());
825 for (
auto&
prod : bids) {
841 unsigned int)
const {
847 std::vector<WrapperBase const*>&,
848 std::vector<unsigned int>&)
const {
854 return std::monostate{};
862 if (edp.get() ==
nullptr) {
864 <<
"put: Cannot put because unique_ptr to product is null." 875 bool changed =
false;
877 for (
auto const&
prod :
preg_->productList()) {
885 auto cbd = std::make_shared<BranchDescription const>(bd);
907 for (
auto&
prod : *
this) {
908 prod->retrieveAndMerge(*
this, mergeableRunProductMetadata);
std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &, unsigned int) const override
void fillPrincipal(DelayedReader *reader)
static ProcessHistory const s_emptyProcessHistory
void getAllProvenance(std::vector< Provenance const *> &provenances) const
ProcessHistoryID processHistoryIDBeforeConfig_
void setupUnscheduled(UnscheduledConfigurator const &)
unsigned int ProductResolverIndex
BasicHandle getByToken(KindOfType kindOfType, TypeID const &typeID, ProductResolverIndex index, bool skipCurrentProcess, bool &ambiguous, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
static std::string const source("source")
ProductResolverCollection productResolvers_
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
std::shared_ptr< ProcessHistory const > processHistoryPtr_
ProductList const & productList() const
BranchID const & branchID() const
static PFTauRenderPlugin instance
ProductRegistry const & productRegistry() const
std::shared_ptr< ProductResolverBase > SharedProductPtr
void addProduct_(std::unique_ptr< ProductResolverBase > phb)
BranchType const & branchType() const
static std::atomic< Principal::CacheIdentifier_t > s_nextIdentifier
StableProvenance const & getStableProvenance(BranchID const &bid) const
std::map< BranchKey, BranchDescription > ProductList
static Principal::CacheIdentifier_t nextIdentifier()
ProcessHistoryID processHistoryID_
void mergeReaders(DelayedReader *other)
ProductResolverBase * getExistingProduct(BranchID const &branchID)
virtual void setupUnscheduled(UnscheduledConfigurator const &)
void getThinnedProducts(ProductID const &, std::vector< WrapperBase const *> &, std::vector< unsigned int > &) const override
void applyToResolvers(F iFunc)
std::string const & processName() const
void prefetchAsync(WaitingTaskHolder waitTask, ProductResolverIndex index, bool skipCurrentProcess, ServiceToken const &token, ModuleCallingContext const *mcc) const
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
edm::propagate_const< HistoryAppender * > historyAppender_
Principal(std::shared_ptr< ProductRegistry const > reg, std::shared_ptr< ProductResolverIndexHelper const > productLookup, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender, bool isForPrimaryProcess=true)
std::string const & friendlyClassName() const
void addUnscheduledProduct(std::shared_ptr< BranchDescription const > bd)
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
void addAliasedProduct(std::shared_ptr< BranchDescription const > bd)
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
std::vector< unsigned int > lookupProcessOrder_
virtual unsigned int processBlockIndex(std::string const &processName) const
WrapperBase const * getIt(ProductID const &) const override
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
std::string const & className() const
std::string const & branchName() const
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
std::shared_ptr< ProductRegistry const > preg_
CacheIdentifier_t cacheIdentifier_
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
std::string const & productInstanceName() const
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
void getAllStableProvenance(std::vector< StableProvenance const *> &provenances) const
ProcessHistoryID orderProcessHistoryID_
virtual void changedIndexes_()
void addSourceProduct(std::shared_ptr< BranchDescription const > bd)
void addPutOnReadInputProduct(std::shared_ptr< BranchDescription const > bd)
void deleteProduct(BranchID const &id) const
bool isSwitchAlias() const
void addDelayedReaderInputProduct(std::shared_ptr< BranchDescription const > bd)
void put_(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
void addParentProcessProduct(std::shared_ptr< BranchDescription const > bd)
ProductData const * findProductByTag(TypeID const &typeID, InputTag const &tag, ModuleCallingContext const *mcc) const
void addScheduledProduct(std::shared_ptr< BranchDescription const > bd)
static BasicHandle makeInvalid()
ProcessHistory const & processHistory() const
void addSwitchProducerProduct(std::shared_ptr< BranchDescription const > bd)
BranchDescription const & branchDescription() const
static std::shared_ptr< cms::Exception > makeNotFoundException(char const *where, KindOfType kindOfType, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
ProductResolverBase const * ConstProductResolverPtr
std::string const & processName() const
void readAllFromSourceAndMergeImmediately(MergeableRunProductMetadata const *mergeableRunProductMetadata=nullptr)
unsigned long CacheIdentifier_t
bool adjustToNewProductRegistry(ProductRegistry const ®)
Provenance const & getProvenance(BranchID const &bid) const
void adjustIndexesAfterProductRegistryAddition()
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
ProductResolverIndexHelper const & productLookup() const
void addTransformProduct(std::shared_ptr< BranchDescription const > bd)
static std::string appendCurrentProcessIfAlias(std::string const &processFromInputTag, std::string const ¤tProcess)
OptionalThinnedKey getThinnedKeyFrom(ProductID const &parent, unsigned int key, ProductID const &thinned) const override
unsigned int startInProcessNames() const
ProductResolverIndex index() const
void recombine(Principal &other, std::vector< BranchID > const &bids)
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
std::string const & moduleLabel() const
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
ProcessConfiguration const * processConfiguration_
void addSwitchAliasProduct(std::shared_ptr< BranchDescription const > bd)
DelayedReader * reader() const
BranchType const & branchType() const
ConstProductResolverPtr getProductResolver(BranchID const &oid) const