CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
VertexAssociatorByPositionAndTracks Class Reference

#include <VertexAssociatorByPositionAndTracks.h>

Inheritance diagram for VertexAssociatorByPositionAndTracks:
reco::VertexToTrackingVertexAssociatorBaseImpl

Public Member Functions

virtual
reco::VertexRecoToSimCollection 
associateRecoToSim (const edm::Handle< edm::View< reco::Vertex > > &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const
 compare reco to sim the handle of reco::Vertex and TrackingVertex collections More...
 
virtual
reco::VertexSimToRecoCollection 
associateSimToReco (const edm::Handle< edm::View< reco::Vertex > > &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const
 compare reco to sim the handle of reco::Vertex and TrackingVertex collections More...
 
 VertexAssociatorByPositionAndTracks (const edm::EDProductGetter *productGetter, double absZ, double sigmaZ, double maxRecoZ, double sharedTrackFraction, const reco::RecoToSimCollection *trackRecoToSimAssociation, const reco::SimToRecoCollection *trackSimToRecoAssociation)
 
virtual ~VertexAssociatorByPositionAndTracks ()
 
- Public Member Functions inherited from reco::VertexToTrackingVertexAssociatorBaseImpl
 VertexToTrackingVertexAssociatorBaseImpl ()
 Constructor. More...
 
virtual ~VertexToTrackingVertexAssociatorBaseImpl ()
 Destructor. More...
 

Private Attributes

const double absZ_
 
const double maxRecoZ_
 
const edm::EDProductGetterproductGetter_
 
const double sharedTrackFraction_
 
const double sigmaZ_
 
const reco::RecoToSimCollectiontrackRecoToSimAssociation_
 
const reco::SimToRecoCollectiontrackSimToRecoAssociation_
 

Detailed Description

This class associates reco::Vertices and TrackingVertices by their position (maximum distance in Z should be smaller than absZ and sigmaZ*zError of reco::Vertex), and (optionally) by the fraction of tracks shared by reco::Vertex and TrackingVertex divided by the number of tracks in reco::Vertex. This fraction is always used as the quality in the association, i.e. multiple associations are sorted by it in descending order.

Definition at line 16 of file VertexAssociatorByPositionAndTracks.h.

Constructor & Destructor Documentation

VertexAssociatorByPositionAndTracks::VertexAssociatorByPositionAndTracks ( const edm::EDProductGetter productGetter,
double  absZ,
double  sigmaZ,
double  maxRecoZ,
double  sharedTrackFraction,
const reco::RecoToSimCollection trackRecoToSimAssociation,
const reco::SimToRecoCollection trackSimToRecoAssociation 
)

Definition at line 6 of file VertexAssociatorByPositionAndTracks.cc.

12  :
13  productGetter_(productGetter),
14  absZ_(absZ),
15  sigmaZ_(sigmaZ),
16  maxRecoZ_(maxRecoZ),
17  sharedTrackFraction_(sharedTrackFraction),
18  trackRecoToSimAssociation_(trackRecoToSimAssociation),
19  trackSimToRecoAssociation_(trackSimToRecoAssociation)
20 {}
const reco::RecoToSimCollection * trackRecoToSimAssociation_
const reco::SimToRecoCollection * trackSimToRecoAssociation_
VertexAssociatorByPositionAndTracks::~VertexAssociatorByPositionAndTracks ( )
virtual

Definition at line 22 of file VertexAssociatorByPositionAndTracks.cc.

22 {}

Member Function Documentation

reco::VertexRecoToSimCollection VertexAssociatorByPositionAndTracks::associateRecoToSim ( const edm::Handle< edm::View< reco::Vertex > > &  vCH,
const edm::Handle< TrackingVertexCollection > &  tVCH 
) const
virtual

compare reco to sim the handle of reco::Vertex and TrackingVertex collections

Implements reco::VertexToTrackingVertexAssociatorBaseImpl.

Definition at line 24 of file VertexAssociatorByPositionAndTracks.cc.

References funct::abs(), absZ_, EncodedEventId::bunchCrossing(), calculateVertexSharedTracks(), EncodedEventId::event(), TrackingVertex::eventId(), HLT_25ns14e33_v1_cff::fraction, edm::AssociationMap< Tag >::insert(), reco::Vertex::isFake(), reco::Vertex::isValid(), LogDebug, LogTrace, maxRecoZ_, TrackingVertex::nDaughterTracks(), reco::Vertex::ndof(), TrackingVertex::position(), edm::AssociationMap< Tag >::post_insert(), productGetter_, run_regression::ret, sharedTrackFraction_, sigmaZ_, edm::View< T >::size(), trackRecoToSimAssociation_, reco::Vertex::tracksSize(), reco::Vertex::z(), and reco::Vertex::zError().

25  {
27 
28  const edm::View<reco::Vertex>& recoVertices = *vCH;
29  const TrackingVertexCollection& simVertices = *tVCH;
30 
31  LogDebug("VertexAssociation") << "VertexAssociatorByPositionAndTracks::associateRecoToSim(): associating "
32  << recoVertices.size() << " reco::Vertices to" << simVertices.size() << " TrackingVertices";
33 
34  for(size_t iReco=0; iReco != recoVertices.size(); ++iReco) {
35  const reco::Vertex& recoVertex = recoVertices[iReco];
36 
37  // skip fake vertices
38  if(std::abs(recoVertex.z()) > maxRecoZ_ || recoVertex.isFake() || !recoVertex.isValid() || recoVertex.ndof() < 0.)
39  continue;
40 
41  LogTrace("VertexAssociation") << " reco::Vertex at Z " << recoVertex.z();
42 
43  int current_event = -1;
44  for(size_t iSim=0; iSim != simVertices.size(); ++iSim) {
45  const TrackingVertex& simVertex = simVertices[iSim];
46 
47  // Associate only to primary vertices of the in-time pileup
48  // events (BX=0, first vertex in each of the events)
49  if(simVertex.eventId().bunchCrossing() != 0) continue;
50  if(simVertex.eventId().event() != current_event) {
51  current_event = simVertex.eventId().event();
52  }
53  else {
54  continue;
55  }
56 
57  LogTrace("VertexAssociation") << " Considering TrackingVertex at Z " << simVertex.position().z();
58 
59  const double zdiff = std::abs(recoVertex.z() - simVertex.position().z());
60  if(zdiff < absZ_ && zdiff / recoVertex.zError() < sigmaZ_) {
61  auto sharedTracks = calculateVertexSharedTracks(recoVertex, simVertex, *trackRecoToSimAssociation_);
62  auto fraction = double(sharedTracks)/recoVertex.tracksSize();
63  if(sharedTrackFraction_ < 0 || fraction > sharedTrackFraction_) {
64  LogTrace("VertexAssociation") << " Matched with significance " << zdiff/recoVertex.zError()
65  << " shared tracks " << sharedTracks << " reco Tracks " << recoVertex.tracksSize() << " TrackingParticles " << simVertex.nDaughterTracks();
66 
67  ret.insert(reco::VertexBaseRef(vCH, iReco), std::make_pair(TrackingVertexRef(tVCH, iSim), sharedTracks));
68  }
69  }
70  }
71  }
72 
73  ret.post_insert();
74 
75  LogDebug("VertexAssociation") << "VertexAssociatorByPositionAndTracks::associateRecoToSim(): finished";
76 
77  return ret;
78 }
#define LogDebug(id)
int event() const
get the contents of the subdetector field (should be protected?)
double zError() const
error on z
Definition: Vertex.h:118
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:60
size_type size() const
const reco::RecoToSimCollection * trackRecoToSimAssociation_
int bunchCrossing() const
get the detector field from this detid
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double z() const
y coordinate
Definition: Vertex.h:112
#define LogTrace(id)
double ndof() const
Definition: Vertex.h:102
edm::Ref< TrackingVertexCollection > TrackingVertexRef
bool isFake() const
Definition: Vertex.h:64
unsigned int nDaughterTracks() const
std::vector< TrackingVertex > TrackingVertexCollection
const EncodedEventId & eventId() const
unsigned int calculateVertexSharedTracks(const reco::Vertex &recoV, const TrackingVertex &simV, const reco::RecoToSimCollection &trackRecoToSimAssociation)
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:34
const LorentzVector & position() const
reco::VertexSimToRecoCollection VertexAssociatorByPositionAndTracks::associateSimToReco ( const edm::Handle< edm::View< reco::Vertex > > &  vCH,
const edm::Handle< TrackingVertexCollection > &  tVCH 
) const
virtual

compare reco to sim the handle of reco::Vertex and TrackingVertex collections

Implements reco::VertexToTrackingVertexAssociatorBaseImpl.

Definition at line 80 of file VertexAssociatorByPositionAndTracks.cc.

References funct::abs(), absZ_, EncodedEventId::bunchCrossing(), calculateVertexSharedTracks(), EncodedEventId::event(), TrackingVertex::eventId(), HLT_25ns14e33_v1_cff::fraction, edm::AssociationMap< Tag >::insert(), reco::Vertex::isFake(), reco::Vertex::isValid(), LogDebug, LogTrace, maxRecoZ_, TrackingVertex::nDaughterTracks(), reco::Vertex::ndof(), TrackingVertex::position(), edm::AssociationMap< Tag >::post_insert(), productGetter_, run_regression::ret, sharedTrackFraction_, sigmaZ_, edm::View< T >::size(), trackSimToRecoAssociation_, reco::Vertex::tracksSize(), reco::Vertex::z(), and reco::Vertex::zError().

81  {
83 
84  const edm::View<reco::Vertex>& recoVertices = *vCH;
85  const TrackingVertexCollection& simVertices = *tVCH;
86 
87  LogDebug("VertexAssociation") << "VertexAssociatorByPositionAndTracks::associateSimToReco(): associating "
88  << simVertices.size() << " TrackingVertices to " << recoVertices.size() << " reco::Vertices";
89 
90  int current_event = -1;
91  for(size_t iSim=0; iSim != simVertices.size(); ++iSim) {
92  const TrackingVertex& simVertex = simVertices[iSim];
93 
94  // Associate only primary vertices of the in-time pileup
95  // events (BX=0, first vertex in each of the events)
96  if(simVertex.eventId().bunchCrossing() != 0) continue;
97  if(simVertex.eventId().event() != current_event) {
98  current_event = simVertex.eventId().event();
99  }
100  else {
101  continue;
102  }
103 
104  LogTrace("VertexAssociation") << " TrackingVertex at Z " << simVertex.position().z();
105 
106  for(size_t iReco=0; iReco != recoVertices.size(); ++iReco) {
107  const reco::Vertex& recoVertex = recoVertices[iReco];
108 
109  // skip fake vertices
110  if(std::abs(recoVertex.z()) > maxRecoZ_ || recoVertex.isFake() || !recoVertex.isValid() || recoVertex.ndof() < 0.)
111  continue;
112 
113  LogTrace("VertexAssociation") << " Considering reco::Vertex at Z " << recoVertex.z();
114 
115  const double zdiff = std::abs(recoVertex.z() - simVertex.position().z());
116  if(zdiff < absZ_ && zdiff / recoVertex.zError() < sigmaZ_) {
117  auto sharedTracks = calculateVertexSharedTracks(simVertex, recoVertex, *trackSimToRecoAssociation_);
118  auto fraction = double(sharedTracks)/recoVertex.tracksSize();
119  if(sharedTrackFraction_ < 0 || fraction > sharedTrackFraction_) {
120  LogTrace("VertexAssociation") << " Matched with significance " << zdiff/recoVertex.zError()
121  << " shared tracks " << sharedTracks << " reco Tracks " << recoVertex.tracksSize() << " TrackingParticles " << simVertex.nDaughterTracks();
122 
123  ret.insert(TrackingVertexRef(tVCH, iSim), std::make_pair(reco::VertexBaseRef(vCH, iReco), sharedTracks));
124  }
125  }
126  }
127  }
128 
129  ret.post_insert();
130 
131  LogDebug("VertexAssociation") << "VertexAssociatorByPositionAndTracks::associateSimToReco(): finished";
132 
133  return ret;
134 }
#define LogDebug(id)
int event() const
get the contents of the subdetector field (should be protected?)
double zError() const
error on z
Definition: Vertex.h:118
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:60
size_type size() const
int bunchCrossing() const
get the detector field from this detid
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double z() const
y coordinate
Definition: Vertex.h:112
#define LogTrace(id)
double ndof() const
Definition: Vertex.h:102
edm::Ref< TrackingVertexCollection > TrackingVertexRef
bool isFake() const
Definition: Vertex.h:64
unsigned int nDaughterTracks() const
std::vector< TrackingVertex > TrackingVertexCollection
const EncodedEventId & eventId() const
unsigned int calculateVertexSharedTracks(const reco::Vertex &recoV, const TrackingVertex &simV, const reco::RecoToSimCollection &trackRecoToSimAssociation)
const reco::SimToRecoCollection * trackSimToRecoAssociation_
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:34
const LorentzVector & position() const

Member Data Documentation

const double VertexAssociatorByPositionAndTracks::absZ_
private

Definition at line 39 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const double VertexAssociatorByPositionAndTracks::maxRecoZ_
private

Definition at line 41 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const edm::EDProductGetter* VertexAssociatorByPositionAndTracks::productGetter_
private

Definition at line 37 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const double VertexAssociatorByPositionAndTracks::sharedTrackFraction_
private

Definition at line 42 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const double VertexAssociatorByPositionAndTracks::sigmaZ_
private

Definition at line 40 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const reco::RecoToSimCollection* VertexAssociatorByPositionAndTracks::trackRecoToSimAssociation_
private

Definition at line 44 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim().

const reco::SimToRecoCollection* VertexAssociatorByPositionAndTracks::trackSimToRecoAssociation_
private

Definition at line 45 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateSimToReco().