CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PrimaryVertexAssignment Class Reference

#include <PrimaryVertexAssignment.h>

Public Types

enum  Quality {
  UsedInFit =7, PrimaryDz =6, PrimaryV0 =5, BTrack =4,
  Unused =3, OtherDz =2, NotReconstructedPrimary =1, Unassigned =0
}
 

Public Member Functions

std::pair< int, PrimaryVertexAssignment::QualitychargedHadronVertex (const reco::VertexCollection &vertices, const reco::TrackRef &trackRef, const reco::Track *track, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
 
std::pair< int, PrimaryVertexAssignment::QualitychargedHadronVertex (const reco::VertexCollection &vertices, const reco::TrackRef &trackRef, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
 
std::pair< int, PrimaryVertexAssignment::QualitychargedHadronVertex (const reco::VertexCollection &vertices, const reco::PFCandidate &pfcand, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
 
std::pair< int, PrimaryVertexAssignment::QualitychargedHadronVertex (const reco::VertexCollection &vertices, const reco::RecoChargedRefCandidate &chcand, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
 
 PrimaryVertexAssignment (const edm::ParameterSet &iConfig)
 
 ~PrimaryVertexAssignment ()
 

Private Attributes

double maxDistanceToJetAxis_
 
double maxDxyForJetAxisAssigment_
 
double maxDxyForNotReconstructedPrimary_
 
double maxDxySigForNotReconstructedPrimary_
 
double maxDzErrorForPrimaryAssignment_
 
double maxDzForJetAxisAssigment_
 
double maxDzForPrimaryAssignment_
 
double maxDzSigForPrimaryAssignment_
 
double maxJetDeltaR_
 
double minJetPt_
 

Detailed Description

Definition at line 18 of file PrimaryVertexAssignment.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

PrimaryVertexAssignment::PrimaryVertexAssignment ( const edm::ParameterSet iConfig)
inline

Definition at line 22 of file PrimaryVertexAssignment.h.

22  :
23  maxDzSigForPrimaryAssignment_(iConfig.getParameter<double>("maxDzSigForPrimaryAssignment")),
24  maxDzForPrimaryAssignment_(iConfig.getParameter<double>("maxDzForPrimaryAssignment")),
25  maxDzErrorForPrimaryAssignment_(iConfig.getParameter<double>("maxDzErrorForPrimaryAssignment")),
26  maxJetDeltaR_(iConfig.getParameter<double>("maxJetDeltaR")),
27  minJetPt_(iConfig.getParameter<double>("minJetPt")),
28  maxDistanceToJetAxis_(iConfig.getParameter<double>("maxDistanceToJetAxis")),
29  maxDzForJetAxisAssigment_(iConfig.getParameter<double>("maxDzForJetAxisAssigment")),
30  maxDxyForJetAxisAssigment_(iConfig.getParameter<double>("maxDxyForJetAxisAssigment")),
31  maxDxySigForNotReconstructedPrimary_(iConfig.getParameter<double>("maxDxySigForNotReconstructedPrimary")),
32  maxDxyForNotReconstructedPrimary_(iConfig.getParameter<double>("maxDxyForNotReconstructedPrimary"))
33  {}
T getParameter(std::string const &) const
PrimaryVertexAssignment::~PrimaryVertexAssignment ( )
inline

Member Function Documentation

std::pair< int, PrimaryVertexAssignment::Quality > PrimaryVertexAssignment::chargedHadronVertex ( const reco::VertexCollection vertices,
const reco::TrackRef trackRef,
const reco::Track track,
const edm::View< reco::Candidate > &  jets,
const TransientTrackBuilder builder 
) const

Definition at line 11 of file PrimaryVertexAssignment.cc.

References funct::abs(), edm::View< T >::at(), edm::View< T >::begin(), BTrack, TransientTrackBuilder::build(), deltaR(), reco::deltaR(), SoftLeptonByDistance_cfi::distance, reco::TrackBase::dxy(), reco::TrackBase::dxyError(), allConversions_cfi::dz, reco::TrackBase::dz(), reco::TrackBase::dzError(), edm::View< T >::end(), diffTreeTool::index, IPTools::jetTrackDistance(), maxDistanceToJetAxis_, maxDxyForJetAxisAssigment_, maxDxyForNotReconstructedPrimary_, maxDxySigForNotReconstructedPrimary_, maxDzErrorForPrimaryAssignment_, maxDzForJetAxisAssigment_, maxDzForPrimaryAssignment_, maxJetDeltaR_, minJetPt_, NotReconstructedPrimary, OtherDz, PrimaryDz, mathSSE::sqrt(), Unassigned, UsedInFit, badGlobalMuonTaggersAOD_cff::vtx, and w.

Referenced by chargedHadronVertex(), PrimaryVertexSorter< ParticlesCollection >::produce(), and ~PrimaryVertexAssignment().

15  {
16 
17  int iVertex = -1;
18  size_t index=0;
19  typedef reco::VertexCollection::const_iterator IV;
21  float bestweight=0;
22  for( auto const & vtx : vertices) {
23  float w = vtx.trackWeight(trackRef);
24  if (w > bestweight){
25  bestweight=w;
26  iVertex=index;
27  }
28  index++;
29  }
30 
31 
32  if(iVertex >= 0 ) return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::UsedInFit);
33 
34  double dzmin = 1e99;
35  int vtxIdMinDz = -1;
36  for(IV iv=vertices.begin(); iv!=vertices.end(); ++iv) {
37  double dz = std::abs(track->dz(iv->position()));
38  if(dz<dzmin) {
39  dzmin = dz;
40  vtxIdMinDz = iv-vertices.begin();
41  }
42  }
43  // first use "closest in Z" with tight cuts (targetting primary particles)
44  float dzE=sqrt(track->dzError()*track->dzError()+vertices[vtxIdMinDz].covariance(2,2));
45  if(vtxIdMinDz>=0 and (dzmin < maxDzForPrimaryAssignment_ and dzmin/dzE < maxDzSigForPrimaryAssignment_ and track->dzError()<maxDzErrorForPrimaryAssignment_))
46  {
47  iVertex=vtxIdMinDz;
48  }
49  if(iVertex >= 0 ) return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::PrimaryDz);
50 
51  // if track not assigned yet, it could be a b-decay secondary , use jet axis dist criterion
52  // first find the closest jet within maxJetDeltaR_
53  int jetIdx = -1;
54  double minDeltaR = maxJetDeltaR_;
55  for(edm::View<reco::Candidate>::const_iterator ij=jets.begin(); ij!=jets.end(); ++ij)
56  {
57  if( ij->pt() < minJetPt_ ) continue; // skip jets below the jet Pt threshold
58 
59  double deltaR = reco::deltaR( *ij, *track );
60  if( deltaR < minDeltaR and track->dzError()<maxDzErrorForPrimaryAssignment_ )
61  {
62  minDeltaR = deltaR;
63  jetIdx = std::distance(jets.begin(), ij);
64  }
65  }
66  // if jet found
67  if( jetIdx!=-1 )
68  {
69  reco::TransientTrack transientTrack = builder.build(*track);
70  GlobalVector direction(jets.at(jetIdx).px(), jets.at(jetIdx).py(), jets.at(jetIdx).pz());
71  // find the vertex with the smallest distanceToJetAxis that is still within maxDistaneToJetAxis_
72  int vtxIdx = -1;
73  double minDistanceToJetAxis = maxDistanceToJetAxis_;
74  for(IV iv=vertices.begin(); iv!=vertices.end(); ++iv)
75  {
76  // only check for vertices that are close enough in Z and for tracks that have not too high dXY
77  if(std::abs(track->dz(iv->position())) > maxDzForJetAxisAssigment_ || std::abs(track->dxy(iv->position())) > maxDxyForJetAxisAssigment_)
78  continue;
79 
80  double distanceToJetAxis = IPTools::jetTrackDistance(transientTrack, direction, *iv).second.value();
81  if( distanceToJetAxis < minDistanceToJetAxis )
82  {
83  minDistanceToJetAxis = distanceToJetAxis;
84  vtxIdx = std::distance(vertices.begin(), iv);
85  }
86  }
87  if( vtxIdx>=0 )
88  {
89  iVertex=vtxIdx;
90  }
91  }
92  if(iVertex >= 0 )
93  return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::BTrack);
94 
95  // if the track is not compatible with other PVs but is compatible with the BeamSpot, we may simply have not reco'ed the PV!
96  // we still point it to the closest in Z, but flag it as possible orphan-primary
97  if(std::abs(track->dxy(vertices[0].position()))<maxDxyForNotReconstructedPrimary_ && std::abs(track->dxy(vertices[0].position())/track->dxyError())<maxDxySigForNotReconstructedPrimary_)
98  return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDz,PrimaryVertexAssignment::NotReconstructedPrimary);
99 
100  //FIXME: here we could better handle V0s and NucInt
101 
102  // all other tracks could be non-B secondaries and we just attach them with closest Z
103  if(vtxIdMinDz>=0)
104  return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDz,PrimaryVertexAssignment::OtherDz);
105  //If for some reason even the dz failed (when?) we consider the track not assigned
106  return std::pair<int,PrimaryVertexAssignment::Quality>(-1,PrimaryVertexAssignment::Unassigned);
107 }
const double w
Definition: UKUtility.cc:23
double dxyError() const
error on dxy
Definition: TrackBase.h:791
reco::TransientTrack build(const reco::Track *p) const
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:200
const_iterator begin() const
T sqrt(T t)
Definition: SSEVec.h:18
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
std::vector< LinkConnSpec >::const_iterator IT
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:604
double dzError() const
error on dz
Definition: TrackBase.h:809
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
const_reference at(size_type pos) const
const_iterator end() const
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:586
std::pair<int,PrimaryVertexAssignment::Quality> PrimaryVertexAssignment::chargedHadronVertex ( const reco::VertexCollection vertices,
const reco::TrackRef trackRef,
const edm::View< reco::Candidate > &  jets,
const TransientTrackBuilder builder 
) const
inline

Definition at line 43 of file PrimaryVertexAssignment.h.

References chargedHadronVertex().

47  {
48  return chargedHadronVertex(vertices,trackRef,&(*trackRef),jets,builder);
49  }
std::pair< int, PrimaryVertexAssignment::Quality > chargedHadronVertex(const reco::VertexCollection &vertices, const reco::TrackRef &trackRef, const reco::Track *track, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
std::pair<int,PrimaryVertexAssignment::Quality> PrimaryVertexAssignment::chargedHadronVertex ( const reco::VertexCollection vertices,
const reco::PFCandidate pfcand,
const edm::View< reco::Candidate > &  jets,
const TransientTrackBuilder builder 
) const
inline

Definition at line 51 of file PrimaryVertexAssignment.h.

References chargedHadronVertex(), reco::PFCandidate::gsfTrackRef(), edm::Ref< C, T, F >::isNull(), fwrapper::jets, reco::PFCandidate::trackRef(), and Unassigned.

54  {
55  if(pfcand.gsfTrackRef().isNull())
56  {
57  if(pfcand.trackRef().isNull())
58  return std::pair<int,PrimaryVertexAssignment::Quality>(-1,PrimaryVertexAssignment::Unassigned);
59  else
60  return chargedHadronVertex(vertices,pfcand.trackRef(),jets,builder);
61  }
62  return chargedHadronVertex(vertices,reco::TrackRef(),&(*pfcand.gsfTrackRef()),jets,builder);
63  }
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:438
vector< PseudoJet > jets
bool isNull() const
Checks for null.
Definition: Ref.h:249
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:476
std::pair< int, PrimaryVertexAssignment::Quality > chargedHadronVertex(const reco::VertexCollection &vertices, const reco::TrackRef &trackRef, const reco::Track *track, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
std::pair<int,PrimaryVertexAssignment::Quality> PrimaryVertexAssignment::chargedHadronVertex ( const reco::VertexCollection vertices,
const reco::RecoChargedRefCandidate chcand,
const edm::View< reco::Candidate > &  jets,
const TransientTrackBuilder builder 
) const
inline

Definition at line 64 of file PrimaryVertexAssignment.h.

References chargedHadronVertex(), edm::Ref< C, T, F >::isNull(), fwrapper::jets, reco::RecoChargedRefCandidate::track(), and Unassigned.

67  {
68  if(chcand.track().isNull())
69  return std::pair<int,PrimaryVertexAssignment::Quality>(-1,PrimaryVertexAssignment::Unassigned);
70  return chargedHadronVertex(vertices,chcand.track(),jets,builder);
71  }
vector< PseudoJet > jets
bool isNull() const
Checks for null.
Definition: Ref.h:249
std::pair< int, PrimaryVertexAssignment::Quality > chargedHadronVertex(const reco::VertexCollection &vertices, const reco::TrackRef &trackRef, const reco::Track *track, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const

Member Data Documentation

double PrimaryVertexAssignment::maxDistanceToJetAxis_
private

Definition at line 80 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDxyForJetAxisAssigment_
private

Definition at line 82 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDxyForNotReconstructedPrimary_
private

Definition at line 84 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDxySigForNotReconstructedPrimary_
private

Definition at line 83 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDzErrorForPrimaryAssignment_
private

Definition at line 77 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDzForJetAxisAssigment_
private

Definition at line 81 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDzForPrimaryAssignment_
private

Definition at line 76 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDzSigForPrimaryAssignment_
private

Definition at line 75 of file PrimaryVertexAssignment.h.

double PrimaryVertexAssignment::maxJetDeltaR_
private

Definition at line 78 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::minJetPt_
private

Definition at line 79 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().