CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGC3DClusterEgID.cc
Go to the documentation of this file.
3 
5  : isPUFilter_(pset.getParameter<bool>("isPUFilter")),
6  preselection_(pset.getParameter<std::string>("preselection")),
7  method_(pset.getParameter<std::string>("method")),
8  weightsFile_(pset.getParameter<std::string>("weightsFile")),
9  reader_(new TMVA::Reader()),
10  wp_(pset.getParameter<std::string>("wp")) {
11  // first create all the variables
12  for (const auto &psvar : pset.getParameter<std::vector<edm::ParameterSet>>("variables")) {
13  variables_.emplace_back(psvar.getParameter<std::string>("name"), psvar.getParameter<std::string>("value"));
14  }
15 }
16 
18  // Declare the variables
19  for (auto &var : variables_)
20  var.declare(*reader_);
21  // then read the weights
22  if (weightsFile_[0] != '/' && weightsFile_[0] != '.') {
23  weightsFile_ = edm::FileInPath(weightsFile_).fullPath();
24  }
25  reco::details::loadTMVAWeights(&*reader_, method_, weightsFile_);
26 }
27 
29  if (preselection_(c)) {
30  for (auto &var : variables_)
31  var.fill(c);
32  float mvaOut = reader_->EvaluateMVA(method_);
33  if (isPUFilter_)
34  cpf.setEgVsPUMVAOut(mvaOut);
35  else
36  cpf.setEgVsPionMVAOut(mvaOut);
37  return (mvaOut > wp_(c) ? 1 : 0);
38  } else {
39  if (isPUFilter_)
40  cpf.setEgVsPUMVAOut(-100.0);
41  else
42  cpf.setEgVsPionMVAOut(-100.0);
43  return 0;
44  }
45 }
HGC3DClusterEgID(const edm::ParameterSet &pset)
const edm::EventSetup & c
void setEgVsPionMVAOut(float egVsPionMVAOut)
Definition: PFCluster.h:63
void setEgVsPUMVAOut(float egVsPUMVAOut)
Definition: PFCluster.h:66
list var
if using global norm cols_to_minmax = [&#39;t_delta&#39;, &#39;t_hmaxNearP&#39;,&#39;t_emaxNearP&#39;, &#39;t_hAnnular&#39;, &#39;t_eAnnular&#39;,&#39;t_pt&#39;,&#39;t_nVtx&#39;,&#39;t_ieta&#39;,&#39;t_eHcal10&#39;, &#39;t_eHcal30&#39;,&#39;t_rhoh&#39;,&#39;t_eHcal&#39;] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() &gt; 0) else 1.0/200.0)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< Var > variables_
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
std::string fullPath() const
Definition: FileInPath.cc:161
float passID(l1t::HGCalMulticluster c, l1t::PFCluster &cpf)