CMS 3D CMS Logo

ChargedCandidateConverter.h
Go to the documentation of this file.
1 #ifndef RecoBTag_FeatureTools_ChargedCandidateConverter_h
2 #define RecoBTag_FeatureTools_ChargedCandidateConverter_h
3 
7 
11 
12 namespace btagbtvdeep {
13 
14  template <typename CandidateType>
15  void commonCandidateToFeatures(const CandidateType* c_pf,
16  const reco::Jet& jet,
17  const TrackInfoBuilder& track_info,
18  const bool& isWeightedJet,
19  const float& drminpfcandsv,
20  const float& jetR,
21  const float& puppiw,
22  ChargedCandidateFeatures& c_pf_features,
23  const bool flip = false,
24  const float& distminpfcandsv = 0) {
25  float trackSip2dVal = track_info.getTrackSip2dVal();
26  float trackSip2dSig = track_info.getTrackSip2dSig();
27  float trackSip3dVal = track_info.getTrackSip3dVal();
28  float trackSip3dSig = track_info.getTrackSip3dSig();
29  if (flip == true) {
34  }
35 
36  c_pf_features.deltaR = reco::deltaR(*c_pf, jet);
37 
38  float constituentWeight = 1.;
39  if (isWeightedJet)
40  constituentWeight = puppiw;
41 
42  c_pf_features.ptrel = catch_infs_and_bound((c_pf->pt() * constituentWeight) / jet.pt(), 0, -1, 0, -1);
43  c_pf_features.ptrel_noclip = (c_pf->pt() * constituentWeight) / jet.pt();
44  c_pf_features.erel = (c_pf->energy() * constituentWeight) / jet.energy();
45 
46  const float etasign = jet.eta() > 0 ? 1 : -1;
47  c_pf_features.etarel = etasign * (c_pf->eta() - jet.eta());
48 
49  c_pf_features.btagPf_trackEtaRel = catch_infs_and_bound(track_info.getTrackEtaRel(), 0, -5, 15);
50  c_pf_features.btagPf_trackPtRel = catch_infs_and_bound(track_info.getTrackPtRel(), 0, -1, 4);
51  c_pf_features.btagPf_trackPPar = catch_infs_and_bound(track_info.getTrackPPar(), 0, -1e5, 1e5);
52  c_pf_features.btagPf_trackDeltaR = catch_infs_and_bound(track_info.getTrackDeltaR(), 0, -5, 5);
53  c_pf_features.btagPf_trackPtRatio = catch_infs_and_bound(track_info.getTrackPtRatio(), 0, -1, 10);
54  c_pf_features.btagPf_trackPParRatio = catch_infs_and_bound(track_info.getTrackPParRatio(), 0, -10, 100);
57  c_pf_features.btagPf_trackSip2dVal = catch_infs_and_bound(trackSip2dVal, 0, -1, 70);
59  c_pf_features.btagPf_trackJetDistVal = catch_infs_and_bound(track_info.getTrackJetDistVal(), 0, -20, 1);
60  c_pf_features.btagPf_trackDecayLen = track_info.getTrackJetDecayLen();
61 
62  c_pf_features.drminsv = catch_infs_and_bound(drminpfcandsv, 0, -1. * jetR, 0, -1. * jetR);
63  c_pf_features.distminsv = distminpfcandsv;
64 
65  std::pair<float, float> drSubjetFeatures = getDRSubjetFeatures(jet, c_pf);
66  c_pf_features.drsubjet1 = drSubjetFeatures.first;
67  c_pf_features.drsubjet2 = drSubjetFeatures.second;
68 
69  c_pf_features.pt = c_pf->pt();
70  c_pf_features.eta = c_pf->eta();
71  c_pf_features.phi = c_pf->phi();
72  c_pf_features.e = c_pf->energy();
73  c_pf_features.px = c_pf->px();
74  c_pf_features.py = c_pf->py();
75  c_pf_features.pz = c_pf->pz();
76  }
77 
79  const pat::Jet& jet,
80  const TrackInfoBuilder& track_info,
81  const bool isWeightedJet,
82  const float drminpfcandsv,
83  const float jetR,
84  const float puppiw,
85  ChargedCandidateFeatures& c_pf_features,
86  const bool flip = false,
87  const float distminpfcandsv = 0);
88 
90  const reco::Jet& jet,
91  const TrackInfoBuilder& track_info,
92  const bool isWeightedJet,
93  const float drminpfcandsv,
94  const float jetR,
95  const float puppiw,
96  const int pv_ass_quality,
97  const reco::VertexRef& pv,
98  ChargedCandidateFeatures& c_pf_features,
99  const bool flip = false,
100  const float distminpfcandsv = 0);
101 
102 } // namespace btagbtvdeep
103 
104 #endif //RecoBTag_FeatureTools_ChargedCandidateConverter_h
const float getTrackJetDistVal() const
const float getTrackSip3dVal() const
const float getTrackJetDecayLen() const
Base class for all types of Jets.
Definition: Jet.h:20
const float getTrackDeltaR() const
std::pair< float, float > getDRSubjetFeatures(const reco::Jet &jet, const reco::Candidate *cand)
const float getTrackPParRatio() const
const float getTrackPtRatio() const
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 float getTrackSip2dVal() const
const float getTrackPtRel() const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
const float getTrackSip3dSig() 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
const float getTrackSip2dSig() const
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
const float getTrackPPar() 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)
const float getTrackEtaRel() const