From 2622189660721884692c474ccd0c7035ef810a37 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 28 Jun 2017 10:39:01 +0200 Subject: [PATCH] add CSC and configurable selection to only store some segments --- .../PatAlgos/plugins/PATMuonSlimmer.cc | 25 ++++++++++++++----- .../python/slimming/slimmedMuons_cfi.py | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATMuonSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATMuonSlimmer.cc index 9f367cb3e69fb..a91286e6ed295 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMuonSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMuonSlimmer.cc @@ -36,7 +36,8 @@ namespace pat { std::vector> pf_; std::vector>> pf2pc_; const bool linkToPackedPF_; - const StringCutObjectSelector saveTeVMuons_, dropDirectionalIso_, dropPfP4_, slimCaloVars_, slimKinkVars_, slimCaloMETCorr_, slimMatches_; + const StringCutObjectSelector saveTeVMuons_, dropDirectionalIso_, dropPfP4_, slimCaloVars_, + slimKinkVars_, slimCaloMETCorr_, slimMatches_,segmentsMuonSelection_; const bool saveSegments_,modifyMuon_; std::unique_ptr > muonModifier_; }; @@ -53,6 +54,7 @@ pat::PATMuonSlimmer::PATMuonSlimmer(const edm::ParameterSet & iConfig) : slimKinkVars_(iConfig.getParameter("slimKinkVars")), slimCaloMETCorr_(iConfig.getParameter("slimCaloMETCorr")), slimMatches_(iConfig.getParameter("slimMatches")), + segmentsMuonSelection_(iConfig.getParameter("segmentsMuonSelection")), saveSegments_(iConfig.getParameter("saveSegments")), modifyMuon_(iConfig.getParameter("modifyMuons")) { @@ -75,7 +77,7 @@ pat::PATMuonSlimmer::PATMuonSlimmer(const edm::ParameterSet & iConfig) : produces >(); if( saveSegments_ ) { produces< DTRecSegment4DCollection >(); - //FIXME do same for CSC + produces< CSCSegmentCollection >(); } } @@ -98,7 +100,8 @@ pat::PATMuonSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup auto outDTSegments = std::make_unique(); std::set dtSegmentsRefs; - //FIXME same for CSC + auto outCSCSegments = std::make_unique(); + std::set cscSegmentsRefs; if( modifyMuon_ ) { muonModifier_->setEvent(iEvent); } @@ -183,9 +186,9 @@ pat::PATMuonSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup smatch.yErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(smatch.yErr); smatch.dXdZErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(smatch.dXdZErr); smatch.dYdZErr = MiniFloatConverter::reduceMantissaToNbitsRounding<12>(smatch.dYdZErr); - if( saveSegments_ ) { + if( saveSegments_ && segmentsMuonSelection_(mu) ) { if(smatch.dtSegmentRef.isNonnull()) dtSegmentsRefs.insert(smatch.dtSegmentRef); - // std::cout << smatch.dtSegmentRef->first << std::endl; + if(smatch.cscSegmentRef.isNonnull()) cscSegmentsRefs.insert(smatch.cscSegmentRef); } } } @@ -195,18 +198,28 @@ pat::PATMuonSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup if( saveSegments_ ) { std::map dtMap; std::vector outDTSegmentsTmp; + std::map cscMap; + std::vector outCSCSegmentsTmp; for(auto & seg : dtSegmentsRefs) { dtMap[seg]=outDTSegments->size(); outDTSegmentsTmp.push_back(*seg); } + for(auto & seg : cscSegmentsRefs) { + cscMap[seg]=outCSCSegments->size(); + outCSCSegmentsTmp.push_back(*seg); + } outDTSegments->put(DTChamberId(),outDTSegmentsTmp.begin(),outDTSegmentsTmp.end()); + outCSCSegments->put(CSCDetId(),outCSCSegmentsTmp.begin(),outCSCSegmentsTmp.end()); auto dtHandle = iEvent.put(std::move(outDTSegments)); + auto cscHandle = iEvent.put(std::move(outCSCSegments)); for( auto & mu : *out) { if(mu.isMatchesValid()) { for (reco::MuonChamberMatch & cmatch : mu.matches()) { for (reco::MuonSegmentMatch & smatch : cmatch.segmentMatches) { if (dtMap.find(smatch.dtSegmentRef) != dtMap.end() ) - smatch.dtSegmentRef=DTRecSegment4DRef(dtHandle,dtMap[smatch.dtSegmentRef]); + smatch.dtSegmentRef=DTRecSegment4DRef(dtHandle,dtMap[smatch.dtSegmentRef]); + if (cscMap.find(smatch.cscSegmentRef) != cscMap.end() ) + smatch.cscSegmentRef=CSCSegmentRef(cscHandle,cscMap[smatch.cscSegmentRef]); } } } diff --git a/PhysicsTools/PatAlgos/python/slimming/slimmedMuons_cfi.py b/PhysicsTools/PatAlgos/python/slimming/slimmedMuons_cfi.py index b52328898e671..291542a799e81 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimmedMuons_cfi.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimmedMuons_cfi.py @@ -12,6 +12,7 @@ slimKinkVars = cms.string("1"), slimCaloMETCorr = cms.string("1"), slimMatches = cms.string("1"), + segmentsMuonSelection = cms.string("pt > 50"), #segments are needed for EXO analysis looking at TOF and for very high pt from e.g. Z' saveSegments = cms.bool(True), modifyMuons = cms.bool(True), modifierConfig = cms.PSet( modifications = cms.VPSet() )