CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GoodVertexFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: GoodVertexFilter
4 // Class: GoodVertexFilter
5 //
13 //
14 // Original Author: Andrea RIZZI
15 // Created: Mon Dec 7 18:02:10 CET 2009
16 // $Id: GoodVertexFilter.cc,v 1.4 2010/02/28 20:10:01 wmtan Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
36 //
37 // class declaration
38 //
39 
41  public:
42  explicit GoodVertexFilter(const edm::ParameterSet&);
44 
45  private:
46  virtual bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
48  const unsigned int minNDOF;
49  const double maxAbsZ;
50  const double maxd0;
51  // ----------member data ---------------------------
52 };
53 
55  vertexSrc{ consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection")) },
56  minNDOF{ iConfig.getParameter<unsigned int>("minimumNDOF") },
57  maxAbsZ{ iConfig.getParameter<double>("maxAbsZ") },
58  maxd0 { iConfig.getParameter<double>("maxd0") }
59 {
60 
61 }
62 
63 
65 {
66 }
67 
68 bool
70 {
71  bool result = false;
73  iEvent.getByToken(vertexSrc,pvHandle);
74  const reco::VertexCollection & vertices = *pvHandle.product();
75  for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it)
76  {
77  if(it->ndof() > minNDOF &&
78  ( (maxAbsZ <=0 ) || fabs(it->z()) <= maxAbsZ ) &&
79  ( (maxd0 <=0 ) || fabs(it->position().rho()) <= maxd0 )
80  ) result = true;
81  }
82 
83  return result;
84 }
85 
86 
87 //define this as a plug-in
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const unsigned int minNDOF
int iEvent
Definition: GenABIO.cc:230
GoodVertexFilter(const edm::ParameterSet &)
tuple result
Definition: query.py:137
const double maxd0
T const * product() const
Definition: Handle.h:81
const double maxAbsZ
virtual bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const edm::EDGetTokenT< reco::VertexCollection > vertexSrc