Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-08 06:28:07

0001 #include "JetMETCorrections/Type1MET/interface/PFJetMETcorrInputProducerT.h"
0002 
0003 #include "DataFormats/PatCandidates/interface/Jet.h"
0004 
0005 #include "PhysicsTools/PatUtils/interface/PATJetCorrExtractor.h"
0006 
0007 namespace PFJetMETcorrInputProducer_namespace {
0008   template <>
0009   class InputTypeCheckerT<pat::Jet, PATJetCorrExtractor> {
0010   public:
0011     void operator()(const pat::Jet& jet) const {
0012       // check that pat::Jet is of PF-type
0013       if (!jet.isPFJet())
0014         throw cms::Exception("InvalidInput") << "Input pat::Jet is not of PF-type !!\n";
0015     }
0016     bool isPatJet(const pat::Jet& jet) const { return true; }
0017   };
0018 
0019   template <>
0020   class RawJetExtractorT<pat::Jet> {
0021   public:
0022     RawJetExtractorT() {}
0023     reco::Candidate::LorentzVector operator()(const pat::Jet& jet) const {
0024       if (jet.jecSetsAvailable())
0025         return jet.correctedP4(0);
0026       else
0027         return jet.p4();
0028     }
0029   };
0030 
0031   // template specialization for pat::Jets
0032   // retrieve combined factor of additional scales applied to the jets
0033   // otherwise just return 1
0034   template <>
0035   class AdditionalScalesT<pat::Jet> {
0036   public:
0037     AdditionalScalesT() {}
0038     float operator()(const pat::Jet& jet) const {
0039       if (jet.jecSetsAvailable()) {
0040         return jet.jecFactor("Uncorrected") / jet.jecFactor(0);
0041       } else
0042         return 1.0;
0043     }
0044   };
0045 }  // namespace PFJetMETcorrInputProducer_namespace
0046 
0047 typedef PFJetMETcorrInputProducerT<pat::Jet, PATJetCorrExtractor> PATPFJetMETcorrInputProducer;
0048 
0049 #include "FWCore/Framework/interface/MakerMacros.h"
0050 
0051 DEFINE_FWK_MODULE(PATPFJetMETcorrInputProducer);