CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PhotonXGBoostEstimator Class Reference

#include <PhotonXGBoostEstimator.h>

Public Member Functions

float computeMva (float rawEnergyIn, float r9In, float sigmaIEtaIEtaIn, float etaWidthIn, float phiWidthIn, float s4In, float etaIn, float hOvrEIn, float ecalPFIsoIn) const
 
 PhotonXGBoostEstimator (const edm::FileInPath &weightsFile, int best_ntree_limit)
 
 ~PhotonXGBoostEstimator ()
 

Private Attributes

int best_ntree_limit_ = -1
 
BoosterHandle booster_
 
std::string config_
 

Detailed Description

Definition at line 7 of file PhotonXGBoostEstimator.h.

Constructor & Destructor Documentation

◆ PhotonXGBoostEstimator()

PhotonXGBoostEstimator::PhotonXGBoostEstimator ( const edm::FileInPath weightsFile,
int  best_ntree_limit 
)

Definition at line 4 of file PhotonXGBoostEstimator.cc.

References best_ntree_limit_, booster_, DiMuonV_cfg::config, config_, NULL, and pfClustersFromHGC3DClusters_cfi::weightsFile.

4  {
5  XGBoosterCreate(NULL, 0, &booster_);
6  // Set number of threads to 1, to avoid spawning hundreds of OpenMP threads
7  // See https://github.com/cms-sw/cmssw/issues/44923 for details
8  XGBoosterSetParam(booster_, "nthread", "1");
9  XGBoosterLoadModel(booster_, weightsFile.fullPath().c_str());
10  best_ntree_limit_ = best_ntree_limit;
11 
12  std::stringstream config;
13  config << "{\"training\": false, \"type\": 0, \"iteration_begin\": 0, \"iteration_end\": " << best_ntree_limit_
14  << ", \"strict_shape\": false}";
15  config_ = config.str();
16 }
#define NULL
Definition: scimark2.h:8
Definition: config.py:1
dictionary config
Read in AllInOne config in JSON format.
Definition: DiMuonV_cfg.py:30

◆ ~PhotonXGBoostEstimator()

PhotonXGBoostEstimator::~PhotonXGBoostEstimator ( )

Definition at line 18 of file PhotonXGBoostEstimator.cc.

References booster_.

18 { XGBoosterFree(booster_); }

Member Function Documentation

◆ computeMva()

float PhotonXGBoostEstimator::computeMva ( float  rawEnergyIn,
float  r9In,
float  sigmaIEtaIEtaIn,
float  etaWidthIn,
float  phiWidthIn,
float  s4In,
float  etaIn,
float  hOvrEIn,
float  ecalPFIsoIn 
) const

Definition at line 34 of file PhotonXGBoostEstimator.cc.

References booster_, config_, PVValHelper::eta, electrons_cff::etaWidth, f, NULL, electrons_cff::phiWidth, electrons_cff::r9, electrons_cff::rawEnergy, runTheMatrix::ret, photons_cff::s4, and trigObjTnPSource_cfi::var.

42  {
43  float var[9];
44  var[rawEnergy] = rawEnergyIn;
45  var[r9] = r9In;
46  var[sigmaIEtaIEta] = sigmaIEtaIEtaIn;
47  var[etaWidth] = etaWidthIn;
48  var[phiWidth] = phiWidthIn;
49  var[s4] = s4In;
50  var[eta] = etaIn;
51  var[hOvrE] = hOvrEIn;
52  var[ecalPFIso] = ecalPFIsoIn;
53 
54  DMatrixHandle dmat;
55  XGDMatrixCreateFromMat(var, 1, 9, -999.9f, &dmat);
56  uint64_t const* out_shape;
57  uint64_t out_dim;
58  const float* out_result = NULL;
59  XGBoosterPredictFromDMatrix(booster_, dmat, config_.c_str(), &out_shape, &out_dim, &out_result);
60  float ret = out_result[0];
61  XGDMatrixFree(dmat);
62  return ret;
63 }
ret
prodAgent to be discontinued
#define NULL
Definition: scimark2.h:8
double f[11][100]
unsigned long long uint64_t
Definition: Time.h:13

Member Data Documentation

◆ best_ntree_limit_

int PhotonXGBoostEstimator::best_ntree_limit_ = -1
private

Definition at line 24 of file PhotonXGBoostEstimator.h.

Referenced by PhotonXGBoostEstimator().

◆ booster_

BoosterHandle PhotonXGBoostEstimator::booster_
private

◆ config_

std::string PhotonXGBoostEstimator::config_
private

Definition at line 25 of file PhotonXGBoostEstimator.h.

Referenced by computeMva(), and PhotonXGBoostEstimator().