-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6989 from Dr15Jones/refToAlias
Fix ProductID problems when using an EDAlias
- Loading branch information
Showing
12 changed files
with
253 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include <iostream> | ||
#include "DataFormats/TestObjects/interface/OtherThing.h" | ||
#include "DataFormats/TestObjects/interface/OtherThingCollection.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "FWCore/Utilities/interface/Exception.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/stream/EDAnalyzer.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
#include "FWCore/Utilities/interface/EDGetToken.h" | ||
|
||
|
||
namespace edmtest { | ||
|
||
class OtherThingRefComparer : public edm::stream::EDAnalyzer<> { | ||
public: | ||
|
||
explicit OtherThingRefComparer(edm::ParameterSet const& pset); | ||
|
||
virtual void analyze(edm::Event const& e, edm::EventSetup const& c) override; | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
private: | ||
edm::EDGetTokenT<OtherThingCollection> token1_; | ||
edm::EDGetTokenT<OtherThingCollection> token2_; | ||
}; | ||
|
||
OtherThingRefComparer::OtherThingRefComparer(edm::ParameterSet const& pset) : | ||
token1_(consumes<OtherThingCollection>(pset.getUntrackedParameter<edm::InputTag>("first"))), | ||
token2_(consumes<OtherThingCollection>(pset.getUntrackedParameter<edm::InputTag>("second"))) | ||
{ | ||
} | ||
|
||
void OtherThingRefComparer::analyze(edm::Event const& e, edm::EventSetup const&) { | ||
edm::Handle<OtherThingCollection> handle1_; | ||
e.getByToken(token1_,handle1_); | ||
edm::Handle<OtherThingCollection> handle2_; | ||
e.getByToken(token2_,handle2_); | ||
|
||
assert(handle1_->size() == handle2_->size()); | ||
|
||
{ | ||
auto iter2 = handle2_->begin(); | ||
for(auto const& o1: *handle1_) { | ||
if(o1.ref != iter2->ref) { | ||
throw cms::Exception("RefCompareFailure")<<"edm::Refs are not equal"<< o1.ref.id()<<" "<<iter2->ref.id(); | ||
} | ||
++iter2; | ||
} | ||
} | ||
|
||
{ | ||
auto iter2 = handle2_->begin(); | ||
for(auto const& o1: *handle1_) { | ||
if(o1.ptr != iter2->ptr) { | ||
throw cms::Exception("RefCompareFailure")<<"edm::Ptrs are not equal"<<o1.ptr.id()<<" "<<iter2->ptr.id(); | ||
} | ||
++iter2; | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
void OtherThingRefComparer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
desc.addUntracked<edm::InputTag>("first",edm::InputTag("OtherThing","testUserTag"))->setComment("Where to get the first OtherThingCollection"); | ||
desc.addUntracked<edm::InputTag>("second",edm::InputTag("OtherThing","testUserTag"))->setComment("Where to get the second OtherThingCollection"); | ||
descriptions.add("otherThingRefComparer", desc); | ||
} | ||
|
||
} | ||
using edmtest::OtherThingRefComparer; | ||
DEFINE_FWK_MODULE(OtherThingRefComparer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
FWCore/Integration/test/ref_alias_compare_drop_alias_cfg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
process = cms.Process("Test") | ||
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10)) | ||
|
||
process.source = cms.Source("EmptySource") | ||
|
||
process.thing = cms.EDProducer("ThingProducer") | ||
|
||
process.thingAlias = cms.EDAlias( thing = cms.VPSet( | ||
cms.PSet(type = cms.string('edmtestThings'), | ||
fromProductInstance = cms.string('*'), | ||
toProductInstance = cms.string('*')))) | ||
|
||
process.otherThing1 = cms.EDProducer("OtherThingProducer", | ||
thingTag=cms.InputTag("thing")) | ||
|
||
process.otherThing2 = cms.EDProducer("OtherThingProducer", | ||
thingTag=cms.InputTag("thingAlias")) | ||
|
||
process.comparer = cms.EDAnalyzer("OtherThingRefComparer", | ||
first = cms.untracked.InputTag("otherThing1:testUserTag"), | ||
second = cms.untracked.InputTag("otherThing2:testUserTag") | ||
) | ||
|
||
process.out = cms.OutputModule("PoolOutputModule", | ||
fileName = cms.untracked.string("ref_alias_drop_alias.root"), | ||
outputCommands = cms.untracked.vstring("keep *", | ||
"drop *_thingAlias_*_*") | ||
) | ||
|
||
process.p = cms.Path(process.thing+process.otherThing1+process.otherThing2+process.comparer) | ||
process.o = cms.EndPath(process.out) |
33 changes: 33 additions & 0 deletions
33
FWCore/Integration/test/ref_alias_compare_drop_original_cfg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
process = cms.Process("Test") | ||
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10)) | ||
|
||
process.source = cms.Source("EmptySource") | ||
|
||
process.thing = cms.EDProducer("ThingProducer") | ||
|
||
process.thingAlias = cms.EDAlias( thing = cms.VPSet( | ||
cms.PSet(type = cms.string('edmtestThings'), | ||
fromProductInstance = cms.string('*'), | ||
toProductInstance = cms.string('*')))) | ||
|
||
process.otherThing1 = cms.EDProducer("OtherThingProducer", | ||
thingTag=cms.InputTag("thing")) | ||
|
||
process.otherThing2 = cms.EDProducer("OtherThingProducer", | ||
thingTag=cms.InputTag("thingAlias")) | ||
|
||
process.comparer = cms.EDAnalyzer("OtherThingRefComparer", | ||
first = cms.untracked.InputTag("otherThing1:testUserTag"), | ||
second = cms.untracked.InputTag("otherThing2:testUserTag") | ||
) | ||
|
||
process.out = cms.OutputModule("PoolOutputModule", | ||
fileName = cms.untracked.string("ref_alias_drop_original.root"), | ||
outputCommands = cms.untracked.vstring("keep *", | ||
"drop *_thing_*_*") | ||
) | ||
|
||
process.p = cms.Path(process.thing+process.otherThing1+process.otherThing2+process.comparer) | ||
process.o = cms.EndPath(process.out) |
26 changes: 26 additions & 0 deletions
26
FWCore/Integration/test/ref_alias_compare_read_alias_cfg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
process = cms.Process("Analyze") | ||
|
||
process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:ref_alias_drop_original.root")) | ||
|
||
process.otherThing3 = cms.EDProducer("OtherThingProducer", | ||
thingTag=cms.InputTag("thingAlias")) | ||
|
||
process.comparerA = cms.EDAnalyzer("OtherThingRefComparer", | ||
first = cms.untracked.InputTag("otherThing1:testUserTag"), | ||
second = cms.untracked.InputTag("otherThing2:testUserTag") | ||
) | ||
|
||
process.comparerB = cms.EDAnalyzer("OtherThingRefComparer", | ||
first = cms.untracked.InputTag("otherThing1:testUserTag"), | ||
second = cms.untracked.InputTag("otherThing3:testUserTag") | ||
) | ||
|
||
process.comparerC = cms.EDAnalyzer("OtherThingRefComparer", | ||
first = cms.untracked.InputTag("otherThing2:testUserTag"), | ||
second = cms.untracked.InputTag("otherThing3:testUserTag") | ||
) | ||
|
||
process.p = cms.Path(process.otherThing3+process.comparerA+process.comparerB+process.comparerC) | ||
|
25 changes: 25 additions & 0 deletions
25
FWCore/Integration/test/ref_alias_compare_read_original_cfg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
process = cms.Process("Analyze") | ||
|
||
process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:ref_alias_drop_alias.root")) | ||
|
||
process.otherThing3 = cms.EDProducer("OtherThingProducer", | ||
thingTag=cms.InputTag("thing")) | ||
|
||
process.comparerA = cms.EDAnalyzer("OtherThingRefComparer", | ||
first = cms.untracked.InputTag("otherThing1:testUserTag"), | ||
second = cms.untracked.InputTag("otherThing2:testUserTag") | ||
) | ||
|
||
process.comparerB = cms.EDAnalyzer("OtherThingRefComparer", | ||
first = cms.untracked.InputTag("otherThing1:testUserTag"), | ||
second = cms.untracked.InputTag("otherThing3:testUserTag") | ||
) | ||
|
||
process.comparerC = cms.EDAnalyzer("OtherThingRefComparer", | ||
first = cms.untracked.InputTag("otherThing2:testUserTag"), | ||
second = cms.untracked.InputTag("otherThing3:testUserTag") | ||
) | ||
|
||
process.p = cms.Path(process.otherThing3+process.comparerA+process.comparerB+process.comparerC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
test=ref_alias_compare_ | ||
|
||
function die { echo Failure $1: status $2 ; exit $2 ; } | ||
|
||
echo LOCAL_TMP_DIR = ${LOCAL_TMP_DIR} | ||
|
||
pushd ${LOCAL_TMP_DIR} | ||
echo ${test}drop_alias_cfg.py ------------------------------------------------------------ | ||
cmsRun -p ${LOCAL_TEST_DIR}/${test}drop_alias_cfg.py || die "cmsRun ${test}drop_alias_cfg.py" $? | ||
|
||
echo ${test}drop_original_cfg.py ------------------------------------------------------------ | ||
cmsRun -p ${LOCAL_TEST_DIR}/${test}drop_original_cfg.py || die "cmsRun ${test}drop_original_cfg.py" $? | ||
|
||
echo ${test}read_alias_cfg.py------------------------------------------------------------ | ||
cmsRun -p ${LOCAL_TEST_DIR}/${test}read_alias_cfg.py || die "cmsRun ${test}read_alias_cfg.py" $? | ||
|
||
echo ${test}read_original_cfg.py------------------------------------------------------------ | ||
cmsRun -p ${LOCAL_TEST_DIR}/${test}read_original_cfg.py || die "cmsRun ${test}read_original_cfg.py" $? | ||
|
||
popd | ||
|
||
exit 0 |