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

Referenced by chargedHadronVertex().

14  {
15 
16  int iVertex = -1;
17  size_t index=0;
18  typedef reco::VertexCollection::const_iterator IV;
20  float bestweight=0;
21  for( auto const & vtx : vertices) {
22  float w = vtx.trackWeight(track);
23  if (w > bestweight){
24  bestweight=w;
25  iVertex=index;
26  }
27  index++;
28  }
29 
30 
31  if(iVertex >= 0 ) return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::UsedInFit);
32 
33  double dzmin = 1e99;
34  int vtxIdMinDz = -1;
35  for(IV iv=vertices.begin(); iv!=vertices.end(); ++iv) {
36  double dz = std::abs(track->dz(iv->position()));
37  if(dz<dzmin) {
38  dzmin = dz;
39  vtxIdMinDz = iv-vertices.begin();
40  }
41  }
42  // first use "closest in Z" with tight cuts (targetting primary particles)
43  if(vtxIdMinDz>=0 and (dzmin < maxDzForPrimaryAssignment_ or dzmin/track->dzError() < maxDzSigForPrimaryAssignment_ ))
44  {
45  iVertex=vtxIdMinDz;
46  }
47  if(iVertex >= 0 ) return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::PrimaryDz);
48 
49  // if track not assigned yet, it could be a b-decay secondary , use jet axis dist criterion
50  // first find the closest jet within maxJetDeltaR_
51  int jetIdx = -1;
52  double minDeltaR = maxJetDeltaR_;
53  for(edm::View<reco::Candidate>::const_iterator ij=jets.begin(); ij!=jets.end(); ++ij)
54  {
55  if( ij->pt() < minJetPt_ ) continue; // skip jets below the jet Pt threshold
56 
57  double deltaR = reco::deltaR( *ij, *track );
58  if( deltaR < minDeltaR )
59  {
60  minDeltaR = deltaR;
61  jetIdx = std::distance(jets.begin(), ij);
62  }
63  }
64  // if jet found
65  if( jetIdx!=-1 )
66  {
67  reco::TransientTrack transientTrack = builder.build(*track);
68  GlobalVector direction(jets.at(jetIdx).px(), jets.at(jetIdx).py(), jets.at(jetIdx).pz());
69  // find the vertex with the smallest distanceToJetAxis that is still within maxDistaneToJetAxis_
70  int vtxIdx = -1;
71  double minDistanceToJetAxis = maxDistanceToJetAxis_;
72  for(IV iv=vertices.begin(); iv!=vertices.end(); ++iv)
73  {
74  // only check for vertices that are close enough in Z and for tracks that have not too high dXY
75  if(std::abs(track->dz(iv->position())) > maxDzForJetAxisAssigment_ || std::abs(track->dxy(iv->position())) > maxDxyForJetAxisAssigment_)
76  continue;
77 
78  double distanceToJetAxis = IPTools::jetTrackDistance(transientTrack, direction, *iv).second.value();
79  if( distanceToJetAxis < minDistanceToJetAxis )
80  {
81  minDistanceToJetAxis = distanceToJetAxis;
82  vtxIdx = std::distance(vertices.begin(), iv);
83  }
84  }
85  if( vtxIdx>=0 )
86  {
87  iVertex=vtxIdx;
88  }
89  }
90  if(iVertex >= 0 )
91  return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::BTrack);
92 
93  // if the track is not compatible with other PVs but is compatible with the BeamSpot, we may simply have not reco'ed the PV!
94  // we still point it to the closest in Z, but flag it as possible orphan-primary
95  if(track->dxy(vertices[0].position())<maxDxyForNotReconstructedPrimary_ && track->dxy(vertices[0].position())/track->dxyError()<maxDxySigForNotReconstructedPrimary_)
96  return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDz,PrimaryVertexAssignment::NotReconstructedPrimary);
97 
98  //FIXME: here we could better handle V0s and NucInt
99 
100  // all other tracks could be non-B secondaries and we just attach them with closest Z
101  if(vtxIdMinDz>=0)
102  return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDz,PrimaryVertexAssignment::OtherDz);
103 
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
reco::TransientTrack build(const reco::Track *p) const
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
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
std::vector< LinkConnSpec >::const_iterator IT
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
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 57 of file PrimaryVertexAssignment.h.

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

60  {
61  if(pfcand.trackRef().isNull())
62  return std::pair<int,PrimaryVertexAssignment::Quality>(-1,PrimaryVertexAssignment::Unassigned);
63  return chargedHadronVertex(vertices,pfcand.trackRef(),jets,builder);
64  }
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
vector< PseudoJet > jets
bool isNull() const
Checks for null.
Definition: Ref.h:247
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> PrimaryVertexAssignment::chargedHadronVertex ( const reco::VertexCollection vertices,
const reco::RecoChargedRefCandidate chcand,
const edm::View< reco::Candidate > &  jets,
const TransientTrackBuilder builder 
) const
inline

Definition at line 65 of file PrimaryVertexAssignment.h.

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

68  {
69  if(chcand.track().isNull())
70  return std::pair<int,PrimaryVertexAssignment::Quality>(-1,PrimaryVertexAssignment::Unassigned);
71  return chargedHadronVertex(vertices,chcand.track(),jets,builder);
72  }
vector< PseudoJet > jets
bool isNull() const
Checks for null.
Definition: Ref.h:247
std::pair< int, PrimaryVertexAssignment::Quality > chargedHadronVertex(const reco::VertexCollection &vertices, const reco::TrackRef &trackRef, 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::maxDzForJetAxisAssigment_
private

Definition at line 81 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

double PrimaryVertexAssignment::maxDzForPrimaryAssignment_
private

Definition at line 77 of file PrimaryVertexAssignment.h.

double PrimaryVertexAssignment::maxDzSigForPrimaryAssignment_
private

Definition at line 76 of file PrimaryVertexAssignment.h.

Referenced by chargedHadronVertex().

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().