Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in consumes handling and dded consumes calls to Framework owned modules #88

Merged
merged 5 commits into from
Jul 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions FWCore/Framework/interface/EDConsumerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
namespace edm {
class ProductHolderIndexHelper;
class ConsumesCollector;
template<typename T> class WillGetIfMatch;

class EDConsumerBase
{
Expand Down Expand Up @@ -73,6 +74,7 @@ namespace edm {

protected:
friend class ConsumesCollector;
template<typename T> friend class WillGetIfMatch;
///Use a ConsumesCollector to gather consumes information from helper functions
ConsumesCollector consumesCollector();

Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/GetterOfProducts.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace edm {

template <typename U, typename M>
GetterOfProducts(U const& match, M* module, edm::BranchType branchType = edm::InEvent) :
matcher_(WillGetIfMatch<T, M>(match, module)),
matcher_(WillGetIfMatch<T>(match, module)),
inputTags_(new std::vector<edm::InputTag>),
branchType_(branchType) {
}
Expand Down
30 changes: 16 additions & 14 deletions FWCore/Framework/interface/WillGetIfMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,44 @@ See comments in the file GetterOfProducts.h.
*/

#include <functional>
#include "FWCore/Utilities/interface/InputTag.h"

namespace edm {

class BranchDescription;
class EDConsumerBase;

template<typename T, typename M>
template<typename T>
class WillGetIfMatch {
public:

template <typename U>
WillGetIfMatch(U const& match, M* module):
WillGetIfMatch(U const& match, EDConsumerBase* module):
match_(match),
module_(module) {
}

bool operator()(BranchDescription const& branchDescription) {
if (match_(branchDescription)){

// We plan to implement a call to a function that
// registers the products a module will get, but
// this has not been implemented yet. This is
// where that function would get called when it
// is implemented, automatically registering
// the gets for the module. (Creating a place to call
// this function is the main reason for the existence
// of this class).
// module_->template willGet<T>(edm::makeInputTag(branchDescription));

auto transition = branchDescription.branchType();
edm::InputTag tag{branchDescription.moduleLabel(),
branchDescription.productInstanceName(),
branchDescription.processName()};
if(transition == edm::InEvent) {
module_->template consumes<T>(tag);
} else if(transition == edm::InLumi) {
module_->template consumes<T,edm::InLumi>(tag);
} else if(transition == edm::InRun) {
module_->template consumes<T,edm::InRun>(tag);
}
return true;
}
return false;
}

private:
std::function<bool(BranchDescription const&)> match_;
M* module_;
EDConsumerBase* module_;
};
}
#endif
16 changes: 9 additions & 7 deletions FWCore/Framework/src/EDConsumerBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ EDConsumerBase::updateLookup(BranchType iBranchType,
auto itLabels = m_tokenInfo.begin<kLabels>();
for(auto itInfo = m_tokenInfo.begin<kLookupInfo>(),itEnd = m_tokenInfo.end<kLookupInfo>();
itInfo != itEnd; ++itInfo,++itKind,++itLabels) {
const unsigned int labelStart = itLabels->m_startOfModuleLabel;
const char* moduleLabel = &(m_tokenLabels[labelStart]);
itInfo->m_index = iHelper.index(*itKind,
itInfo->m_type,
moduleLabel,
moduleLabel+itLabels->m_deltaToProductInstance,
moduleLabel+itLabels->m_deltaToProcessName);
if(itInfo->m_branchType == iBranchType) {
const unsigned int labelStart = itLabels->m_startOfModuleLabel;
const char* moduleLabel = &(m_tokenLabels[labelStart]);
itInfo->m_index = iHelper.index(*itKind,
itInfo->m_type,
moduleLabel,
moduleLabel+itLabels->m_deltaToProductInstance,
moduleLabel+itLabels->m_deltaToProcessName);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion FWCore/Framework/test/stubs/DeleteEarlyModules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ namespace edmtest {
public:
DeleteEarlyReader(edm::ParameterSet const& pset):
m_tag(pset.getUntrackedParameter<edm::InputTag>("tag"))
{}
{
consumes<DeleteEarly>(m_tag);
}

virtual void analyze(edm::Event const& e, edm::EventSetup const& ) {
edm::Handle<DeleteEarly> h;
Expand Down
1 change: 1 addition & 0 deletions FWCore/Framework/test/stubs/TestFilterModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace edmtest
expected_pathname_(ps.getUntrackedParameter<std::string>("pathname", "")),
expected_modulelabel_(ps.getUntrackedParameter<std::string>("modlabel", ""))
{
consumesMany<edm::TriggerResults>();
}

TestResultAnalyzer::~TestResultAnalyzer()
Expand Down
75 changes: 75 additions & 0 deletions FWCore/Framework/test/stubs/TestMergeResults.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,81 @@ namespace edmtest {
edm::Wrapper<edmtest::ThingWithIsEqual> w_thingWithIsEqual(ap_thingwithisequal);
assert(!w_thingWithIsEqual.isMergeable());
assert(w_thingWithIsEqual.hasIsProductEqual());

if(expectedDroppedEvent_.size() > 0) {
consumes<edmtest::ThingWithIsEqual>(edm::InputTag{"makeThingToBeDropped", "event", "PROD"});
consumes<edmtest::ThingWithMerge>(edm::InputTag{"makeThingToBeDropped", "event", "PROD"});

consumes<edmtest::ThingWithIsEqual,edm::InRun>(edm::InputTag{"makeThingToBeDropped", "beginRun", "PROD"});
}
for(auto const& parent : expectedParents_) {
mayConsume<edmtest::Thing>(edm::InputTag{parent,"event","PROD"});
}
if(expectedDroppedEvent1_.size() > droppedIndex1_) {
consumes<edmtest::ThingWithIsEqual>(edm::InputTag{"makeThingToBeDropped1", "event", "PROD"});
}
consumes<edmtest::Thing>(edm::InputTag{"thingWithMergeProducer", "event", "PROD"});

if(testAlias_){
consumes<edmtest::Thing>(edm::InputTag{"aliasForThingToBeDropped2", "instance2"});
consumes<edmtest::Thing>(edm::InputTag{"aliasForThingToBeDropped2", "instance2","PROD"});
}

{
edm::InputTag tag("thingWithMergeProducer", "endRun", "PROD");
consumes<edmtest::Thing,edm::InRun>(tag);
consumes<edmtest::ThingWithMerge,edm::InRun>(tag);
consumes<edmtest::ThingWithIsEqual,edm::InRun>(tag);
}

{
edm::InputTag tag("thingWithMergeProducer", "endRun");
consumes<edmtest::Thing,edm::InRun>(tag);
consumes<edmtest::ThingWithMerge,edm::InRun>(tag);
consumes<edmtest::ThingWithIsEqual,edm::InRun>(tag);
}

if(expectedDroppedEvent_.size() > 2) {
edm::InputTag tag("makeThingToBeDropped", "endRun", "PROD");
consumes<edmtest::ThingWithMerge,edm::InRun>(tag);
consumes<edmtest::ThingWithIsEqual,edm::InRun>(tag);
}

if (testAlias_) {
consumes<edmtest::Thing,edm::InRun>(edm::InputTag{"aliasForThingToBeDropped2", "endRun2"});
edm::InputTag tag("aliasForThingToBeDropped2", "endRun2","PROD");
consumes<edmtest::Thing,edm::InRun>(tag);
}

if(expectedDroppedEvent_.size() > 3) {
edm::InputTag tag("makeThingToBeDropped", "beginLumi", "PROD");
consumes<edmtest::ThingWithIsEqual,edm::InLumi>(tag);
}
{
edm::InputTag tag("thingWithMergeProducer", "endLumi", "PROD");
consumes<edmtest::Thing,edm::InLumi>(tag);
consumes<edmtest::ThingWithMerge,edm::InLumi>(tag);
consumes<edmtest::ThingWithIsEqual,edm::InLumi>(tag);
}

{
edm::InputTag tag("thingWithMergeProducer", "endLumi");
consumes<edmtest::Thing,edm::InLumi>(tag);
consumes<edmtest::ThingWithMerge,edm::InLumi>(tag);
consumes<edmtest::ThingWithIsEqual,edm::InLumi>(tag);
}

if(expectedDroppedEvent_.size() > 4) {
edm::InputTag tag("makeThingToBeDropped", "endLumi", "PROD");
consumes<edmtest::ThingWithIsEqual,edm::InLumi>(tag);
consumes<edmtest::ThingWithMerge,edm::InLumi>(tag);
}

if (testAlias_) {
consumes<edmtest::Thing,edm::InLumi>(edm::InputTag{"aliasForThingToBeDropped2", "endLumi2"});
edm::InputTag tag("aliasForThingToBeDropped2", "endLumi2","PROD");
consumes<edmtest::Thing,edm::InLumi>(tag);
}
}

// -----------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions FWCore/Framework/test/stubs/TestPRegisterModule2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using namespace edm;

TestPRegisterModule2::TestPRegisterModule2(edm::ParameterSet const&){
produces<edmtest::DoubleProduct>();
consumes<edmtest::StringProduct>(edm::InputTag{"m2"});
}

void TestPRegisterModule2::produce(Event& e, EventSetup const&)
Expand Down
1 change: 1 addition & 0 deletions FWCore/Framework/test/stubs/TestTriggerNames.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace edmtest {
dumpPSetRegistry_(ps.getUntrackedParameter<bool>("dumpPSetRegistry", false)),
expectedTriggerResultsHLT_(ps.getUntrackedParameter<std::vector<unsigned int> >("expectedTriggerResultsHLT", std::vector<unsigned int>())),
expectedTriggerResultsPROD_(ps.getUntrackedParameter<std::vector<unsigned int> >("expectedTriggerResultsPROD", std::vector<unsigned int>())) {
consumesMany<edm::TriggerResults>();
}

// -----------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions FWCore/Framework/test/stubs/ToyAnalyzers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace edmtest {
IntTestAnalyzer(edm::ParameterSet const& iPSet) :
value_(iPSet.getUntrackedParameter<int>("valueMustMatch")),
moduleLabel_(iPSet.getUntrackedParameter<std::string>("moduleLabel"), "") {
consumes<IntProduct>(moduleLabel_);
}

void analyze(edm::Event const& iEvent, edm::EventSetup const&) {
Expand Down
4 changes: 4 additions & 0 deletions FWCore/Framework/test/stubs/ToyIntProducers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ namespace edmtest {
public:
explicit IntProducerFromTransient(edm::ParameterSet const&) {
produces<IntProduct>();
consumes<TransientIntProduct>(edm::InputTag{"TransientThing"});
}
explicit IntProducerFromTransient() {
produces<IntProduct>();
Expand Down Expand Up @@ -210,6 +211,9 @@ namespace edmtest {
explicit AddIntsProducer(edm::ParameterSet const& p) :
labels_(p.getParameter<std::vector<std::string> >("labels")) {
produces<IntProduct>();
for( auto const& label: labels_) {
consumes<IntProduct>(edm::InputTag{label});
}
}
virtual ~AddIntsProducer() {}
virtual void produce(edm::Event& e, edm::EventSetup const& c);
Expand Down
2 changes: 2 additions & 0 deletions FWCore/Framework/test/stubs/ToyModules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ namespace edmtest {
explicit AVSimpleProducer(edm::ParameterSet const& p) :
src_(p.getParameter<edm::InputTag>("src")) {
produces<AVSimpleProduct>();
consumes<std::vector<edmtest::Simple>>(src_);
}

virtual ~AVSimpleProducer() {}
Expand Down Expand Up @@ -367,6 +368,7 @@ namespace edmtest {
explicit ProdigalProducer(edm::ParameterSet const& p) :
label_(p.getParameter<std::string>("label")) {
produces<Prodigal>();
consumes<IntProduct>(edm::InputTag{label_});
}
virtual ~ProdigalProducer() {}
virtual void produce(edm::Event& e, edm::EventSetup const& c);
Expand Down
3 changes: 3 additions & 0 deletions FWCore/Framework/test/stubs/ToyRefProducers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace edmtest {
explicit IntVecRefVectorProducer(edm::ParameterSet const& p) :
target_(p.getParameter<std::string>("target")) {
produces<product_type>();
consumes<std::vector<int>>(edm::InputTag{target_});
}
virtual ~IntVecRefVectorProducer() {}
virtual void produce(edm::Event& e, edm::EventSetup const& c);
Expand Down Expand Up @@ -80,6 +81,7 @@ namespace edmtest {
explicit IntVecRefToBaseVectorProducer(edm::ParameterSet const& p) :
target_(p.getParameter<std::string>("target")) {
produces<product_type>();
consumes<edm::View<int>>(edm::InputTag{target_});
}
virtual ~IntVecRefToBaseVectorProducer() {}
virtual void produce(edm::Event& e, edm::EventSetup const& c);
Expand Down Expand Up @@ -112,6 +114,7 @@ namespace edmtest {
explicit IntVecPtrVectorProducer(edm::ParameterSet const& p) :
target_(p.getParameter<std::string>("target")) {
produces<product_type>();
consumes<edm::View<int>>(edm::InputTag{target_});
}
virtual ~IntVecPtrVectorProducer() {}
virtual void produce(edm::Event& e, edm::EventSetup const& c);
Expand Down
1 change: 1 addition & 0 deletions FWCore/Integration/test/ProdigalAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace edmtest {
ProdigalAnalyzer::ProdigalAnalyzer(edm::ParameterSet const& )
{
consumes<Prodigal>(edm::InputTag{"maker"});
}

void ProdigalAnalyzer::analyze(edm::Event const& e, edm::EventSetup const&) {
Expand Down
29 changes: 29 additions & 0 deletions FWCore/Integration/test/ViewAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,35 @@ namespace edmtest
{

ViewAnalyzer::ViewAnalyzer(ParameterSet const&) {
consumes<edm::View<int>>(edm::InputTag{"intvec","","TEST"});
consumes<edm::View<int>>(edm::InputTag{"intvec",""});
consumes<std::vector<int>>(edm::InputTag{"intvec"});
consumes<edm::View<int>>(edm::InputTag{"intvec"});
consumes<std::list<int>>(edm::InputTag{"intlist"});
consumes<edm::View<int>>(edm::InputTag{"intlist"});
consumes<std::deque<int>>(edm::InputTag{"intdeque"});
consumes<edm::View<int>>(edm::InputTag{"intdeque"});
consumes<std::set<int>>(edm::InputTag{"intset"});
consumes<edm::View<int>>(edm::InputTag{"intset"});
consumes<SCSimpleProduct>(edm::InputTag{"simple"});
consumes<edm::View<SCSimpleProduct::value_type>>(edm::InputTag{"simple"});
consumes<OVSimpleProduct>(edm::InputTag{"ovsimple"});
consumes<edm::View<OVSimpleProduct::value_type>>(edm::InputTag{"ovsimple"});
consumes<edmtest::DSVSimpleProduct>(edm::InputTag{"dsvsimple"});
consumes<edm::View<edmtest::DSVSimpleProduct::value_type>>(edm::InputTag{"dsvsimple"});

consumes<OVSimpleDerivedProduct>(edm::InputTag{"ovsimple","derived"});
consumes<edm::View<Simple>>(edm::InputTag{"ovsimple","derived"});

consumes<RefVector<std::vector<int>>>(edm::InputTag{"intvecrefvec"});
consumes<edm::View<int>>(edm::InputTag{"intvecrefvec"});

consumes<RefToBaseVector<int>>(edm::InputTag{"intvecreftbvec"});
consumes<edm::View<int>>(edm::InputTag{"intvecreftbvec"});

consumes<PtrVector<int>>(edm::InputTag{"intvecptrvec"});
consumes<edm::View<int>>(edm::InputTag{"intvecptrvec"});
mayConsume<edm::View<int>>(edm::InputTag{"intvecptrvecdoesNotExist"});
}

ViewAnalyzer::~ViewAnalyzer() {
Expand Down
22 changes: 21 additions & 1 deletion FWCore/Modules/src/EventContentAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "FWCore/Utilities/interface/MemberWithDict.h"
#include "FWCore/Utilities/interface/ObjectWithDict.h"
#include "FWCore/Utilities/interface/TypeWithDict.h"
#include "FWCore/Utilities/interface/TypeToGet.h"

// system include files
#include <algorithm>
Expand Down Expand Up @@ -293,10 +294,29 @@ namespace edm {
getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels", std::vector<std::string>())),
getData_(iConfig.getUntrackedParameter("getData", false) || getModuleLabels_.size()>0),
evno_(1),
listContent_(iConfig.getUntrackedParameter("listContent", true)){
listContent_(iConfig.getUntrackedParameter("listContent", true))
{
//now do what ever initialization is needed
sort_all(moduleLabels_);
sort_all(getModuleLabels_);
if(getData_) {
callWhenNewProductsRegistered([this](edm::BranchDescription const& iBranch) {
if(getModuleLabels_.empty()) {
this->consumes(edm::TypeToGet{iBranch.unwrappedTypeID(),PRODUCT_TYPE},
edm::InputTag{iBranch.moduleLabel(),iBranch.productInstanceName(),iBranch.processName()});
} else {
for (auto const& mod : this->getModuleLabels_) {
if (iBranch.moduleLabel() == mod) {
this->consumes(edm::TypeToGet{iBranch.unwrappedTypeID(),PRODUCT_TYPE},
edm::InputTag{mod,iBranch.productInstanceName(),iBranch.processName()});
break;
}
}
}
}
);
}

}

EventContentAnalyzer::~EventContentAnalyzer() {
Expand Down
1 change: 1 addition & 0 deletions IOPool/SecondaryInput/test/SecondaryProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace edm {

produces<edmtest::ThingCollection>();
produces<edmtest::OtherThingCollection>("testUserTag");
consumes<edmtest::IntProduct>(edm::InputTag{"EventNumber"});
}

void SecondaryProducer::beginJob() {
Expand Down