CMS 3D CMS Logo

ChargedCandidateConverter.cc
Go to the documentation of this file.
2 
3 namespace btagbtvdeep {
4 
6  const pat::Jet& jet,
7  const TrackInfoBuilder& track_info,
8  const float drminpfcandsv,
9  const float jetR,
10  ChargedCandidateFeatures& c_pf_features,
11  const bool flip) {
12  commonCandidateToFeatures(c_pf, jet, track_info, drminpfcandsv, jetR, c_pf_features, flip);
13 
14  c_pf_features.vtx_ass = c_pf->pvAssociationQuality();
15 
16  c_pf_features.puppiw = c_pf->puppiWeight();
17 
18  // if PackedCandidate does not have TrackDetails this gives an Exception
19  // because unpackCovariance might be called for pseudoTrack/bestTrack
20  if (c_pf->hasTrackDetails()) {
21  const auto& pseudo_track = c_pf->pseudoTrack();
22  c_pf_features.chi2 = catch_infs_and_bound(pseudo_track.normalizedChi2(), 300, -1, 300);
23  // this returns the quality enum not a mask.
24  c_pf_features.quality = pseudo_track.qualityMask();
25  } else {
26  // default negative chi2 and loose track if notTrackDetails
27  c_pf_features.chi2 = catch_infs_and_bound(-1, 300, -1, 300);
28  c_pf_features.quality = (1 << reco::TrackBase::loose);
29  }
30 
31  c_pf_features.dxy = catch_infs(c_pf->dxy());
32  c_pf_features.dz = catch_infs(c_pf->dz());
33  c_pf_features.dxysig = c_pf->bestTrack() ? catch_infs(c_pf->dxy() / c_pf->dxyError()) : 0;
34  c_pf_features.dzsig = c_pf->bestTrack() ? catch_infs(c_pf->dz() / c_pf->dzError()) : 0;
35  }
36 
38  const reco::Jet& jet,
39  const TrackInfoBuilder& track_info,
40  const float drminpfcandsv,
41  const float jetR,
42  const float puppiw,
43  const int pv_ass_quality,
44  const reco::VertexRef& pv,
45  ChargedCandidateFeatures& c_pf_features,
46  const bool flip) {
47  commonCandidateToFeatures(c_pf, jet, track_info, drminpfcandsv, jetR, c_pf_features, flip);
48 
49  c_pf_features.vtx_ass = vtx_ass_from_pfcand(*c_pf, pv_ass_quality, pv);
50  c_pf_features.puppiw = puppiw;
51 
52  const auto& pseudo_track = (c_pf->bestTrack()) ? *c_pf->bestTrack() : reco::Track();
53  c_pf_features.chi2 = catch_infs_and_bound(std::floor(pseudo_track.normalizedChi2()), 300, -1, 300);
54  c_pf_features.quality = quality_from_pfcand(*c_pf);
55 
56  // To be implemented if FatJet tag becomes RECO compatible
57  // const auto *trk =
58  // float dz =
59  // float dxy =
60 
61  // c_pf_features.dxy =
62  // c_pf_features.dz =
63  // c_pf_features.dxysig =
64  // c_pf_features.dzsig =
65  }
66 
67 } // namespace btagbtvdeep
float puppiWeight() const
float quality_from_pfcand(const reco::PFCandidate &pfcand)
Definition: deep_helpers.cc:96
const float catch_infs(const float in, const float replace_value=0.)
Definition: deep_helpers.cc:21
const reco::Track * bestTrack() const override
Definition: PFCandidate.h:150
Base class for all types of Jets.
Definition: Jet.h:20
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:30
const PVAssociationQuality pvAssociationQuality() const
float dzError() const override
uncertainty on dz
def pv(vc)
Definition: MetAnalyzer.py:7
float vtx_ass_from_pfcand(const reco::PFCandidate &pfcand, int pv_ass_quality, const reco::VertexRef &pv)
Definition: deep_helpers.cc:88
float dxyError() const override
uncertainty on dxy
void packedCandidateToFeatures(const pat::PackedCandidate *c_pf, const pat::Jet &jet, const TrackInfoBuilder &track_info, const float drminpfcandsv, const float jetR, ChargedCandidateFeatures &c_pf_features, const bool flip=false)
const reco::Track * bestTrack() const override
return a pointer to the track if present. otherwise, return a null pointer
void recoCandidateToFeatures(const reco::PFCandidate *c_pf, const reco::Jet &jet, const TrackInfoBuilder &track_info, const float drminpfcandsv, const float jetR, const float puppiw, const int pv_ass_quality, const reco::VertexRef &pv, ChargedCandidateFeatures &c_pf_features, const bool flip=false)
Analysis-level calorimeter jet class.
Definition: Jet.h:77
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
virtual float dxy() const
dxy with respect to the PV ref
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
void commonCandidateToFeatures(const CandidateType *c_pf, const reco::Jet &jet, const TrackInfoBuilder &track_info, const float &drminpfcandsv, const float &jetR, ChargedCandidateFeatures &c_pf_features, const bool flip=false)
virtual const reco::Track & pseudoTrack() const
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.