Skip to content

Commit

Permalink
Merge pull request #11491 from cms-met/METCorTool75X-092515
Browse files Browse the repository at this point in the history
Disabling the reclustering in the MET correction and uncertainty tool (76X)
  • Loading branch information
davidlange6 committed Oct 5, 2015
2 parents 118d7b0 + 28db46c commit fd763e1
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 42 deletions.
63 changes: 63 additions & 0 deletions PhysicsTools/PatAlgos/plugins/RecoMETExtractor.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include "PhysicsTools/PatAlgos/plugins/RecoMETExtractor.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include <memory>

using namespace pat;

RecoMETExtractor::RecoMETExtractor(const edm::ParameterSet& iConfig) {

edm::InputTag metIT = iConfig.getParameter<edm::InputTag>("metSource");
metSrcToken_ = consumes<pat::METCollection>(metIT);

std::string corLevel = iConfig.getParameter<std::string>("correctionLevel");

//all possible met flavors
if(corLevel=="raw") { corLevel_=pat::MET::Raw;}
else if(corLevel=="type1") { corLevel_=pat::MET::Type1;}
else if(corLevel=="type01") { corLevel_=pat::MET::Type01;}
else if(corLevel=="typeXY") { corLevel_=pat::MET::TypeXY;}
else if(corLevel=="type1XY") { corLevel_=pat::MET::Type1XY;}
else if(corLevel=="type01XY") { corLevel_=pat::MET::Type01XY;}
else if(corLevel=="type1Smear") { corLevel_=pat::MET::Type1Smear;}
else if(corLevel=="type01Smear") { corLevel_=pat::MET::Type01Smear;}
else if(corLevel=="type1SmearXY") { corLevel_=pat::MET::Type1SmearXY;}
else if(corLevel=="type01SmearXY") { corLevel_=pat::MET::Type01SmearXY;}
else if(corLevel=="rawCalo") { corLevel_=pat::MET::RawCalo;}
else {
//throw exception

}

// produces vector of recoMet
produces<std::vector<reco::MET> >();
}


RecoMETExtractor::~RecoMETExtractor() {

}


void RecoMETExtractor::produce(edm::StreamID streamID, edm::Event & iEvent,
const edm::EventSetup & iSetup) const {

edm::Handle<std::vector<pat::MET> > src;
iEvent.getByToken(metSrcToken_, src);
if(src->size()==0) edm::LogError("RecoMETExtractor::produce") << "input reco MET collection is empty" ;

std::vector<reco::MET> *metCol = new std::vector<reco::MET>();

reco::MET met(src->front().corP4(corLevel_), src->front().vertex() );
metCol->push_back( met );

std::auto_ptr<std::vector<reco::MET> > recoMETs(metCol);
iEvent.put(recoMETs);
}


#include "FWCore/Framework/interface/MakerMacros.h"

DEFINE_FWK_MODULE(RecoMETExtractor);
47 changes: 47 additions & 0 deletions PhysicsTools/PatAlgos/plugins/RecoMETExtractor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef PhysicsTools_PatAlgos_RecoMETExtractor_h
#define PhysicsTools_PatAlgos_RecoMETExtractor_h

/**
\class pat::RecoMETExtractor RecoMETExtractor.h "PhysicsTools/PatAlgos/interface/RecoMETExtractor.h"
\brief Retrieves the recoMET from a pat::MET
The RecoMETExtractor produces the analysis-level pat::MET starting from
a collection of objects of METType.
\author Matthieu Marionneau
\version $Id: RecoMETExtractor.h,v 1.0 2015/07/22 mmarionn Exp $
*/


#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include "DataFormats/PatCandidates/interface/MET.h"
#include "DataFormats/METReco/interface/MET.h"

namespace pat {

class RecoMETExtractor : public edm::global::EDProducer<> {

public:

explicit RecoMETExtractor(const edm::ParameterSet& iConfig);
~RecoMETExtractor();

virtual void produce(edm::StreamID streamID, edm::Event & iEvent,
const edm::EventSetup & iSetup) const;

private:

edm::EDGetTokenT<std::vector<pat::MET> > metSrcToken_;

pat::MET::METCorrectionLevel corLevel_;

};

}

#endif
2 changes: 1 addition & 1 deletion PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def miniAOD_customizeCommon(process):
)
runMetCorAndUncForMiniAODProduction(process,
pfCandColl=cms.InputTag("noHFCands"),
recomputeMET=True, #needed for HF removal
recoMetFromPFCs=True, #needed for HF removal
postfix="NoHF"
)
process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
Expand Down
11 changes: 7 additions & 4 deletions PhysicsTools/PatAlgos/test/corMETFromMiniAOD.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#configurable options =======================================================================
runOnData=False #data/MC switch
usePrivateSQlite=True #use external JECs (sqlite file)
usePrivateSQlite=False #use external JECs (sqlite file)
useHFCandidates=False #create an additionnal NoHF slimmed MET collection if the option is set to false
applyResiduals=True #application of residual corrections. Have to be set to True once the 13 TeV residual corrections are available. False to be kept meanwhile. Can be kept to False later for private tests or for analysis checks and developments (not the official recommendation!).
#===================================================================
Expand All @@ -45,8 +45,8 @@
process.GlobalTag.globaltag = autoCond['run2_data']
#process.GlobalTag.globaltag = '75X_dataRun1_v2' #'74X_dataRun2_Prompt_v1'
else:
#process.GlobalTag.globaltag = 'MCRUN2_74_v9'
process.GlobalTag.globaltag = autoCond['run2_mc']
process.GlobalTag.globaltag = 'MCRUN2_75_V5'
# process.GlobalTag.globaltag = autoCond['run2_mc']
# process.GlobalTag = GlobaTag(GlobalTag, 'auto:run2_mc', '')

if usePrivateSQlite:
Expand Down Expand Up @@ -85,7 +85,8 @@
else:
#75X file : root://eoscms.cern.ch//store/relval/CMSSW_7_5_0/RelValTTbar_13/MINIAODSIM/75X_mcRun2_asymptotic_v1-v1/00000/92A928E7-842A-E511-87CC-0025905A60E0.root
#74X file : root://eoscms.cern.ch//store/mc/RunIISpring15DR74/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/MINIAODSIM/Asympt50ns_MCRUN2_74_V9A-v2/60000/001C7571-0511-E511-9B8E-549F35AE4FAF.root
fname = 'root://eoscms.cern.ch//store/mc/RunIISpring15DR74/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/MINIAODSIM/Asympt50ns_MCRUN2_74_V9A-v2/60000/001C7571-0511-E511-9B8E-549F35AE4FAF.root'
fname = 'root://eoscms.cern.ch//store/relval/CMSSW_7_5_3/RelValZEE_13/MINIAODSIM/75X_mcRun2_asymptotic_v5-v1/00000/F8C5D3F4-A861-E511-BA41-002618943906.root'

# Define the input source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring([ fname ])
Expand Down Expand Up @@ -117,6 +118,8 @@
runMetCorAndUncFromMiniAOD(process,
isData=runOnData,
pfCandColl=cms.InputTag("noHFCands"),
reclusterJets=True, #needed for NoHF
recoMetFromPFCs=True, #needed for NoHF
postfix="NoHF"
)

Expand Down
Loading

0 comments on commit fd763e1

Please sign in to comment.