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 failedToRegisterConsumesMany(
edm::TypeID const& iType) {
96 exception <<
"::getManyByType called for " << iType
97 <<
" without a corresponding consumesMany being called for this module. \n";
101 void failedToRegisterConsumes(
KindOfType kindOfType,
102 TypeID
const& productType,
107 exception <<
"::getByLabel without corresponding call to consumes or mayConsumes for this module.\n" 108 << (kindOfType ==
PRODUCT_TYPE ?
" type: " :
" type: edm::View<") << productType
110 <<
"\n product instance name: '" << productInstanceName <<
"'\n process name: '" <<
processName 123 std::shared_ptr<ProductResolverIndexHelper const> productLookup,
127 bool isForPrimaryProcess)
129 processHistoryPtr_(),
131 processHistoryIDBeforeConfig_(),
132 processConfiguration_(&pc),
135 productLookup_(productLookup),
136 lookupProcessOrder_(productLookup->lookupProcessNames().
size(), 0),
139 historyAppender_(historyAppender),
148 bool hasAliases =
false;
149 bool hasSwitchAliases =
false;
150 for (
auto const&
prod : prodsList) {
156 }
else if (
bd.isSwitchAlias()) {
157 hasSwitchAliases =
true;
159 auto cbd = std::make_shared<BranchDescription const>(
bd);
163 }
else if (
bd.onDemand()) {
165 if (
bd.isTransform()) {
183 auto cbd = std::make_shared<BranchDescription const>(
bd);
190 for (
auto const&
prod : prodsList) {
198 if (hasSwitchAliases) {
199 for (
auto const&
prod : prodsList) {
203 auto cbd = std::make_shared<BranchDescription const>(
bd);
221 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
223 std::vector<bool> ambiguous(lookupProcessNames.size(),
false);
225 std::vector<TypeID>
const& sortedTypeIDs =
productLookup_->sortedTypeIDs();
227 std::vector<ProductResolverIndexHelper::IndexAndNames>
const& indexAndNames =
productLookup_->indexAndNames();
228 std::vector<char>
const& processNamesCharArray =
productLookup_->processNames();
230 unsigned int numberOfMatches = 0;
232 if (!sortedTypeIDs.empty()) {
234 for (
unsigned int k = 0, kEnd = sortedTypeIDs.size();
k < kEnd; ++
k) {
243 std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
245 bool productMadeAtEnd =
false;
247 for (
unsigned int j = 0;
j < matchingHolders.size(); ++
j) {
249 productResolvers_[matchingHolders[
j]]->branchDescription().availableOnlyAtEndTransition()) {
250 productMadeAtEnd =
true;
254 std::shared_ptr<ProductResolverBase> newHolder =
255 std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
259 ambiguous.assign(lookupProcessNames.size(),
false);
263 productResolverIndex = product.
index();
266 auto iter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(),
process);
267 assert(iter != lookupProcessNames.end());
269 lastMatchIndex = iMatchingIndex;
274 ambiguous.at(iter - lookupProcessNames.begin()) =
true;
276 matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
285 std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
287 bool productMadeAtEnd =
false;
288 for (
unsigned int i = 0;
i < matchingHolders.size(); ++
i) {
290 productResolvers_[matchingHolders[
i]]->branchDescription().availableOnlyAtEndTransition()) {
291 productMadeAtEnd =
true;
295 std::shared_ptr<ProductResolverBase> newHolder =
296 std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
309 for (
auto const&
prod : *
this) {
310 if (
prod->singleProduct() &&
311 !
prod->productUnavailable() && !
prod->unscheduledWasNotRun() && !
prod->branchDescription().dropped()) {
321 for (
auto const&
prod : prodsList) {
324 auto cbd = std::make_shared<BranchDescription const>(
bd);
326 if (phb ==
nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
336 auto phb = std::make_unique<PuttableProductResolver>(
std::move(
bd));
341 auto phb = std::make_unique<PuttableProductResolver>(
std::move(
bd));
395 for (
auto&
prod : *
this) {
396 prod->resetProductData();
403 phb->unsafe_deleteProduct();
431 std::shared_ptr<ProcessHistory const> inputProcessHistory;
433 if (
hist.isValid()) {
435 auto noDel = [](
void const*) {};
436 inputProcessHistory = std::shared_ptr<ProcessHistory const>(
processHistory, noDel);
437 if (inputProcessHistory.get() ==
nullptr) {
439 <<
"Input ProcessHistory not found in registry\n" 440 <<
"Contact a Framework developer\n";
444 inputProcessHistory = std::shared_ptr<ProcessHistory const>(&
s_emptyProcessHistory, [](
void const*) {});
455 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
468 auto nameIterCurrentProcess =
470 if (nameIterCurrentProcess != lookupProcessNames.end()) {
484 auto nameIter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
485 if (nameIter == lookupProcessNames.end()) {
499 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
502 auto iter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(), processNameOfBlock);
503 if (iter != lookupProcessNames.end()) {
526 <<
"Principal::getExistingProduct\n" 527 <<
" Branch " << newProduct.
branchName() <<
" has same branch ID as branch " <<
existing.branchName()
529 <<
"Workaround: change process name or product instance name of " << newProduct.
branchName() <<
"\n";
540 assert(!
bd.friendlyClassName().empty());
552 if (phb !=
nullptr) {
555 <<
"addProductOrThrow: Problem found while adding product, " 556 <<
"product already exists for (" <<
bd.friendlyClassName() <<
"," <<
bd.moduleLabel() <<
"," 557 <<
bd.productInstanceName() <<
"," <<
bd.processName() <<
")\n";
624 bool skipCurrentProcess,
630 assert(
nullptr != productResolver.get());
631 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
639 if (productData ==
nullptr) {
644 return BasicHandle(productData->wrapper(), &(productData->provenance()));
649 bool skipCurrentProcess,
653 assert(
nullptr != productResolver.get());
654 productResolver->prefetchAsync(
task, *
this, skipCurrentProcess,
token,
nullptr, mcc);
668 failedToRegisterConsumesMany(typeID);
674 if (
matches.numberOfMatches() == 0) {
703 std::vector<ProductResolverBase const*> holders;
705 for (
unsigned int i = 0;
i <
matches.numberOfMatches(); ++
i) {
709 if (!holders.empty()) {
717 holders.push_back(productResolver);
721 if (!holders.empty()) {
734 for (
auto productResolver : holders) {
738 if (
bd.isAnyAlias()) {
742 ProductData const* productData = productResolver->resolveProduct(*
this,
false, sra, mcc).data();
758 bool skipCurrentProcess =
inputTag.willSkipCurrentProcess();
764 if (skipCurrentProcess) {
781 for (
auto const&
item :
preg_->productList()) {
782 auto const&
bd =
item.second;
783 if (
bd.present() and
bd.unwrappedTypeID() == typeID and
bd.moduleLabel() ==
inputTag.label() and
784 bd.productInstanceName() ==
inputTag.instance()) {
787 (skipCurrentProcess and not inCurrentProcess)
or 789 failedToRegisterConsumes(
803 failedToRegisterConsumes(kindOfType,
812 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
838 for (
auto const&
item :
preg_->productList()) {
839 auto const&
bd =
item.second;
840 if (
bd.present() and
bd.unwrappedTypeID() == typeID and
bd.moduleLabel() ==
label and
856 auto resolution = productResolver->resolveProduct(*
this,
false, sra, mcc);
875 if (phb ==
nullptr) {
879 if (phb->unscheduledWasNotRun()) {
881 <<
"Requesting provenance from unrun EDProducer. The requested branch ID was: " << bid;
883 return *phb->provenance();
888 if (phb ==
nullptr) {
892 return *phb->stableProvenance();
900 for (
auto const& productResolver : *
this) {
901 if (productResolver->singleProduct() && productResolver->provenanceAvailable() &&
902 !productResolver->branchDescription().isAnyAlias()) {
905 if (productResolver->provenance()->branchDescription().present()) {
906 provenances.push_back(productResolver->provenance());
917 for (
auto const& productResolver : *
this) {
918 if (productResolver->singleProduct() && !productResolver->branchDescription().isAnyAlias()) {
919 if (productResolver->stableProvenance()->branchDescription().present()) {
920 provenances.push_back(productResolver->stableProvenance());
927 for (
auto&
prod : bids) {
943 unsigned int)
const {
949 std::vector<WrapperBase const*>&,
950 std::vector<unsigned int>&)
const {
956 return std::monostate{};
964 if (edp.get() ==
nullptr) {
966 <<
"put: Cannot put because unique_ptr to product is null." 977 bool changed =
false;
979 for (
auto const&
prod :
preg_->productList()) {
987 auto cbd = std::make_shared<BranchDescription const>(
bd);
1009 for (
auto&
prod : *
this) {
1010 prod->retrieveAndMerge(*
this, mergeableRunProductMetadata);
std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &, unsigned int) const override
void findProducts(std::vector< ProductResolverBase const *> const &holders, TypeID const &typeID, BasicHandleVec &results, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
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
Provenance const & provenance() const
std::shared_ptr< ProductResolverBase > SharedProductPtr
void addProduct_(std::unique_ptr< ProductResolverBase > phb)
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)
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)
WrapperBase const * wrapper() const
void addUnscheduledProduct(std::shared_ptr< BranchDescription const > bd)
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
void getManyByType(TypeID const &typeID, BasicHandleVec &results, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
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
deep_tau::DeepTauBase::BasicDiscriminator bd
WrapperBase const * getIt(ProductID const &) const override
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
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::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
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
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
ProcessConfiguration const * processConfiguration_
void addSwitchAliasProduct(std::shared_ptr< BranchDescription const > bd)
std::vector< BasicHandle > BasicHandleVec
DelayedReader * reader() const
BranchType const & branchType() const
ConstProductResolverPtr getProductResolver(BranchID const &oid) const