diff --git a/DataFormats/PatCandidates/interface/MET.h b/DataFormats/PatCandidates/interface/MET.h index 561a2979dbbd2..ac3764533449b 100644 --- a/DataFormats/PatCandidates/interface/MET.h +++ b/DataFormats/PatCandidates/interface/MET.h @@ -57,12 +57,12 @@ namespace pat { /// constructor for corrected METs (keeping specific informations from src MET) MET(const reco::MET & corMET, const MET& srcMET ); /// destructor - virtual ~MET(); + ~MET() override; MET& operator=(MET const&); /// required reimplementation of the Candidate's clone method - virtual MET * clone() const { return new MET(*this); } + MET * clone() const override { return new MET(*this); } // ---- methods for generated MET link ---- /// return the associated GenMET @@ -76,7 +76,6 @@ namespace pat { // get the MET significance double metSignificance() const; - // ---- methods for uncorrected MET ---- // Methods not yet defined //float uncorrectedPt() const; @@ -150,21 +149,21 @@ namespace pat { // ---- members for MET corrections ---- enum METUncertainty { - JetResUp=0, JetResDown=1, JetEnUp=2, JetEnDown=3, - MuonEnUp=4, MuonEnDown=5, ElectronEnUp=6, ElectronEnDown=7, - TauEnUp=8, TauEnDown=9, UnclusteredEnUp=10, UnclusteredEnDown=11, - PhotonEnUp=12, PhotonEnDown=13, NoShift=14, METUncertaintySize=15, - JetResUpSmear=16, JetResDownSmear=17, METFullUncertaintySize=18 + JetResUp=0, JetResDown=1, JetEnUp=2, JetEnDown=3, + MuonEnUp=4, MuonEnDown=5, ElectronEnUp=6, ElectronEnDown=7, + TauEnUp=8, TauEnDown=9, UnclusteredEnUp=10, UnclusteredEnDown=11, + PhotonEnUp=12, PhotonEnDown=13, NoShift=14, METUncertaintySize=15, + JetResUpSmear=16, JetResDownSmear=17, METFullUncertaintySize=18 }; enum METCorrectionLevel { - Raw=0, Type1=1, Type01=2, TypeXY=3, Type1XY=4, Type01XY=5, - Type1Smear=6, Type01Smear=7, Type1SmearXY=8, - Type01SmearXY=9, RawCalo=10, METCorrectionLevelSize=11 + Raw=0, Type1=1, Type01=2, TypeXY=3, Type1XY=4, Type01XY=5, + Type1Smear=6, Type01Smear=7, Type1SmearXY=8, + Type01SmearXY=9, RawCalo=10, RawChs=11, RawTrk=12, METCorrectionLevelSize=13 }; enum METCorrectionType { - None=0, T1=1, T0=2, TXY=3, TXYForRaw=4, - TXYForT01=5, TXYForT1Smear=6, TXYForT01Smear=7, - Smear=8, Calo=9, METCorrectionTypeSize=10 + None=0, T1=1, T0=2, TXY=3, TXYForRaw=4, + TXYForT01=5, TXYForT1Smear=6, TXYForT01Smear=7, + Smear=8, Calo=9, Chs=10, Trk=11, METCorrectionTypeSize=12 }; struct Vector2 { diff --git a/DataFormats/PatCandidates/src/MET.cc b/DataFormats/PatCandidates/src/MET.cc index 5cfa31ed882e4..494321d86645b 100644 --- a/DataFormats/PatCandidates/src/MET.cc +++ b/DataFormats/PatCandidates/src/MET.cc @@ -16,11 +16,11 @@ MET::MET() { /// constructor from reco::MET MET::MET(const reco::MET & aMET) : PATObject(aMET) { const reco::CaloMET * calo = dynamic_cast(&aMET); - if (calo != 0) caloMET_.push_back(calo->getSpecific()); + if (calo != nullptr) caloMET_.push_back(calo->getSpecific()); const reco::PFMET * pf = dynamic_cast(&aMET); - if (pf != 0) pfMET_.push_back(pf->getSpecific()); + if (pf != nullptr) pfMET_.push_back(pf->getSpecific()); const pat::MET * pm = dynamic_cast(&aMET); - if (pm != 0) this->operator=(*pm); + if (pm != nullptr) this->operator=(*pm); metSig_ =0.; initCorMap(); @@ -30,11 +30,11 @@ MET::MET(const reco::MET & aMET) : PATObject(aMET) { /// constructor from ref to reco::MET MET::MET(const edm::RefToBase & aMETRef) : PATObject(aMETRef) { const reco::CaloMET * calo = dynamic_cast(aMETRef.get()); - if (calo != 0) caloMET_.push_back(calo->getSpecific()); + if (calo != nullptr) caloMET_.push_back(calo->getSpecific()); const reco::PFMET * pf = dynamic_cast(aMETRef.get()); - if (pf != 0) pfMET_.push_back(pf->getSpecific()); + if (pf != nullptr) pfMET_.push_back(pf->getSpecific()); const pat::MET * pm = dynamic_cast(aMETRef.get()); - if (pm != 0) this->operator=(*pm); + if (pm != nullptr) this->operator=(*pm); metSig_ =0.; initCorMap(); @@ -43,11 +43,11 @@ MET::MET(const edm::RefToBase & aMETRef) : PATObject(aMETR /// constructor from ref to reco::MET MET::MET(const edm::Ptr & aMETRef) : PATObject(aMETRef) { const reco::CaloMET * calo = dynamic_cast(aMETRef.get()); - if (calo != 0) caloMET_.push_back(calo->getSpecific()); + if (calo != nullptr) caloMET_.push_back(calo->getSpecific()); const reco::PFMET * pf = dynamic_cast(aMETRef.get()); - if (pf != 0) pfMET_.push_back(pf->getSpecific()); + if (pf != nullptr) pfMET_.push_back(pf->getSpecific()); const pat::MET * pm = dynamic_cast(aMETRef.get()); - if (pm != 0) this->operator=(*pm); + if (pm != nullptr) this->operator=(*pm); metSig_ =0.; initCorMap(); @@ -108,7 +108,7 @@ MET& MET::operator=(MET const& iOther) { /// return the generated MET from neutrinos const reco::GenMET * MET::genMET() const { - return (genMET_.size() > 0 ? &genMET_.front() : 0 ); + return (!genMET_.empty() ? &genMET_.front() : nullptr ); } /// method to set the generated MET @@ -127,7 +127,6 @@ double MET::metSignificance() const { return metSig_; } - void MET::initCorMap() { @@ -184,6 +183,16 @@ MET::initCorMap() { std::vector tmpRawCalo; tmpRawCalo.push_back(MET::Calo); corMap_[MET::RawCalo] = tmpRawCalo; + + //specific chs case + std::vector tmpRawChs; + tmpRawChs.push_back(MET::Chs); + corMap_[MET::RawChs] = tmpRawChs; + + //specific trk case + std::vector tmpRawTrk; + tmpRawTrk.push_back(MET::Trk); + corMap_[MET::RawTrk] = tmpRawTrk; } const MET::PackedMETUncertainty @@ -230,7 +239,7 @@ MET::Vector2 MET::shiftedP2(MET::METUncertainty shift, MET::METCorrectionLevel c //backward compatibility with 74X samples -> the only one // with uncertaintiesType1_/uncertaintiesRaw_ not empty //will be removed once 74X is not used anymore - if(uncertaintiesType1_.size()!=0 || uncertaintiesRaw_.size()!=0) { + if(!uncertaintiesType1_.empty() || !uncertaintiesRaw_.empty()) { if(cor!=MET::METCorrectionLevel::RawCalo) { vo = shiftedP2_74x(shift, cor); } else { @@ -253,7 +262,7 @@ MET::Vector MET::shiftedP3(MET::METUncertainty shift, MET::METCorrectionLevel co //backward compatibility with 74X samples -> the only one // with uncertaintiesType1_/uncertaintiesRaw_ not empty //will be removed once 74X is not used anymore - if(uncertaintiesType1_.size()!=0 || uncertaintiesRaw_.size()!=0) { + if(!uncertaintiesType1_.empty() || !uncertaintiesRaw_.empty()) { if(cor!=MET::METCorrectionLevel::RawCalo) { vo = shiftedP3_74x(shift, cor); } else { @@ -276,7 +285,7 @@ MET::LorentzVector MET::shiftedP4(METUncertainty shift, MET::METCorrectionLevel //backward compatibility with 74X samples -> the only one // with uncertaintiesType1_/uncertaintiesRaw_ not empty //will be removed once 74X is not used anymore - if(uncertaintiesType1_.size()!=0 || uncertaintiesRaw_.size()!=0) { + if(!uncertaintiesType1_.empty() || !uncertaintiesRaw_.empty()) { if(cor!=MET::METCorrectionLevel::RawCalo) { vo = shiftedP4_74x(shift, cor); } else { @@ -301,7 +310,7 @@ double MET::shiftedSumEt(MET::METUncertainty shift, MET::METCorrectionLevel cor) //backward compatibility with 74X samples -> the only one // with uncertaintiesType1_/uncertaintiesRaw_ not empty //will be removed once 74X is not used anymore - if(uncertaintiesType1_.size()!=0 || uncertaintiesRaw_.size()!=0) { + if(!uncertaintiesType1_.empty() || !uncertaintiesRaw_.empty()) { if(cor!=MET::METCorrectionLevel::RawCalo) { sumEto = shiftedSumEt_74x(shift, cor); } else { diff --git a/PhysicsTools/PatAlgos/plugins/PATMETProducer.cc b/PhysicsTools/PatAlgos/plugins/PATMETProducer.cc index 8399f35c5f44a..b154eadef8766 100755 --- a/PhysicsTools/PatAlgos/plugins/PATMETProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMETProducer.cc @@ -95,6 +95,7 @@ void PATMETProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup // add the generated MET if (addGenMET_) amet.setGenMET((*genMETs)[idx]); + //add the MET significance if(calculateMETSignificance_) { const reco::METCovMatrix& sigcov = getMETCovMatrix(iEvent, iSetup); @@ -116,7 +117,6 @@ void PATMETProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup userDataHelper_.add( amet, iEvent, iSetup ); } - // correct for muons if demanded... never more: it's now done by JetMETCorrections // add the MET to the vector of METs patMETs->push_back(amet); diff --git a/PhysicsTools/PatAlgos/plugins/PATMETProducer.h b/PhysicsTools/PatAlgos/plugins/PATMETProducer.h index be716951f20cf..5e2d8540b0995 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMETProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATMETProducer.h @@ -40,9 +40,9 @@ namespace pat { public: explicit PATMETProducer(const edm::ParameterSet & iConfig); - ~PATMETProducer(); + ~PATMETProducer() override; - virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override; + void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override; static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); diff --git a/PhysicsTools/PatAlgos/plugins/PATMETSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATMETSlimmer.cc index b1902d557d9e9..a9e21d55cadf0 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMETSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMETSlimmer.cc @@ -19,9 +19,9 @@ namespace pat { class PATMETSlimmer : public edm::global::EDProducer<> { public: explicit PATMETSlimmer(const edm::ParameterSet & iConfig); - virtual ~PATMETSlimmer() { } + ~PATMETSlimmer() override { } - virtual void produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup & iSetup) const; + void produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup & iSetup) const override; private: class OneMETShift { @@ -65,6 +65,8 @@ pat::PATMETSlimmer::PATMETSlimmer(const edm::ParameterSet & iConfig) : maybeReadShifts( iConfig, "tXYUncForT1Smear", pat::MET::TXYForT1Smear ); maybeReadShifts( iConfig, "tXYUncForT01Smear", pat::MET::TXYForT01Smear ); maybeReadShifts( iConfig, "caloMET", pat::MET::Calo ); + maybeReadShifts( iConfig, "chsMET", pat::MET::Chs ); + maybeReadShifts( iConfig, "trkMET", pat::MET::Trk ); produces >(); } diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/metProducer_cfi.py b/PhysicsTools/PatAlgos/python/producersLayer1/metProducer_cfi.py index a101dbc8b8de6..5a529171fc48a 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/metProducer_cfi.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/metProducer_cfi.py @@ -2,6 +2,7 @@ from RecoMET.METProducers.METSignificanceParams_cfi import METSignificanceParams + patMETs = cms.EDProducer("PATMETProducer", # input metSource = cms.InputTag("pfMetT1"), @@ -58,5 +59,3 @@ srcRho = cms.InputTag('fixedGridRhoAll'), parameters = METSignificanceParams ) - - diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 6006dbb003218..af752e840d57b 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -172,6 +172,56 @@ def miniAOD_customizeCommon(process): del process.slimmedMETsNoHF.caloMET # ================== NoHF pfMET + # ================== CHSMET + process.CHSCands = cms.EDFilter("CandPtrSelector", + src=cms.InputTag("packedPFCandidates"), + cut=cms.string("fromPV(0) > 0") + ) + task.add(process.CHSCands) + + process.pfMetCHS = cms.EDProducer("PFMETProducer", + src = cms.InputTag("CHSCands"), + alias = cms.string('pfMet'), + globalThreshold = cms.double(0.0), + calculateSignificance = cms.bool(False), + ) + task.add(process.pfMetCHS) + + addMETCollection(process, + labelName = "patCHSMet", + metSource = "pfMetCHS" + ) + + process.patCHSMet.computeMETSignificance = cms.bool(False) + + # ================== CHSMET + + # ================== TrkMET + process.TrkCands = cms.EDFilter("CandPtrSelector", + src=cms.InputTag("packedPFCandidates"), + cut=cms.string("charge()!=0 && pvAssociationQuality()>=4 && vertexRef().key()==0") + ) + task.add(process.TrkCands) + + process.pfMetTrk = cms.EDProducer("PFMETProducer", + src = cms.InputTag("TrkCands"), + alias = cms.string('pfMet'), + globalThreshold = cms.double(0.0), + calculateSignificance = cms.bool(False), + ) + + task.add(process.pfMetTrk) + + addMETCollection(process, + labelName = "patTrkMet", + metSource = "pfMetTrk" + ) + + process.patTrkMet.computeMETSignificance = cms.bool(False) + + # ================== TrkMET + + ## PU JetID process.load("RecoJets.JetProducers.PileupJetID_cfi") task.add(process.pileUpJetIDTask) diff --git a/PhysicsTools/PatAlgos/python/slimming/slimmedMETs_cfi.py b/PhysicsTools/PatAlgos/python/slimming/slimmedMETs_cfi.py index b4a8ddad62442..d1e07ebd70259 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimmedMETs_cfi.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimmedMETs_cfi.py @@ -16,6 +16,10 @@ #caloMET, will be used for the beginning of ata takin by the JetMET people caloMET = cms.InputTag("patCaloMet"), + #adding CHS and Track MET for the Jet/MET studies + chsMET = cms.InputTag("patCHSMet"), + trkMET = cms.InputTag("patTrkMet"), + #switch to read the type0 correction from the existing slimmedMET #when running on top of miniAOD (type0 cannot be redone at the miniAOD level runningOnMiniAOD = cms.bool(False) diff --git a/PhysicsTools/PatAlgos/test/patTuple_updateMet_fromMiniAOD_cfg.py b/PhysicsTools/PatAlgos/test/patTuple_updateMet_fromMiniAOD_cfg.py index e0f734a084535..1678f52130b01 100644 --- a/PhysicsTools/PatAlgos/test/patTuple_updateMet_fromMiniAOD_cfg.py +++ b/PhysicsTools/PatAlgos/test/patTuple_updateMet_fromMiniAOD_cfg.py @@ -36,6 +36,8 @@ process.out.outputCommands = MINIAODSIMEventContent.outputCommands process.out.outputCommands.append("keep *_slimmedMETs_*_*") process.out.outputCommands.append("keep *_patPFMet_*_*") +process.out.outputCommands.append("keep *_patCHSMet_*_*") +process.out.outputCommands.append("keep *_patTrkMet_*_*") process.out.outputCommands.append("keep *_patPFMetT1_*_*") process.out.outputCommands.append("keep *_patPFMetT1JetResDown_*_*") process.out.outputCommands.append("keep *_patPFMetT1JetResUp_*_*") diff --git a/PhysicsTools/PatUtils/python/tools/runMETCorrectionsAndUncertainties.py b/PhysicsTools/PatUtils/python/tools/runMETCorrectionsAndUncertainties.py index 1f2bffd92258f..12eb6b8d6eeb3 100644 --- a/PhysicsTools/PatUtils/python/tools/runMETCorrectionsAndUncertainties.py +++ b/PhysicsTools/PatUtils/python/tools/runMETCorrectionsAndUncertainties.py @@ -330,8 +330,8 @@ def toolCode(self, process): postfix) #pre-preparation to run over miniAOD - if onMiniAOD: - self.miniAODConfigurationPre(process, patMetModuleSequence, postfix) + if onMiniAOD: + self.miniAODConfigurationPre(process, patMetModuleSequence, pfCandCollection, postfix) #default MET production self.produceMET(process, metType,patMetModuleSequence, postfix) @@ -1509,7 +1509,7 @@ def ak4JetReclustering(self,process, pfCandCollection, patMetModuleSequence, pos - def miniAODConfigurationPre(self, process, patMetModuleSequence, postfix): + def miniAODConfigurationPre(self, process, patMetModuleSequence, pfCandCollection, postfix): #extractor for caloMET === temporary for the beginning of the data taking self.extractMET(process,"rawCalo",patMetModuleSequence,postfix) @@ -1520,6 +1520,56 @@ def miniAODConfigurationPre(self, process, patMetModuleSequence, postfix): ) getattr(process,"patCaloMet").addGenMET = False + ##adding the necessary chs and track met configuration + task = getPatAlgosToolsTask(process) + + pfCHS = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string("fromPV(0)>0")) + addToProcessAndTask("pfCHS", pfCHS, process, task) + pfMetCHS = cms.EDProducer("PFMETProducer", + src = cms.InputTag('pfCHS'), + alias = cms.string('pfMet'), + globalThreshold = cms.double(0.0), + calculateSignificance = cms.bool(False), + ) + + addToProcessAndTask("pfMetCHS", pfMetCHS, process, task) + + addMETCollection(process, + labelName = "patCHSMet", + metSource = "pfMetCHS" + ) + + process.patCHSMet.computeMETSignificant = cms.bool(False) + process.patCHSMet.addGenMET = cms.bool(False) + + patMetModuleSequence += getattr(process, "pfCHS") + patMetModuleSequence += getattr(process, "pfMetCHS") + patMetModuleSequence += getattr(process, "patCHSMet") + + pfTrk = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string("fromPV(0) > 0 && charge()!=0")) + addToProcessAndTask("pfTrk", pfTrk, process, task) + pfMetTrk = cms.EDProducer("PFMETProducer", + src = cms.InputTag('pfTrk'), + alias = cms.string('pfMet'), + globalThreshold = cms.double(0.0), + calculateSignificance = cms.bool(False), + ) + + addToProcessAndTask("pfMetTrk", pfMetTrk, process, task) + + addMETCollection(process, + labelName = "patTrkMet", + metSource = "pfMetTrk" + ) + + process.patTrkMet.computeMETSignificant = cms.bool(False) + process.patTrkMet.addGenMET = cms.bool(False) + + patMetModuleSequence += getattr(process, "pfTrk") + patMetModuleSequence += getattr(process, "pfMetTrk") + patMetModuleSequence += getattr(process, "patTrkMet") + + def miniAODConfigurationPost(self, process, postfix): if self._parameters["metType"].value == "PF":