Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-23 03:25:23

0001 #ifndef RecoJets_JetProducers_plugins_PileupJetIDProducer_h
0002 #define RecoJets_JetProducers_plugins_PileupJetIDProducer_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    PileupJetIdProducer
0007 // Class:      PileupJetIdProducer
0008 //
0009 /**\class PileupJetIdProducer PileupJetIdProducer.cc CMGTools/PileupJetIdProducer/src/PileupJetIdProducer.cc
0010 
0011 Description: Produces a value map of jet --> pileup jet ID
0012 
0013 Implementation:
0014 [Notes on implementation]
0015 */
0016 //
0017 // Original Author:  Pasquale Musella,40 2-A12,+41227671706,
0018 //         Created:  Wed Apr 18 15:48:47 CEST 2012
0019 //
0020 //
0021 
0022 // system include files
0023 #include <memory>
0024 
0025 // user include files
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/stream/EDProducer.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030 #include "FWCore/Framework/interface/ESHandle.h"
0031 #include "FWCore/Framework/interface/EventSetup.h"
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 
0034 #include "RecoJets/JetProducers/interface/PileupJetIdAlgo.h"
0035 
0036 #include "DataFormats/JetReco/interface/Jet.h"
0037 #include "DataFormats/Common/interface/ValueMap.h"
0038 #include "DataFormats/JetReco/interface/PileupJetIdentifier.h"
0039 #include "DataFormats/VertexReco/interface/Vertex.h"
0040 
0041 #include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
0042 #include "CondFormats/JetMETObjects/interface/FactorizedJetCorrector.h"
0043 #include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h"
0044 
0045 #include "FWCore/ParameterSet/interface/FileInPath.h"
0046 
0047 // ------------------------------------------------------------------------------------------
0048 
0049 class GBRForestsAndConstants {
0050 public:
0051   GBRForestsAndConstants(edm::ParameterSet const&);
0052 
0053   std::vector<PileupJetIdAlgo::AlgoGBRForestsAndConstants> const& vAlgoGBRForestsAndConstants() const {
0054     return vAlgoGBRForestsAndConstants_;
0055   }
0056 
0057   bool runMvas() const { return runMvas_; }
0058   bool produceJetIds() const { return produceJetIds_; }
0059   bool inputIsCorrected() const { return inputIsCorrected_; }
0060   bool applyJec() const { return applyJec_; }
0061   std::string const& jec() const { return jec_; }
0062   bool residualsFromTxt() const { return residualsFromTxt_; }
0063   edm::FileInPath const& residualsTxt() const { return residualsTxt_; }
0064   bool usePuppi() const { return usePuppi_; }
0065 
0066 private:
0067   std::vector<PileupJetIdAlgo::AlgoGBRForestsAndConstants> vAlgoGBRForestsAndConstants_;
0068 
0069   bool runMvas_;
0070   bool produceJetIds_;
0071   bool inputIsCorrected_;
0072   bool applyJec_;
0073   std::string jec_;
0074   bool residualsFromTxt_;
0075   edm::FileInPath residualsTxt_;
0076   bool usePuppi_;
0077 };
0078 
0079 class PileupJetIdProducer : public edm::stream::EDProducer<edm::GlobalCache<GBRForestsAndConstants>> {
0080 public:
0081   explicit PileupJetIdProducer(const edm::ParameterSet&, GBRForestsAndConstants const*);
0082   ~PileupJetIdProducer() override;
0083 
0084   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0085 
0086   static std::unique_ptr<GBRForestsAndConstants> initializeGlobalCache(edm::ParameterSet const& pset) {
0087     return std::make_unique<GBRForestsAndConstants>(pset);
0088   }
0089 
0090   static void globalEndJob(GBRForestsAndConstants*) {}
0091 
0092 private:
0093   void produce(edm::Event&, const edm::EventSetup&) override;
0094 
0095   void initJetEnergyCorrector(const edm::EventSetup& iSetup, bool isData);
0096 
0097   std::vector<std::pair<std::string, std::unique_ptr<PileupJetIdAlgo>>> algos_;
0098 
0099   std::unique_ptr<FactorizedJetCorrector> jecCor_;
0100   std::vector<JetCorrectorParameters> jetCorPars_;
0101 
0102   edm::EDGetTokenT<edm::View<reco::Jet>> input_jet_token_;
0103   edm::EDGetTokenT<reco::VertexCollection> input_vertex_token_;
0104   edm::EDGetTokenT<edm::ValueMap<StoredPileupJetIdentifier>> input_vm_pujetid_token_;
0105   edm::EDGetTokenT<double> input_rho_token_;
0106   edm::ESGetToken<JetCorrectorParametersCollection, JetCorrectionsRecord> parameters_token_;
0107 };
0108 
0109 #endif