CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::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
chargedHadronVertex (const reco::VertexCollection &vertices, const reco::TrackRef &trackRef, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
 
std::pair< int,
PrimaryVertexAssignment::Quality
chargedHadronVertex (const reco::VertexCollection &vertices, const reco::PFCandidate &pfcand, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
 
std::pair< int,
PrimaryVertexAssignment::Quality
chargedHadronVertex (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 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  maxJetDeltaR_(iConfig.getParameter<double>("maxJetDeltaR")),
26  minJetPt_(iConfig.getParameter<double>("minJetPt")),
27  maxDistanceToJetAxis_(iConfig.getParameter<double>("maxDistanceToJetAxis")),
28  maxDzForJetAxisAssigment_(iConfig.getParameter<double>("maxDzForJetAxisAssigment")),
29  maxDxyForJetAxisAssigment_(iConfig.getParameter<double>("maxDxyForJetAxisAssigment")),
30  maxDxySigForNotReconstructedPrimary_(iConfig.getParameter<double>("maxDxySigForNotReconstructedPrimary")),
31  maxDxyForNotReconstructedPrimary_(iConfig.getParameter<double>("maxDxyForNotReconstructedPrimary"))
32  {}
T getParameter(std::string const &) const
PrimaryVertexAssignment::~PrimaryVertexAssignment ( )
inline

Definition at line 34 of file PrimaryVertexAssignment.h.

34 {}

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(), HLT_25ns10e33_v2_cff::distance, reco::TrackBase::dxy(), reco::TrackBase::dxyError(), reco::TrackBase::dz(), edm::View< T >::end(), cmsHarvester::index, IPTools::jetTrackDistance(), maxDistanceToJetAxis_, maxDxyForJetAxisAssigment_, maxDxyForNotReconstructedPrimary_, maxDxySigForNotReconstructedPrimary_, maxDzForJetAxisAssigment_, maxDzSigForPrimaryAssignment_, maxJetDeltaR_, HLT_25ns10e33_v2_cff::minDeltaR, minJetPt_, NotReconstructedPrimary, OtherDz, PrimaryDz, Unassigned, UsedInFit, and w.

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

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  if(vtxIdMinDz>=0 and (dzmin < maxDzForPrimaryAssignment_ or dzmin/track->dzError() < maxDzSigForPrimaryAssignment_ ))
45  {
46  iVertex=vtxIdMinDz;
47  }
48  if(iVertex >= 0 ) return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::PrimaryDz);
49 
50  // if track not assigned yet, it could be a b-decay secondary , use jet axis dist criterion
51  // first find the closest jet within maxJetDeltaR_
52  int jetIdx = -1;
53  double minDeltaR = maxJetDeltaR_;
54  for(edm::View<reco::Candidate>::const_iterator ij=jets.begin(); ij!=jets.end(); ++ij)
55  {
56  if( ij->pt() < minJetPt_ ) continue; // skip jets below the jet Pt threshold
57 
58  double deltaR = reco::deltaR( *ij, *track );
59  if( deltaR < minDeltaR )
60  {
61  minDeltaR = deltaR;
62  jetIdx = std::distance(jets.begin(), ij);
63  }
64  }
65  // if jet found
66  if( jetIdx!=-1 )
67  {
68  reco::TransientTrack transientTrack = builder.build(*track);
69  GlobalVector direction(jets.at(jetIdx).px(), jets.at(jetIdx).py(), jets.at(jetIdx).pz());
70  // find the vertex with the smallest distanceToJetAxis that is still within maxDistaneToJetAxis_
71  int vtxIdx = -1;
72  double minDistanceToJetAxis = maxDistanceToJetAxis_;
73  for(IV iv=vertices.begin(); iv!=vertices.end(); ++iv)
74  {
75  // only check for vertices that are close enough in Z and for tracks that have not too high dXY
76  if(std::abs(track->dz(iv->position())) > maxDzForJetAxisAssigment_ || std::abs(track->dxy(iv->position())) > maxDxyForJetAxisAssigment_)
77  continue;
78 
79  double distanceToJetAxis = IPTools::jetTrackDistance(transientTrack, direction, *iv).second.value();
80  if( distanceToJetAxis < minDistanceToJetAxis )
81  {
82  minDistanceToJetAxis = distanceToJetAxis;
83  vtxIdx = std::distance(vertices.begin(), iv);
84  }
85  }
86  if( vtxIdx>=0 )
87  {
88  iVertex=vtxIdx;
89  }
90  }
91  if(iVertex >= 0 )
92  return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::BTrack);
93 
94  // if the track is not compatible with other PVs but is compatible with the BeamSpot, we may simply have not reco'ed the PV!
95  // we still point it to the closest in Z, but flag it as possible orphan-primary
96  if(std::abs(track->dxy(vertices[0].position()))<maxDxyForNotReconstructedPrimary_ && std::abs(track->dxy(vertices[0].position())/track->dxyError())<maxDxySigForNotReconstructedPrimary_)
97  return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDz,PrimaryVertexAssignment::NotReconstructedPrimary);
98 
99  //FIXME: here we could better handle V0s and NucInt
100 
101  // all other tracks could be non-B secondaries and we just attach them with closest Z
102  if(vtxIdMinDz>=0)
103  return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDz,PrimaryVertexAssignment::OtherDz);
104  //If for some reason even the dz failed (when?) we consider the track not assigned
105  return std::pair<int,PrimaryVertexAssignment::Quality>(-1,PrimaryVertexAssignment::Unassigned);
106 }
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
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 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:81
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
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 42 of file PrimaryVertexAssignment.h.

References chargedHadronVertex().

46  {
47  return chargedHadronVertex(vertices,trackRef,&(*trackRef),jets,builder);
48  }
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 50 of file PrimaryVertexAssignment.h.

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

53  {
54  if(pfcand.gsfTrackRef().isNull())
55  {
56  if(pfcand.trackRef().isNull())
57  return std::pair<int,PrimaryVertexAssignment::Quality>(-1,PrimaryVertexAssignment::Unassigned);
58  else
59  return chargedHadronVertex(vertices,pfcand.trackRef(),jets,builder);
60  }
61  return chargedHadronVertex(vertices,reco::TrackRef(),&(*pfcand.gsfTrackRef()),jets,builder);
62  }
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
vector< PseudoJet > jets
bool isNull() const
Checks for null.
Definition: Ref.h:249
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:471
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 63 of file PrimaryVertexAssignment.h.

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

66  {
67  if(chcand.track().isNull())
68  return std::pair<int,PrimaryVertexAssignment::Quality>(-1,PrimaryVertexAssignment::Unassigned);
69  return chargedHadronVertex(vertices,chcand.track(),jets,builder);
70  }
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 78 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDxyForJetAxisAssigment_
private

Definition at line 80 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDxyForNotReconstructedPrimary_
private

Definition at line 82 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDxySigForNotReconstructedPrimary_
private

Definition at line 81 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDzForJetAxisAssigment_
private

Definition at line 79 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDzForPrimaryAssignment_
private

Definition at line 75 of file PrimaryVertexAssignment.h.

double PrimaryVertexAssignment::maxDzSigForPrimaryAssignment_
private

Definition at line 74 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxJetDeltaR_
private

Definition at line 76 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::minJetPt_
private

Definition at line 77 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().