CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PVObjectSelector.h
Go to the documentation of this file.
1 #ifndef Analysis_AnalysisFilters_interface_PVObjectSelector_h
2 #define Analysis_AnalysisFilters_interface_PVObjectSelector_h
3 
6 
9 
10 #include <vector>
11 #include <string>
12 
13 // make a selector for this selection
14 class PVObjectSelector : public Selector<reco::Vertex> {
15 public:
16 
18 
19  PVObjectSelector( edm::ParameterSet const & params ) {
20  push_back("PV NDOF", params.getParameter<double>("minNdof") );
21  push_back("PV Z", params.getParameter<double>("maxZ") );
22  push_back("PV RHO", params.getParameter<double>("maxRho") );
23  set("PV NDOF");
24  set("PV Z");
25  set("PV RHO");
26 
27  indexNDOF_ = index_type (&bits_, "PV NDOF");
28  indexZ_ = index_type (&bits_, "PV Z");
29  indexRho_ = index_type (&bits_, "PV RHO");
30 
31  if ( params.exists("cutsToIgnore") )
32  setIgnoredCuts( params.getParameter<std::vector<std::string> >("cutsToIgnore") );
33 
35  }
36 
37  bool operator() ( reco::Vertex const & pv, pat::strbitset & ret ) {
38  if ( pv.isFake() ) return false;
39 
40  if ( pv.ndof() >= cut(indexNDOF_, double() )
41  || ignoreCut(indexNDOF_) ) {
42  passCut(ret, indexNDOF_ );
43  if ( fabs(pv.z()) <= cut(indexZ_, double())
44  || ignoreCut(indexZ_) ) {
45  passCut(ret, indexZ_ );
46  if ( fabs(pv.position().Rho()) <= cut(indexRho_, double() )
47  || ignoreCut(indexRho_) ) {
48  passCut( ret, indexRho_);
49  }
50  }
51  }
52 
53  setIgnored(ret);
54 
55  return (bool)ret;
56  }
57 
59 
60 private:
64 };
65 
66 #endif
T getParameter(std::string const &) const
void set(std::string const &s, bool val=true)
Set a given selection cut, on or off.
Definition: Selector.h:105
bool exists(std::string const &parameterName) const
checks if a parameter exists
pat::strbitset::index_type index_type
Definition: Selector.h:29
void setIgnored(pat::strbitset &ret)
set ignored bits
Definition: Selector.h:224
pat::strbitset retInternal_
internal ret if users don&#39;t care about return bits
Definition: Selector.h:287
const Point & position() const
position
Definition: Vertex.h:92
pat::strbitset bits_
the bitset indexed by strings
Definition: Selector.h:286
void passCut(pat::strbitset &ret, std::string const &s)
Passing cuts.
Definition: Selector.h:176
bool ignoreCut(std::string const &s) const
ignore the cut at index &quot;s&quot;
Definition: Selector.h:159
double z() const
y coordinate
Definition: Vertex.h:98
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:46
PVObjectSelector(edm::ParameterSet const &params)
Functor that operates on &lt;T&gt;
Definition: Selector.h:24
double ndof() const
Definition: Vertex.h:88
bool isFake() const
Definition: Vertex.h:64
index_type indexRho_
index_type indexNDOF_
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:212
bool operator()(reco::Vertex const &pv, pat::strbitset &ret)
This provides the interface for base classes to select objects.
void setIgnoredCuts(std::vector< std::string > const &bitsToIgnore)
set the bits to ignore from a vector
Definition: Selector.h:167
int cut(index_type const &i, int val) const
Access the int cut values at index &quot;s&quot;.
Definition: Selector.h:194