CMS 3D CMS Logo

PhotonXGBoostEstimator.cc
Go to the documentation of this file.
2 #include <sstream>
3 
5  XGBoosterCreate(NULL, 0, &booster_);
6  XGBoosterLoadModel(booster_, weightsFile.fullPath().c_str());
7  best_ntree_limit_ = best_ntree_limit;
8 
9  std::stringstream config;
10  config << "{\"training\": false, \"type\": 0, \"iteration_begin\": 0, \"iteration_end\": " << best_ntree_limit_
11  << ", \"strict_shape\": false}";
12  config_ = config.str();
13 }
14 
16 
17 namespace {
18  enum inputIndexes {
19  rawEnergy = 0, // 0
20  r9 = 1, // 1
21  sigmaIEtaIEta = 2, // 2
22  etaWidth = 3, // 3
23  phiWidth = 4, // 4
24  s4 = 5, // 5
25  eta = 6, // 6
26  hOvrE = 7, // 7
27  ecalPFIso = 8, // 8
28  };
29 } // namespace
30 
31 float PhotonXGBoostEstimator::computeMva(float rawEnergyIn,
32  float r9In,
33  float sigmaIEtaIEtaIn,
34  float etaWidthIn,
35  float phiWidthIn,
36  float s4In,
37  float etaIn,
38  float hOvrEIn,
39  float ecalPFIsoIn) const {
40  float var[9];
41  var[rawEnergy] = rawEnergyIn;
42  var[r9] = r9In;
43  var[sigmaIEtaIEta] = sigmaIEtaIEtaIn;
44  var[etaWidth] = etaWidthIn;
45  var[phiWidth] = phiWidthIn;
46  var[s4] = s4In;
47  var[eta] = etaIn;
48  var[hOvrE] = hOvrEIn;
49  var[ecalPFIso] = ecalPFIsoIn;
50 
51  DMatrixHandle dmat;
52  XGDMatrixCreateFromMat(var, 1, 9, -999.9f, &dmat);
53  uint64_t const* out_shape;
54  uint64_t out_dim;
55  const float* out_result = NULL;
56  XGBoosterPredictFromDMatrix(booster_, dmat, config_.c_str(), &out_shape, &out_dim, &out_result);
57  float ret = out_result[0];
58  XGDMatrixFree(dmat);
59  return ret;
60 }
ret
prodAgent to be discontinued
#define NULL
Definition: scimark2.h:8
Definition: config.py:1
float computeMva(float rawEnergyIn, float r9In, float sigmaIEtaIEtaIn, float etaWidthIn, float phiWidthIn, float s4In, float etaIn, float hOvrEIn, float ecalPFIsoIn) const
double f[11][100]
unsigned long long uint64_t
Definition: Time.h:13
dictionary config
Read in AllInOne config in JSON format.
Definition: DiMuonV_cfg.py:30
PhotonXGBoostEstimator(const edm::FileInPath &weightsFile, int best_ntree_limit)