Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:58:45

0001 #ifndef RecoBTag_FeatureTools_NeutralCandidateConverter_h
0002 #define RecoBTag_FeatureTools_NeutralCandidateConverter_h
0003 
0004 #include "RecoBTag/FeatureTools/interface/deep_helpers.h"
0005 #include "DataFormats/BTauReco/interface/NeutralCandidateFeatures.h"
0006 
0007 #include "DataFormats/PatCandidates/interface/PackedCandidate.h"
0008 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0009 #include "DataFormats/JetReco/interface/Jet.h"
0010 #include "DataFormats/PatCandidates/interface/Jet.h"
0011 
0012 namespace btagbtvdeep {
0013 
0014   void packedCandidateToFeatures(const pat::PackedCandidate* n_pf,
0015                                  const pat::Jet& jet,
0016                                  const bool isWeightedJet,
0017                                  const float drminpfcandsv,
0018                                  const float jetR,
0019                                  const float puppiw,
0020                                  NeutralCandidateFeatures& n_pf_features);
0021 
0022   void recoCandidateToFeatures(const reco::PFCandidate* n_pf,
0023                                const reco::Jet& jet,
0024                                const bool isWeightedJet,
0025                                const float drminpfcandsv,
0026                                const float jetR,
0027                                const float puppiw,
0028                                NeutralCandidateFeatures& n_pf_features);
0029 
0030   template <typename CandidateType>
0031   static void commonCandidateToFeatures(const CandidateType* n_pf,
0032                                         const reco::Jet& jet,
0033                                         const bool& isWeightedJet,
0034                                         const float& drminpfcandsv,
0035                                         const float& jetR,
0036                                         const float& puppiw,
0037                                         NeutralCandidateFeatures& n_pf_features) {
0038     std::pair<float, float> drSubjetFeatures = getDRSubjetFeatures(jet, n_pf);
0039     n_pf_features.drsubjet1 = drSubjetFeatures.first;
0040     n_pf_features.drsubjet2 = drSubjetFeatures.second;
0041 
0042     float constituentWeight = 1.;
0043     if (isWeightedJet)
0044       constituentWeight = puppiw;
0045 
0046     // Jet relative vars
0047     n_pf_features.ptrel = catch_infs_and_bound((n_pf->pt() * constituentWeight) / jet.pt(), 0, -1, 0, -1);
0048     n_pf_features.ptrel_noclip = (n_pf->pt() * constituentWeight) / jet.pt();
0049     n_pf_features.erel = (n_pf->energy() * constituentWeight) / jet.energy();
0050 
0051     n_pf_features.deltaR = catch_infs_and_bound(reco::deltaR(*n_pf, jet), 0, -0.6, 0, -0.6);
0052     n_pf_features.deltaR_noclip = reco::deltaR(*n_pf, jet);
0053 
0054     n_pf_features.isGamma = 0;
0055     if (std::abs(n_pf->pdgId()) == 22)
0056       n_pf_features.isGamma = 1;
0057 
0058     n_pf_features.drminsv = catch_infs_and_bound(drminpfcandsv, 0, -1. * jetR, 0, -1. * jetR);
0059 
0060     n_pf_features.etarel = catch_infs_and_bound(std::fabs(n_pf->eta() - jet.eta()), 0, -2, 0, -0.5);
0061     n_pf_features.phirel = catch_infs_and_bound(std::fabs(reco::deltaPhi(n_pf->phi(), jet.phi())), 0, -2, 0, -0.5);
0062     n_pf_features.pt = n_pf->pt();
0063     n_pf_features.eta = n_pf->eta();
0064     n_pf_features.phi = n_pf->phi();
0065     n_pf_features.e = n_pf->energy();
0066     n_pf_features.px = n_pf->px();
0067     n_pf_features.py = n_pf->py();
0068     n_pf_features.pz = n_pf->pz();
0069   }
0070 
0071 }  // namespace btagbtvdeep
0072 
0073 #endif  //RecoBTag_FeatureTools_NeutralCandidateConverter_h