Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Store information needed to evaluate independent JEC uncertainties
Browse files Browse the repository at this point in the history
The main problem is that jets down to 15 GeV need to be stored in order
to propagate variation in JEC into MET. The cut in jet definition is
lowered, which increases the number of stored jets by about a factor of
two in data.

Also store MET with undone T1 correction from jets. This is done using
the actual correction that is applied to stored MET by the standard MET
tool. The resulting MET with undone correction coinsides with the raw
MET in both data and simulation. It is expected in simulation. In data
the real raw PF MET should be different because of the additional
corrections due to spurious muons and ECAL gain switch. But in reality
PATMETSlimmer is configured to store MET with this additional
corrections as the raw MET.
  • Loading branch information
andrey-popov committed Mar 24, 2017
1 parent 2408991 commit 4b78a39
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
41 changes: 33 additions & 8 deletions plugins/PECJetMET.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ PECJetMET::PECJetMET(edm::ParameterSet const &cfg):
for (InputTag const &tag: cfg.getParameter<vector<InputTag>>("contIDMaps"))
contIDMapTokens.emplace_back(consumes<ValueMap<float>>(tag));

for (InputTag const &tag: cfg.getParameter<vector<InputTag>>("metCorrToUndo"))
metCorrectorTokens.emplace_back(consumes<CorrMETData>(tag));


// Currently plugin does not read any information from the ID maps. Throw an exception if any
//are actually given.
Expand All @@ -49,16 +52,18 @@ void PECJetMET::fillDescriptions(edm::ConfigurationDescriptions &descriptions)
{
edm::ParameterSetDescription desc;
desc.add<bool>("runOnData")->
setComment("Indicates whether data or simulation is being processed.");
setComment("Indicates whether data or simulation is being processed.");
desc.add<InputTag>("jets")->setComment("Collection of jets.");
desc.add<vector<string>>("jetSelection", vector<string>(0))->
setComment("User-defined selections for jets whose results will be stored in the output "
"tree.");
desc.add<vector<InputTag>>("contIDMaps", vector<InputTag>(0))->
setComment("Maps with real-valued ID decisions to be stored.");
desc.add<vector<string>>("jetSelection", vector<string>())->
setComment("User-defined selections for jets whose results will be stored in the output "
"tree.");
desc.add<vector<InputTag>>("contIDMaps", vector<InputTag>())->
setComment("Maps with real-valued ID decisions to be stored.");
desc.add<bool>("rawJetMomentaOnly", false)->
setComment("Requests that only raw jet momenta are saved but not their corrections.");
setComment("Requests that only raw jet momenta are saved but not their corrections.");
desc.add<InputTag>("met")->setComment("MET.");
desc.add<vector<InputTag>>("metCorrToUndo", vector<InputTag>())->
setComment("MET corrections to undo for (partly) uncorreted METs.");

descriptions.add("jetMET", desc);
}
Expand Down Expand Up @@ -210,7 +215,7 @@ void PECJetMET::analyze(Event const &event, EventSetup const &)
}


// Loose PF jet ID [1]. Accessors to energy factions take into account JEC, so there is no
// Loose PF jet ID [1]. Accessors to energy fractions take into account JEC, so there is no
//need to undo the corrections.
//[1] https://twiki.cern.ch/twiki/bin/view/CMS/JetID13TeVRun2016?rev=1
bool passPFID = false;
Expand Down Expand Up @@ -257,6 +262,14 @@ void PECJetMET::analyze(Event const &event, EventSetup const &)
event.getByToken(metToken, metHandle);
pat::MET const &met = metHandle->front();


// Read MET correctors that will be used to undo the corrections
vector<Handle<CorrMETData>> metCorrectors(metCorrectorTokens.size());

for (unsigned i = 0; i < metCorrectorTokens.size(); ++i)
event.getByToken(metCorrectorTokens.at(i), metCorrectors.at(i));


storeMETSignificance = met.metSignificance();

storeMETs.clear();
Expand Down Expand Up @@ -303,6 +316,18 @@ void PECJetMET::analyze(Event const &event, EventSetup const &)
storeMET.SetPhi(metUncorrT1.Phi());
storeUncorrMETs.emplace_back(storeMET);

// (Partly) uncorrected MET for each given corrector
for (auto const &metCorrector: metCorrectors)
{
TVector2 const uncorrMET(
met.shiftedPx(pat::MET::NoShift, pat::MET::Type1) - metCorrector->mex,
met.shiftedPy(pat::MET::NoShift, pat::MET::Type1) - metCorrector->mey);
storeMET.Reset();
storeMET.SetPt(uncorrMET.Mod());
storeMET.SetPhi(uncorrMET.Phi());
storeUncorrMETs.emplace_back(storeMET);
}


// Fill the output tree
outTree->Fill();
Expand Down
10 changes: 8 additions & 2 deletions plugins/PECJetMET.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <FWCore/ParameterSet/interface/ConfigurationDescriptions.h>
#include <FWCore/ParameterSet/interface/ParameterSetDescription.h>

#include <DataFormats/METReco/interface/CorrMETData.h>
#include <DataFormats/PatCandidates/interface/Jet.h>
#include <DataFormats/PatCandidates/interface/MET.h>
#include <CommonTools/Utils/interface/StringCutObjectSelector.h>
Expand Down Expand Up @@ -38,8 +39,10 @@
* not necessarily symmetric, and the largest one is chosen as the uncertainty to store.
*
* In addition to fully corrected MET and its systematic variations, this plugin saves raw MET and
* MET from which corrections induced by stored jets are removed. The latter is useful to reapply
* T1 corrections on top of PEC tuples.
* several other versions of (partly) uncorrected MET. First of them is MET from which T1
* corrections induced by stored jets are removed. User can provide a list of MET correction
* objects (same as used by the standard MET tool); for each of them the plugin stores fully
* corrected MET from which that correction is undone.
*/
class PECJetMET: public edm::EDAnalyzer
{
Expand Down Expand Up @@ -102,6 +105,9 @@ class PECJetMET: public edm::EDAnalyzer
*/
bool const rawJetMomentaOnly;

// MET corrections to undo when computing uncorrected METs
std::vector<edm::EDGetTokenT<CorrMETData>> metCorrectorTokens;


/// An object to handle the output ROOT file
edm::Service<TFileService> fileService;
Expand Down
3 changes: 2 additions & 1 deletion python/MiniAOD_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ def append(self, *modules):
runOnData = cms.bool(runOnData),
jets = cms.InputTag('analysisPatJets'),
jetSelection = jetQualityCuts,
met = metTag
met = metTag,
metCorrToUndo = cms.VInputTag(cms.InputTag('patPFMetT1T2Corr', 'type1'))
)

process.pecPileUp = cms.EDAnalyzer('PECPileUp',
Expand Down
4 changes: 2 additions & 2 deletions python/ObjectsDefinitions_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ def define_jets(process, reapplyJEC=False, runOnData=False):
process.analysisPatJets = cms.EDFilter('JERCJetSelector',
src = cms.InputTag(recorrectedJetsLabel),
jetTypeLabel = cms.string('AK4PFchs'),
preselection = cms.string('abs(eta) < 5.2'),
minPt = cms.double(20.),
preselection = cms.string(''),
minPt = cms.double(15.),
includeJERCVariations = cms.bool(not runOnData),
genJets = cms.InputTag('slimmedGenJets'),
rho = cms.InputTag('fixedGridRhoFastjetAll')
Expand Down

0 comments on commit 4b78a39

Please sign in to comment.