41 returnValue += currentProcess;
45 return processFromInputTag;
52 <<
"Principal::" << where <<
": no product with given branch id: "<< bid <<
"\n";
56 std::shared_ptr<cms::Exception>
61 *exception <<
"Principal::" << where <<
": Found zero products matching all criteria\nLooking for type: " << productType <<
"\n" 62 <<
"Looking for module label: " << label <<
"\n" <<
"Looking for productInstanceName: " << instance <<
"\n" 63 << (process.empty() ?
"" :
"Looking for process: ") << process <<
"\n";
65 *exception <<
"Principal::" << where <<
": Found zero products matching all criteria\nLooking for a container with elements of type: " << productType <<
"\n" 66 <<
"Looking for module label: " << label <<
"\n" <<
"Looking for productInstanceName: " << instance <<
"\n" 67 << (process.empty() ?
"" :
"Looking for process: ") << process <<
"\n";
76 exception <<
"Principal::" << where <<
": More than 1 product matches all criteria\nLooking for type: " << productType <<
"\n" 77 <<
"Looking for module label: " << label <<
"\n" <<
"Looking for productInstanceName: " << instance <<
"\n" 78 << (process.empty() ?
"" :
"Looking for process: ") << process <<
"\n" 79 <<
"This can only occur with get function calls using a Handle<View> argument.\n" 80 <<
"Try a get not using a View or change the instance name of one of the products";
86 void failedToRegisterConsumesMany(
edm::TypeID const& iType) {
88 exception <<
"::getManyByType called for " << iType
89 <<
" without a corresponding consumesMany being called for this module. \n";
93 void failedToRegisterConsumes(
KindOfType kindOfType,
99 exception <<
"::getByLabel without corresponding call to consumes or mayConsumes for this module.\n" 100 << (kindOfType ==
PRODUCT_TYPE ?
" type: " :
" type: edm::View<") << productType
101 << (kindOfType ==
PRODUCT_TYPE ?
"\n module label: " :
">\n module label: ") << moduleLabel
102 <<
"\n product instance name: '" << productInstanceName
103 <<
"'\n process name: '" << processName <<
"'\n";
115 std::shared_ptr<ProductResolverIndexHelper const> productLookup,
119 bool isForPrimaryProcess) :
121 processHistoryPtr_(),
123 processHistoryIDBeforeConfig_(),
124 processConfiguration_(&pc),
127 productLookup_(productLookup),
128 lookupProcessOrder_(productLookup->lookupProcessNames().
size(), 0),
131 historyAppender_(historyAppender),
141 bool hasAliases =
false;
142 for(
auto const&
prod : prodsList) {
149 auto cbd = std::make_shared<BranchDescription const>(bd);
165 auto cbd =std::make_shared<BranchDescription const>(bd);
172 for(
auto const&
prod : prodsList) {
175 auto cbd = std::make_shared<BranchDescription const>(bd);
184 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
186 std::vector<bool> ambiguous(lookupProcessNames.size(),
false);
188 std::vector<TypeID>
const& sortedTypeIDs =
productLookup_->sortedTypeIDs();
190 std::vector<ProductResolverIndexHelper::IndexAndNames>
const& indexAndNames =
productLookup_->indexAndNames();
191 std::vector<char>
const& processNamesCharArray =
productLookup_->processNames();
193 unsigned int numberOfMatches = 0;
195 if (!sortedTypeIDs.empty()) {
197 for(
unsigned int k = 0, kEnd = sortedTypeIDs.size();
k < kEnd; ++
k) {
199 for (
unsigned int i = range.
begin();
i < range.
end(); ++
i) {
203 if ((numberOfMatches == 1) and
206 productResolvers_.at(productResolverIndex) = std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
208 bool productMadeAtEnd =
false;
210 for(
unsigned int i=0;
i< matchingHolders.size();++
i) {
211 if( (not ambiguous[
i]) and
213 productResolvers_[matchingHolders[
i]]->branchDescription().availableOnlyAtEndTransition()) {
214 productMadeAtEnd =
true;
218 std::shared_ptr<ProductResolverBase> newHolder = std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
222 ambiguous.assign(lookupProcessNames.size(),
false);
226 productResolverIndex = product.
index();
229 auto iter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(),
process);
230 assert(iter != lookupProcessNames.end());
232 lastMatchIndex = iMatchingIndex;
236 assert(
k >= beginElements);
237 ambiguous.at(iter - lookupProcessNames.begin()) =
true;
239 matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
245 if ((numberOfMatches == 1) and
248 productResolvers_.at(productResolverIndex) = std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
250 bool productMadeAtEnd =
false;
251 for(
unsigned int i=0;
i< matchingHolders.size();++
i) {
252 if( (not ambiguous[
i]) and
254 productResolvers_[matchingHolders[
i]]->branchDescription().availableOnlyAtEndTransition()) {
255 productMadeAtEnd =
true;
259 std::shared_ptr<ProductResolverBase> newHolder = std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
274 for(
auto const&
prod : *
this) {
275 if(
prod->singleProduct() &&
276 !
prod->productUnavailable() &&
277 !
prod->unscheduledWasNotRun() &&
278 !
prod->branchDescription().dropped()) {
289 for(
auto const&
prod : prodsList) {
292 auto cbd = std::make_shared<BranchDescription const>(bd);
294 if(phb ==
nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
305 auto phb = std::make_unique<PuttableProductResolver>(
std::move(bd));
311 auto phb = std::make_unique<PuttableProductResolver>(
std::move(bd));
345 for(
auto&
prod : *
this) {
346 prod->resetProductData();
353 assert(
nullptr != phb);
354 phb->unsafe_deleteProduct();
380 processHistoryRegistry. getMapped(hist),
387 std::shared_ptr<ProcessHistory const> inputProcessHistory;
391 auto noDel =[](
void const*){};
392 inputProcessHistory =
393 std::shared_ptr<ProcessHistory const>(processHistoryRegistry.
getMapped(hist),noDel);
394 if (inputProcessHistory.get() ==
nullptr) {
396 <<
"Principal::fillPrincipal\n" 397 <<
"Input ProcessHistory not found in registry\n" 398 <<
"Contact a Framework developer\n";
402 inputProcessHistory = std::shared_ptr<ProcessHistory const>(&
s_emptyProcessHistory,[](
void const*){});
407 processHistoryPtr_ = inputProcessHistory;
413 std::vector<std::string>
const& lookupProcessNames =
productLookup_->lookupProcessNames();
426 if (nameIter != lookupProcessNames.end()) {
439 auto nameIter =
std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
440 if (nameIter == lookupProcessNames.end()) {
469 throw cms::Exception(
"HashCollision") <<
"Principal::getExistingProduct\n" <<
470 " Branch " << newProduct.
branchName() <<
" has same branch ID as branch " << existing.
branchName() <<
"\n" <<
471 "Workaround: change process name or product instance name of " << newProduct.
branchName() <<
"\n";
499 <<
"addProductOrThrow: Problem found while adding product, " 500 <<
"product already exists for (" 535 if(result ==
nullptr) {
555 if(result ==
nullptr) {
567 bool skipCurrentProcess,
573 assert(
nullptr!=productResolver.get());
574 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
575 if(resolution.isAmbiguous()) {
579 auto productData = resolution.data();
580 if(productData ==
nullptr) {
583 return BasicHandle(productData->wrapper(), &(productData->provenance()));
589 bool skipCurrentProcess,
593 assert(
nullptr!=productResolver.get());
594 productResolver->prefetchAsync(task,*
this, skipCurrentProcess,token,
nullptr,mcc);
604 assert(results.empty());
607 failedToRegisterConsumesMany(typeID);
643 std::vector<ProductResolverBase const*> holders;
650 if(!holders.empty()) {
657 assert(productResolver);
658 holders.push_back(productResolver);
662 if(!holders.empty()) {
677 iter != iEnd; ++iter) {
679 for (
auto productResolver : holders) {
688 ProductData const* productData = productResolver->resolveProduct(*
this,
false, sra, mcc).data();
713 if (skipCurrentProcess) {
721 inputTag.
label().c_str(),
734 failedToRegisterConsumes(kindOfType,typeID,inputTag.
label(),inputTag.
instance(),
741 auto resolution = productResolver->resolveProduct(*
this, skipCurrentProcess, sra, mcc);
772 failedToRegisterConsumes(kindOfType,typeID,label,instance,process);
777 auto resolution = productResolver->resolveProduct(*
this,
false, sra, mcc);
804 if(phb->unscheduledWasNotRun()) {
805 if(not phb->resolveProduct(*
this,
false,
nullptr, mcc).data() ) {
809 return *phb->provenance();
818 for(
auto const& productResolver : *
this) {
819 if(productResolver->singleProduct() && productResolver->provenanceAvailable() && !productResolver->branchDescription().isAlias()) {
822 if(productResolver->provenance()->branchDescription().present()) {
823 provenances.push_back(productResolver->provenance());
835 for(
auto const& productResolver : *
this) {
836 if(productResolver->singleProduct() && !productResolver->branchDescription().isAlias()) {
837 if(productResolver->stableProvenance()->branchDescription().present()) {
838 provenances.push_back(productResolver->stableProvenance());
846 for(
auto&
prod : bids) {
870 std::vector<WrapperBase const*>&,
871 std::vector<unsigned int>&)
const {
882 if(edp.get() ==
nullptr) {
884 <<
"put: Cannot put because unique_ptr to product is null." 898 for(
auto const&
prod :
preg_->productList()) {
906 auto cbd = std::make_shared<BranchDescription const>(bd);
917 if(not
reader()) {
return;}
919 for(
auto &
prod : *
this) {
920 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
bool registeredToConsumeMany(TypeID const &, BranchType) const
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
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