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

Adding PUPPI jets and METs to offline DQM - backport to 14_0_X #44752

Merged
merged 2 commits into from
Apr 24, 2024
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
3 changes: 3 additions & 0 deletions DQMOffline/JetMET/interface/JetAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ class JetAnalyzer : public DQMEDAnalyzer {
edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> gtToken_;
edm::EDGetTokenT<reco::CaloJetCollection> caloJetsToken_;
edm::EDGetTokenT<reco::PFJetCollection> pfJetsToken_;
edm::EDGetTokenT<reco::PFJetCollection> puppiJetsToken_;

edm::EDGetTokenT<reco::PFMETCollection> pfMetToken_;
edm::EDGetTokenT<reco::CaloMETCollection> caloMetToken_;
edm::EDGetTokenT<pat::METCollection> patMetToken_;
edm::EDGetTokenT<reco::PFMETCollection> puppiMetToken_;

edm::EDGetTokenT<reco::MuonCollection> MuonsToken_;
edm::EDGetTokenT<pat::JetCollection> patJetsToken_;
Expand Down Expand Up @@ -786,6 +788,7 @@ class JetAnalyzer : public DQMEDAnalyzer {
bool isCaloJet_;
bool isPFJet_;
bool isMiniAODJet_;
bool isPUPPIJet_;

bool fill_jet_high_level_histo;

Expand Down
6 changes: 6 additions & 0 deletions DQMOffline/JetMET/python/jetAnalyzer_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
*jetDQMAnalyzerAk4PFCHSCleaned
)

_jetDQMAnalyzerSequenceWithPUPPI = cms.Sequence(jetDQMAnalyzerAk4CaloCleaned
*jetDQMAnalyzerAk4PFUncleaned*jetDQMAnalyzerAk4PFCleaned
*jetDQMAnalyzerAk4PFCHSCleaned*jetDQMAnalizerAk4PUPPICleaned
)

jetDQMAnalyzerSequenceCosmics = cms.Sequence(jetDQMAnalyzerAk4CaloUncleaned)

jetDQMAnalyzerSequenceMiniAOD = cms.Sequence(jetDQMAnalyzerAk4PFCHSUncleanedMiniAOD*jetDQMAnalyzerAk4PFCHSCleanedMiniAOD*jetDQMAnalyzerAk8PFPUPPICleanedMiniAOD*jetDQMAnalyzerAk4PFCHSPuppiCleanedMiniAOD)
Expand Down Expand Up @@ -37,6 +42,7 @@
* jetDQMAnalyzerAkCs4PF
)
from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
(~pp_on_AA).toReplaceWith(jetDQMAnalyzerSequence, _jetDQMAnalyzerSequenceWithPUPPI)
pp_on_AA.toReplaceWith( jetDQMAnalyzerSequence, _jetDQMAnalyzerSequenceHI )
pp_on_AA.toModify( jetDQMAnalyzerAkPU4Calo, srcVtx = cms.untracked.InputTag("offlinePrimaryVertices") )
pp_on_AA.toModify( jetDQMAnalyzerAkPU3PF, srcVtx = cms.untracked.InputTag("offlinePrimaryVertices") )
Expand Down
10 changes: 10 additions & 0 deletions DQMOffline/JetMET/python/jetAnalyzer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@
fillCHShistos = True
)

jetDQMAnalizerAk4PUPPICleaned=jetDQMAnalyzerAk4PFCleaned.clone(
JetType = cms.string('puppi'),
jetsrc = "ak4PFJetsPuppi",
METCollectionLabel = "pfMetPuppi",
JetCorrections = "ak4PFPuppiL1FastL2L3ResidualCorrector",
JetIDVersion = "RUN2ULPUPPI",
JetIDQuality = cms.string("TIGHT"),
fillCHShistos = True,
)

jetDQMAnalyzerAk4PFCHSUncleanedMiniAOD=jetDQMAnalyzerAk4PFUncleaned.clone(
filljetHighLevel = True,
CleaningParameters = cleaningParameters.clone(
Expand Down
57 changes: 56 additions & 1 deletion DQMOffline/JetMET/python/jetMETDQMOfflineSource_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@
inputIsCorrected = False
)

pileupJetIdCalculatorPUPPIDQM=pileupJetIdCalculator.clone(
jets = "ak4PFJetsPuppi",
jec = "AK4PFPuppi",
applyJec = True,
inputIsCorrected = False
)

pileupJetIdEvaluatorPUPPIDQM=pileupJetIdEvaluator.clone(
jets = "ak4PFJetsPuppi",
jetids = "pileupJetIdCalculatorPUPPIDQM",
jec = "AK4PFPuppi",
applyJec = True,
inputIsCorrected = False
)

from JetMETCorrections.Configuration.JetCorrectors_cff import ak4CaloL2L3ResidualCorrectorChain,ak4CaloL2L3ResidualCorrector,ak4CaloResidualCorrector,ak4CaloL2L3Corrector,ak4CaloL3AbsoluteCorrector,ak4CaloL2RelativeCorrector

dqmAk4CaloL2L3ResidualCorrector = ak4CaloL2L3ResidualCorrector.clone()
Expand Down Expand Up @@ -77,6 +92,13 @@
dqmAk4PFCHSL1FastL2L3Corrector
)

from JetMETCorrections.Configuration.JetCorrectors_cff import ak4PFPuppiL1FastL2L3ResidualCorrectorChain,ak4PFPuppiL1FastL2L3ResidualCorrector,ak4PFPuppiL1FastL2L3Corrector,ak4PFPuppiResidualCorrector,ak4PFPuppiL3AbsoluteCorrector,ak4PFPuppiL2RelativeCorrector,ak4PFPuppiL1FastjetCorrector

dqmAk4PFPuppiL1FastL2L3ResidualCorrector = ak4PFPuppiL1FastL2L3ResidualCorrector.clone()
dqmAk4PFPuppiL1FastL2L3ResidualCorrectorChain = cms.Sequence(
dqmAk4PFPuppiL1FastL2L3ResidualCorrector
)

HBHENoiseFilterResultProducerDQM=HBHENoiseFilterResultProducer.clone()

jetPreDQMTask = cms.Task(ak4CaloL2RelativeCorrector,
Expand All @@ -89,9 +111,27 @@
ak4PFCHSL1FastjetCorrector,
ak4PFCHSL2RelativeCorrector,
ak4PFCHSL3AbsoluteCorrector,
ak4PFCHSResidualCorrector
ak4PFCHSResidualCorrector,
)

_jetPreDQMTaskWithPUPPI = cms.Task(ak4CaloL2RelativeCorrector,
ak4CaloL3AbsoluteCorrector,
ak4CaloResidualCorrector,
ak4PFL1FastjetCorrector,
ak4PFL2RelativeCorrector,
ak4PFL3AbsoluteCorrector,
ak4PFResidualCorrector,
ak4PFCHSL1FastjetCorrector,
ak4PFCHSL2RelativeCorrector,
ak4PFCHSL3AbsoluteCorrector,
ak4PFCHSResidualCorrector,
ak4PFPuppiL1FastjetCorrector,
ak4PFPuppiL2RelativeCorrector,
ak4PFPuppiL3AbsoluteCorrector,
ak4PFPuppiResidualCorrector,
)
jetPreDQMSeq=cms.Sequence(jetPreDQMTask)
_jetPreDQMSeqWithPUPPI=cms.Sequence(_jetPreDQMTaskWithPUPPI)

from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1
from JetMETCorrections.Type1MET.correctionTermsPfMetType0PFCandidate_cff import *
Expand All @@ -115,6 +155,21 @@
*METDQMAnalyzerSequence
*pfCandidateDQMAnalyzer)

_jetMETDQMOfflineSourceWithPUPPI = cms.Sequence(AnalyzeSUSYDQM*QGTagger*
pileupJetIdCalculatorCHSDQM*pileupJetIdEvaluatorCHSDQM*
pileupJetIdCalculatorDQM*pileupJetIdEvaluatorDQM*
pileupJetIdCalculatorPUPPIDQM*pileupJetIdEvaluatorPUPPIDQM*
_jetPreDQMSeqWithPUPPI*
dqmAk4CaloL2L3ResidualCorrectorChain*dqmAk4PFL1FastL2L3ResidualCorrectorChain*dqmAk4PFCHSL1FastL2L3ResidualCorrectorChain*dqmAk4PFCHSL1FastL2L3CorrectorChain*dqmAk4PFPuppiL1FastL2L3ResidualCorrectorChain*
cms.ignore(goodOfflinePrimaryVerticesDQM)*
dqmCorrPfMetType1*pfMETT1*jetDQMAnalyzerSequence*HBHENoiseFilterResultProducer*
cms.ignore(CSCTightHaloFilterDQM)*cms.ignore(CSCTightHalo2015FilterDQM)*cms.ignore(eeBadScFilterDQM)*cms.ignore(EcalDeadCellTriggerPrimitiveFilterDQM)*cms.ignore(EcalDeadCellBoundaryEnergyFilterDQM)*cms.ignore(HcalStripHaloFilterDQM)
*METDQMAnalyzerSequence
*pfCandidateDQMAnalyzer)

from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
(~pp_on_AA).toReplaceWith(jetMETDQMOfflineSource, _jetMETDQMOfflineSourceWithPUPPI)

from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel

jetMETDQMOfflineRedoProductsMiniAOD = cms.Sequence(cms.ignore(goodOfflinePrimaryVerticesDQMforMiniAOD))
Expand Down
5 changes: 5 additions & 0 deletions DQMOffline/JetMET/python/metDQMConfig_cff.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import FWCore.ParameterSet.Config as cms
from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA

from DQMOffline.JetMET.metDQMConfig_cfi import *

#correction for type 1 done in JetMETDQMOfflineSource now
METDQMAnalyzerSequence = cms.Sequence(caloMetDQMAnalyzer*pfMetDQMAnalyzer*pfChMetDQMAnalyzer*pfMetT1DQMAnalyzer)

_METDQMAnalyzerSequenceWithPUPPI = cms.Sequence(caloMetDQMAnalyzer*pfMetDQMAnalyzer*pfChMetDQMAnalyzer*pfMetT1DQMAnalyzer*pfMetPUPPIDQMAnalyzer)

METDQMAnalyzerSequenceMiniAOD = cms.Sequence(pfMetDQMAnalyzerMiniAOD*pfPuppiMetDQMAnalyzerMiniAOD)

METDQMAnalyzerSequenceCosmics = cms.Sequence(caloMetDQMAnalyzer)

METDQMAnalyzerSequenceHI = cms.Sequence(caloMetDQMAnalyzer*pfMetDQMAnalyzer)

(~pp_on_AA).toReplaceWith(METDQMAnalyzerSequence, _METDQMAnalyzerSequenceWithPUPPI)
6 changes: 6 additions & 0 deletions DQMOffline/JetMET/python/metDQMConfig_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@
Filter = True
),
)
pfMetPUPPIDQMAnalyzer = pfMetDQMAnalyzer.clone(
METType = 'pf',
METCollectionLabel = "pfMetPuppi",
JetCollectionLabel = "ak4PFJetsPuppi",
JetCorrections = "dqmAk4PuppiL2L3ResidualCorrector",
)
pfMetDQMAnalyzerMiniAOD = pfMetDQMAnalyzer.clone(
fillMetHighLevel = True,#fills only lumisec plots
fillCandidateMaps = False,
Expand Down
80 changes: 77 additions & 3 deletions DQMOffline/JetMET/src/JetAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ JetAnalyzer::JetAnalyzer(const edm::ParameterSet& pSet)
isCaloJet_ = (std::string("calo") == jetType_);
//isJPTJet_ = (std::string("jpt") ==jetType_);
isPFJet_ = (std::string("pf") == jetType_);
isPUPPIJet_ = (std::string("puppi") == jetType_);
isMiniAODJet_ = (std::string("miniaod") == jetType_);
jetCorrectorTag_ = pSet.getParameter<edm::InputTag>("JetCorrections");
if (!isMiniAODJet_) { //in MiniAOD jet is already corrected
Expand All @@ -98,6 +99,12 @@ JetAnalyzer::JetAnalyzer(const edm::ParameterSet& pSet)
pfMetToken_ =
consumes<reco::PFMETCollection>(edm::InputTag(pSet.getParameter<edm::InputTag>("METCollectionLabel")));
}
if (isPUPPIJet_) {
puppiJetsToken_ = consumes<reco::PFJetCollection>(mInputCollection_);
MuonsToken_ = consumes<reco::MuonCollection>(pSet.getParameter<edm::InputTag>("muonsrc"));
puppiMetToken_ =
consumes<reco::PFMETCollection>(edm::InputTag(pSet.getParameter<edm::InputTag>("METCollectionLabel")));
}
if (isMiniAODJet_) {
patJetsToken_ = consumes<pat::JetCollection>(mInputCollection_);
patMetToken_ = consumes<pat::METCollection>(edm::InputTag(pSet.getParameter<edm::InputTag>("METCollectionLabel")));
Expand Down Expand Up @@ -149,7 +156,7 @@ JetAnalyzer::JetAnalyzer(const edm::ParameterSet& pSet)
}

//Jet ID definitions for PFJets
if (isPFJet_ || isMiniAODJet_) {
if (isPFJet_ || isMiniAODJet_ || isPUPPIJet_) {
if (JetIDVersion_ == "FIRSTDATA") {
pfjetidversion = PFJetIDSelectionFunctor::FIRSTDATA;
} else if (JetIDVersion_ == "RUNIISTARTUP") {
Expand Down Expand Up @@ -283,11 +290,12 @@ void JetAnalyzer::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRu
DirName = "JetMET/Jet/Uncleaned" + mInputCollection_.label();
}

jetME = ibooker.book1D("jetReco", "jetReco", 4, 1, 5);
jetME = ibooker.book1D("jetReco", "jetReco", 5, 1, 5);
jetME->setBinLabel(1, "CaloJets", 1);
jetME->setBinLabel(2, "PFJets", 1);
jetME->setBinLabel(3, "JPTJets", 1);
jetME->setBinLabel(4, "MiniAODJets", 1);
jetME->setBinLabel(5, "PUPPIJets", 1);

map_of_MEs.insert(std::pair<std::string, MonitorElement*>(DirName + "/" + "jetReco", jetME));

Expand Down Expand Up @@ -870,7 +878,7 @@ void JetAnalyzer::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRu
mMuMultiplicity_highPt_Barrel));
}
//
if (isMiniAODJet_ || isPFJet_) {
if (isMiniAODJet_ || isPFJet_ || isPUPPIJet_) {
if (!filljetsubstruc_) { //not available for ak8 -> so just take out
mMVAPUJIDDiscriminant_lowPt_Barrel =
ibooker.book1D("MVAPUJIDDiscriminant_lowPt_Barrel", "MVAPUJIDDiscriminant_lowPt_Barrel", 50, -1.00, 1.00);
Expand Down Expand Up @@ -2394,6 +2402,7 @@ void JetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu
edm::Handle<JPTJetCollection> jptJets;
edm::Handle<PFJetCollection> pfJets;
edm::Handle<pat::JetCollection> patJets;
edm::Handle<PFJetCollection> puppiJets;

edm::Handle<MuonCollection> Muons;

Expand Down Expand Up @@ -2464,6 +2473,63 @@ void JetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu
}
}
}
if (isPUPPIJet_) {
iEvent.getByToken(puppiJetsToken_, puppiJets);
double pt0 = -1;
double pt1 = -1;
//fill it only for cleaned jets
if (jetCleaningFlag_ && Muons.isValid() && Muons->size() > 1) {
for (unsigned int i = 0; i < Muons->size(); i++) {
bool pass_muon_id = false;
bool pass_muon_iso = false;
double dxy = fabs((*Muons)[i].muonBestTrack()->dxy());
double dz = fabs((*Muons)[i].muonBestTrack()->dz());
if (numPV > 0) {
dxy = fabs((*Muons)[i].muonBestTrack()->dxy((*vertexHandle)[0].position()));
dz = fabs((*Muons)[i].muonBestTrack()->dz((*vertexHandle)[0].position()));
}
if ((*Muons)[i].pt() > 20 && fabs((*Muons)[i].eta()) < 2.3) {
if ((*Muons)[i].isGlobalMuon() && (*Muons)[i].isPFMuon() &&
(*Muons)[i].globalTrack()->hitPattern().numberOfValidMuonHits() > 0 &&
(*Muons)[i].numberOfMatchedStations() > 1 && dxy < 0.2 && (*Muons)[i].numberOfMatchedStations() > 1 &&
dz < 0.5 && (*Muons)[i].innerTrack()->hitPattern().numberOfValidPixelHits() > 0 &&
(*Muons)[i].innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5) {
pass_muon_id = true;
}
// Muon pf isolation DB corrected
float muonIsoPFdb =
((*Muons)[i].pfIsolationR04().sumChargedHadronPt +
std::max(0.,
(*Muons)[i].pfIsolationR04().sumNeutralHadronEt + (*Muons)[i].pfIsolationR04().sumPhotonEt -
0.5 * (*Muons)[i].pfIsolationR04().sumPUPt)) /
(*Muons)[i].pt();
if (muonIsoPFdb < 0.12) {
pass_muon_iso = true;
}

if (pass_muon_id && pass_muon_iso) {
if ((*Muons)[i].pt() > pt0) {
mu_index1 = mu_index0;
pt1 = pt0;
mu_index0 = i;
pt0 = (*Muons)[i].pt();
} else if ((*Muons)[i].pt() > pt1) {
mu_index1 = i;
pt1 = (*Muons)[i].pt();
}
}
}
}
if (mu_index0 >= 0 && mu_index1 >= 0) {
if ((*Muons)[mu_index0].charge() * (*Muons)[mu_index1].charge() < 0) {
zCand = (*Muons)[mu_index0].polarP4() + (*Muons)[mu_index1].polarP4();
if (fabs(zCand.M() - 91.) < 20 && zCand.Pt() > 30) {
pass_Z_selection = true;
}
}
}
}
}
if (isMiniAODJet_)
iEvent.getByToken(patJetsToken_, patJets);

Expand All @@ -2482,6 +2548,8 @@ void JetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu
//if (isJPTJet_) jetCollectionIsValid = jptJets.isValid();
if (isPFJet_)
jetCollectionIsValid = pfJets.isValid();
if (isPUPPIJet_)
jetCollectionIsValid = puppiJets.isValid();
if (isMiniAODJet_)
jetCollectionIsValid = patJets.isValid();

Expand All @@ -2503,6 +2571,9 @@ void JetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu
collSize = pfJets->size();
if (isMiniAODJet_)
collSize = patJets->size();
if (isPUPPIJet_) {
collSize = puppiJets->size();
}

double scale = -1;
//now start changes for jets
Expand Down Expand Up @@ -2560,6 +2631,9 @@ void JetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu
if (isPFJet_) {
correctedJet = (*pfJets)[ijet];
}
if (isPUPPIJet_) {
correctedJet = (*puppiJets)[ijet];
}
if (isMiniAODJet_) {
correctedJet = (*patJets)[ijet];
}
Expand Down