Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:38

0001 #include "RecoBTag/FeatureTools/interface/ChargedCandidateConverter.h"
0002 
0003 namespace btagbtvdeep {
0004 
0005   void packedCandidateToFeatures(const pat::PackedCandidate* c_pf,
0006                                  const pat::Jet& jet,
0007                                  const TrackInfoBuilder& track_info,
0008                                  const float drminpfcandsv,
0009                                  const float jetR,
0010                                  ChargedCandidateFeatures& c_pf_features,
0011                                  const bool flip) {
0012     commonCandidateToFeatures(c_pf, jet, track_info, drminpfcandsv, jetR, c_pf_features, flip);
0013 
0014     c_pf_features.vtx_ass = c_pf->pvAssociationQuality();
0015 
0016     c_pf_features.puppiw = c_pf->puppiWeight();
0017 
0018     // if PackedCandidate does not have TrackDetails this gives an Exception
0019     // because unpackCovariance might be called for pseudoTrack/bestTrack
0020     if (c_pf->hasTrackDetails()) {
0021       const auto& pseudo_track = c_pf->pseudoTrack();
0022       c_pf_features.chi2 = catch_infs_and_bound(pseudo_track.normalizedChi2(), 300, -1, 300);
0023       // this returns the quality enum not a mask.
0024       c_pf_features.quality = pseudo_track.qualityMask();
0025     } else {
0026       // default negative chi2 and loose track if notTrackDetails
0027       c_pf_features.chi2 = catch_infs_and_bound(-1, 300, -1, 300);
0028       c_pf_features.quality = (1 << reco::TrackBase::loose);
0029     }
0030 
0031     c_pf_features.dxy = catch_infs(c_pf->dxy());
0032     c_pf_features.dz = catch_infs(c_pf->dz());
0033     c_pf_features.dxysig = c_pf->bestTrack() ? catch_infs(c_pf->dxy() / c_pf->dxyError()) : 0;
0034     c_pf_features.dzsig = c_pf->bestTrack() ? catch_infs(c_pf->dz() / c_pf->dzError()) : 0;
0035   }
0036 
0037   void recoCandidateToFeatures(const reco::PFCandidate* c_pf,
0038                                const reco::Jet& jet,
0039                                const TrackInfoBuilder& track_info,
0040                                const float drminpfcandsv,
0041                                const float jetR,
0042                                const float puppiw,
0043                                const int pv_ass_quality,
0044                                const reco::VertexRef& pv,
0045                                ChargedCandidateFeatures& c_pf_features,
0046                                const bool flip) {
0047     commonCandidateToFeatures(c_pf, jet, track_info, drminpfcandsv, jetR, c_pf_features, flip);
0048 
0049     c_pf_features.vtx_ass = vtx_ass_from_pfcand(*c_pf, pv_ass_quality, pv);
0050     c_pf_features.puppiw = puppiw;
0051 
0052     const auto& pseudo_track = (c_pf->bestTrack()) ? *c_pf->bestTrack() : reco::Track();
0053     c_pf_features.chi2 = catch_infs_and_bound(std::floor(pseudo_track.normalizedChi2()), 300, -1, 300);
0054     c_pf_features.quality = quality_from_pfcand(*c_pf);
0055 
0056     // To be implemented if FatJet tag becomes RECO compatible
0057     // const auto *trk =
0058     // float dz =
0059     // float dxy =
0060 
0061     // c_pf_features.dxy =
0062     // c_pf_features.dz =
0063     // c_pf_features.dxysig =
0064     // c_pf_features.dzsig =
0065   }
0066 
0067 }  // namespace btagbtvdeep