From 94a0448044f8ac4f73863fdd28b68eca4017d7a5 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Jul 2013 20:32:23 -0400 Subject: [PATCH 1/4] Report if products are gotten from Event, Lumi or Run without corresponding consumes call Each time a data product is gotten from the Event, LuminosityBlock or Run without having the module calling the corresponding consumes, mayConsume or consumesMany call we issue a MessageLogger warning. This required passing back from the Principal exactly which ProductHolderIndex was used to find the data. In the fully threaded framework this will be changed to throw an exception. --- FWCore/Framework/interface/EDConsumerBase.h | 6 ++ FWCore/Framework/interface/Principal.h | 12 ++-- FWCore/Framework/src/EDConsumerBase.cc | 31 +++++++++ FWCore/Framework/src/Principal.cc | 25 ++++--- FWCore/Framework/src/PrincipalGetAdapter.cc | 67 +++++++++++++++++-- FWCore/Framework/test/Event_t.cpp | 5 +- .../test/eventprincipal_t.cppunit.cc | 3 +- .../src/GetProductCheckerOutputModule.cc | 6 +- .../SecondaryInput/test/SecondaryProducer.cc | 7 +- 9 files changed, 137 insertions(+), 25 deletions(-) diff --git a/FWCore/Framework/interface/EDConsumerBase.h b/FWCore/Framework/interface/EDConsumerBase.h index ad6b461458292..e3df52cf27e2d 100644 --- a/FWCore/Framework/interface/EDConsumerBase.h +++ b/FWCore/Framework/interface/EDConsumerBase.h @@ -52,6 +52,12 @@ namespace edm { void itemsToGet(BranchType, std::vector&) const; void itemsMayGet(BranchType, std::vector&) const; + + ///\return true if the product corresponding to the index was registered via consumes or mayConsume call + bool registeredToConsume(ProductHolderIndex, BranchType) const; + + ///\return true of TypeID corresponds to a type specified in a consumesMany call + bool registeredToConsumeMany(TypeID const&, BranchType) const; // ---------- static member functions -------------------- // ---------- member functions --------------------------- diff --git a/FWCore/Framework/interface/Principal.h b/FWCore/Framework/interface/Principal.h index f85e02c4cc930..f6338715cd635 100644 --- a/FWCore/Framework/interface/Principal.h +++ b/FWCore/Framework/interface/Principal.h @@ -105,13 +105,15 @@ namespace edm { BasicHandle getByLabel(KindOfType kindOfType, TypeID const& typeID, - InputTag const& inputTag) const; + InputTag const& inputTag, + ProductHolderIndex& oIndex) const; BasicHandle getByLabel(KindOfType kindOfType, TypeID const& typeID, std::string const& label, std::string const& instance, - std::string const& process) const; + std::string const& process, + ProductHolderIndex& oIndex) const; BasicHandle getByToken(KindOfType kindOfType, TypeID const& typeID, @@ -202,13 +204,15 @@ namespace edm { ProductData const* findProductByLabel(KindOfType kindOfType, TypeID const& typeID, - InputTag const& inputTag) const; + InputTag const& inputTag, + ProductHolderIndex& oIndex) const; ProductData const* findProductByLabel(KindOfType kindOfType, TypeID const& typeID, std::string const& label, std::string const& instance, - std::string const& process) const; + std::string const& process, + ProductHolderIndex& oIndex) const; // defaults to no-op unless overridden in derived class. virtual void resolveProduct_(ProductHolderBase const&, bool /*fillOnDemand*/) const {} diff --git a/FWCore/Framework/src/EDConsumerBase.cc b/FWCore/Framework/src/EDConsumerBase.cc index 48a7c46762bf9..006bbda52fe36 100644 --- a/FWCore/Framework/src/EDConsumerBase.cc +++ b/FWCore/Framework/src/EDConsumerBase.cc @@ -270,6 +270,37 @@ EDConsumerBase::labelsForToken(EDGetToken iToken, Labels& oLabels) const oLabels.process = oLabels.module+labels.m_deltaToProcessName; } +bool +EDConsumerBase::registeredToConsume(ProductHolderIndex iIndex, BranchType iBranch) const +{ + for(auto it = m_tokenInfo.begin(), + itEnd = m_tokenInfo.end(); + it != itEnd; ++it) { + if(it->m_index == iIndex and + it->m_branchType == iBranch) { + return true; + } + } + return false; +} + +bool +EDConsumerBase::registeredToConsumeMany(TypeID const& iType, BranchType iBranch) const +{ + for(auto it = m_tokenInfo.begin(), + itEnd = m_tokenInfo.end(); + it != itEnd; ++it) { + //consumesMany entries do not have their index resolved + if(it->m_index == ProductHolderIndexInvalid and + it->m_type == iType and + it->m_branchType == iBranch) { + return true; + } + } + return false; + +} + void EDConsumerBase::throwTypeMismatch(edm::TypeID const& iType, EDGetToken iToken) const diff --git a/FWCore/Framework/src/Principal.cc b/FWCore/Framework/src/Principal.cc index 608854d786c7b..197691f8bc879 100644 --- a/FWCore/Framework/src/Principal.cc +++ b/FWCore/Framework/src/Principal.cc @@ -420,9 +420,10 @@ namespace edm { BasicHandle Principal::getByLabel(KindOfType kindOfType, TypeID const& typeID, - InputTag const& inputTag) const { + InputTag const& inputTag, + ProductHolderIndex& oIndex) const { - ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag); + ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, oIndex); if(result == 0) { boost::shared_ptr whyFailed = makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(), inputTag.process()); @@ -436,9 +437,10 @@ namespace edm { TypeID const& typeID, std::string const& label, std::string const& instance, - std::string const& process) const { + std::string const& process, + ProductHolderIndex& oIndex) const { - ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process); + ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,oIndex); if(result == 0) { boost::shared_ptr whyFailed = makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process); @@ -580,7 +582,8 @@ namespace edm { ProductData const* Principal::findProductByLabel(KindOfType kindOfType, TypeID const& typeID, - InputTag const& inputTag) const { + InputTag const& inputTag, + ProductHolderIndex& oIndex) const { bool skipCurrentProcess = inputTag.willSkipCurrentProcess(); @@ -608,11 +611,12 @@ namespace edm { if (matches.numberOfMatches() == 0) { maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries()); } + oIndex=index; return 0; } inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry()); } - + oIndex = index; boost::shared_ptr const& productHolder = productHolders_[index]; ProductHolderBase::ResolveStatus resolveStatus; @@ -628,7 +632,8 @@ namespace edm { TypeID const& typeID, std::string const& label, std::string const& instance, - std::string const& process) const { + std::string const& process, + ProductHolderIndex& oIndex) const { ProductHolderIndex index = productLookup().index(kindOfType, typeID, @@ -645,8 +650,10 @@ namespace edm { if (matches.numberOfMatches() == 0) { maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries()); } + oIndex=index; return 0; } + oIndex=index; boost::shared_ptr const& productHolder = productHolders_[index]; ProductHolderBase::ResolveStatus resolveStatus; @@ -659,10 +666,12 @@ namespace edm { ProductData const* Principal::findProductByTag(TypeID const& typeID, InputTag const& tag) const { + ProductHolderIndex index; ProductData const* productData = findProductByLabel(PRODUCT_TYPE, typeID, - tag); + tag, + index); if(productData == nullptr) { throwNotFoundException("findProductByTag", typeID, tag); } diff --git a/FWCore/Framework/src/PrincipalGetAdapter.cc b/FWCore/Framework/src/PrincipalGetAdapter.cc index 40937f7f7015d..c3f6fa82abd20 100644 --- a/FWCore/Framework/src/PrincipalGetAdapter.cc +++ b/FWCore/Framework/src/PrincipalGetAdapter.cc @@ -20,7 +20,9 @@ namespace edm { ModuleDescription const& md) : //putProducts_(), principal_(pcpl), - md_(md) { + md_(md), + consumer_(nullptr) + { } PrincipalGetAdapter::~PrincipalGetAdapter() { @@ -99,6 +101,34 @@ namespace edm { << "() was called.\n" << "The index of the token was "<\n module label: "<registeredToConsume(index,principal_.branchType())))) { + failedToRegisterConsumes(typeID,tag.label(),tag.instance(),tag.process()); + } + return h; } BasicHandle @@ -149,7 +184,12 @@ namespace edm { std::string const& label, std::string const& instance, std::string const& process) const { - return principal_.getByLabel(PRODUCT_TYPE, typeID, label, instance, process); + ProductHolderIndex index; + auto h = principal_.getByLabel(PRODUCT_TYPE, typeID, label, instance, process,index); + if(unlikely( consumer_ and (not consumer_->registeredToConsume(index,principal_.branchType())))) { + failedToRegisterConsumes(typeID,label,instance,process); + } + return h; } BasicHandle @@ -175,7 +215,12 @@ namespace edm { BasicHandle PrincipalGetAdapter::getMatchingSequenceByLabel_(TypeID const& typeID, InputTag const& tag) const { - return principal_.getByLabel(ELEMENT_TYPE, typeID, tag); + ProductHolderIndex index; + auto h = principal_.getByLabel(ELEMENT_TYPE, typeID, tag,index); + if(unlikely( consumer_ and (not consumer_->registeredToConsume(index,principal_.branchType())))) { + failedToRegisterConsumesForView(typeID,tag.label(),tag.instance(),tag.process()); + } + return h; } BasicHandle @@ -183,16 +228,26 @@ namespace edm { std::string const& label, std::string const& instance, std::string const& process) const { - return principal_.getByLabel(ELEMENT_TYPE, + ProductHolderIndex index; + auto h= principal_.getByLabel(ELEMENT_TYPE, typeID, label, instance, - process); + process, + index); + if(unlikely( consumer_ and (not consumer_->registeredToConsume(index,principal_.branchType())))) { + failedToRegisterConsumesForView(typeID,label,instance,process); + } + + return h; } void PrincipalGetAdapter::getManyByType_(TypeID const& tid, BasicHandleVec& results) const { + if(unlikely(consumer_ and (not consumer_->registeredToConsumeMany(tid,principal_.branchType())))) { + failedToRegisterConsumesMany(tid); + } principal_.getManyByType(tid, results); } diff --git a/FWCore/Framework/test/Event_t.cpp b/FWCore/Framework/test/Event_t.cpp index 857f1158cf38f..8c4787f803515 100644 --- a/FWCore/Framework/test/Event_t.cpp +++ b/FWCore/Framework/test/Event_t.cpp @@ -574,10 +574,11 @@ void testEvent::getByLabel() { } - BasicHandle bh = principal_->getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "modMulti", "int1", "LATE"); + edm::ProductHolderIndex index; + BasicHandle bh = principal_->getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "modMulti", "int1", "LATE",index); convert_handle(bh, h); CPPUNIT_ASSERT(h->value == 100); - BasicHandle bh2(principal_->getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "modMulti", "int1", "nomatch")); + BasicHandle bh2(principal_->getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "modMulti", "int1", "nomatch",index)); CPPUNIT_ASSERT(!bh2.isValid()); boost::shared_ptr const> ptr = getProductByTag(*principal_, inputTag); diff --git a/FWCore/Framework/test/eventprincipal_t.cppunit.cc b/FWCore/Framework/test/eventprincipal_t.cppunit.cc index 97f9a4f7f22a7..50a7fe4640341 100644 --- a/FWCore/Framework/test/eventprincipal_t.cppunit.cc +++ b/FWCore/Framework/test/eventprincipal_t.cppunit.cc @@ -235,7 +235,8 @@ void test_ep::failgetbyLabelTest() { std::string label("this does not exist"); - edm::BasicHandle h(pEvent_->getByLabel(edm::PRODUCT_TYPE, tid, label, std::string(), std::string())); + edm::ProductHolderIndex index; + edm::BasicHandle h(pEvent_->getByLabel(edm::PRODUCT_TYPE, tid, label, std::string(), std::string(),index)); CPPUNIT_ASSERT(h.failedToGet()); } diff --git a/FWCore/Modules/src/GetProductCheckerOutputModule.cc b/FWCore/Modules/src/GetProductCheckerOutputModule.cc index 1de41ccae8e01..ff65880c6b5df 100644 --- a/FWCore/Modules/src/GetProductCheckerOutputModule.cc +++ b/FWCore/Modules/src/GetProductCheckerOutputModule.cc @@ -90,12 +90,14 @@ namespace edm { if(0 != oh.desc() && oh.desc()->branchID() != branchID) { throw cms::Exception("BranchIDMissMatch") << "While processing " << id << " request for BranchID " << branchID << " returned BranchID " << oh.desc()->branchID() << "\n"; } - + + ProductHolderIndex index; TypeID const& tid((*it)->branchDescription().unwrappedTypeID()); BasicHandle bh = p.getByLabel(PRODUCT_TYPE, tid, (*it)->branchDescription().moduleLabel(), (*it)->branchDescription().productInstanceName(), - (*it)->branchDescription().processName()); + (*it)->branchDescription().processName(), + index); /*This doesn't appear to be an error, it just means the Product isn't available, which can be legitimate if(!bh.product()) { diff --git a/IOPool/SecondaryInput/test/SecondaryProducer.cc b/IOPool/SecondaryInput/test/SecondaryProducer.cc index 57a5c9d75f59a..09b5acf559b60 100644 --- a/IOPool/SecondaryInput/test/SecondaryProducer.cc +++ b/IOPool/SecondaryInput/test/SecondaryProducer.cc @@ -101,10 +101,12 @@ namespace edm { EventNumber_t en = eventPrincipal.id().event(); // Check that secondary source products are retrieved from the same event as the EventAuxiliary + ProductHolderIndex index; BasicHandle bhandle = eventPrincipal.getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "EventNumber", "", - ""); + "", + index); assert(bhandle.isValid()); Handle handle; convert_handle(bhandle, handle); @@ -117,7 +119,8 @@ namespace edm { BasicHandle bh = eventPrincipal.getByLabel(PRODUCT_TYPE, TypeID(typeid(TC)), "Thing", "", - ""); + "", + index); assert(bh.isValid()); if(!(bh.interface()->dynamicTypeInfo() == typeid(TC))) { handleimpl::throwConvertTypeError(typeid(TC), bh.interface()->dynamicTypeInfo()); From 1868b3936aff6710b8d99cecd1b07937fdc06764 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Jul 2013 21:42:22 -0400 Subject: [PATCH 2/4] Issue warning only on the first time Temporarily have the registeredToConsume* functions only return false the first time an unregistered item is checked. This avoids having the checker issue a warning message each time. This is only temporary since this is not thread safe and in the threaded framework such a case would cause a fatal exception. --- FWCore/Framework/src/EDConsumerBase.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/FWCore/Framework/src/EDConsumerBase.cc b/FWCore/Framework/src/EDConsumerBase.cc index 006bbda52fe36..bd4a572e9d14e 100644 --- a/FWCore/Framework/src/EDConsumerBase.cc +++ b/FWCore/Framework/src/EDConsumerBase.cc @@ -281,6 +281,14 @@ EDConsumerBase::registeredToConsume(ProductHolderIndex iIndex, BranchType iBranc return true; } } + //TEMPORARY: Remember so we do not have to do this again + //non thread-safe + EDConsumerBase* nonConstThis = const_cast(this); + nonConstThis->m_tokenInfo.emplace_back(TokenLookupInfo{TypeID{},iIndex,iBranch}, + true, + LabelPlacement{0,0,0}, + PRODUCT_TYPE); + return false; } @@ -297,6 +305,13 @@ EDConsumerBase::registeredToConsumeMany(TypeID const& iType, BranchType iBranch) return true; } } + //TEMPORARY: Remember so we do not have to do this again + //non thread-safe + EDConsumerBase* nonConstThis = const_cast(this); + nonConstThis->m_tokenInfo.emplace_back(TokenLookupInfo{iType,ProductHolderIndexInvalid,iBranch}, + true, + LabelPlacement{0,0,0}, + PRODUCT_TYPE); return false; } From 4d1a3a325c0c414dce9ae95b55af0ea55ea8a91e Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 11 Jul 2013 14:20:28 +0200 Subject: [PATCH 3/4] Principal has to be the one to check to see if data being requested has been registered by the EDConsumerBase since if it has not been registered we need to fail before any attempt is made to run the Producer in unscheduled mode. --- FWCore/Framework/interface/Principal.h | 12 ++-- FWCore/Framework/src/Principal.cc | 60 +++++++++++++----- FWCore/Framework/src/PrincipalGetAdapter.cc | 61 ++----------------- FWCore/Framework/test/Event_t.cpp | 5 +- .../test/eventprincipal_t.cppunit.cc | 5 +- .../src/GetProductCheckerOutputModule.cc | 3 +- .../SecondaryInput/test/SecondaryProducer.cc | 5 +- 7 files changed, 65 insertions(+), 86 deletions(-) diff --git a/FWCore/Framework/interface/Principal.h b/FWCore/Framework/interface/Principal.h index f6338715cd635..100dd49d08729 100644 --- a/FWCore/Framework/interface/Principal.h +++ b/FWCore/Framework/interface/Principal.h @@ -44,6 +44,7 @@ namespace edm { class HistoryAppender; class ProductHolderIndexHelper; + class EDConsumerBase; struct FilledProductPtr { bool operator()(boost::shared_ptr const& iObj) { return bool(iObj);} @@ -106,14 +107,14 @@ namespace edm { BasicHandle getByLabel(KindOfType kindOfType, TypeID const& typeID, InputTag const& inputTag, - ProductHolderIndex& oIndex) const; + EDConsumerBase const* consumes) const; BasicHandle getByLabel(KindOfType kindOfType, TypeID const& typeID, std::string const& label, std::string const& instance, std::string const& process, - ProductHolderIndex& oIndex) const; + EDConsumerBase const* consumes) const; BasicHandle getByToken(KindOfType kindOfType, TypeID const& typeID, @@ -122,7 +123,8 @@ namespace edm { bool& ambiguous) const; void getManyByType(TypeID const& typeID, - BasicHandleVec& results) const; + BasicHandleVec& results, + EDConsumerBase const* consumes) const; ProcessHistory const& processHistory() const { return *processHistoryPtr_; @@ -205,14 +207,14 @@ namespace edm { ProductData const* findProductByLabel(KindOfType kindOfType, TypeID const& typeID, InputTag const& inputTag, - ProductHolderIndex& oIndex) const; + EDConsumerBase const* consumer) const; ProductData const* findProductByLabel(KindOfType kindOfType, TypeID const& typeID, std::string const& label, std::string const& instance, std::string const& process, - ProductHolderIndex& oIndex) const; + EDConsumerBase const* consumer) const; // defaults to no-op unless overridden in derived class. virtual void resolveProduct_(ProductHolderBase const&, bool /*fillOnDemand*/) const {} diff --git a/FWCore/Framework/src/Principal.cc b/FWCore/Framework/src/Principal.cc index 197691f8bc879..a063cb75c14f1 100644 --- a/FWCore/Framework/src/Principal.cc +++ b/FWCore/Framework/src/Principal.cc @@ -9,6 +9,7 @@ #include "FWCore/Framework/interface/DelayedReader.h" #include "FWCore/Framework/interface/HistoryAppender.h" #include "FWCore/Framework/interface/ProductDeletedException.h" +#include "FWCore/Framework/interface/EDConsumerBase.h" #include "FWCore/Utilities/interface/Algorithms.h" #include "FWCore/Utilities/interface/EDMException.h" #include "FWCore/Utilities/interface/DictionaryTools.h" @@ -16,6 +17,9 @@ #include "FWCore/Utilities/interface/TypeID.h" #include "FWCore/Utilities/interface/WrappedClassName.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + + #include #include #include @@ -98,7 +102,25 @@ namespace edm { boost::shared_ptr exception = makeNotFoundException(where, PRODUCT_TYPE, productType, tag.label(), tag.instance(), tag.process()); throw *exception; } - + + namespace { + void failedToRegisterConsumesMany(edm::TypeID const& iType) { + LogError("GetManyWithoutRegistration")<<"::getManyByType called for "<\n module label: ")< reg, boost::shared_ptr productLookup, @@ -421,9 +443,9 @@ namespace edm { Principal::getByLabel(KindOfType kindOfType, TypeID const& typeID, InputTag const& inputTag, - ProductHolderIndex& oIndex) const { + EDConsumerBase const* consumer) const { - ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, oIndex); + ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer); if(result == 0) { boost::shared_ptr whyFailed = makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(), inputTag.process()); @@ -438,9 +460,9 @@ namespace edm { std::string const& label, std::string const& instance, std::string const& process, - ProductHolderIndex& oIndex) const { + EDConsumerBase const* consumer) const { - ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,oIndex); + ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,consumer); if(result == 0) { boost::shared_ptr whyFailed = makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process); @@ -472,10 +494,15 @@ namespace edm { void Principal::getManyByType(TypeID const& typeID, - BasicHandleVec& results) const { + BasicHandleVec& results, + EDConsumerBase const* consumer) const { assert(results.empty()); + if(unlikely(consumer and (not consumer->registeredToConsumeMany(typeID,branchType())))) { + failedToRegisterConsumesMany(typeID); + } + // This finds the indexes to all the ProductHolder's matching the type ProductHolderIndexHelper::Matches matches = productLookup().relatedIndexes(PRODUCT_TYPE, typeID); @@ -583,7 +610,7 @@ namespace edm { Principal::findProductByLabel(KindOfType kindOfType, TypeID const& typeID, InputTag const& inputTag, - ProductHolderIndex& oIndex) const { + EDConsumerBase const* consumer) const { bool skipCurrentProcess = inputTag.willSkipCurrentProcess(); @@ -611,12 +638,15 @@ namespace edm { if (matches.numberOfMatches() == 0) { maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries()); } - oIndex=index; return 0; } inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry()); } - oIndex = index; + if(unlikely( consumer and (not consumer->registeredToConsume(index,branchType())))) { + failedToRegisterConsumes(kindOfType,typeID,inputTag.label(),inputTag.instance(),inputTag.process()); + } + + boost::shared_ptr const& productHolder = productHolders_[index]; ProductHolderBase::ResolveStatus resolveStatus; @@ -633,7 +663,7 @@ namespace edm { std::string const& label, std::string const& instance, std::string const& process, - ProductHolderIndex& oIndex) const { + EDConsumerBase const* consumer) const { ProductHolderIndex index = productLookup().index(kindOfType, typeID, @@ -650,10 +680,13 @@ namespace edm { if (matches.numberOfMatches() == 0) { maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries()); } - oIndex=index; return 0; } - oIndex=index; + + if(unlikely( consumer and (not consumer->registeredToConsume(index,branchType())))) { + failedToRegisterConsumes(kindOfType,typeID,label,instance,process); + } + boost::shared_ptr const& productHolder = productHolders_[index]; ProductHolderBase::ResolveStatus resolveStatus; @@ -666,12 +699,11 @@ namespace edm { ProductData const* Principal::findProductByTag(TypeID const& typeID, InputTag const& tag) const { - ProductHolderIndex index; ProductData const* productData = findProductByLabel(PRODUCT_TYPE, typeID, tag, - index); + nullptr); if(productData == nullptr) { throwNotFoundException("findProductByTag", typeID, tag); } diff --git a/FWCore/Framework/src/PrincipalGetAdapter.cc b/FWCore/Framework/src/PrincipalGetAdapter.cc index c3f6fa82abd20..748edf711e460 100644 --- a/FWCore/Framework/src/PrincipalGetAdapter.cc +++ b/FWCore/Framework/src/PrincipalGetAdapter.cc @@ -102,34 +102,6 @@ namespace edm { << "The index of the token was "<\n module label: "<registeredToConsume(index,principal_.branchType())))) { - failedToRegisterConsumes(typeID,tag.label(),tag.instance(),tag.process()); - } - return h; + return principal_.getByLabel(PRODUCT_TYPE, typeID, tag, consumer_); } BasicHandle @@ -184,12 +151,7 @@ namespace edm { std::string const& label, std::string const& instance, std::string const& process) const { - ProductHolderIndex index; - auto h = principal_.getByLabel(PRODUCT_TYPE, typeID, label, instance, process,index); - if(unlikely( consumer_ and (not consumer_->registeredToConsume(index,principal_.branchType())))) { - failedToRegisterConsumes(typeID,label,instance,process); - } - return h; + return principal_.getByLabel(PRODUCT_TYPE, typeID, label, instance, process, consumer_); } BasicHandle @@ -215,12 +177,7 @@ namespace edm { BasicHandle PrincipalGetAdapter::getMatchingSequenceByLabel_(TypeID const& typeID, InputTag const& tag) const { - ProductHolderIndex index; - auto h = principal_.getByLabel(ELEMENT_TYPE, typeID, tag,index); - if(unlikely( consumer_ and (not consumer_->registeredToConsume(index,principal_.branchType())))) { - failedToRegisterConsumesForView(typeID,tag.label(),tag.instance(),tag.process()); - } - return h; + return principal_.getByLabel(ELEMENT_TYPE, typeID, tag, consumer_); } BasicHandle @@ -228,27 +185,19 @@ namespace edm { std::string const& label, std::string const& instance, std::string const& process) const { - ProductHolderIndex index; auto h= principal_.getByLabel(ELEMENT_TYPE, typeID, label, instance, process, - index); - if(unlikely( consumer_ and (not consumer_->registeredToConsume(index,principal_.branchType())))) { - failedToRegisterConsumesForView(typeID,label,instance,process); - } - + consumer_); return h; } void PrincipalGetAdapter::getManyByType_(TypeID const& tid, BasicHandleVec& results) const { - if(unlikely(consumer_ and (not consumer_->registeredToConsumeMany(tid,principal_.branchType())))) { - failedToRegisterConsumesMany(tid); - } - principal_.getManyByType(tid, results); + principal_.getManyByType(tid, results, consumer_); } ProcessHistory const& diff --git a/FWCore/Framework/test/Event_t.cpp b/FWCore/Framework/test/Event_t.cpp index 8c4787f803515..d1b676f290e5f 100644 --- a/FWCore/Framework/test/Event_t.cpp +++ b/FWCore/Framework/test/Event_t.cpp @@ -574,11 +574,10 @@ void testEvent::getByLabel() { } - edm::ProductHolderIndex index; - BasicHandle bh = principal_->getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "modMulti", "int1", "LATE",index); + BasicHandle bh = principal_->getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "modMulti", "int1", "LATE",nullptr); convert_handle(bh, h); CPPUNIT_ASSERT(h->value == 100); - BasicHandle bh2(principal_->getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "modMulti", "int1", "nomatch",index)); + BasicHandle bh2(principal_->getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "modMulti", "int1", "nomatch",nullptr)); CPPUNIT_ASSERT(!bh2.isValid()); boost::shared_ptr const> ptr = getProductByTag(*principal_, inputTag); diff --git a/FWCore/Framework/test/eventprincipal_t.cppunit.cc b/FWCore/Framework/test/eventprincipal_t.cppunit.cc index 50a7fe4640341..5a08d684b2743 100644 --- a/FWCore/Framework/test/eventprincipal_t.cppunit.cc +++ b/FWCore/Framework/test/eventprincipal_t.cppunit.cc @@ -235,8 +235,7 @@ void test_ep::failgetbyLabelTest() { std::string label("this does not exist"); - edm::ProductHolderIndex index; - edm::BasicHandle h(pEvent_->getByLabel(edm::PRODUCT_TYPE, tid, label, std::string(), std::string(),index)); + edm::BasicHandle h(pEvent_->getByLabel(edm::PRODUCT_TYPE, tid, label, std::string(), std::string(),nullptr)); CPPUNIT_ASSERT(h.failedToGet()); } @@ -245,7 +244,7 @@ void test_ep::failgetManybyTypeTest() { edm::TypeID tid(dummy); std::vector handles; - pEvent_->getManyByType(tid, handles); + pEvent_->getManyByType(tid, handles,nullptr); CPPUNIT_ASSERT(handles.empty()); } diff --git a/FWCore/Modules/src/GetProductCheckerOutputModule.cc b/FWCore/Modules/src/GetProductCheckerOutputModule.cc index ff65880c6b5df..d5524393d9824 100644 --- a/FWCore/Modules/src/GetProductCheckerOutputModule.cc +++ b/FWCore/Modules/src/GetProductCheckerOutputModule.cc @@ -91,13 +91,12 @@ namespace edm { throw cms::Exception("BranchIDMissMatch") << "While processing " << id << " request for BranchID " << branchID << " returned BranchID " << oh.desc()->branchID() << "\n"; } - ProductHolderIndex index; TypeID const& tid((*it)->branchDescription().unwrappedTypeID()); BasicHandle bh = p.getByLabel(PRODUCT_TYPE, tid, (*it)->branchDescription().moduleLabel(), (*it)->branchDescription().productInstanceName(), (*it)->branchDescription().processName(), - index); + nullptr); /*This doesn't appear to be an error, it just means the Product isn't available, which can be legitimate if(!bh.product()) { diff --git a/IOPool/SecondaryInput/test/SecondaryProducer.cc b/IOPool/SecondaryInput/test/SecondaryProducer.cc index 09b5acf559b60..6b211378a5e6c 100644 --- a/IOPool/SecondaryInput/test/SecondaryProducer.cc +++ b/IOPool/SecondaryInput/test/SecondaryProducer.cc @@ -101,12 +101,11 @@ namespace edm { EventNumber_t en = eventPrincipal.id().event(); // Check that secondary source products are retrieved from the same event as the EventAuxiliary - ProductHolderIndex index; BasicHandle bhandle = eventPrincipal.getByLabel(PRODUCT_TYPE, TypeID(typeid(edmtest::IntProduct)), "EventNumber", "", "", - index); + nullptr); assert(bhandle.isValid()); Handle handle; convert_handle(bhandle, handle); @@ -120,7 +119,7 @@ namespace edm { "Thing", "", "", - index); + nullptr); assert(bh.isValid()); if(!(bh.interface()->dynamicTypeInfo() == typeid(TC))) { handleimpl::throwConvertTypeError(typeid(TC), bh.interface()->dynamicTypeInfo()); From b2638688e98724408e43aa4936cc1073a1978787 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 11 Jul 2013 16:50:28 +0200 Subject: [PATCH 4/4] Updated to conform to new Principal interface --- SimGeneral/MixingModule/interface/PileUpEventPrincipal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimGeneral/MixingModule/interface/PileUpEventPrincipal.h b/SimGeneral/MixingModule/interface/PileUpEventPrincipal.h index 91e2c3f903031..76df77d8ee862 100644 --- a/SimGeneral/MixingModule/interface/PileUpEventPrincipal.h +++ b/SimGeneral/MixingModule/interface/PileUpEventPrincipal.h @@ -50,7 +50,7 @@ class PileUpEventPrincipal { getByLabel(edm::InputTag const& tag, edm::Handle& result) const { typedef typename T::value_type ItemType; typedef typename T::iterator iterator; - edm::BasicHandle bh = principal_.getByLabel(edm::PRODUCT_TYPE, edm::TypeID(typeid(T)), tag); + edm::BasicHandle bh = principal_.getByLabel(edm::PRODUCT_TYPE, edm::TypeID(typeid(T)), tag, nullptr); convert_handle(bh, result); if(result.isValid() && addLabel(edm::TypeID(typeid(T)), tag.label())) { T& product = const_cast(*result.product());