CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
btagbtvdeep::TrackInfoBuilder Class Reference

#include <TrackInfoBuilder.h>

Public Member Functions

void buildTrackInfo (const reco::Candidate *candidate, const math::XYZVector &jetDir, GlobalVector refjetdirection, const reco::Vertex &pv)
 
const float getTrackDeltaR () const
 
const float getTrackEta () const
 
const float getTrackEtaRel () const
 
const float getTrackJetDistSig () const
 
const float getTrackJetDistVal () const
 
const float getTrackMomentum () const
 
const float getTrackPPar () const
 
const float getTrackPParRatio () const
 
const float getTrackPtRatio () const
 
const float getTrackPtRel () const
 
const float getTrackSip2dSig () const
 
const float getTrackSip2dVal () const
 
const float getTrackSip3dSig () const
 
const float getTrackSip3dVal () const
 
 TrackInfoBuilder (edm::ESHandle< TransientTrackBuilder > &build)
 

Private Attributes

edm::ESHandle< TransientTrackBuilderbuilder_
 
float trackDeltaR_
 
float trackEta_
 
float trackEtaRel_
 
float trackJetDistSig_
 
float trackJetDistVal_
 
float trackMomentum_
 
float trackPPar_
 
float trackPParRatio_
 
float trackPtRatio_
 
float trackPtRel_
 
float trackSip2dSig_
 
float trackSip2dVal_
 
float trackSip3dSig_
 
float trackSip3dVal_
 

Detailed Description

Definition at line 12 of file TrackInfoBuilder.h.

Constructor & Destructor Documentation

btagbtvdeep::TrackInfoBuilder::TrackInfoBuilder ( edm::ESHandle< TransientTrackBuilder > &  build)

Definition at line 15 of file TrackInfoBuilder.cc.

15  :
16  builder_(build),
17  trackMomentum_(0),
18  trackEta_(0),
19  trackEtaRel_(0),
20  trackPtRel_(0),
21  trackPPar_(0),
22  trackDeltaR_(0),
23  trackPtRatio_(0),
24  trackPParRatio_(0),
25  trackSip2dVal_(0),
26  trackSip2dSig_(0),
27  trackSip3dVal_(0),
28  trackSip3dSig_(0),
31 {
32 
33 }
edm::ESHandle< TransientTrackBuilder > builder_

Member Function Documentation

void btagbtvdeep::TrackInfoBuilder::buildTrackInfo ( const reco::Candidate candidate,
const math::XYZVector jetDir,
GlobalVector  refjetdirection,
const reco::Vertex pv 
)

Definition at line 36 of file TrackInfoBuilder.cc.

References reco::PFCandidate::bestTrack(), TransientTrackBuilder::build(), builder_, reco::deltaR(), reco::Candidate::eta(), reco::btau::etaRel(), IPTools::jetTrackDistance(), reco::Candidate::momentum(), reco::Candidate::p(), IPTools::signedImpactParameter3D(), IPTools::signedTransverseImpactParameter(), Measurement1D::significance(), mathSSE::sqrt(), trackDeltaR_, trackEta_, trackEtaRel_, trackJetDistSig_, trackJetDistVal_, trackMomentum_, trackPPar_, trackPParRatio_, trackPtRatio_, trackPtRel_, trackSip2dSig_, trackSip2dVal_, trackSip3dSig_, trackSip3dVal_, and Measurement1D::value().

Referenced by DeepBoostedJetTagInfoProducer::fillParticleFeatures().

36  {
37  TVector3 jetDir3(jetDir.x(),jetDir.y(),jetDir.z());
38 
39 
40  // deal with PAT/AOD polymorphism to get track
41  const reco::Track * track_ptr = nullptr;
42  auto packed_candidate = dynamic_cast<const pat::PackedCandidate *>(candidate);
43  auto pf_candidate = dynamic_cast<const reco::PFCandidate *>(candidate);
44  if (pf_candidate) {
45  track_ptr = pf_candidate->bestTrack(); // trackRef was sometimes null
46  } else if (packed_candidate && packed_candidate->hasTrackDetails()) {
47  // if PackedCandidate does not have TrackDetails this gives an Exception
48  // because unpackCovariance might be called for pseudoTrack/bestTrack
49  track_ptr = &(packed_candidate->pseudoTrack());
50  }
51 
52  if(!track_ptr) {
53  TVector3 trackMom3(
54  candidate->momentum().x(),
55  candidate->momentum().y(),
56  candidate->momentum().z()
57  );
58  trackMomentum_=candidate->p();
59  trackEta_= candidate->eta();
60  trackEtaRel_=reco::btau::etaRel(jetDir, candidate->momentum());
61  trackPtRel_=trackMom3.Perp(jetDir3);
62  trackPPar_=jetDir.Dot(candidate->momentum());
63  trackDeltaR_=reco::deltaR(candidate->momentum(), jetDir);
64  trackPtRatio_=trackMom3.Perp(jetDir3) / candidate->p();
65  trackPParRatio_=jetDir.Dot(candidate->momentum()) / candidate->p();
66  trackSip2dVal_=0.;
67  trackSip2dSig_=0.;
68  trackSip3dVal_=0.;
69  trackSip3dSig_=0.;
72  return;
73  }
74 
75  math::XYZVector trackMom = track_ptr->momentum();
76  double trackMag = std::sqrt(trackMom.Mag2());
77  TVector3 trackMom3(trackMom.x(),trackMom.y(),trackMom.z());
78 
79  trackMomentum_=std::sqrt(trackMom.Mag2());
80  trackEta_= trackMom.Eta();
81  trackEtaRel_=reco::btau::etaRel(jetDir, trackMom);
82  trackPtRel_=trackMom3.Perp(jetDir3);
83  trackPPar_=jetDir.Dot(trackMom);
84  trackDeltaR_=reco::deltaR(trackMom, jetDir);
85  trackPtRatio_=trackMom3.Perp(jetDir3) / trackMag;
86  trackPParRatio_=jetDir.Dot(trackMom) / trackMag;
87 
88  reco::TransientTrack transientTrack;
89  transientTrack=builder_->build(*track_ptr);
90  Measurement1D meas_ip2d=IPTools::signedTransverseImpactParameter(transientTrack, refjetdirection, pv).second;
91  Measurement1D meas_ip3d=IPTools::signedImpactParameter3D(transientTrack, refjetdirection, pv).second;
92  Measurement1D jetdist=IPTools::jetTrackDistance(transientTrack, refjetdirection, pv).second;
93  trackSip2dVal_=static_cast<float>(meas_ip2d.value());
94  trackSip2dSig_=static_cast<float>(meas_ip2d.significance());
95  trackSip3dVal_=static_cast<float>(meas_ip3d.value());
96  trackSip3dSig_=static_cast<float>(meas_ip3d.significance());
97  trackJetDistVal_=static_cast<float>(jetdist.value());
98  trackJetDistSig_=static_cast<float>(jetdist.significance());
99 
100  }
double etaRel(const math::XYZVector &dir, const math::XYZVector &track)
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
reco::TransientTrack build(const reco::Track *p) const
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
edm::ESHandle< TransientTrackBuilder > builder_
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:200
T sqrt(T t)
Definition: SSEVec.h:18
virtual double p() const =0
magnitude of momentum vector
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
double significance() const
Definition: Measurement1D.h:29
virtual double eta() const =0
momentum pseudorapidity
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
double value() const
Definition: Measurement1D.h:25
virtual Vector momentum() const =0
spatial momentum vector
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
const reco::Track * bestTrack() const override
Definition: PFCandidate.h:162
const float btagbtvdeep::TrackInfoBuilder::getTrackDeltaR ( ) const
inline

Definition at line 17 of file TrackInfoBuilder.h.

References trackDeltaR_.

Referenced by btagbtvdeep::commonCandidateToFeatures().

const float btagbtvdeep::TrackInfoBuilder::getTrackEta ( ) const
inline

Definition at line 18 of file TrackInfoBuilder.h.

References trackEta_.

const float btagbtvdeep::TrackInfoBuilder::getTrackEtaRel ( ) const
inline
const float btagbtvdeep::TrackInfoBuilder::getTrackJetDistSig ( ) const
inline

Definition at line 20 of file TrackInfoBuilder.h.

References trackJetDistSig_.

const float btagbtvdeep::TrackInfoBuilder::getTrackJetDistVal ( ) const
inline
const float btagbtvdeep::TrackInfoBuilder::getTrackMomentum ( ) const
inline

Definition at line 22 of file TrackInfoBuilder.h.

References trackMomentum_.

const float btagbtvdeep::TrackInfoBuilder::getTrackPPar ( ) const
inline

Definition at line 23 of file TrackInfoBuilder.h.

References trackPPar_.

Referenced by btagbtvdeep::commonCandidateToFeatures().

const float btagbtvdeep::TrackInfoBuilder::getTrackPParRatio ( ) const
inline
const float btagbtvdeep::TrackInfoBuilder::getTrackPtRatio ( ) const
inline
const float btagbtvdeep::TrackInfoBuilder::getTrackPtRel ( ) const
inline

Definition at line 26 of file TrackInfoBuilder.h.

References trackPtRel_.

Referenced by btagbtvdeep::commonCandidateToFeatures().

const float btagbtvdeep::TrackInfoBuilder::getTrackSip2dSig ( ) const
inline
const float btagbtvdeep::TrackInfoBuilder::getTrackSip2dVal ( ) const
inline
const float btagbtvdeep::TrackInfoBuilder::getTrackSip3dSig ( ) const
inline
const float btagbtvdeep::TrackInfoBuilder::getTrackSip3dVal ( ) const
inline

Member Data Documentation

edm::ESHandle<TransientTrackBuilder> btagbtvdeep::TrackInfoBuilder::builder_
private

Definition at line 34 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo().

float btagbtvdeep::TrackInfoBuilder::trackDeltaR_
private

Definition at line 41 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackDeltaR().

float btagbtvdeep::TrackInfoBuilder::trackEta_
private

Definition at line 37 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackEta().

float btagbtvdeep::TrackInfoBuilder::trackEtaRel_
private

Definition at line 38 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackEtaRel().

float btagbtvdeep::TrackInfoBuilder::trackJetDistSig_
private

Definition at line 50 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackJetDistSig().

float btagbtvdeep::TrackInfoBuilder::trackJetDistVal_
private

Definition at line 49 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackJetDistVal().

float btagbtvdeep::TrackInfoBuilder::trackMomentum_
private

Definition at line 36 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackMomentum().

float btagbtvdeep::TrackInfoBuilder::trackPPar_
private

Definition at line 40 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackPPar().

float btagbtvdeep::TrackInfoBuilder::trackPParRatio_
private

Definition at line 43 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackPParRatio().

float btagbtvdeep::TrackInfoBuilder::trackPtRatio_
private

Definition at line 42 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackPtRatio().

float btagbtvdeep::TrackInfoBuilder::trackPtRel_
private

Definition at line 39 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackPtRel().

float btagbtvdeep::TrackInfoBuilder::trackSip2dSig_
private

Definition at line 45 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackSip2dSig().

float btagbtvdeep::TrackInfoBuilder::trackSip2dVal_
private

Definition at line 44 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackSip2dVal().

float btagbtvdeep::TrackInfoBuilder::trackSip3dSig_
private

Definition at line 47 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackSip3dSig().

float btagbtvdeep::TrackInfoBuilder::trackSip3dVal_
private

Definition at line 46 of file TrackInfoBuilder.h.

Referenced by buildTrackInfo(), and getTrackSip3dVal().