CMS 3D CMS Logo

NeutralCandidateConverter.h
Go to the documentation of this file.
1 #ifndef RecoSV_DeepFlavour_NeutralCandidateConverter_h
2 #define RecoSV_DeepFlavour_NeutralCandidateConverter_h
3 
4 #include "deep_helpers.h"
6 
10 
11 namespace btagbtvdeep {
12 
14  public:
15 
16  template <typename CandidateType>
17  static void CommonCandidateToFeatures(const CandidateType * n_pf,
18  const reco::Jet & jet,
19  const float & drminpfcandsv,
20  NeutralCandidateFeatures & n_pf_features) {
21 
22  n_pf_features.ptrel = catch_infs_and_bound(n_pf->pt()/jet.pt(),
23  0,-1,0,-1);
24  n_pf_features.deltaR = catch_infs_and_bound(reco::deltaR(*n_pf,jet),
25  0,-0.6,0,-0.6);
26  n_pf_features.isGamma = 0;
27  if(std::abs(n_pf->pdgId())==22) n_pf_features.isGamma = 1;
28 
29 
30  n_pf_features.drminsv = catch_infs_and_bound(drminpfcandsv,
31  0,-0.4,0,-0.4);
32 
33  }
34 
36  const pat::Jet & jet,
37  const float drminpfcandsv,
38  NeutralCandidateFeatures & n_pf_features) {
39 
40  CommonCandidateToFeatures(n_pf, jet, drminpfcandsv, n_pf_features);
41 
42  n_pf_features.hadFrac = n_pf->hcalFraction();
43  n_pf_features.puppiw = n_pf->puppiWeight();
44 
45  }
46 
47  static void RecoCandidateToFeatures(const reco::PFCandidate * n_pf,
48  const reco::Jet & jet,
49  const float drminpfcandsv, const float puppiw,
50  NeutralCandidateFeatures & n_pf_features) {
51 
52  CommonCandidateToFeatures(n_pf, jet, drminpfcandsv, n_pf_features);
53  n_pf_features.puppiw = puppiw;
54 
55  // need to get a value map and more stuff to do properly
56  // otherwise will be different than for PackedCandidates
57  // https://github.com/cms-sw/cmssw/blob/master/PhysicsTools/PatAlgos/python/slimming/packedPFCandidates_cfi.py
58  if(abs(n_pf->pdgId()) == 1 || abs(n_pf->pdgId()) == 130) {
59  n_pf_features.hadFrac = n_pf->hcalEnergy()/(n_pf->ecalEnergy()+n_pf->hcalEnergy());
60  } else {
61  n_pf_features.hadFrac = 0;
62  }
63 
64  }
65 
66  };
67 
68 }
69 
70 #endif //RecoSV_DeepFlavour_NeutralCandidateConverter_h
float puppiWeight() const
Set both weights at once (with option for only full PUPPI)
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:222
int pdgId() const final
PDG identifier.
float hcalFraction() const
Set the fraction of Hcal needed for HF and neutral hadrons and isolated charged hadrons.
Base class for all types of Jets.
Definition: Jet.h:20
double pt() const final
transverse momentum
static void PackedCandidateToFeatures(const pat::PackedCandidate *n_pf, const pat::Jet &jet, const float drminpfcandsv, NeutralCandidateFeatures &n_pf_features)
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.h:26
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
static void CommonCandidateToFeatures(const CandidateType *n_pf, const reco::Jet &jet, const float &drminpfcandsv, NeutralCandidateFeatures &n_pf_features)
static void RecoCandidateToFeatures(const reco::PFCandidate *n_pf, const reco::Jet &jet, const float drminpfcandsv, const float puppiw, NeutralCandidateFeatures &n_pf_features)
Analysis-level calorimeter jet class.
Definition: Jet.h:80
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
double hcalEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:232