File indexing completed on 2024-04-06 12:25:31
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef RecoJets_JetProducers_plugins_PileupJetIdAlgo_h
0009 #define RecoJets_JetProducers_plugins_PileupJetIdAlgo_h
0010
0011 #include "DataFormats/JetReco/interface/Jet.h"
0012 #include "DataFormats/JetReco/interface/PFJetCollection.h"
0013 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0014 #include "DataFormats/PatCandidates/interface/Jet.h"
0015 #include "DataFormats/PatCandidates/interface/PackedCandidate.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017
0018 #include "DataFormats/JetReco/interface/PileupJetIdentifier.h"
0019 #include "CondFormats/GBRForest/interface/GBRForest.h"
0020
0021
0022 class PileupJetIdAlgo {
0023 public:
0024 enum version_t { USER = -1, PHILv0 = 0 };
0025
0026 class AlgoGBRForestsAndConstants;
0027
0028 PileupJetIdAlgo(AlgoGBRForestsAndConstants const* cache);
0029 ~PileupJetIdAlgo();
0030
0031 PileupJetIdentifier computeIdVariables(const reco::Jet* jet,
0032 float jec,
0033 const reco::Vertex*,
0034 const reco::VertexCollection&,
0035 double rho,
0036 edm::ValueMap<float>& constituentWeights,
0037 bool applyConstituentWeight);
0038
0039 void set(const PileupJetIdentifier&);
0040 float getMVAval(const std::vector<std::string>&, const std::unique_ptr<const GBRForest>&);
0041 PileupJetIdentifier computeMva();
0042 const std::string method() const { return cache_->tmvaMethod(); }
0043
0044 std::string dumpVariables() const;
0045
0046 typedef std::map<std::string, std::pair<float*, float>> variables_list_t;
0047
0048 std::pair<int, int> getJetIdKey(float jetPt, float jetEta);
0049 int computeCutIDflag(float betaStarClassic, float dR2Mean, float nvtx, float jetPt, float jetEta);
0050 int computeIDflag(float mva, float jetPt, float jetEta);
0051 int computeIDflag(float mva, int ptId, int etaId);
0052
0053
0054 const variables_list_t& getVariables() const { return variables_; };
0055
0056
0057
0058
0059
0060
0061 class AlgoGBRForestsAndConstants {
0062 public:
0063 AlgoGBRForestsAndConstants(edm::ParameterSet const&, bool runMvas);
0064
0065 std::unique_ptr<const GBRForest> const& reader() const { return reader_; }
0066 std::vector<std::unique_ptr<const GBRForest>> const& etaReader() const { return etaReader_; }
0067 bool cutBased() const { return cutBased_; }
0068 bool etaBinnedWeights() const { return etaBinnedWeights_; }
0069 bool runMvas() const { return runMvas_; }
0070 int nEtaBins() const { return nEtaBins_; }
0071 std::vector<double> const& jEtaMin() const { return jEtaMin_; }
0072 std::vector<double> const& jEtaMax() const { return jEtaMax_; }
0073 std::string const& label() const { return label_; }
0074 std::string const& tmvaMethod() const { return tmvaMethod_; }
0075 std::vector<std::string> const& tmvaVariables() const { return tmvaVariables_; }
0076 std::vector<std::vector<std::string>> const& tmvaEtaVariables() const { return tmvaEtaVariables_; }
0077
0078 typedef float array_t[3][5][4];
0079 array_t const& mvacut() const { return mvacut_; }
0080 array_t const& rmsCut() const { return rmsCut_; }
0081 array_t const& betaStarCut() const { return betaStarCut_; }
0082
0083 private:
0084 std::unique_ptr<const GBRForest> reader_;
0085 std::vector<std::unique_ptr<const GBRForest>> etaReader_;
0086 bool cutBased_;
0087 bool etaBinnedWeights_;
0088 bool runMvas_;
0089 int nEtaBins_;
0090 std::vector<double> jEtaMin_;
0091 std::vector<double> jEtaMax_;
0092 std::string label_;
0093 std::string tmvaMethod_;
0094 std::vector<std::string> tmvaVariables_;
0095 std::vector<std::vector<std::string>> tmvaEtaVariables_;
0096
0097 float mvacut_[3][5][4];
0098 float rmsCut_[3][5][4];
0099 float betaStarCut_[3][5][4];
0100
0101 std::map<std::string, std::string> tmvaNames_;
0102 };
0103
0104 protected:
0105 void runMva();
0106 void resetVariables();
0107 void initVariables();
0108
0109 PileupJetIdentifier internalId_;
0110 variables_list_t variables_;
0111 AlgoGBRForestsAndConstants const* cache_;
0112 };
0113 #endif