CMS 3D CMS Logo

NeutralCandidateConverter.h
Go to the documentation of this file.
1 #ifndef RecoBTag_FeatureTools_NeutralCandidateConverter_h
2 #define RecoBTag_FeatureTools_NeutralCandidateConverter_h
3 
6 
11 
12 namespace btagbtvdeep {
13 
15  const pat::Jet& jet,
16  const bool isWeightedJet,
17  const float drminpfcandsv,
18  const float jetR,
19  const float puppiw,
20  NeutralCandidateFeatures& n_pf_features);
21 
23  const reco::Jet& jet,
24  const bool isWeightedJet,
25  const float drminpfcandsv,
26  const float jetR,
27  const float puppiw,
28  NeutralCandidateFeatures& n_pf_features);
29 
30  template <typename CandidateType>
31  static void commonCandidateToFeatures(const CandidateType* n_pf,
32  const reco::Jet& jet,
33  const bool& isWeightedJet,
34  const float& drminpfcandsv,
35  const float& jetR,
36  const float& puppiw,
37  NeutralCandidateFeatures& n_pf_features) {
38  std::pair<float, float> drSubjetFeatures = getDRSubjetFeatures(jet, n_pf);
39  n_pf_features.drsubjet1 = drSubjetFeatures.first;
40  n_pf_features.drsubjet2 = drSubjetFeatures.second;
41 
42  float constituentWeight = 1.;
43  if (isWeightedJet)
44  constituentWeight = puppiw;
45 
46  // Jet relative vars
47  n_pf_features.ptrel = catch_infs_and_bound((n_pf->pt() * constituentWeight) / jet.pt(), 0, -1, 0, -1);
48  n_pf_features.ptrel_noclip = (n_pf->pt() * constituentWeight) / jet.pt();
49  n_pf_features.erel = (n_pf->energy() * constituentWeight) / jet.energy();
50 
51  n_pf_features.deltaR = catch_infs_and_bound(reco::deltaR(*n_pf, jet), 0, -0.6, 0, -0.6);
52  n_pf_features.deltaR_noclip = reco::deltaR(*n_pf, jet);
53 
54  n_pf_features.isGamma = 0;
55  if (std::abs(n_pf->pdgId()) == 22)
56  n_pf_features.isGamma = 1;
57 
58  n_pf_features.drminsv = catch_infs_and_bound(drminpfcandsv, 0, -1. * jetR, 0, -1. * jetR);
59 
60  n_pf_features.etarel = catch_infs_and_bound(std::fabs(n_pf->eta() - jet.eta()), 0, -2, 0, -0.5);
61  n_pf_features.phirel = catch_infs_and_bound(std::fabs(reco::deltaPhi(n_pf->phi(), jet.phi())), 0, -2, 0, -0.5);
62  n_pf_features.pt = n_pf->pt();
63  n_pf_features.eta = n_pf->eta();
64  n_pf_features.phi = n_pf->phi();
65  n_pf_features.e = n_pf->energy();
66  n_pf_features.px = n_pf->px();
67  n_pf_features.py = n_pf->py();
68  n_pf_features.pz = n_pf->pz();
69  }
70 
71 } // namespace btagbtvdeep
72 
73 #endif //RecoBTag_FeatureTools_NeutralCandidateConverter_h
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
Base class for all types of Jets.
Definition: Jet.h:20
std::pair< float, float > getDRSubjetFeatures(const reco::Jet &jet, const reco::Candidate *cand)
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
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
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
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)