test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  virtual 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 {
42  token_secondaryVertex = consumes<Product>(params.getParameter<edm::InputTag>("secondaryVertices"));
43  produces<Product>();
44 }
45 
46 template <class VTX>
48 {
49  using namespace reco;
50 
52  event.getByToken(token_secondaryVertex, secondaryVertices);
53 
54  VertexDistance3D dist;
55  std::auto_ptr<Product> recoVertices(new Product);
56  for(typename Product::const_iterator sv = secondaryVertices->begin();
57  sv != secondaryVertices->end(); ++sv) {
58  recoVertices->push_back(*sv);
59  }
60  for(typename Product::iterator sv = recoVertices->begin();
61  sv != recoVertices->end(); ++sv) {
62 
63  bool shared=false;
64  VertexState s1(RecoVertex::convertPos(sv->position()),RecoVertex::convertError(sv->error()));
65  for(typename Product::iterator sv2 = recoVertices->begin();
66  sv2 != recoVertices->end(); ++sv2) {
67  VertexState s2(RecoVertex::convertPos(sv2->position()),RecoVertex::convertError(sv2->error()));
68  double fr=vertexTools::computeSharedTracks(*sv2, *sv);
69  // std::cout << sv2-recoVertices->begin() << " vs " << sv-recoVertices->begin() << " : " << fr << " " << computeSharedTracks(*sv, *sv2) << " sig " << dist.distance(*sv,*sv2).significance() << std::endl;
70  // std::cout << (fr > maxFraction) << " && " << (dist.distance(*sv,*sv2).significance() < 2) << " && " << (sv-sv2!=0) << " && " << (fr >= computeSharedTracks(*sv2, *sv)) << std::endl;
71  if (fr > maxFraction && dist.distance(s1,s2).significance() < minSignificance && sv-sv2!=0
72  && fr >= vertexTools::computeSharedTracks(*sv, *sv2) )
73  {
74  shared=true;
75  // std::cout << "shared " << sv-recoVertices->begin() << " and " << sv2-recoVertices->begin() << " fractions: " << fr << " , " << computeSharedTracks(*sv2, *sv) << " sig: " << dist.distance(*sv,*sv2).significance() << std::endl;
76 
77  }
78 
79 
80  }
81  if(shared) { sv=recoVertices->erase(sv)-1; }
82  // std::cout << "it = " << sv-recoVertices->begin() << " new size is: " << recoVertices->size() << std::endl;
83  }
84 
85  event.put(recoVertices);
86 
87 
88 
89 }
90 
93 
reco::Vertex::Point convertPos(const GlobalPoint &p)
T getParameter(std::string const &) const
edm::EDGetTokenT< Product > token_secondaryVertex
Definition: VertexMerger.cc:32
TemplatedVertexMerger< reco::VertexCompositePtrCandidate > CandidateVertexMerger
Definition: VertexMerger.cc:92
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
TemplatedVertexMerger(const edm::ParameterSet &params)
Definition: VertexMerger.cc:38
std::vector< VTX > Product
Definition: VertexMerger.cc:24
double computeSharedTracks(const reco::Vertex &pv, const std::vector< reco::TrackRef > &svTracks, double minTrackWeight=0.5, float unused=0)
Definition: SharedTracks.cc:4
tuple s2
Definition: indexGen.py:106
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
TemplatedVertexMerger< reco::Vertex > VertexMerger
Definition: VertexMerger.cc:91
bool trackFilter(const reco::TrackRef &track) const
virtual void produce(edm::Event &event, const edm::EventSetup &es) override
Definition: VertexMerger.cc:47