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 bool isWeightedJet,
9  const float drminpfcandsv,
10  const float jetR,
11  const float puppiw,
12  ChargedCandidateFeatures& c_pf_features,
13  const bool flip) {
14  commonCandidateToFeatures(c_pf, jet, track_info, isWeightedJet, drminpfcandsv, jetR, puppiw, c_pf_features, flip);
15 
16  c_pf_features.vtx_ass = c_pf->pvAssociationQuality();
17 
18  c_pf_features.puppiw = puppiw;
19 
20  // if PackedCandidate does not have TrackDetails this gives an Exception
21  // because unpackCovariance might be called for pseudoTrack/bestTrack
22  if (c_pf->hasTrackDetails()) {
23  const auto& pseudo_track = c_pf->pseudoTrack();
24  c_pf_features.chi2 = catch_infs_and_bound(pseudo_track.normalizedChi2(), 300, -1, 300);
25  // this returns the quality enum not a mask.
26  c_pf_features.quality = pseudo_track.qualityMask();
27  } else {
28  // default negative chi2 and loose track if notTrackDetails
29  c_pf_features.chi2 = catch_infs_and_bound(-1, 300, -1, 300);
30  c_pf_features.quality = (1 << reco::TrackBase::loose);
31  }
32 
33  c_pf_features.dxy = catch_infs(c_pf->dxy());
34  c_pf_features.dz = catch_infs(c_pf->dz());
35  c_pf_features.dxysig = c_pf->bestTrack() ? catch_infs(c_pf->dxy() / c_pf->dxyError()) : 0;
36  c_pf_features.dzsig = c_pf->bestTrack() ? catch_infs(c_pf->dz() / c_pf->dzError()) : 0;
37  }
38 
40  const reco::Jet& jet,
41  const TrackInfoBuilder& track_info,
42  const bool isWeightedJet,
43  const float drminpfcandsv,
44  const float jetR,
45  const float puppiw,
46  const int pv_ass_quality,
47  const reco::VertexRef& pv,
48  ChargedCandidateFeatures& c_pf_features,
49  const bool flip) {
50  commonCandidateToFeatures(c_pf, jet, track_info, isWeightedJet, drminpfcandsv, jetR, puppiw, c_pf_features, flip);
51 
52  c_pf_features.vtx_ass = vtx_ass_from_pfcand(*c_pf, pv_ass_quality, pv);
53  c_pf_features.puppiw = puppiw;
54 
55  const auto& pseudo_track = (c_pf->bestTrack()) ? *c_pf->bestTrack() : reco::Track();
56  c_pf_features.chi2 = catch_infs_and_bound(std::floor(pseudo_track.normalizedChi2()), 300, -1, 300);
57  c_pf_features.quality = quality_from_pfcand(*c_pf);
58 
59  // To be implemented if FatJet tag becomes RECO compatible
60  // const auto *trk =
61  // float dz =
62  // float dxy =
63 
64  // c_pf_features.dxy =
65  // c_pf_features.dz =
66  // c_pf_features.dxysig =
67  // c_pf_features.dzsig =
68  }
69 
70 } // namespace btagbtvdeep
float quality_from_pfcand(const reco::PFCandidate &pfcand)
Definition: deep_helpers.cc:96
void commonCandidateToFeatures(const CandidateType *c_pf, const reco::Jet &jet, const TrackInfoBuilder &track_info, const bool &isWeightedJet, const float &drminpfcandsv, const float &jetR, const float &puppiw, ChargedCandidateFeatures &c_pf_features, const bool flip=false)
const float catch_infs(const float in, const float replace_value=0.)
Definition: deep_helpers.cc:21
void packedCandidateToFeatures(const pat::PackedCandidate *c_pf, const pat::Jet &jet, const TrackInfoBuilder &track_info, const bool isWeightedJet, const float drminpfcandsv, const float jetR, const float puppiw, ChargedCandidateFeatures &c_pf_features, const bool flip=false)
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
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
const reco::Track * bestTrack() const override
return a pointer to the track if present. otherwise, return a null pointer
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]
virtual const reco::Track & pseudoTrack() const
void recoCandidateToFeatures(const reco::PFCandidate *c_pf, const reco::Jet &jet, const TrackInfoBuilder &track_info, const bool isWeightedJet, 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)
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.