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 e2x2In, 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 l1tPFClustersFromHGC3DClusters_cfi::weightsFile.

4  {
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 }
#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 15 of file PhotonXGBoostEstimator.cc.

References booster_.

15 { XGBoosterFree(booster_); }

Member Function Documentation

◆ computeMva()

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

Definition at line 31 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, and trigObjTnPSource_cfi::var.

39  {
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[e2x2] = e2x2In;
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
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().