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

PFProducer fix for PFMuonAlgo's fillPSetDescription #30936

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
22 changes: 22 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,32 @@ def customiseFor2017DtUnpacking(process):

return process

def customiseFor30936(process):
"""PFProducer fix for PFMuonAlgo's fillPSetDescription"""

for producer in producers_by_type(process, "PFProducer"):
del producer.PFMuonAlgoParameters
# The parameters should be populated automatically via fillPSetDescription

# for PFBlockProducer
for producer in producers_by_type(process, "PFBlockProducer"):
if hasattr(producer,'elementImporters'):
for ps in producer.elementImporters.value():
if hasattr(ps,'importerName') and (ps.importerName == 'GeneralTracksImporter'):
if not hasattr(ps,'muonMaxDPtOPt'):
ps.muonMaxDPtOPt = cms.double(1) # <== to be added
if not hasattr(ps,'trackQuality'):
ps.trackQuality = cms.string("highPurity") # <== to be added
if not hasattr(ps,'cleanBadConvertedBrems'):
ps.cleanBadConvertedBrems = cms.bool(False) # <== to be added

return process

# CMSSW version specific customizations
def customizeHLTforCMSSW(process, menuType="GRun"):

# add call to action function in proper order: newest last!
# process = customiseFor12718(process)
process = customiseFor30936(process)

return process
5 changes: 4 additions & 1 deletion RecoHI/Configuration/python/Reconstruction_hiPF_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@
cms.PSet( importerName = cms.string("GeneralTracksImporter"),
source = cms.InputTag("pfTrack"),
muonSrc = cms.InputTag("hiMuons1stStep"),
trackQuality = cms.string("highPurity"),
cleanBadConvertedBrems = cms.bool(False),
useIterativeTracking = cms.bool(False),
DPtOverPtCuts_byTrackAlgo = cms.vdouble(-1.0,-1.0,-1.0,
1.0,1.0),
NHitCuts_byTrackAlgo = cms.vuint32(3,3,3,3,3)
NHitCuts_byTrackAlgo = cms.vuint32(3,3,3,3,3),
muonMaxDPtOPt = cms.double(1)
),
# to properly set SC based links you need to run ECAL importer
# after you've imported all SCs to the block
Expand Down
15 changes: 6 additions & 9 deletions RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PFMuonAlgo {
static void printMuonProperties(const reco::MuonRef& muonRef);

////POST CLEANING AND MOMEMNTUM ASSIGNMENT
bool hasValidTrack(const reco::MuonRef& muonRef, bool loose = false);
static bool hasValidTrack(const reco::MuonRef& muonRef, bool loose, double maxDPtOPt);

//Make a PF Muon : Basic method
bool reconstructMuon(reco::PFCandidate&, const reco::MuonRef&, bool allowLoose = false);
Expand Down Expand Up @@ -76,17 +76,14 @@ class PFMuonAlgo {
return std::move(pfAddedMuonCandidates_);
}

static std::vector<reco::Muon::MuonTrackTypePair> muonTracks(const reco::MuonRef& muon,
double maxDPtOPt = 1e+9,
bool includeSA = false);

private:
//Gives the track with the smallest Dpt/Pt
//Give the track with the smallest Dpt/Pt
MuonTrackTypePair getTrackWithSmallestError(const std::vector<MuonTrackTypePair>&);

std::vector<reco::Muon::MuonTrackTypePair> muonTracks(const reco::MuonRef& muon,
bool includeSA = false,
double dpt = 1e+9);

//Gets the good tracks
std::vector<reco::Muon::MuonTrackTypePair> goodMuonTracks(const reco::MuonRef& muon, bool includeSA = false);

//Estimate MET and SUmET for post cleaning
void estimateEventQuantities(const reco::PFCandidateCollection*);

Expand Down
19 changes: 9 additions & 10 deletions RecoParticleFlow/PFProducer/plugins/PFProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ PFProducer::PFProducer(const edm::ParameterSet& iConfig)

// Reading new EGamma selection cuts
bool useProtectionsForJetMET(false);

// Reading new EGamma ubiased collections and value maps
if (use_EGammaFilters_) {
inputTagPFEGammaCandidates_ =
Expand All @@ -153,8 +154,15 @@ PFProducer::PFProducer(const edm::ParameterSet& iConfig)
inputTagValueMapGedPhotons_ =
consumes<edm::ValueMap<reco::PhotonRef>>(iConfig.getParameter<edm::InputTag>("GedPhotonValueMap"));
useProtectionsForJetMET = iConfig.getParameter<bool>("useProtectionsForJetMET");

const edm::ParameterSet pfEGammaFiltersParams =
iConfig.getParameter<edm::ParameterSet>("PFEGammaFiltersParameters");
pfegamma_ = std::make_unique<PFEGammaFilters>(pfEGammaFiltersParams);
}

// EGamma filters
pfAlgo_.setEGammaParameters(use_EGammaFilters_, useProtectionsForJetMET);

//Secondary tracks and displaced vertices parameters

bool rejectTracks_Bad = iConfig.getParameter<bool>("rejectTracks_Bad");
Expand All @@ -174,15 +182,6 @@ PFProducer::PFProducer(const edm::ParameterSet& iConfig)
if (useCalibrationsFromDB_)
calibrationsLabel_ = iConfig.getParameter<std::string>("calibrationsLabel");

// EGamma filters
pfAlgo_.setEGammaParameters(use_EGammaFilters_, useProtectionsForJetMET);

if (use_EGammaFilters_) {
const edm::ParameterSet pfEGammaFiltersParams =
iConfig.getParameter<edm::ParameterSet>("PFEGammaFiltersParameters");
pfegamma_ = std::make_unique<PFEGammaFilters>(pfEGammaFiltersParams);
}

// Secondary tracks and displaced vertices parameters
pfAlgo_.setDisplacedVerticesParameters(
rejectTracks_Bad, rejectTracks_Step45, usePFNuclearInteractions, usePFConversions, usePFDecays, dptRel_DispVtx);
Expand Down Expand Up @@ -349,7 +348,7 @@ void PFProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions)

// For PFMuonAlgo
edm::ParameterSetDescription psd_PFMuonAlgo;
PFEGammaFilters::fillPSetDescription(psd_PFMuonAlgo);
PFMuonAlgo::fillPSetDescription(psd_PFMuonAlgo);
desc.add<edm::ParameterSetDescription>("PFMuonAlgoParameters", psd_PFMuonAlgo);

// Input displaced vertices
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#include <memory>

#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "RecoParticleFlow/PFProducer/interface/BlockElementImporterBase.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecTrack.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "RecoParticleFlow/PFProducer/interface/BlockElementImporterBase.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h"
#include "RecoParticleFlow/PFTracking/interface/PFTrackAlgoTools.h"

Expand All @@ -16,18 +14,12 @@ class GeneralTracksImporter : public BlockElementImporterBase {
: BlockElementImporterBase(conf, sumes),
src_(sumes.consumes<reco::PFRecTrackCollection>(conf.getParameter<edm::InputTag>("source"))),
muons_(sumes.consumes<reco::MuonCollection>(conf.getParameter<edm::InputTag>("muonSrc"))),
trackQuality_((conf.existsAs<std::string>("trackQuality"))
? reco::TrackBase::qualityByName(conf.getParameter<std::string>("trackQuality"))
: reco::TrackBase::highPurity),
trackQuality_(reco::TrackBase::qualityByName(conf.getParameter<std::string>("trackQuality"))),
DPtovPtCut_(conf.getParameter<std::vector<double> >("DPtOverPtCuts_byTrackAlgo")),
NHitCut_(conf.getParameter<std::vector<unsigned> >("NHitCuts_byTrackAlgo")),
useIterTracking_(conf.getParameter<bool>("useIterativeTracking")),
cleanBadConvBrems_(
conf.existsAs<bool>("cleanBadConvertedBrems") ? conf.getParameter<bool>("cleanBadConvertedBrems") : false) {
bool postMuonCleaning =
conf.existsAs<bool>("postMuonCleaning") ? conf.getParameter<bool>("postMuonCleaning") : false;
pfmu_ = std::make_unique<PFMuonAlgo>(conf, postMuonCleaning);
}
cleanBadConvBrems_(conf.getParameter<bool>("cleanBadConvertedBrems")),
muonMaxDPtOPt_(conf.getParameter<double>("muonMaxDPtOPt")) {}

void importToBlock(const edm::Event&, ElementList&) const override;

Expand All @@ -40,7 +32,7 @@ class GeneralTracksImporter : public BlockElementImporterBase {
const std::vector<double> DPtovPtCut_;
const std::vector<unsigned> NHitCut_;
const bool useIterTracking_, cleanBadConvBrems_;
std::unique_ptr<PFMuonAlgo> pfmu_;
const double muonMaxDPtOPt_;
};

DEFINE_EDM_PLUGIN(BlockElementImporterFactory, GeneralTracksImporter, "GeneralTracksImporter");
Expand Down Expand Up @@ -117,8 +109,9 @@ void GeneralTracksImporter::importToBlock(const edm::Event& e, BlockElementImpor
bool thisIsAPotentialMuon = false;
if (muId != -1) {
muonref = reco::MuonRef(muons, muId);
thisIsAPotentialMuon = ((pfmu_->hasValidTrack(muonref, true) && PFMuonAlgo::isLooseMuon(muonref)) ||
(pfmu_->hasValidTrack(muonref, false) && PFMuonAlgo::isMuon(muonref)));
thisIsAPotentialMuon =
((PFMuonAlgo::hasValidTrack(muonref, true, muonMaxDPtOPt_) && PFMuonAlgo::isLooseMuon(muonref)) ||
(PFMuonAlgo::hasValidTrack(muonref, false, muonMaxDPtOPt_) && PFMuonAlgo::isMuon(muonref)));
}
if (thisIsAPotentialMuon || PFTrackAlgoTools::goodPtResolution(
pftrackref->trackRef(), DPtovPtCut_, NHitCut_, useIterTracking_, trackQuality_)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#include <memory>

#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "RecoParticleFlow/PFProducer/interface/BlockElementImporterBase.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecTrack.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "RecoParticleFlow/PFProducer/interface/BlockElementImporterBase.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h"
#include "RecoParticleFlow/PFTracking/interface/PFTrackAlgoTools.h"

Expand All @@ -17,18 +15,12 @@ class GeneralTracksImporterWithVeto : public BlockElementImporterBase {
src_(sumes.consumes<reco::PFRecTrackCollection>(conf.getParameter<edm::InputTag>("source"))),
veto_(sumes.consumes<reco::PFRecTrackCollection>(conf.getParameter<edm::InputTag>("veto"))),
muons_(sumes.consumes<reco::MuonCollection>(conf.getParameter<edm::InputTag>("muonSrc"))),
trackQuality_((conf.existsAs<std::string>("trackQuality"))
? reco::TrackBase::qualityByName(conf.getParameter<std::string>("trackQuality"))
: reco::TrackBase::highPurity),
trackQuality_(reco::TrackBase::qualityByName(conf.getParameter<std::string>("trackQuality"))),
DPtovPtCut_(conf.getParameter<std::vector<double> >("DPtOverPtCuts_byTrackAlgo")),
NHitCut_(conf.getParameter<std::vector<unsigned> >("NHitCuts_byTrackAlgo")),
useIterTracking_(conf.getParameter<bool>("useIterativeTracking")),
cleanBadConvBrems_(
conf.existsAs<bool>("cleanBadConvertedBrems") ? conf.getParameter<bool>("cleanBadConvertedBrems") : false) {
bool postMuonCleaning =
conf.existsAs<bool>("postMuonCleaning") ? conf.getParameter<bool>("postMuonCleaning") : false;
pfmu_ = std::make_unique<PFMuonAlgo>(conf, postMuonCleaning);
}
cleanBadConvBrems_(conf.getParameter<bool>("cleanBadConvertedBrems")),
muonMaxDPtOPt_(conf.getParameter<double>("muonMaxDPtOPt")) {}

void importToBlock(const edm::Event&, ElementList&) const override;

Expand All @@ -41,8 +33,7 @@ class GeneralTracksImporterWithVeto : public BlockElementImporterBase {
const std::vector<double> DPtovPtCut_;
const std::vector<unsigned> NHitCut_;
const bool useIterTracking_, cleanBadConvBrems_;

std::unique_ptr<PFMuonAlgo> pfmu_;
const double muonMaxDPtOPt_;
};

DEFINE_EDM_PLUGIN(BlockElementImporterFactory, GeneralTracksImporterWithVeto, "GeneralTracksImporterWithVeto");
Expand Down Expand Up @@ -126,8 +117,9 @@ void GeneralTracksImporterWithVeto::importToBlock(const edm::Event& e,
bool thisIsAPotentialMuon = false;
if (muId != -1) {
muonref = reco::MuonRef(muons, muId);
thisIsAPotentialMuon = ((pfmu_->hasValidTrack(muonref, true) && PFMuonAlgo::isLooseMuon(muonref)) ||
(pfmu_->hasValidTrack(muonref, false) && PFMuonAlgo::isMuon(muonref)));
thisIsAPotentialMuon =
((PFMuonAlgo::hasValidTrack(muonref, true, muonMaxDPtOPt_) && PFMuonAlgo::isLooseMuon(muonref)) ||
(PFMuonAlgo::hasValidTrack(muonref, false, muonMaxDPtOPt_) && PFMuonAlgo::isMuon(muonref)));
}
if (thisIsAPotentialMuon || PFTrackAlgoTools::goodPtResolution(
pftrackref->trackRef(), DPtovPtCut_, NHitCut_, useIterTracking_, trackQuality_)) {
Expand Down
3 changes: 2 additions & 1 deletion RecoParticleFlow/PFProducer/python/particleFlowBlock_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
useIterativeTracking = cms.bool(True),
DPtOverPtCuts_byTrackAlgo = cms.vdouble(10.0,10.0,10.0,
10.0,10.0,5.0),
NHitCuts_byTrackAlgo = cms.vuint32(3,3,3,3,3,3)
NHitCuts_byTrackAlgo = cms.vuint32(3,3,3,3,3,3),
muonMaxDPtOPt = cms.double(1)
),
# secondary GSF tracks are also turned off
#cms.PSet( importerName = cms.string("GSFTrackImporter"),
Expand Down
Loading