CMS 3D CMS Logo

MTDTrackQualityMVA.cc
Go to the documentation of this file.
2 
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 }
14 
16  const reco::TrackRef& ext_trk,
17  const edm::ValueMap<float>& btl_chi2s,
18  const edm::ValueMap<float>& btl_time_chi2s,
19  const edm::ValueMap<float>& etl_chi2s,
20  const edm::ValueMap<float>& etl_time_chi2s,
21  const edm::ValueMap<float>& tmtds,
22  const edm::ValueMap<float>& trk_lengths) const {
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 }
MTDTrackQualityMVA::VarID::etlMatchChi2
MTDTrackQualityMVA::VarID::pt
AlcaSiPixelAliHarvester0T_cff.method
method
Definition: AlcaSiPixelAliHarvester0T_cff.py:41
MTDTrackQualityMVA.h
MTDTrackQualityMVA::VarID::etlMatchTimeChi2
MTDTrackQualityMVA::operator()
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
Definition: MTDTrackQualityMVA.cc:15
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
edm::Ref< TrackCollection >
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
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
edm::ValueMap< float >
MTDTrackQualityMVA::VarID::ndof
AlcaSiPixelAliHarvester0T_cff.options
options
Definition: AlcaSiPixelAliHarvester0T_cff.py:42
MTDTrackQualityMVA::MTDTrackQualityMVA
MTDTrackQualityMVA(std::string weights_file)
Definition: MTDTrackQualityMVA.cc:3
MTDTrackQualityMVA::VarID::numberOfValidHits
edm::ValueMap::contains
bool contains(ProductID id) const
Definition: ValueMap.h:155
MTDTrackQualityMVA::VarID::phi