test
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 absT, double sigmaT, double maxRecoT, double sharedTrackFraction, const reco::RecoToSimCollection *trackRecoToSimAssociation, const reco::SimToRecoCollection *trackSimToRecoAssociation)
 
 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 absT_
 
const double absZ_
 
const double maxRecoT_
 
const double maxRecoZ_
 
const edm::EDProductGetterproductGetter_
 
const double sharedTrackFraction_
 
const double sigmaT_
 
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  absT,
double  sigmaT,
double  maxRecoT,
double  sharedTrackFraction,
const reco::RecoToSimCollection trackRecoToSimAssociation,
const reco::SimToRecoCollection trackSimToRecoAssociation 
)

Definition at line 7 of file VertexAssociatorByPositionAndTracks.cc.

16  :
17  productGetter_(productGetter),
18  absZ_(absZ),
19  sigmaZ_(sigmaZ),
20  maxRecoZ_(maxRecoZ),
21  absT_(absT),
22  sigmaT_(sigmaT),
23  maxRecoT_(maxRecoT),
24  sharedTrackFraction_(sharedTrackFraction),
25  trackRecoToSimAssociation_(trackRecoToSimAssociation),
26  trackSimToRecoAssociation_(trackSimToRecoAssociation)
27 {}
const reco::RecoToSimCollection * trackRecoToSimAssociation_
const reco::SimToRecoCollection * trackSimToRecoAssociation_
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 29 of file VertexAssociatorByPositionAndTracks.cc.

35  :
36  productGetter_(productGetter),
37  absZ_(absZ),
38  sigmaZ_(sigmaZ),
39  maxRecoZ_(maxRecoZ),
43  sharedTrackFraction_(sharedTrackFraction),
44  trackRecoToSimAssociation_(trackRecoToSimAssociation),
45  trackSimToRecoAssociation_(trackSimToRecoAssociation)
46 {}
const reco::RecoToSimCollection * trackRecoToSimAssociation_
const reco::SimToRecoCollection * trackSimToRecoAssociation_
VertexAssociatorByPositionAndTracks::~VertexAssociatorByPositionAndTracks ( )
virtual

Definition at line 48 of file VertexAssociatorByPositionAndTracks.cc.

48 {}

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 50 of file VertexAssociatorByPositionAndTracks.cc.

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

51  {
53 
54  const edm::View<reco::Vertex>& recoVertices = *vCH;
55  const TrackingVertexCollection& simVertices = *tVCH;
56 
57  LogDebug("VertexAssociation") << "VertexAssociatorByPositionAndTracks::associateRecoToSim(): associating "
58  << recoVertices.size() << " reco::Vertices to" << simVertices.size() << " TrackingVertices";
59 
60  for(size_t iReco=0; iReco != recoVertices.size(); ++iReco) {
61  const reco::Vertex& recoVertex = recoVertices[iReco];
62 
63  // skip fake vertices
64  if(std::abs(recoVertex.z()) > maxRecoZ_ || recoVertex.isFake() || !recoVertex.isValid() || recoVertex.ndof() < 0.)
65  continue;
66 
67  LogTrace("VertexAssociation") << " reco::Vertex at Z " << recoVertex.z();
68 
69  int current_event = -1;
70  for(size_t iSim=0; iSim != simVertices.size(); ++iSim) {
71  const TrackingVertex& simVertex = simVertices[iSim];
72 
73  // Associate only to primary vertices of the in-time pileup
74  // events (BX=0, first vertex in each of the events)
75  if(simVertex.eventId().bunchCrossing() != 0) continue;
76  if(simVertex.eventId().event() != current_event) {
77  current_event = simVertex.eventId().event();
78  }
79  else {
80  continue;
81  }
82 
83  LogTrace("VertexAssociation") << " Considering TrackingVertex at Z " << simVertex.position().z();
84 
85  // recoVertex.t() == 0. is a special value
86  // need to change this to std::numeric_limits<double>::max() or something more clear
87  const bool useTiming = ( absT_ != std::numeric_limits<double>::max() && recoVertex.t() != 0. );
88  if( useTiming ) {
89  LogTrace("VertexAssociation") << " and T " << recoVertex.t()*CLHEP::second << std::endl;
90  }
91 
92  const double tdiff = std::abs(recoVertex.t() - simVertex.position().t()*CLHEP::second);
93  const double zdiff = std::abs(recoVertex.z() - simVertex.position().z());
94  if( zdiff < absZ_ && zdiff / recoVertex.zError() < sigmaZ_ &&
95  ( !useTiming || ( tdiff < absT_ && tdiff / recoVertex.tError() < sigmaT_ ) ) ) {
96  auto sharedTracks = calculateVertexSharedTracks(recoVertex, simVertex, *trackRecoToSimAssociation_);
97  auto fraction = double(sharedTracks)/recoVertex.tracksSize();
98  if(sharedTrackFraction_ < 0 || fraction > sharedTrackFraction_) {
99  LogTrace("VertexAssociation") << " Matched with significance " << zdiff/recoVertex.zError() << " " << tdiff/recoVertex.tError()
100  << " shared tracks " << sharedTracks << " reco Tracks " << recoVertex.tracksSize() << " TrackingParticles " << simVertex.nDaughterTracks();
101 
102  ret.insert(reco::VertexBaseRef(vCH, iReco), std::make_pair(TrackingVertexRef(tVCH, iSim), sharedTracks));
103  }
104  }
105  }
106  }
107 
108  ret.post_insert();
109 
110  LogDebug("VertexAssociation") << "VertexAssociatorByPositionAndTracks::associateRecoToSim(): finished";
111 
112  return ret;
113 }
#define LogDebug(id)
tuple ret
prodAgent to be discontinued
int event() const
get the contents of the subdetector field (should be protected?)
double zError() const
error on z
Definition: Vertex.h:123
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:68
size_type size() const
const reco::RecoToSimCollection * trackRecoToSimAssociation_
U second(std::pair< T, U > const &p)
int bunchCrossing() const
get the detector field from this detid
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double z() const
z coordinate
Definition: Vertex.h:115
#define LogTrace(id)
double ndof() const
Definition: Vertex.h:105
edm::Ref< TrackingVertexCollection > TrackingVertexRef
bool isFake() const
Definition: Vertex.h:72
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)
double tError() const
error on t
Definition: Vertex.h:125
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:71
double t() const
t coordinate
Definition: Vertex.h:117
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 115 of file VertexAssociatorByPositionAndTracks.cc.

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

116  {
118 
119  const edm::View<reco::Vertex>& recoVertices = *vCH;
120  const TrackingVertexCollection& simVertices = *tVCH;
121 
122  LogDebug("VertexAssociation") << "VertexAssociatorByPositionAndTracks::associateSimToReco(): associating "
123  << simVertices.size() << " TrackingVertices to " << recoVertices.size() << " reco::Vertices";
124 
125  int current_event = -1;
126  for(size_t iSim=0; iSim != simVertices.size(); ++iSim) {
127  const TrackingVertex& simVertex = simVertices[iSim];
128 
129  // Associate only primary vertices of the in-time pileup
130  // events (BX=0, first vertex in each of the events)
131  if(simVertex.eventId().bunchCrossing() != 0) continue;
132  if(simVertex.eventId().event() != current_event) {
133  current_event = simVertex.eventId().event();
134  }
135  else {
136  continue;
137  }
138 
139  LogTrace("VertexAssociation") << " TrackingVertex at Z " << simVertex.position().z();
140 
141  for(size_t iReco=0; iReco != recoVertices.size(); ++iReco) {
142  const reco::Vertex& recoVertex = recoVertices[iReco];
143 
144  // skip fake vertices
145  if(std::abs(recoVertex.z()) > maxRecoZ_ || recoVertex.isFake() || !recoVertex.isValid() || recoVertex.ndof() < 0.)
146  continue;
147 
148  LogTrace("VertexAssociation") << " Considering reco::Vertex at Z " << recoVertex.z();
149  const bool useTiming = ( absT_ != std::numeric_limits<double>::max() && recoVertex.t() != 0. );
150  if( useTiming ) {
151  LogTrace("VertexAssociation") << " and T " << recoVertex.t()*CLHEP::second << std::endl;
152  }
153 
154  const double tdiff = std::abs(recoVertex.t() - simVertex.position().t()*CLHEP::second);
155  const double zdiff = std::abs(recoVertex.z() - simVertex.position().z());
156  if( zdiff < absZ_ && zdiff / recoVertex.zError() < sigmaZ_ &&
157  ( !useTiming || ( tdiff < absT_ && tdiff / recoVertex.tError() < sigmaT_ ) ) ) {
158  auto sharedTracks = calculateVertexSharedTracks(simVertex, recoVertex, *trackSimToRecoAssociation_);
159  auto fraction = double(sharedTracks)/recoVertex.tracksSize();
160  if(sharedTrackFraction_ < 0 || fraction > sharedTrackFraction_) {
161  LogTrace("VertexAssociation") << " Matched with significance " << zdiff/recoVertex.zError() << " " << tdiff/recoVertex.tError()
162  << " shared tracks " << sharedTracks << " reco Tracks " << recoVertex.tracksSize() << " TrackingParticles " << simVertex.nDaughterTracks();
163 
164  ret.insert(TrackingVertexRef(tVCH, iSim), std::make_pair(reco::VertexBaseRef(vCH, iReco), sharedTracks));
165  }
166  }
167  }
168  }
169 
170  ret.post_insert();
171 
172  LogDebug("VertexAssociation") << "VertexAssociatorByPositionAndTracks::associateSimToReco(): finished";
173 
174  return ret;
175 }
#define LogDebug(id)
tuple ret
prodAgent to be discontinued
int event() const
get the contents of the subdetector field (should be protected?)
double zError() const
error on z
Definition: Vertex.h:123
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:68
size_type size() const
U second(std::pair< T, U > const &p)
int bunchCrossing() const
get the detector field from this detid
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double z() const
z coordinate
Definition: Vertex.h:115
#define LogTrace(id)
double ndof() const
Definition: Vertex.h:105
edm::Ref< TrackingVertexCollection > TrackingVertexRef
bool isFake() const
Definition: Vertex.h:72
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_
double tError() const
error on t
Definition: Vertex.h:125
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:71
double t() const
t coordinate
Definition: Vertex.h:117
const LorentzVector & position() const

Member Data Documentation

const double VertexAssociatorByPositionAndTracks::absT_
private

Definition at line 53 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const double VertexAssociatorByPositionAndTracks::absZ_
private

Definition at line 50 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const double VertexAssociatorByPositionAndTracks::maxRecoT_
private

Definition at line 55 of file VertexAssociatorByPositionAndTracks.h.

const double VertexAssociatorByPositionAndTracks::maxRecoZ_
private

Definition at line 52 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const edm::EDProductGetter* VertexAssociatorByPositionAndTracks::productGetter_
private

Definition at line 48 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const double VertexAssociatorByPositionAndTracks::sharedTrackFraction_
private

Definition at line 56 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const double VertexAssociatorByPositionAndTracks::sigmaT_
private

Definition at line 54 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const double VertexAssociatorByPositionAndTracks::sigmaZ_
private

Definition at line 51 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim(), and associateSimToReco().

const reco::RecoToSimCollection* VertexAssociatorByPositionAndTracks::trackRecoToSimAssociation_
private

Definition at line 58 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateRecoToSim().

const reco::SimToRecoCollection* VertexAssociatorByPositionAndTracks::trackSimToRecoAssociation_
private

Definition at line 59 of file VertexAssociatorByPositionAndTracks.h.

Referenced by associateSimToReco().