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 reco::TrackRef &ext_trk, 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.

Constructor & Destructor Documentation

◆ MTDTrackQualityMVA()

MTDTrackQualityMVA::MTDTrackQualityMVA ( std::string  weights_file)

Definition at line 3 of file MTDTrackQualityMVA.cc.

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 }

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

Member Function Documentation

◆ operator()()

float MTDTrackQualityMVA::operator() ( const reco::TrackRef trk,
const reco::TrackRef ext_trk,
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.

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

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

Member Data Documentation

◆ mva_

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

Definition at line 51 of file MTDTrackQualityMVA.h.

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

◆ spec_vars_

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

Definition at line 50 of file MTDTrackQualityMVA.h.

Referenced by MTDTrackQualityMVA().

◆ vars_

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

Definition at line 50 of file MTDTrackQualityMVA.h.

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

MTDTrackQualityMVA::VarID::etlMatchChi2
MTDTrackQualityMVA::VarID::pt
AlcaSiPixelAliHarvester0T_cff.method
method
Definition: AlcaSiPixelAliHarvester0T_cff.py:41
MTDTrackQualityMVA::VarID::etlMatchTimeChi2
MTDTrackQualityMVA::VarID::btlMatchTimeChi2
MTDTrackQualityMVA::VarID::path_len
MTDTrackQualityMVA::spec_vars_
std::vector< std::string > spec_vars_
Definition: MTDTrackQualityMVA.h:50
MTDTrackQualityMVA::vars_
std::vector< std::string > vars_
Definition: MTDTrackQualityMVA.h:50
MTDTrackQualityMVA::VarID::eta
MTDTrackQualityMVA::VarID::numberOfValidPixelEndcapHits
options
Definition: options.py:1
MTDBDTVAR_STRING
#define MTDBDTVAR_STRING(STRING)
Definition: MTDTrackQualityMVA.h:29
vars
vars
Definition: DeepTauId.cc:164
MTDTrackQualityMVA::VarID::mtdt
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
MTDBDTVAR_ENUM
#define MTDBDTVAR_ENUM(ENUM)
Definition: MTDTrackQualityMVA.h:28
MTDTrackQualityMVA::VarID::numberOfValidPixelBarrelHits
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
MTDTrackQualityMVA::VarID::btlMatchChi2
MTDTRACKQUALITYMVA_VARS
#define MTDTRACKQUALITYMVA_VARS(MTDBDTVAR)
Definition: MTDTrackQualityMVA.h:12
MTDTrackQualityMVA::mva_
std::unique_ptr< TMVAEvaluator > mva_
Definition: MTDTrackQualityMVA.h:51
edm::Ref::id
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
MTDTrackQualityMVA::VarID::chi2
MTDTrackQualityMVA::VarID::ndof
AlcaSiPixelAliHarvester0T_cff.options
options
Definition: AlcaSiPixelAliHarvester0T_cff.py:42
MTDTrackQualityMVA::VarID::numberOfValidHits
edm::ValueMap::contains
bool contains(ProductID id) const
Definition: ValueMap.h:155
MTDTrackQualityMVA::VarID::phi