Skip to content

Commit

Permalink
Merge pull request #41903 from andrea21z/updateMVAIDmodel
Browse files Browse the repository at this point in the history
Update Muon MVA ID model and working points in MiniAOD and NanoAOD
  • Loading branch information
cmsbuild authored Jul 11, 2023
2 parents cea8d15 + 4443ff6 commit 546d4a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion PhysicsTools/NanoAOD/python/muons_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
inputTensorName= cms.string("float_input"),
outputNames = cms.vstring(["probGOOD", "wpMedium", "wpTight"]),
batch_eval =cms.bool(True),
outputFormulas = cms.vstring(["at(1)", "? at(1) > 0.14 ? 1 : 0", "? at(1) > 0.35 ? 1 : 0"]),
outputFormulas = cms.vstring(["at(1)", "? at(1) > 0.08 ? 1 : 0", "? at(1) > 0.20 ? 1 : 0"]),
variablesOrder = cms.vstring(["LepGood_global_muon","LepGood_validFraction","Muon_norm_chi2_extended","LepGood_local_chi2","LepGood_kink","LepGood_segmentComp","Muon_n_Valid_hits_extended","LepGood_n_MatchedStations","LepGood_Valid_pixel","LepGood_tracker_layers","LepGood_pt","LepGood_eta"]),
variables = cms.PSet(
LepGood_global_muon = cms.string("isGlobalMuon"),
Expand Down
16 changes: 9 additions & 7 deletions PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ namespace pat {
std::vector<double> effectiveAreaVec_;
std::vector<double> miniIsoParams_;
double relMiniIsoPUCorrected_;

/// working points of the muon MVA ID
double mvaIDtightCut_;
double mvaIDmediumCut_;
/// embed the track from best muon measurement (global pflow)
bool embedBestTrack_;
/// embed the track from best muon measurement (muon only)
Expand Down Expand Up @@ -347,6 +349,10 @@ PATMuonProducer::PATMuonProducer(const edm::ParameterSet& iConfig, PATMuonHeavyO
geometryToken_{esConsumes()},
transientTrackBuilderToken_{esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))},
patMuonPutToken_{produces<std::vector<Muon>>()} {
// Muon MVA ID wps
mvaIDmediumCut_ = iConfig.getParameter<double>("mvaIDwpMedium");
mvaIDtightCut_ = iConfig.getParameter<double>("mvaIDwpTight");

// input source
muonToken_ = consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("muonSource"));
// embedding of tracks
Expand Down Expand Up @@ -990,19 +996,15 @@ void PATMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
// MVA ID
float mvaID = 0.0;
constexpr int MVAsentinelValue = -99;
constexpr float mvaIDmediumCut = 0.08;
constexpr float mvaIDtightCut = 0.12;
if (computeMuonIDMVA_) {
const double dz = std::abs(muon.muonBestTrack()->dz(primaryVertex.position()));
const double dxy = std::abs(muon.muonBestTrack()->dxy(primaryVertex.position()));
if (muon.isLooseMuon()) {
mvaID = globalCache()->muonMvaIDEstimator().computeMVAID(muon)[1];
} else {
mvaID = MVAsentinelValue;
}
muon.setMvaIDValue(mvaID);
muon.setSelector(reco::Muon::MvaIDwpMedium, muon.mvaIDValue() > mvaIDmediumCut);
muon.setSelector(reco::Muon::MvaIDwpTight, muon.mvaIDValue() > mvaIDtightCut and dz < 0.5 and dxy < 0.2);
muon.setSelector(reco::Muon::MvaIDwpMedium, muon.mvaIDValue() > mvaIDmediumCut_);
muon.setSelector(reco::Muon::MvaIDwpTight, muon.mvaIDValue() > mvaIDtightCut_);
}

//SOFT MVA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
# Don't forget to set flags properly in miniAOD_tools.py
computeMuonIDMVA = cms.bool(False),
mvaIDTrainingFile = cms.FileInPath("RecoMuon/MuonIdentification/data/mvaID.onnx"),
mvaIDwpMedium = cms.double(0.08),
mvaIDwpTight = cms.double(0.20),
recomputeBasicSelectors = cms.bool(True),
useJec = cms.bool(True),
mvaDrMax = cms.double(0.4),
Expand Down

0 comments on commit 546d4a7

Please sign in to comment.