Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:59:49

0001 #ifndef RecoJets_JetProducers_plugins_MVAJetPuId_h
0002 #define RecoJets_JetProducers_plugins_MVAJetPuId_h
0003 
0004 #include "DataFormats/JetReco/interface/Jet.h"
0005 #include "DataFormats/JetReco/interface/PFJetCollection.h"
0006 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 
0009 #include "TMVA/Tools.h"
0010 #include "TMVA/Reader.h"
0011 #include "TMVA/Tools.h"
0012 #include "TMVA/Reader.h"
0013 
0014 #include "DataFormats/JetReco/interface/PileupJetIdentifier.h"
0015 
0016 class MVAJetPuId {
0017   static constexpr int NWPs = 3;
0018   static constexpr int NPts = 4;
0019   static constexpr int NEtas = 4;
0020 
0021 public:
0022   enum version_t { USER = -1, CATEv0 = 0 };
0023 
0024   MVAJetPuId(int version = CATEv0,
0025              const std::string &tmvaWeight = "",
0026              const std::string &tmvaMethod = "",
0027              Float_t impactParTkThreshod_ = 1.,
0028              const std::vector<std::string> &tmvaVariables = std::vector<std::string>());
0029   MVAJetPuId(const edm::ParameterSet &ps);
0030   ~MVAJetPuId();
0031 
0032   PileupJetIdentifier computeIdVariables(const reco::Jet *jet,
0033                                          float jec,
0034                                          const reco::Vertex *,
0035                                          const reco::VertexCollection &,
0036                                          double rho,
0037                                          bool calculateMva = false);
0038 
0039   void set(const PileupJetIdentifier &);
0040   PileupJetIdentifier computeMva();
0041   const std::string method() const { return tmvaMethod_; }
0042 
0043   std::string dumpVariables() const;
0044 
0045   typedef std::map<std::string, std::pair<float *, float> > variables_list_t;
0046 
0047   std::pair<int, int> getJetIdKey(float jetPt, float jetEta);
0048   int computeCutIDflag(float betaStarClassic, float dR2Mean, float nvtx, float jetPt, float jetEta);
0049   int computeIDflag(float mva, float jetPt, float jetEta);
0050   int computeIDflag(float mva, int ptId, int etaId);
0051 
0052   const variables_list_t &getVariables() const { return variables_; };
0053 
0054 protected:
0055   void setup();
0056   void runMva();
0057   void bookReader();
0058   void resetVariables();
0059   void initVariables();
0060 
0061   PileupJetIdentifier internalId_;
0062   variables_list_t variables_;
0063 
0064   TMVA::Reader *reader_;
0065   std::string tmvaWeights_, tmvaMethod_;
0066   std::vector<std::string> tmvaVariables_;
0067   std::vector<std::string> tmvaSpectators_;
0068   std::map<std::string, std::string> tmvaNames_;
0069 
0070   Int_t version_;
0071   Float_t impactParTkThreshod_;
0072   bool cutBased_;
0073   Float_t mvacut_[NWPs][NEtas][NPts];       //Keep the array fixed
0074   Float_t rmsCut_[NWPs][NEtas][NPts];       //Keep the array fixed
0075   Float_t betaStarCut_[NWPs][NEtas][NPts];  //Keep the array fixed
0076 };
0077 
0078 #endif