00001 #include "PhysicsTools/PatUtils/interface/SmearedJetProducerT.h" 00002 00003 #include "DataFormats/PatCandidates/interface/Jet.h" 00004 00005 #include "RecoMET/METAlgorithms/interface/SignAlgoResolutions.h" 00006 #include "RecoMET/METAlgorithms/interface/SigInputObj.h" 00007 #include "RecoMET/METAlgorithms/interface/significanceAlgo.h" 00008 #include "DataFormats/JetReco/interface/PFJet.h" 00009 00010 #include "PhysicsTools/PatUtils/interface/PATJetCorrExtractor.h" 00011 00012 namespace SmearedJetProducer_namespace 00013 { 00014 template <> 00015 class GenJetMatcherT<pat::Jet> 00016 { 00017 public: 00018 00019 GenJetMatcherT(const edm::ParameterSet& cfg) 00020 : dRmaxGenJetMatch_(0) 00021 { 00022 TString dRmaxGenJetMatch_formula = cfg.getParameter<std::string>("dRmaxGenJetMatch").data(); 00023 dRmaxGenJetMatch_formula.ReplaceAll("genJetPt", "x"); 00024 dRmaxGenJetMatch_ = new TFormula("dRmaxGenJetMatch", dRmaxGenJetMatch_formula.Data()); 00025 } 00026 ~GenJetMatcherT() 00027 { 00028 delete dRmaxGenJetMatch_; 00029 } 00030 00031 const reco::GenJet* operator()(const pat::Jet& jet, edm::Event* evt = 0) const 00032 { 00033 const reco::GenJet* retVal = 0; 00034 00035 // CV: apply matching criterion which is tighter than PAT default, 00036 // in order to avoid "accidental" matches for which the difference between genJetPt and recJetPt is large 00037 // (the large effect of such bad matches on the MEt smearing is "unphysical", 00038 // because the large difference between genJetPt and recJetPt results from the matching 00039 // and not from the particle/jet reconstruction) 00040 //retVal = jet.genJet(); 00041 if ( jet.genJet() ) { 00042 const reco::GenJet* genJet = jet.genJet(); 00043 double dR = deltaR(jet.p4(), genJet->p4()); 00044 if ( dR < dRmaxGenJetMatch_->Eval(genJet->pt()) ) retVal = genJet; 00045 } 00046 00047 return retVal; 00048 } 00049 00050 private: 00051 00052 TFormula* dRmaxGenJetMatch_; 00053 }; 00054 00055 template <> 00056 class JetResolutionExtractorT<pat::Jet> 00057 { 00058 public: 00059 00060 JetResolutionExtractorT(const edm::ParameterSet& cfg) 00061 : jetResolutions_(cfg) 00062 {} 00063 ~JetResolutionExtractorT() {} 00064 00065 double operator()(const pat::Jet& jet) const 00066 { 00067 if ( jet.isPFJet() ) { 00068 reco::PFJet pfJet(jet.p4(), jet.vertex(), jet.pfSpecific(), jet.getJetConstituents()); 00069 metsig::SigInputObj pfJetResolution = jetResolutions_.evalPFJet(&pfJet); 00070 if ( pfJetResolution.get_energy() > 0. ) { 00071 return jet.energy()*(pfJetResolution.get_sigma_e()/pfJetResolution.get_energy()); 00072 } else { 00073 return 0.; 00074 } 00075 } else { 00076 throw cms::Exception("SmearedJetProducer::produce") 00077 << " Jets of type other than PF not supported yet !!\n"; 00078 } 00079 } 00080 00081 metsig::SignAlgoResolutions jetResolutions_; 00082 }; 00083 } 00084 00085 typedef SmearedJetProducerT<pat::Jet, PATJetCorrExtractor> SmearedPATJetProducer; 00086 00087 #include "FWCore/Framework/interface/MakerMacros.h" 00088 00089 DEFINE_FWK_MODULE(SmearedPATJetProducer);