From 5faecffd27baae7a21b3e2163ddf215e94fc44da Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 8 Sep 2020 12:33:52 +0200 Subject: [PATCH 1/4] clean up --- .../plugins/ME0MuonTrackCollProducer.cc | 40 ++++--------------- CommonTools/RecoAlgos/python/me0Associator.py | 1 - 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc b/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc index f35b6225dc0c0..983a4a227f2c1 100644 --- a/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc +++ b/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc @@ -1,43 +1,24 @@ +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "DataFormats/TrackReco/interface/Track.h" -#include "DataFormats/MuonDetId/interface/CSCDetId.h" -#include "DataFormats/MuonDetId/interface/DTChamberId.h" -#include "DataFormats/MuonDetId/interface/MuonSubdetId.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/MuonReco/interface/Muon.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/MuonReco/interface/ME0Muon.h" +#include "DataFormats/MuonReco/interface/ME0MuonCollection.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "RecoMuon/MuonIdentification/interface/ME0MuonSelector.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include #include -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/MuonReco/interface/MuonFwd.h" -#include "DataFormats/MuonReco/interface/ME0Muon.h" -#include "DataFormats/MuonReco/interface/ME0MuonCollection.h" -#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" -#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" -#include "DataFormats/HepMCCandidate/interface/GenParticle.h" class ME0MuonTrackCollProducer : public edm::stream::EDProducer<> { public: explicit ME0MuonTrackCollProducer(const edm::ParameterSet&); - //std::vector findSimVtx(edm::Event& iEvent); ~ME0MuonTrackCollProducer() override; private: void produce(edm::Event&, const edm::EventSetup&) override; - edm::Handle > OurMuons; - //edm::Handle muonCollectionH; - edm::InputTag OurMuonsTag; - std::vector selectionTags; const edm::ParameterSet parset_; edm::EDGetTokenT OurMuonsToken_; }; @@ -48,11 +29,8 @@ class ME0MuonTrackCollProducer : public edm::stream::EDProducer<> { DEFINE_FWK_MODULE(ME0MuonTrackCollProducer); ME0MuonTrackCollProducer::ME0MuonTrackCollProducer(const edm::ParameterSet& parset) - : OurMuonsTag(parset.getParameter("me0MuonTag")), - selectionTags(parset.getParameter >("selectionTags")), - parset_(parset) { + : parset_(parset), OurMuonsToken_(consumes(parset.getParameter("me0MuonTag"))) { produces(); - OurMuonsToken_ = consumes(OurMuonsTag); } ME0MuonTrackCollProducer::~ME0MuonTrackCollProducer() {} @@ -77,11 +55,7 @@ void ME0MuonTrackCollProducer::produce(edm::Event& iEvent, const edm::EventSetup trackref = thismuon->innerTrack(); const reco::Track* trk = &(*trackref); - // pointer to old track: - //reco::Track* newTrk = new reco::Track(*trk); - selectedTracks->push_back(*trk); - //selectedTrackExtras->push_back( *newExtra ); } iEvent.put(std::move(selectedTracks)); } diff --git a/CommonTools/RecoAlgos/python/me0Associator.py b/CommonTools/RecoAlgos/python/me0Associator.py index f5de9d5d7845b..1b873a5c41a94 100644 --- a/CommonTools/RecoAlgos/python/me0Associator.py +++ b/CommonTools/RecoAlgos/python/me0Associator.py @@ -4,7 +4,6 @@ #----------ME0Muon Collection Production for association by chi2 me0muon = cms.EDProducer("ME0MuonTrackCollProducer", me0MuonTag = cms.InputTag("me0SegmentMatching"), - selectionTags = cms.vstring('All'), ) #-------------------- me0muonColl_seq = cms.Sequence( From 7e3511095dd65cafb5da8613b0d96af916622a99 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 8 Sep 2020 12:52:52 +0200 Subject: [PATCH 2/4] clean up --- CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc b/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc index 983a4a227f2c1..5ae12a0664a83 100644 --- a/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc +++ b/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc @@ -15,7 +15,7 @@ class ME0MuonTrackCollProducer : public edm::stream::EDProducer<> { public: explicit ME0MuonTrackCollProducer(const edm::ParameterSet&); - ~ME0MuonTrackCollProducer() override; + ~ME0MuonTrackCollProducer() override = default; private: void produce(edm::Event&, const edm::EventSetup&) override; @@ -33,8 +33,6 @@ ME0MuonTrackCollProducer::ME0MuonTrackCollProducer(const edm::ParameterSet& pars produces(); } -ME0MuonTrackCollProducer::~ME0MuonTrackCollProducer() {} - void ME0MuonTrackCollProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace reco; using namespace edm; From dfc024f18e9758c14ac8573bbe6f5e20c6d30a58 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 9 Sep 2020 14:52:20 +0200 Subject: [PATCH 3/4] Move ME0MuonTrackCollProducer in RecoMuon/MuonIdentification --- CommonTools/RecoAlgos/BuildFile.xml | 1 - .../plugins/ME0MuonTrackCollProducer.cc | 59 +++++++++++++++++++ .../python/me0Associator.py | 11 ++++ .../test/testME0MuonAnalyzer_Example.py | 2 +- 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 RecoMuon/MuonIdentification/plugins/ME0MuonTrackCollProducer.cc create mode 100644 RecoMuon/MuonIdentification/python/me0Associator.py diff --git a/CommonTools/RecoAlgos/BuildFile.xml b/CommonTools/RecoAlgos/BuildFile.xml index 0e2712608a101..3b52eda82bb6c 100644 --- a/CommonTools/RecoAlgos/BuildFile.xml +++ b/CommonTools/RecoAlgos/BuildFile.xml @@ -10,7 +10,6 @@ - diff --git a/RecoMuon/MuonIdentification/plugins/ME0MuonTrackCollProducer.cc b/RecoMuon/MuonIdentification/plugins/ME0MuonTrackCollProducer.cc new file mode 100644 index 0000000000000..5ae12a0664a83 --- /dev/null +++ b/RecoMuon/MuonIdentification/plugins/ME0MuonTrackCollProducer.cc @@ -0,0 +1,59 @@ + +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/MuonReco/interface/ME0Muon.h" +#include "DataFormats/MuonReco/interface/ME0MuonCollection.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "RecoMuon/MuonIdentification/interface/ME0MuonSelector.h" + +#include + +class ME0MuonTrackCollProducer : public edm::stream::EDProducer<> { +public: + explicit ME0MuonTrackCollProducer(const edm::ParameterSet&); + ~ME0MuonTrackCollProducer() override = default; + +private: + void produce(edm::Event&, const edm::EventSetup&) override; + const edm::ParameterSet parset_; + edm::EDGetTokenT OurMuonsToken_; +}; + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_FWK_MODULE(ME0MuonTrackCollProducer); + +ME0MuonTrackCollProducer::ME0MuonTrackCollProducer(const edm::ParameterSet& parset) + : parset_(parset), OurMuonsToken_(consumes(parset.getParameter("me0MuonTag"))) { + produces(); +} + +void ME0MuonTrackCollProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace reco; + using namespace edm; + Handle OurMuons; + iEvent.getByToken(OurMuonsToken_, OurMuons); + + std::unique_ptr selectedTracks(new reco::TrackCollection); + + reco::TrackRefProd rTracks = iEvent.getRefBeforePut(); + + for (std::vector::const_iterator thismuon = OurMuons->begin(); thismuon != OurMuons->end(); + ++thismuon) { + if (!muon::me0::isGoodMuon(*thismuon, muon::me0::Tight)) + continue; + reco::TrackRef trackref; + + if (thismuon->innerTrack().isNonnull()) + trackref = thismuon->innerTrack(); + + const reco::Track* trk = &(*trackref); + selectedTracks->push_back(*trk); + } + iEvent.put(std::move(selectedTracks)); +} diff --git a/RecoMuon/MuonIdentification/python/me0Associator.py b/RecoMuon/MuonIdentification/python/me0Associator.py new file mode 100644 index 0000000000000..1b873a5c41a94 --- /dev/null +++ b/RecoMuon/MuonIdentification/python/me0Associator.py @@ -0,0 +1,11 @@ +import FWCore.ParameterSet.Config as cms + + +#----------ME0Muon Collection Production for association by chi2 +me0muon = cms.EDProducer("ME0MuonTrackCollProducer", + me0MuonTag = cms.InputTag("me0SegmentMatching"), + ) +#-------------------- +me0muonColl_seq = cms.Sequence( + me0muon + ) diff --git a/RecoMuon/MuonIdentification/test/testME0MuonAnalyzer_Example.py b/RecoMuon/MuonIdentification/test/testME0MuonAnalyzer_Example.py index f93bb5bccfff0..711c91d6afd3e 100644 --- a/RecoMuon/MuonIdentification/test/testME0MuonAnalyzer_Example.py +++ b/RecoMuon/MuonIdentification/test/testME0MuonAnalyzer_Example.py @@ -56,7 +56,7 @@ ) -from CommonTools.RecoAlgos.me0Associator import * +from RecoMuon.MuonIdentification.me0Associator import * #process.me0MuonSel = cms.Sequence( # me0muonColl_seq From 20831bd833844019696466ef638ebafa1ba1a91e Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 9 Sep 2020 15:11:10 +0200 Subject: [PATCH 4/4] Move ME0MuonTrackCollProducer in RecoMuon/MuonIdentification --- .../plugins/ME0MuonTrackCollProducer.cc | 59 ------------------- CommonTools/RecoAlgos/python/me0Associator.py | 11 ---- 2 files changed, 70 deletions(-) delete mode 100644 CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc delete mode 100644 CommonTools/RecoAlgos/python/me0Associator.py diff --git a/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc b/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc deleted file mode 100644 index 5ae12a0664a83..0000000000000 --- a/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc +++ /dev/null @@ -1,59 +0,0 @@ - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/MuonReco/interface/ME0Muon.h" -#include "DataFormats/MuonReco/interface/ME0MuonCollection.h" -#include "DataFormats/TrackReco/interface/Track.h" -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "RecoMuon/MuonIdentification/interface/ME0MuonSelector.h" - -#include - -class ME0MuonTrackCollProducer : public edm::stream::EDProducer<> { -public: - explicit ME0MuonTrackCollProducer(const edm::ParameterSet&); - ~ME0MuonTrackCollProducer() override = default; - -private: - void produce(edm::Event&, const edm::EventSetup&) override; - const edm::ParameterSet parset_; - edm::EDGetTokenT OurMuonsToken_; -}; - -#include "FWCore/PluginManager/interface/ModuleDef.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(ME0MuonTrackCollProducer); - -ME0MuonTrackCollProducer::ME0MuonTrackCollProducer(const edm::ParameterSet& parset) - : parset_(parset), OurMuonsToken_(consumes(parset.getParameter("me0MuonTag"))) { - produces(); -} - -void ME0MuonTrackCollProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { - using namespace reco; - using namespace edm; - Handle OurMuons; - iEvent.getByToken(OurMuonsToken_, OurMuons); - - std::unique_ptr selectedTracks(new reco::TrackCollection); - - reco::TrackRefProd rTracks = iEvent.getRefBeforePut(); - - for (std::vector::const_iterator thismuon = OurMuons->begin(); thismuon != OurMuons->end(); - ++thismuon) { - if (!muon::me0::isGoodMuon(*thismuon, muon::me0::Tight)) - continue; - reco::TrackRef trackref; - - if (thismuon->innerTrack().isNonnull()) - trackref = thismuon->innerTrack(); - - const reco::Track* trk = &(*trackref); - selectedTracks->push_back(*trk); - } - iEvent.put(std::move(selectedTracks)); -} diff --git a/CommonTools/RecoAlgos/python/me0Associator.py b/CommonTools/RecoAlgos/python/me0Associator.py deleted file mode 100644 index 1b873a5c41a94..0000000000000 --- a/CommonTools/RecoAlgos/python/me0Associator.py +++ /dev/null @@ -1,11 +0,0 @@ -import FWCore.ParameterSet.Config as cms - - -#----------ME0Muon Collection Production for association by chi2 -me0muon = cms.EDProducer("ME0MuonTrackCollProducer", - me0MuonTag = cms.InputTag("me0SegmentMatching"), - ) -#-------------------- -me0muonColl_seq = cms.Sequence( - me0muon - )