CMS 3D CMS Logo

VertexMerging.cc
Go to the documentation of this file.
2 
4  : maxFraction(params.getParameter<double>("maxFraction")),
5  minSignificance(params.getParameter<double>("minSignificance")) {}
6 
7 static double computeSharedTracks(const reco::Vertex &pv, const reco::Vertex &sv) {
8  std::set<reco::TrackRef> pvTracks;
9  for (std::vector<reco::TrackBaseRef>::const_iterator iter = pv.tracks_begin(); iter != pv.tracks_end(); iter++) {
10  if (pv.trackWeight(*iter) >= 0.5)
11  pvTracks.insert(iter->castTo<reco::TrackRef>());
12  }
13 
14  unsigned int count = 0, total = 0;
15  for (std::vector<reco::TrackBaseRef>::const_iterator iter = sv.tracks_begin(); iter != sv.tracks_end(); iter++) {
16  if (sv.trackWeight(*iter) >= 0.5) {
17  total++;
18  count += pvTracks.count(iter->castTo<reco::TrackRef>());
19  }
20  }
21 
22  return (double)count / (double)total;
23 }
24 
26  VertexDistance3D dist;
27  reco::VertexCollection recoVertices;
28  for (std::vector<reco::Vertex>::const_iterator sv = secondaryVertices.begin(); sv != secondaryVertices.end(); ++sv) {
29  recoVertices.push_back(*sv);
30  }
31  for (std::vector<reco::Vertex>::iterator sv = recoVertices.begin(); sv != recoVertices.end(); ++sv) {
32  bool shared = false;
33  for (std::vector<reco::Vertex>::iterator sv2 = recoVertices.begin(); sv2 != recoVertices.end(); ++sv2) {
34  double fr = computeSharedTracks(*sv2, *sv);
35  // std::cout << sv2-recoVertices->begin() << " vs " << sv-recoVertices->begin() << " : " << fr << " " << computeSharedTracks(*sv, *sv2) << " sig " << dist.distance(*sv,*sv2).significance() << std::endl;
36  // std::cout << (fr > maxFraction) << " && " << (dist.distance(*sv,*sv2).significance() < 2) << " && " << (sv-sv2!=0) << " && " << (fr >= computeSharedTracks(*sv2, *sv)) << std::endl;
37  if (fr > maxFraction && dist.distance(*sv, *sv2).significance() < minSignificance && sv - sv2 != 0 &&
38  fr >= computeSharedTracks(*sv, *sv2)) {
39  shared = true;
40  // std::cout << "shared " << sv-recoVertices->begin() << " and " << sv2-recoVertices->begin() << " fractions: " << fr << " , " << computeSharedTracks(*sv2, *sv) << " sig: " << dist.distance(*sv,*sv2).significance() << std::endl;
41  }
42  }
43  if (shared) {
44  sv = recoVertices.erase(sv) - 1;
45  }
46  // std::cout << "it = " << sv-recoVertices->begin() << " new size is: " << recoVertices->size() << std::endl;
47  }
48 
49  return recoVertices;
50 }
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
HLT_FULL_cff.maxFraction
maxFraction
Definition: HLT_FULL_cff.py:52019
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
VertexDistance3D::distance
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
Definition: VertexDistance3D.cc:17
computeSharedTracks
static double computeSharedTracks(const reco::Vertex &pv, const reco::Vertex &sv)
Definition: VertexMerging.cc:7
edm::Ref< TrackCollection >
VertexMerging::VertexMerging
VertexMerging(const edm::ParameterSet &params)
Definition: VertexMerging.cc:3
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
VertexDistance3D
Definition: VertexDistance3D.h:13
Measurement1D::significance
double significance() const
Definition: Measurement1D.h:29
edm::ParameterSet
Definition: ParameterSet.h:47
VertexMerging::maxFraction
double maxFraction
Definition: VertexMerging.h:26
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
HLT_FULL_cff.secondaryVertices
secondaryVertices
Definition: HLT_FULL_cff.py:52018
HLT_FULL_cff.minSignificance
minSignificance
Definition: HLT_FULL_cff.py:13799
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
VertexMerging::minSignificance
double minSignificance
Definition: VertexMerging.h:27
VertexMerging.h
VertexMerging::mergeVertex
reco::VertexCollection mergeVertex(reco::VertexCollection &secondaryVertices)
Definition: VertexMerging.cc:25
reco::Vertex
Definition: Vertex.h:35