Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef RecoBTag_FeatureTools_ChargedCandidateConverter_h
0002 #define RecoBTag_FeatureTools_ChargedCandidateConverter_h
0003 
0004 #include "RecoBTag/FeatureTools/interface/deep_helpers.h"
0005 #include "RecoBTag/FeatureTools/interface/TrackInfoBuilder.h"
0006 #include "DataFormats/BTauReco/interface/ChargedCandidateFeatures.h"
0007 
0008 #include "DataFormats/PatCandidates/interface/PackedCandidate.h"
0009 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0010 #include "DataFormats/PatCandidates/interface/Jet.h"
0011 
0012 namespace btagbtvdeep {
0013 
0014   template <typename CandidateType>
0015   void commonCandidateToFeatures(const CandidateType* c_pf,
0016                                  const reco::Jet& jet,
0017                                  const TrackInfoBuilder& track_info,
0018                                  const bool& isWeightedJet,
0019                                  const float& drminpfcandsv,
0020                                  const float& jetR,
0021                                  const float& puppiw,
0022                                  ChargedCandidateFeatures& c_pf_features,
0023                                  const bool flip = false,
0024                                  const float& distminpfcandsv = 0) {
0025     float trackSip2dVal = track_info.getTrackSip2dVal();
0026     float trackSip2dSig = track_info.getTrackSip2dSig();
0027     float trackSip3dVal = track_info.getTrackSip3dVal();
0028     float trackSip3dSig = track_info.getTrackSip3dSig();
0029     if (flip == true) {
0030       trackSip2dVal = -trackSip2dVal;
0031       trackSip2dSig = -trackSip2dSig;
0032       trackSip3dSig = -trackSip3dSig;
0033       trackSip3dVal = -trackSip3dVal;
0034     }
0035 
0036     c_pf_features.deltaR = reco::deltaR(*c_pf, jet);
0037 
0038     float constituentWeight = 1.;
0039     if (isWeightedJet)
0040       constituentWeight = puppiw;
0041 
0042     c_pf_features.ptrel = catch_infs_and_bound((c_pf->pt() * constituentWeight) / jet.pt(), 0, -1, 0, -1);
0043     c_pf_features.ptrel_noclip = (c_pf->pt() * constituentWeight) / jet.pt();
0044     c_pf_features.erel = (c_pf->energy() * constituentWeight) / jet.energy();
0045 
0046     const float etasign = jet.eta() > 0 ? 1 : -1;
0047     c_pf_features.etarel = etasign * (c_pf->eta() - jet.eta());
0048 
0049     c_pf_features.btagPf_trackEtaRel = catch_infs_and_bound(track_info.getTrackEtaRel(), 0, -5, 15);
0050     c_pf_features.btagPf_trackPtRel = catch_infs_and_bound(track_info.getTrackPtRel(), 0, -1, 4);
0051     c_pf_features.btagPf_trackPPar = catch_infs_and_bound(track_info.getTrackPPar(), 0, -1e5, 1e5);
0052     c_pf_features.btagPf_trackDeltaR = catch_infs_and_bound(track_info.getTrackDeltaR(), 0, -5, 5);
0053     c_pf_features.btagPf_trackPtRatio = catch_infs_and_bound(track_info.getTrackPtRatio(), 0, -1, 10);
0054     c_pf_features.btagPf_trackPParRatio = catch_infs_and_bound(track_info.getTrackPParRatio(), 0, -10, 100);
0055     c_pf_features.btagPf_trackSip3dVal = catch_infs_and_bound(trackSip3dVal, 0, -1, 1e5);
0056     c_pf_features.btagPf_trackSip3dSig = catch_infs_and_bound(trackSip3dSig, 0, -1, 4e4);
0057     c_pf_features.btagPf_trackSip2dVal = catch_infs_and_bound(trackSip2dVal, 0, -1, 70);
0058     c_pf_features.btagPf_trackSip2dSig = catch_infs_and_bound(trackSip2dSig, 0, -1, 4e4);
0059     c_pf_features.btagPf_trackJetDistVal = catch_infs_and_bound(track_info.getTrackJetDistVal(), 0, -20, 1);
0060 
0061     c_pf_features.drminsv = catch_infs_and_bound(drminpfcandsv, 0, -1. * jetR, 0, -1. * jetR);
0062     c_pf_features.distminsv = distminpfcandsv;
0063 
0064     std::pair<float, float> drSubjetFeatures = getDRSubjetFeatures(jet, c_pf);
0065     c_pf_features.drsubjet1 = drSubjetFeatures.first;
0066     c_pf_features.drsubjet2 = drSubjetFeatures.second;
0067 
0068     c_pf_features.pt = c_pf->pt();
0069     c_pf_features.eta = c_pf->eta();
0070     c_pf_features.phi = c_pf->phi();
0071     c_pf_features.e = c_pf->energy();
0072     c_pf_features.px = c_pf->px();
0073     c_pf_features.py = c_pf->py();
0074     c_pf_features.pz = c_pf->pz();
0075   }
0076 
0077   void packedCandidateToFeatures(const pat::PackedCandidate* c_pf,
0078                                  const pat::Jet& jet,
0079                                  const TrackInfoBuilder& track_info,
0080                                  const bool isWeightedJet,
0081                                  const float drminpfcandsv,
0082                                  const float jetR,
0083                                  const float puppiw,
0084                                  ChargedCandidateFeatures& c_pf_features,
0085                                  const bool flip = false,
0086                                  const float distminpfcandsv = 0);
0087 
0088   void recoCandidateToFeatures(const reco::PFCandidate* c_pf,
0089                                const reco::Jet& jet,
0090                                const TrackInfoBuilder& track_info,
0091                                const bool isWeightedJet,
0092                                const float drminpfcandsv,
0093                                const float jetR,
0094                                const float puppiw,
0095                                const int pv_ass_quality,
0096                                const reco::VertexRef& pv,
0097                                ChargedCandidateFeatures& c_pf_features,
0098                                const bool flip = false,
0099                                const float distminpfcandsv = 0);
0100 
0101 }  // namespace btagbtvdeep
0102 
0103 #endif  //RecoBTag_FeatureTools_ChargedCandidateConverter_h