CMS 3D CMS Logo

deep_helpers.h
Go to the documentation of this file.
1 #ifndef RecoBTag_FeatureTools_deep_helpers_h
2 #define RecoBTag_FeatureTools_deep_helpers_h
3 
6 
8 
10 
13 //#include "RecoVertex/VertexTools/interface/VertexDistanceXY.h"
14 
17 
18 namespace btagbtvdeep {
19 
20  // remove infs and NaNs with value (adapted from DeepNTuples)
21  const float catch_infs(const float in, const float replace_value = 0.);
22 
23  // remove infs/NaN and bound (adapted from DeepNTuples)
24  const float catch_infs_and_bound(const float in,
25  const float replace_value,
26  const float lowerbound,
27  const float upperbound,
28  const float offset = 0.,
29  const bool use_offsets = true);
30 
31  // 2D distance between SV and PV (adapted from DeepNTuples)
33 
34  //3D distance between SV and PV (adapted from DeepNTuples)
36 
37  // dot product between SV and PV (adapted from DeepNTuples)
39 
40  // helper to order vertices by significance (adapted from DeepNTuples)
41  template <typename SVType, typename PVType>
42  bool sv_vertex_comparator(const SVType &sva, const SVType &svb, const PVType &pv) {
43  auto adxy = vertexDxy(sva, pv);
44  auto bdxy = vertexDxy(svb, pv);
45  float aval = adxy.value();
46  float bval = bdxy.value();
47  float aerr = adxy.error();
48  float berr = bdxy.error();
49 
50  float asig = catch_infs(aval / aerr, 0.);
51  float bsig = catch_infs(bval / berr, 0.);
52  return bsig < asig;
53  }
54 
55  // write tagging variables to vector (adapted from DeepNTuples)
56  template <typename T>
58  std::vector<T> vals = from.getList(name, false);
59  size_t size = std::min(vals.size(), max);
60  if (size > 0) {
61  for (size_t i = 0; i < vals.size(); i++) {
62  to[i] = catch_infs(vals[i], -0.1);
63  }
64  }
65  return size;
66  }
67 
68  // compute minimum dr between SVs and a candidate (from DeepNTuples, now polymorphic)
69  float mindrsvpfcand(const std::vector<reco::VertexCompositePtrCandidate> &svs,
70  const reco::Candidate *cand,
71  float mindr = 0.4);
72 
73  // mimic the calculation in PackedCandidate
74  float vtx_ass_from_pfcand(const reco::PFCandidate &pfcand, int pv_ass_quality, const reco::VertexRef &pv);
77 } // namespace btagbtvdeep
78 #endif //RecoBTag_FeatureTools_deep_helpers_h
btagbtvdeep
Definition: BoostedDoubleSVTagInfoFeatures.h:4
Measurement1D
Definition: Measurement1D.h:11
mps_fire.i
i
Definition: mps_fire.py:355
btagbtvdeep::dump_vector
int dump_vector(reco::TaggingVariableList &from, T *to, reco::btau::TaggingVariableName name, const size_t max)
Definition: deep_helpers.h:57
PFCandidate.h
CandIPTagInfo.h
min
T min(T a, T b)
Definition: MathUtil.h:58
reco::TaggingVariableList
Definition: TaggingVariable.h:194
btagbtvdeep::vertexDxy
Measurement1D vertexDxy(const reco::VertexCompositePtrCandidate &svcand, const reco::Vertex &pv)
Definition: deep_helpers.cc:49
Measurement1D.h
to
btagbtvdeep::sv_vertex_comparator
bool sv_vertex_comparator(const SVType &sva, const SVType &svb, const PVType &pv)
Definition: deep_helpers.h:42
reco::TaggingVariableList::getList
std::vector< TaggingValue > getList(TaggingVariableName tag, bool throwOnEmptyList=true) const
Definition: TaggingVariable.cc:375
reco::VertexCompositePtrCandidate
Definition: VertexCompositePtrCandidate.h:16
edm::Ref< VertexCollection >
pfDeepBoostedJetPreprocessParams_cfi.pfcand
pfcand
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:8
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:226
VertexCompositePtrCandidate.h
btagbtvdeep::catch_infs_and_bound
const float catch_infs_and_bound(const float in, const float replace_value, const float lowerbound, const float upperbound, const float offset=0., const bool use_offsets=true)
Definition: deep_helpers.cc:32
btagbtvdeep::vtx_ass_from_pfcand
float vtx_ass_from_pfcand(const reco::PFCandidate &pfcand, int pv_ass_quality, const reco::VertexRef &pv)
Definition: deep_helpers.cc:90
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
recoMuon::in
Definition: RecoMuonEnumerators.h:6
cand
Definition: decayParser.h:34
btagbtvdeep::catch_infs
const float catch_infs(const float in, const float replace_value=0.)
Definition: deep_helpers.cc:20
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
btagbtvdeep::mindrsvpfcand
float mindrsvpfcand(const std::vector< reco::VertexCompositePtrCandidate > &svs, const reco::Candidate *cand, float mindr=0.4)
Definition: deep_helpers.cc:74
Jet.h
reco::Candidate
Definition: Candidate.h:27
VertexFwd.h
IPTools.h
MTVHistoProducerAlgoForTrackerBlock_cfi.mindr
mindr
Definition: MTVHistoProducerAlgoForTrackerBlock_cfi.py:79
T
long double T
Definition: Basic3DVectorLD.h:48
btagbtvdeep::quality_from_pfcand
float quality_from_pfcand(const reco::PFCandidate &pfcand)
Definition: deep_helpers.cc:98
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
btagbtvdeep::vertexD3d
Measurement1D vertexD3d(const reco::VertexCompositePtrCandidate &svcand, const reco::Vertex &pv)
Definition: deep_helpers.cc:58
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
TaggingVariable.h
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78
btagbtvdeep::lost_inner_hits_from_pfcand
float lost_inner_hits_from_pfcand(const reco::PFCandidate &pfcand)
Definition: deep_helpers.cc:114
reco::Vertex
Definition: Vertex.h:35
reco::btau::TaggingVariableName
TaggingVariableName
Definition: TaggingVariable.h:30
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
btagbtvdeep::vertexDdotP
float vertexDdotP(const reco::VertexCompositePtrCandidate &sv, const reco::Vertex &pv)
Definition: deep_helpers.cc:67