File indexing completed on 2024-04-06 12:25:33
0001 #ifndef RecoJets_JetProducers_plugins_PileupJetIDProducer_h
0002 #define RecoJets_JetProducers_plugins_PileupJetIDProducer_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include <memory>
0024
0025
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 applyConstituentWeight() const { return applyConstituentWeight_; }
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 applyConstituentWeight_;
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::ValueMap<float> constituentWeights_;
0103 edm::EDGetTokenT<edm::ValueMap<float>> input_constituent_weights_token_;
0104 edm::EDGetTokenT<edm::View<reco::Jet>> input_jet_token_;
0105 edm::EDGetTokenT<reco::VertexCollection> input_vertex_token_;
0106 edm::EDGetTokenT<edm::ValueMap<StoredPileupJetIdentifier>> input_vm_pujetid_token_;
0107 edm::EDGetTokenT<double> input_rho_token_;
0108 edm::ESGetToken<JetCorrectorParametersCollection, JetCorrectionsRecord> parameters_token_;
0109 };
0110
0111 #endif