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);
175 auto cbd = std::make_shared<BranchDescription const>(bd);
182 for (
auto const&
prod : prodsList) {
190 if (hasSwitchAliases) {
191 for (
auto const&
prod : prodsList) {
195 auto cbd = std::make_shared<BranchDescription const>(bd);
213 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
215 std::vector<bool> ambiguous(lookupProcessNames.size(),
false);
217 std::vector<TypeID>
const& sortedTypeIDs =
productLookup_->sortedTypeIDs();
219 std::vector<ProductResolverIndexHelper::IndexAndNames>
const& indexAndNames =
productLookup_->indexAndNames();
220 std::vector<char>
const& processNamesCharArray =
productLookup_->processNames();
222 unsigned int numberOfMatches = 0;
224 if (!sortedTypeIDs.empty()) {
226 for (
unsigned int k = 0, kEnd = sortedTypeIDs.size();
k < kEnd; ++
k) {
228 for (
unsigned int i = range.
begin();
i < range.
end(); ++
i) {
235 std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
237 bool productMadeAtEnd =
false;
239 for (
unsigned int i = 0;
i < matchingHolders.size(); ++
i) {
241 productResolvers_[matchingHolders[
i]]->branchDescription().availableOnlyAtEndTransition()) {
242 productMadeAtEnd =
true;
246 std::shared_ptr<ProductResolverBase> newHolder =
247 std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
251 ambiguous.assign(lookupProcessNames.size(),
false);
255 productResolverIndex = product.
index();
258 auto iter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(),
process);
259 assert(iter != lookupProcessNames.end());
261 lastMatchIndex = iMatchingIndex;
265 assert(
k >= beginElements);
266 ambiguous.at(iter - lookupProcessNames.begin()) =
true;
268 matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
277 std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
279 bool productMadeAtEnd =
false;
280 for (
unsigned int i = 0;
i < matchingHolders.size(); ++
i) {
282 productResolvers_[matchingHolders[
i]]->branchDescription().availableOnlyAtEndTransition()) {
283 productMadeAtEnd =
true;
287 std::shared_ptr<ProductResolverBase> newHolder =
288 std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
301 for (
auto const&
prod : *
this) {
302 if (
prod->singleProduct() &&
303 !
prod->productUnavailable() && !
prod->unscheduledWasNotRun() && !
prod->branchDescription().dropped()) {
313 for (
auto const&
prod : prodsList) {
316 auto cbd = std::make_shared<BranchDescription const>(bd);
318 if (phb ==
nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
328 auto phb = std::make_unique<PuttableProductResolver>(
std::move(bd));
333 auto phb = std::make_unique<PuttableProductResolver>(
std::move(bd));
379 for (
auto&
prod : *
this) {
380 prod->resetProductData();
386 assert(
nullptr != phb);
387 phb->unsafe_deleteProduct();
412 std::shared_ptr<ProcessHistory const> inputProcessHistory;
416 auto noDel = [](
void const*) {};
417 inputProcessHistory = std::shared_ptr<ProcessHistory const>(processHistoryRegistry.
getMapped(hist), noDel);
418 if (inputProcessHistory.get() ==
nullptr) {
420 <<
"Input ProcessHistory not found in registry\n" 421 <<
"Contact a Framework developer\n";
425 inputProcessHistory = std::shared_ptr<ProcessHistory const>(&
s_emptyProcessHistory, [](
void const*) {});
430 processHistoryPtr_ = inputProcessHistory;
436 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
450 if (nameIter != lookupProcessNames.end()) {
463 auto nameIter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
464 if (nameIter == lookupProcessNames.end()) {
491 <<
"Principal::getExistingProduct\n" 492 <<
" Branch " << newProduct.
branchName() <<
" has same branch ID as branch " << existing.
branchName()
494 <<
"Workaround: change process name or product instance name of " << newProduct.
branchName() <<
"\n";
517 if (phb !=
nullptr) {
520 <<
"addProductOrThrow: Problem found while adding product, " 547 if (result ==
nullptr) {
570 if (result ==
nullptr) {
581 bool skipCurrentProcess,
587 assert(
nullptr != productResolver.get());
588 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
589 if (resolution.isAmbiguous()) {
595 auto productData = resolution.data();
596 if (productData ==
nullptr) {
601 return BasicHandle(productData->wrapper(), &(productData->provenance()));
606 bool skipCurrentProcess,
610 assert(
nullptr != productResolver.get());
611 productResolver->prefetchAsync(task, *
this, skipCurrentProcess, token,
nullptr, mcc);
619 assert(results.empty());
622 failedToRegisterConsumesMany(typeID);
657 std::vector<ProductResolverBase const*> holders;
663 if (!holders.empty()) {
670 assert(productResolver);
671 holders.push_back(productResolver);
675 if (!holders.empty()) {
688 for (
auto productResolver : holders) {
696 ProductData const* productData = productResolver->resolveProduct(*
this,
false, sra, mcc).data();
718 if (skipCurrentProcess) {
739 failedToRegisterConsumes(kindOfType,
748 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
768 productLookup().
index(kindOfType, typeID, label.c_str(), instance.c_str(), process.c_str());
777 failedToRegisterConsumes(kindOfType, typeID, label, instance, process);
782 auto resolution = productResolver->resolveProduct(*
this,
false, sra, mcc);
798 if (phb ==
nullptr) {
802 if (phb->unscheduledWasNotRun()) {
803 if (not phb->resolveProduct(*
this,
false,
nullptr, mcc).data()) {
807 return *phb->provenance();
815 for (
auto const& productResolver : *
this) {
816 if (productResolver->singleProduct() && productResolver->provenanceAvailable() &&
817 !productResolver->branchDescription().isAnyAlias()) {
820 if (productResolver->provenance()->branchDescription().present()) {
821 provenances.push_back(productResolver->provenance());
832 for (
auto const& productResolver : *
this) {
833 if (productResolver->singleProduct() && !productResolver->branchDescription().isAnyAlias()) {
834 if (productResolver->stableProvenance()->branchDescription().present()) {
835 provenances.push_back(productResolver->stableProvenance());
842 for (
auto&
prod : bids) {
863 std::vector<WrapperBase const*>&,
864 std::vector<unsigned int>&)
const {
873 if (edp.get() ==
nullptr) {
875 <<
"put: Cannot put because unique_ptr to product is null." 887 for (
auto const&
prod :
preg_->productList()) {
895 auto cbd = std::make_shared<BranchDescription const>(bd);
909 for (
auto&
prod : *
this) {
910 prod->retrieveAndMerge(*
this, mergeableRunProductMetadata);
ProductResolverIndex index(unsigned int i) const
static ProcessHistory const s_emptyProcessHistory
ProductRegistry const & productRegistry() const
Provenance const & provenance() const
std::string const & branchName() const
BranchType const & branchType() const
ProcessHistoryID processHistoryIDBeforeConfig_
void setupUnscheduled(UnscheduledConfigurator const &)
unsigned int ProductResolverIndex
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
static std::string const source("source")
ProductResolverCollection productResolvers_
std::shared_ptr< ProcessHistory const > processHistoryPtr_
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
Provenance getProvenance(BranchID const &bid, ModuleCallingContext const *mcc) const
WrapperBase const * wrapper() const
void getThinnedProducts(ProductID const &, std::vector< WrapperBase const * > &, std::vector< unsigned int > &) const override
unsigned int startInProcessNames() const
std::string const & processName() const
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)
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
edm::propagate_const< HistoryAppender * > historyAppender_
void readAllFromSourceAndMergeImmediately(MergeableRunProductMetadata const *mergeableRunProductMetadata=0)
void prefetchAsync(WaitingTask *waitTask, ProductResolverIndex index, bool skipCurrentProcess, ServiceToken const &token, ModuleCallingContext const *mcc) const
void putOrMergeProduct(std::unique_ptr< WrapperBase > edp, MergeableRunProductMetadata const *mergeableRunProductMetadata=nullptr) 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_
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_
BranchType const & branchType() const
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
void putOrMerge(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
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
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_
std::string const & friendlyClassName() const
BranchID const & branchID() const
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void addParentProcessProduct(std::shared_ptr< BranchDescription const > bd)
DelayedReader * reader() 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)
WrapperBase const * getIt(ProductID const &) const override
ProductResolverIndexHelper const & productLookup() 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
void findProducts(std::vector< ProductResolverBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
unsigned long CacheIdentifier_t
WrapperBase const * getThinnedProduct(ProductID const &, unsigned int &) 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
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)
void addAliasedProduct(std::shared_ptr< BranchDescription const > bd)
void fillPrincipal(ProcessHistoryID const &hist, ProcessHistoryRegistry const &phr, DelayedReader *reader)
void recombine(Principal &other, std::vector< BranchID > const &bids)
ProcessConfiguration const * processConfiguration_
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