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 float drminpfcandsv,
17  const float jetR,
18  NeutralCandidateFeatures& n_pf_features);
19 
21  const reco::Jet& jet,
22  const float drminpfcandsv,
23  const float jetR,
24  const float puppiw,
25  NeutralCandidateFeatures& n_pf_features);
26 
27  template <typename CandidateType>
28  static void commonCandidateToFeatures(const CandidateType* n_pf,
29  const reco::Jet& jet,
30  const float& drminpfcandsv,
31  const float& jetR,
32  NeutralCandidateFeatures& n_pf_features) {
33  const auto* patJet = dynamic_cast<const pat::Jet*>(&jet);
34 
35  if (!patJet) {
36  throw edm::Exception(edm::errors::InvalidReference) << "Input is not a pat::Jet.";
37  }
38  // Do Subjets
39  if (patJet->nSubjetCollections() > 0) {
40  auto subjets = patJet->subjets();
41  // sort by pt
42  std::sort(subjets.begin(), subjets.end(), [](const edm::Ptr<pat::Jet>& p1, const edm::Ptr<pat::Jet>& p2) {
43  return p1->pt() > p2->pt();
44  });
45  n_pf_features.drsubjet1 = !subjets.empty() ? reco::deltaR(*n_pf, *subjets.at(0)) : -1;
46  n_pf_features.drsubjet2 = subjets.size() > 1 ? reco::deltaR(*n_pf, *subjets.at(1)) : -1;
47  } else {
48  n_pf_features.drsubjet1 = -1;
49  n_pf_features.drsubjet2 = -1;
50  }
51 
52  // Jet relative vars
53  n_pf_features.ptrel = catch_infs_and_bound(n_pf->pt() / jet.pt(), 0, -1, 0, -1);
54  n_pf_features.ptrel_noclip = n_pf->pt() / jet.pt();
55  n_pf_features.deltaR = catch_infs_and_bound(reco::deltaR(*n_pf, jet), 0, -0.6, 0, -0.6);
56  n_pf_features.deltaR_noclip = reco::deltaR(*n_pf, jet);
57  n_pf_features.erel = n_pf->energy() / jet.energy();
58  n_pf_features.isGamma = 0;
59  if (std::abs(n_pf->pdgId()) == 22)
60  n_pf_features.isGamma = 1;
61 
62  n_pf_features.drminsv = catch_infs_and_bound(drminpfcandsv, 0, -1. * jetR, 0, -1. * jetR);
63  }
64 
65 } // namespace btagbtvdeep
66 
67 #endif //RecoBTag_FeatureTools_NeutralCandidateConverter_h
btagbtvdeep
Definition: BoostedDoubleSVTagInfoFeatures.h:4
btagbtvdeep::NeutralCandidateFeatures::deltaR_noclip
float deltaR_noclip
Definition: NeutralCandidateFeatures.h:17
btagbtvdeep::recoCandidateToFeatures
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)
Definition: ChargedCandidateConverter.cc:37
reco::Jet
Base class for all types of Jets.
Definition: Jet.h:20
btagbtvdeep::commonCandidateToFeatures
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)
Definition: ChargedCandidateConverter.h:15
edm::errors::InvalidReference
Definition: EDMException.h:39
PFCandidate.h
btagbtvdeep::NeutralCandidateFeatures::ptrel_noclip
float ptrel_noclip
Definition: NeutralCandidateFeatures.h:9
Jet.h
LHEJetFilter_cfi.jetR
jetR
Definition: LHEJetFilter_cfi.py:5
btagbtvdeep::packedCandidateToFeatures
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)
Definition: ChargedCandidateConverter.cc:5
btagbtvdeep::NeutralCandidateFeatures::deltaR
float deltaR
Definition: NeutralCandidateFeatures.h:16
pat::Jet
Analysis-level calorimeter jet class.
Definition: Jet.h:77
NeutralCandidateFeatures.h
p2
double p2[4]
Definition: TauolaWrapper.h:90
btagbtvdeep::catch_infs_and_bound
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
btagbtvdeep::NeutralCandidateFeatures::drminsv
float drminsv
Definition: NeutralCandidateFeatures.h:21
btagbtvdeep::NeutralCandidateFeatures
Definition: NeutralCandidateFeatures.h:6
pat::PackedCandidate
Definition: PackedCandidate.h:22
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
PackedCandidate.h
btagbtvdeep::NeutralCandidateFeatures::drsubjet2
float drsubjet2
Definition: NeutralCandidateFeatures.h:13
p1
double p1[4]
Definition: TauolaWrapper.h:89
btagbtvdeep::NeutralCandidateFeatures::erel
float erel
Definition: NeutralCandidateFeatures.h:10
Jet.h
btagbtvdeep::NeutralCandidateFeatures::drsubjet1
float drsubjet1
Definition: NeutralCandidateFeatures.h:12
edm::Ptr< pat::Jet >
btagbtvdeep::NeutralCandidateFeatures::isGamma
float isGamma
Definition: NeutralCandidateFeatures.h:18
metsig::jet
Definition: SignAlgoResolutions.h:47
Exception
Definition: hltDiff.cc:245
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
deep_helpers.h
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
btagbtvdeep::NeutralCandidateFeatures::ptrel
float ptrel
Definition: NeutralCandidateFeatures.h:8