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  const float distminpfcandsv) {
16  c_pf, jet, track_info, isWeightedJet, drminpfcandsv, jetR, puppiw, c_pf_features, flip, distminpfcandsv);
17 
18  c_pf_features.vtx_ass = c_pf->pvAssociationQuality();
19 
20  c_pf_features.puppiw = puppiw;
21  c_pf_features.charge = c_pf->charge();
22 
23  c_pf_features.CaloFrac = c_pf->caloFraction();
24  c_pf_features.HadFrac = c_pf->hcalFraction();
25  c_pf_features.lostInnerHits = catch_infs(c_pf->lostInnerHits(), 2);
26  c_pf_features.numberOfPixelHits = catch_infs(c_pf->numberOfPixelHits(), -1);
27  c_pf_features.numberOfStripHits = catch_infs(c_pf->stripLayersWithMeasurement(), -1);
28 
29  // if PackedCandidate does not have TrackDetails this gives an Exception
30  // because unpackCovariance might be called for pseudoTrack/bestTrack
31  if (c_pf->hasTrackDetails()) {
32  const auto& pseudo_track = c_pf->pseudoTrack();
33  c_pf_features.chi2 = catch_infs_and_bound(pseudo_track.normalizedChi2(), 300, -1, 300);
34  // this returns the quality enum not a mask.
35  c_pf_features.quality = pseudo_track.qualityMask();
36  } else {
37  // default negative chi2 and loose track if notTrackDetails
38  c_pf_features.chi2 = catch_infs_and_bound(-1, 300, -1, 300);
39  c_pf_features.quality = (1 << reco::TrackBase::loose);
40  }
41 
42  c_pf_features.dxy = catch_infs(c_pf->dxy());
43  c_pf_features.dz = catch_infs(c_pf->dz());
44  c_pf_features.dxysig = c_pf->bestTrack() ? catch_infs(c_pf->dxy() / c_pf->dxyError()) : 0;
45  c_pf_features.dzsig = c_pf->bestTrack() ? catch_infs(c_pf->dz() / c_pf->dzError()) : 0;
46 
47  float pdgid_;
48  if (abs(c_pf->pdgId()) == 11 and c_pf->charge() != 0) {
49  pdgid_ = 0.0;
50  } else if (abs(c_pf->pdgId()) == 13 and c_pf->charge() != 0) {
51  pdgid_ = 1.0;
52  } else if (abs(c_pf->pdgId()) == 22 and c_pf->charge() == 0) {
53  pdgid_ = 2.0;
54  } else if (abs(c_pf->pdgId()) != 22 and c_pf->charge() == 0 and abs(c_pf->pdgId()) != 1 and
55  abs(c_pf->pdgId()) != 2) {
56  pdgid_ = 3.0;
57  } else if (abs(c_pf->pdgId()) != 11 and abs(c_pf->pdgId()) != 13 and c_pf->charge() != 0) {
58  pdgid_ = 4.0;
59  } else if (c_pf->charge() == 0 and abs(c_pf->pdgId()) == 1) {
60  pdgid_ = 5.0;
61  } else if (c_pf->charge() == 0 and abs(c_pf->pdgId()) == 2) {
62  pdgid_ = 6.0;
63  } else {
64  pdgid_ = 7.0;
65  }
66  c_pf_features.pdgID = pdgid_;
67  }
68 
70  const reco::Jet& jet,
71  const TrackInfoBuilder& track_info,
72  const bool isWeightedJet,
73  const float drminpfcandsv,
74  const float jetR,
75  const float puppiw,
76  const int pv_ass_quality,
77  const reco::VertexRef& pv,
78  ChargedCandidateFeatures& c_pf_features,
79  const bool flip,
80  const float distminpfcandsv) {
82  c_pf, jet, track_info, isWeightedJet, drminpfcandsv, jetR, puppiw, c_pf_features, flip, distminpfcandsv);
83 
84  c_pf_features.vtx_ass = vtx_ass_from_pfcand(*c_pf, pv_ass_quality, pv);
85  c_pf_features.puppiw = puppiw;
86 
87  const auto& pseudo_track = (c_pf->bestTrack()) ? *c_pf->bestTrack() : reco::Track();
88  c_pf_features.chi2 = catch_infs_and_bound(std::floor(pseudo_track.normalizedChi2()), 300, -1, 300);
89  c_pf_features.quality = quality_from_pfcand(*c_pf);
90 
91  // To be implemented if FatJet tag becomes RECO compatible
92  // const auto *trk =
93  // float dz =
94  // float dxy =
95 
96  // c_pf_features.dxy =
97  // c_pf_features.dz =
98  // c_pf_features.dxysig =
99  // c_pf_features.dzsig =
100  }
101 
102 } // namespace btagbtvdeep
float quality_from_pfcand(const reco::PFCandidate &pfcand)
int charge() const override
electric charge
const float catch_infs(const float in, const float replace_value=0.)
Definition: deep_helpers.cc:34
int numberOfPixelHits() const
const reco::Track * bestTrack() const override
Definition: PFCandidate.h:150
Base class for all types of Jets.
Definition: Jet.h:20
float caloFraction() const
Set the fraction of ECAL+HCAL energy over candidate energy.
int pdgId() const override
PDG identifier.
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 float distminpfcandsv=0)
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:43
const PVAssociationQuality pvAssociationQuality() const
float dzError() const override
uncertainty on dz
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float vtx_ass_from_pfcand(const reco::PFCandidate &pfcand, int pv_ass_quality, const reco::VertexRef &pv)
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
int stripLayersWithMeasurement() const
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 &distminpfcandsv=0)
Analysis-level calorimeter jet class.
Definition: Jet.h:77
float hcalFraction() const
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
LostInnerHits lostInnerHits() 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, const float distminpfcandsv=0)
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
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.