41 returnValue += currentProcess;
45 return processFromInputTag;
49 throw Exception(error,
"InvalidID") <<
"Principal::" << where <<
": no product with given branch id: " << bid
61 *exception <<
"Principal::" << where
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";
67 *exception <<
"Principal::" << where
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";
83 exception <<
"Principal::" << where
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
109 << (kindOfType ==
PRODUCT_TYPE ?
"\n module label: " :
">\n module label: ") << moduleLabel
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) {
157 hasSwitchAliases =
true;
159 auto cbd = std::make_shared<BranchDescription const>(
bd);
179 auto cbd = std::make_shared<BranchDescription const>(
bd);
186 for (
auto const& prod : prodsList) {
194 if (hasSwitchAliases) {
195 for (
auto const& prod : prodsList) {
199 auto cbd = std::make_shared<BranchDescription const>(
bd);
217 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
219 std::vector<bool> ambiguous(lookupProcessNames.size(),
false);
221 std::vector<TypeID>
const& sortedTypeIDs =
productLookup_->sortedTypeIDs();
223 std::vector<ProductResolverIndexHelper::IndexAndNames>
const& indexAndNames =
productLookup_->indexAndNames();
224 std::vector<char>
const& processNamesCharArray =
productLookup_->processNames();
226 unsigned int numberOfMatches = 0;
228 if (!sortedTypeIDs.empty()) {
230 for (
unsigned int k = 0, kEnd = sortedTypeIDs.size();
k < kEnd; ++
k) {
232 for (
unsigned int i = range.
begin();
i < range.
end(); ++
i) {
239 std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
241 bool productMadeAtEnd =
false;
243 for (
unsigned int j = 0;
j < matchingHolders.size(); ++
j) {
245 productResolvers_[matchingHolders[
j]]->branchDescription().availableOnlyAtEndTransition()) {
246 productMadeAtEnd =
true;
250 std::shared_ptr<ProductResolverBase> newHolder =
251 std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
255 ambiguous.assign(lookupProcessNames.size(),
false);
259 productResolverIndex = product.
index();
262 auto iter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(),
process);
263 assert(iter != lookupProcessNames.end());
265 lastMatchIndex = iMatchingIndex;
270 ambiguous.at(iter - lookupProcessNames.begin()) =
true;
272 matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
281 std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
283 bool productMadeAtEnd =
false;
284 for (
unsigned int i = 0;
i < matchingHolders.size(); ++
i) {
286 productResolvers_[matchingHolders[
i]]->branchDescription().availableOnlyAtEndTransition()) {
287 productMadeAtEnd =
true;
291 std::shared_ptr<ProductResolverBase> newHolder =
292 std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
305 for (
auto const& prod : *
this) {
306 if (prod->singleProduct() &&
307 !prod->productUnavailable() && !prod->unscheduledWasNotRun() && !prod->branchDescription().dropped()) {
317 for (
auto const& prod : prodsList) {
320 auto cbd = std::make_shared<BranchDescription const>(
bd);
322 if (phb ==
nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
332 auto phb = std::make_unique<PuttableProductResolver>(
std::move(bd));
337 auto phb = std::make_unique<PuttableProductResolver>(
std::move(bd));
387 for (
auto& prod : *
this) {
388 prod->resetProductData();
395 phb->unsafe_deleteProduct();
423 std::shared_ptr<ProcessHistory const> inputProcessHistory;
427 auto noDel = [](
void const*) {};
428 inputProcessHistory = std::shared_ptr<ProcessHistory const>(
processHistory, noDel);
429 if (inputProcessHistory.get() ==
nullptr) {
431 <<
"Input ProcessHistory not found in registry\n"
432 <<
"Contact a Framework developer\n";
436 inputProcessHistory = std::shared_ptr<ProcessHistory const>(&
s_emptyProcessHistory, [](
void const*) {});
441 processHistoryPtr_ = inputProcessHistory;
447 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
460 auto nameIterCurrentProcess =
462 if (nameIterCurrentProcess != lookupProcessNames.end()) {
476 auto nameIter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
477 if (nameIter == lookupProcessNames.end()) {
491 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
494 auto iter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(), processNameOfBlock);
495 if (iter != lookupProcessNames.end()) {
518 <<
"Principal::getExistingProduct\n"
519 <<
" Branch " << newProduct.
branchName() <<
" has same branch ID as branch " << existing.
branchName()
521 <<
"Workaround: change process name or product instance name of " << newProduct.
branchName() <<
"\n";
544 if (phb !=
nullptr) {
547 <<
"addProductOrThrow: Problem found while adding product, "
582 if (result ==
nullptr) {
605 if (result ==
nullptr) {
616 bool skipCurrentProcess,
622 assert(
nullptr != productResolver.get());
623 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
624 if (resolution.isAmbiguous()) {
630 auto productData = resolution.data();
631 if (productData ==
nullptr) {
636 return BasicHandle(productData->wrapper(), &(productData->provenance()));
641 bool skipCurrentProcess,
645 assert(
nullptr != productResolver.get());
646 productResolver->prefetchAsync(task, *
this, skipCurrentProcess, token,
nullptr, mcc);
660 failedToRegisterConsumesMany(typeID);
695 std::vector<ProductResolverBase const*> holders;
701 if (!holders.empty()) {
709 holders.push_back(productResolver);
713 if (!holders.empty()) {
726 for (
auto productResolver : holders) {
734 ProductData const* productData = productResolver->resolveProduct(*
this,
false, sra, mcc).data();
756 if (skipCurrentProcess) {
777 failedToRegisterConsumes(kindOfType,
786 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
806 productLookup().
index(kindOfType, typeID, label.c_str(), instance.c_str(), process.c_str());
815 failedToRegisterConsumes(kindOfType, typeID, label, instance, process);
820 auto resolution = productResolver->resolveProduct(*
this,
false, sra, mcc);
839 if (phb ==
nullptr) {
843 if (phb->unscheduledWasNotRun()) {
845 <<
"Requesting provenance from unrun EDProducer. The requested branch ID was: " << bid;
847 return *phb->provenance();
852 if (phb ==
nullptr) {
856 return *phb->stableProvenance();
864 for (
auto const& productResolver : *
this) {
865 if (productResolver->singleProduct() && productResolver->provenanceAvailable() &&
866 !productResolver->branchDescription().isAnyAlias()) {
869 if (productResolver->provenance()->branchDescription().present()) {
870 provenances.push_back(productResolver->provenance());
881 for (
auto const& productResolver : *
this) {
882 if (productResolver->singleProduct() && !productResolver->branchDescription().isAnyAlias()) {
883 if (productResolver->stableProvenance()->branchDescription().present()) {
884 provenances.push_back(productResolver->stableProvenance());
891 for (
auto& prod : bids) {
907 unsigned int)
const {
913 std::vector<WrapperBase const*>&,
914 std::vector<unsigned int>&)
const {
920 return std::monostate{};
928 if (edp.get() ==
nullptr) {
930 <<
"put: Cannot put because unique_ptr to product is null."
941 bool changed =
false;
943 for (
auto const& prod :
preg_->productList()) {
951 auto cbd = std::make_shared<BranchDescription const>(
bd);
973 for (
auto& prod : *
this) {
974 prod->retrieveAndMerge(*
this, mergeableRunProductMetadata);
void fillPrincipal(DelayedReader *reader)
ProductResolverIndex index(unsigned int i) const
static ProcessHistory const s_emptyProcessHistory
ProductRegistry const & productRegistry() const
Provenance const & provenance() const
void getThinnedProducts(ProductID const &, std::vector< WrapperBase const * > &, std::vector< unsigned int > &) const override
std::string const & branchName() const
BranchType const & branchType() const
ProcessHistoryID processHistoryIDBeforeConfig_
void setupUnscheduled(UnscheduledConfigurator const &)
unsigned int ProductResolverIndex
static std::string const source("source")
ProductResolverCollection productResolvers_
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
std::shared_ptr< ProcessHistory const > processHistoryPtr_
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
static PFTauRenderPlugin instance
std::shared_ptr< ProductResolverBase > SharedProductPtr
void addProduct_(std::unique_ptr< ProductResolverBase > phb)
static std::atomic< Principal::CacheIdentifier_t > s_nextIdentifier
std::map< BranchKey, BranchDescription > ProductList
static Principal::CacheIdentifier_t nextIdentifier()
ProcessHistoryID processHistoryID_
void mergeReaders(DelayedReader *other)
ProductResolverBase * getExistingProduct(BranchID const &branchID)
bool isFullyResolved(unsigned int i) const
virtual void setupUnscheduled(UnscheduledConfigurator const &)
void getAllProvenance(std::vector< Provenance const * > &provenances) const
void applyToResolvers(F iFunc)
void getAllStableProvenance(std::vector< StableProvenance const * > &provenances) const
StableProvenance const & getStableProvenance(BranchID const &bid) const
WrapperBase const * wrapper() const
unsigned int startInProcessNames() const
std::string const & processName() 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)
Principal(std::shared_ptr< ProductRegistry const > reg, std::shared_ptr< ProductResolverIndexHelper const > productLookup, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender, bool isForPrimaryProcess=true)
edm::propagate_const< HistoryAppender * > historyAppender_
ProcessHistory const & processHistory() const
const uint16_t range(const Frame &aFrame)
void prefetchAsync(WaitingTaskHolder waitTask, ProductResolverIndex index, bool skipCurrentProcess, ServiceToken const &token, ModuleCallingContext const *mcc) const
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
std::string const & processName() const
ProductList const & productList() const
std::vector< unsigned int > lookupProcessOrder_
deep_tau::DeepTauBase::BasicDiscriminator bd
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
void addScheduledProduct(std::shared_ptr< BranchDescription const > bd)
ProductResolverIndex index() const
std::string const & className() const
ProductData const * findProductByTag(TypeID const &typeID, InputTag const &tag, ModuleCallingContext const *mcc) const
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
std::string const & moduleLabel() const
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
std::shared_ptr< ProductRegistry const > preg_
std::string const & productInstanceName() const
bool registeredToConsume(ProductResolverIndex, bool, BranchType) const
CacheIdentifier_t cacheIdentifier_
void addDelayedReaderInputProduct(std::shared_ptr< BranchDescription const > bd)
BranchType const & branchType() const
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
unsigned int numberOfMatches() const
void addSourceProduct(std::shared_ptr< BranchDescription const > bd)
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
ProcessHistoryID orderProcessHistoryID_
virtual void changedIndexes_()
std::string const & friendlyClassName() const
BranchID const & branchID() const
std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &, unsigned int) const override
void addParentProcessProduct(std::shared_ptr< BranchDescription const > bd)
DelayedReader * reader() const
virtual unsigned int processBlockIndex(std::string const &processName) const
static BasicHandle makeInvalid()
bool registeredToConsumeMany(TypeID const &, BranchType) const
void addSwitchAliasProduct(std::shared_ptr< BranchDescription const > bd)
void addUnscheduledProduct(std::shared_ptr< BranchDescription const > bd)
ProductResolverIndexHelper const & productLookup() const
void addPutOnReadInputProduct(std::shared_ptr< BranchDescription const > bd)
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
void findProducts(std::vector< ProductResolverBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
void readAllFromSourceAndMergeImmediately(MergeableRunProductMetadata const *mergeableRunProductMetadata=nullptr)
unsigned long CacheIdentifier_t
WrapperBase const * getIt(ProductID const &) const override
bool adjustToNewProductRegistry(ProductRegistry const ®)
BranchDescription const & branchDescription() const
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
void addSwitchProducerProduct(std::shared_ptr< BranchDescription const > bd)
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
Provenance const & getProvenance(BranchID const &bid) const
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
unsigned int begin() const
void adjustIndexesAfterProductRegistryAddition()
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
BasicHandle getByToken(KindOfType kindOfType, TypeID const &typeID, ProductResolverIndex index, bool skipCurrentProcess, bool &ambiguous, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
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
void addAliasedProduct(std::shared_ptr< BranchDescription const > bd)
void recombine(Principal &other, std::vector< BranchID > const &bids)
ProcessConfiguration const * processConfiguration_
tuple size
Write out results.
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
std::vector< BasicHandle > BasicHandleVec
void getManyByType(TypeID const &typeID, BasicHandleVec &results, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
void deleteProduct(BranchID const &id) const
bool isSwitchAlias() const
void put_(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const