CMS 3D CMS Logo

VertexMerger.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <set>
3 
9 
20 
21 template <class VTX>
23 public:
24  typedef std::vector<VTX> Product;
26 
27  void produce(edm::Event &event, const edm::EventSetup &es) override;
28 
29 private:
30  bool trackFilter(const reco::TrackRef &track) const;
31 
33  double maxFraction;
35 };
36 
37 template <class VTX>
39  : maxFraction(params.getParameter<double>("maxFraction")),
40  minSignificance(params.getParameter<double>("minSignificance")) {
41  token_secondaryVertex = consumes<Product>(params.getParameter<edm::InputTag>("secondaryVertices"));
42  produces<Product>();
43 }
44 
45 template <class VTX>
47  using namespace reco;
48 
50  event.getByToken(token_secondaryVertex, secondaryVertices);
51 
52  VertexDistance3D dist;
53  auto recoVertices = std::make_unique<Product>();
54  for (typename Product::const_iterator sv = secondaryVertices->begin(); sv != secondaryVertices->end(); ++sv) {
55  recoVertices->push_back(*sv);
56  }
57  for (typename Product::iterator sv = recoVertices->begin(); sv != recoVertices->end(); ++sv) {
58  bool shared = false;
60  for (typename Product::iterator sv2 = recoVertices->begin(); sv2 != recoVertices->end(); ++sv2) {
61  VertexState s2(RecoVertex::convertPos(sv2->position()), RecoVertex::convertError(sv2->error()));
62  double fr = vertexTools::computeSharedTracks(*sv2, *sv);
63  // std::cout << sv2-recoVertices->begin() << " vs " << sv-recoVertices->begin() << " : " << fr << " " << computeSharedTracks(*sv, *sv2) << " sig " << dist.distance(*sv,*sv2).significance() << std::endl;
64  // std::cout << (fr > maxFraction) << " && " << (dist.distance(*sv,*sv2).significance() < 2) << " && " << (sv-sv2!=0) << " && " << (fr >= computeSharedTracks(*sv2, *sv)) << std::endl;
65  if (fr > maxFraction && dist.distance(s1, s2).significance() < minSignificance && sv - sv2 != 0 &&
66  fr >= vertexTools::computeSharedTracks(*sv, *sv2)) {
67  shared = true;
68  // std::cout << "shared " << sv-recoVertices->begin() << " and " << sv2-recoVertices->begin() << " fractions: " << fr << " , " << computeSharedTracks(*sv2, *sv) << " sig: " << dist.distance(*sv,*sv2).significance() << std::endl;
69  }
70  }
71  if (shared) {
72  sv = recoVertices->erase(sv) - 1;
73  }
74  // std::cout << "it = " << sv-recoVertices->begin() << " new size is: " << recoVertices->size() << std::endl;
75  }
76 
77  event.put(std::move(recoVertices));
78 }
79 
82 
Handle.h
TemplatedVertexMerger
Definition: VertexMerger.cc:22
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
TemplatedVertexMerger::minSignificance
double minSignificance
Definition: VertexMerger.cc:34
edm::EDGetTokenT< Product >
HLT_FULL_cff.maxFraction
maxFraction
Definition: HLT_FULL_cff.py:52022
VertexDistance3D::distance
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
Definition: VertexDistance3D.cc:17
CandidateVertexMerger
TemplatedVertexMerger< reco::VertexCompositePtrCandidate > CandidateVertexMerger
Definition: VertexMerger.cc:81
EDProducer.h
ConvertToFromReco.h
VertexDistance3D.h
indexGen.s2
s2
Definition: indexGen.py:107
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
TemplatedVertexMerger::token_secondaryVertex
edm::EDGetTokenT< Product > token_secondaryVertex
Definition: VertexMerger.cc:32
vertexTools::computeSharedTracks
double computeSharedTracks(const reco::Vertex &pv, const std::vector< reco::TrackRef > &svTracks, double minTrackWeight=0.5, float unused=0)
Definition: SharedTracks.cc:4
edm::Ref< TrackCollection >
MakerMacros.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
VertexCompositePtrCandidate.h
VertexState.h
VertexDistance3D
Definition: VertexDistance3D.h:13
Vertex.h
Measurement1D::significance
double significance() const
Definition: Measurement1D.h:29
VertexMerger
TemplatedVertexMerger< reco::Vertex > VertexMerger
Definition: VertexMerger.cc:80
edm::ParameterSet
Definition: ParameterSet.h:47
RecoVertex::convertError
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
Event.h
TemplatedVertexMerger::trackFilter
bool trackFilter(const reco::TrackRef &track) const
TemplatedVertexMerger::maxFraction
double maxFraction
Definition: VertexMerger.cc:33
edm::stream::EDProducer
Definition: EDProducer.h:38
TemplatedVertexMerger::Product
std::vector< VTX > Product
Definition: VertexMerger.cc:24
HLT_FULL_cff.secondaryVertices
secondaryVertices
Definition: HLT_FULL_cff.py:52021
edm::EventSetup
Definition: EventSetup.h:57
SharedTracks.h
InputTag.h
VertexFwd.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
TemplatedVertexMerger::TemplatedVertexMerger
TemplatedVertexMerger(const edm::ParameterSet &params)
Definition: VertexMerger.cc:38
VertexState
Definition: VertexState.h:13
HLT_FULL_cff.minSignificance
minSignificance
Definition: HLT_FULL_cff.py:13802
TemplatedVertexMerger::produce
void produce(edm::Event &event, const edm::EventSetup &es) override
Definition: VertexMerger.cc:46
RecoVertex::convertPos
reco::Vertex::Point convertPos(const GlobalPoint &p)
Definition: ConvertToFromReco.h:7
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15