CMS 3D CMS Logo

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

#include <MTDTrackQualityMVA.h>

Public Types

enum  VarID {
  VarID::pt, VarID::eta, VarID::phi, VarID::chi2,
  VarID::ndof, VarID::numberOfValidHits, VarID::numberOfValidPixelBarrelHits, VarID::numberOfValidPixelEndcapHits,
  VarID::btlMatchChi2, VarID::btlMatchTimeChi2, VarID::etlMatchChi2, VarID::etlMatchTimeChi2,
  VarID::mtdt, VarID::path_len
}
 

Public Member Functions

 MTDTrackQualityMVA (std::string weights_file)
 
float operator() (const reco::TrackRef &trk, const edm::ValueMap< int > &npixBarrels, const edm::ValueMap< int > &npixEndcaps, const edm::ValueMap< float > &btl_chi2s, const edm::ValueMap< float > &btl_time_chi2s, const edm::ValueMap< float > &etl_chi2s, const edm::ValueMap< float > &etl_time_chi2s, const edm::ValueMap< float > &tmtds, const edm::ValueMap< float > &trk_lengths) const
 

Private Attributes

std::unique_ptr< TMVAEvaluatormva_
 
std::vector< std::string > spec_vars_
 
std::vector< std::string > vars_
 

Detailed Description

Definition at line 31 of file MTDTrackQualityMVA.h.

Member Enumeration Documentation

◆ VarID

Enumerator
pt 
eta 
phi 
chi2 
ndof 
numberOfValidHits 
numberOfValidPixelBarrelHits 
numberOfValidPixelEndcapHits 
btlMatchChi2 
btlMatchTimeChi2 
etlMatchChi2 
etlMatchTimeChi2 
mtdt 
path_len 

Definition at line 36 of file MTDTrackQualityMVA.h.

#define MTDBDTVAR_ENUM(ENUM)
#define MTDTRACKQUALITYMVA_VARS(MTDBDTVAR)

Constructor & Destructor Documentation

◆ MTDTrackQualityMVA()

MTDTrackQualityMVA::MTDTrackQualityMVA ( std::string  weights_file)

Definition at line 3 of file MTDTrackQualityMVA.cc.

References AlcaSiPixelAliHarvester0T_cff::method, MTDBDTVAR_STRING, MTDTRACKQUALITYMVA_VARS, mva_, AlcaSiPixelAliHarvester0T_cff::options, spec_vars_, AlCaHLTBitMon_QueryRunRegistry::string, and vars_.

3  {
4  std::string options("!Color:Silent");
5  std::string method("BDT");
6 
8  int nvars = sizeof(vars_array) / sizeof(vars_array[0]);
9  vars_.assign(vars_array, vars_array + nvars);
10 
11  mva_ = std::make_unique<TMVAEvaluator>();
12  mva_->initialize(options, method, weights_file, vars_, spec_vars_, true, false); //use GBR, GradBoost
13 }
#define MTDBDTVAR_STRING(STRING)
#define MTDTRACKQUALITYMVA_VARS(MTDBDTVAR)
std::vector< std::string > spec_vars_
std::vector< std::string > vars_
std::unique_ptr< TMVAEvaluator > mva_

Member Function Documentation

◆ operator()()

float MTDTrackQualityMVA::operator() ( const reco::TrackRef trk,
const edm::ValueMap< int > &  npixBarrels,
const edm::ValueMap< int > &  npixEndcaps,
const edm::ValueMap< float > &  btl_chi2s,
const edm::ValueMap< float > &  btl_time_chi2s,
const edm::ValueMap< float > &  etl_chi2s,
const edm::ValueMap< float > &  etl_time_chi2s,
const edm::ValueMap< float > &  tmtds,
const edm::ValueMap< float > &  trk_lengths 
) const

Definition at line 15 of file MTDTrackQualityMVA.cc.

References btlMatchChi2, btlMatchTimeChi2, chi2, edm::ValueMap< T >::contains(), eta, etlMatchChi2, etlMatchTimeChi2, mtdt, mva_, ndof, numberOfValidHits, numberOfValidPixelBarrelHits, numberOfValidPixelEndcapHits, path_len, phi, pt, mathSSE::sqrt(), and vars_.

23  {
24  std::map<std::string, float> vars;
25 
26  //---training performed only above 0.5 GeV
27  constexpr float minPtForMVA = 0.5;
28  if (trk->pt() < minPtForMVA)
29  return -1;
30 
31  //---training performed only for tracks with MTD hits
32  if (tmtds[trk] > 0) {
33  vars.emplace(vars_[int(VarID::pt)], trk->pt());
34  vars.emplace(vars_[int(VarID::eta)], trk->eta());
35  vars.emplace(vars_[int(VarID::phi)], trk->phi());
36  vars.emplace(vars_[int(VarID::chi2)], trk->chi2());
37  vars.emplace(vars_[int(VarID::ndof)], trk->ndof());
38  vars.emplace(vars_[int(VarID::numberOfValidHits)], trk->numberOfValidHits());
39  vars.emplace(vars_[int(VarID::numberOfValidPixelBarrelHits)], npixBarrels[trk]);
40  vars.emplace(vars_[int(VarID::numberOfValidPixelEndcapHits)], npixEndcaps[trk]);
41  vars.emplace(vars_[int(VarID::btlMatchChi2)], btl_chi2s.contains(trk.id()) ? btl_chi2s[trk] : -1);
42  vars.emplace(vars_[int(VarID::btlMatchTimeChi2)], btl_time_chi2s.contains(trk.id()) ? btl_time_chi2s[trk] : -1);
43  vars.emplace(vars_[int(VarID::etlMatchChi2)], etl_chi2s.contains(trk.id()) ? etl_chi2s[trk] : -1);
44  vars.emplace(vars_[int(VarID::etlMatchTimeChi2)], etl_time_chi2s.contains(trk.id()) ? etl_time_chi2s[trk] : -1);
45  vars.emplace(vars_[int(VarID::mtdt)], tmtds[trk]);
46  vars.emplace(vars_[int(VarID::path_len)], trk_lengths[trk]);
47  return 1. / (1 + sqrt(2 / (1 + mva_->evaluate(vars, false)) - 1)); //return values between 0-1 (probability)
48  } else
49  return -1;
50 }
vars
Definition: DeepTauIdBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< std::string > vars_
std::unique_ptr< TMVAEvaluator > mva_
bool contains(ProductID id) const
Definition: ValueMap.h:149

Member Data Documentation

◆ mva_

std::unique_ptr<TMVAEvaluator> MTDTrackQualityMVA::mva_
private

Definition at line 52 of file MTDTrackQualityMVA.h.

Referenced by MTDTrackQualityMVA(), and operator()().

◆ spec_vars_

std::vector<std::string> MTDTrackQualityMVA::spec_vars_
private

Definition at line 51 of file MTDTrackQualityMVA.h.

Referenced by MTDTrackQualityMVA().

◆ vars_

std::vector<std::string> MTDTrackQualityMVA::vars_
private

Definition at line 51 of file MTDTrackQualityMVA.h.

Referenced by MTDTrackQualityMVA(), and operator()().