CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PVSelector.h
Go to the documentation of this file.
1 #ifndef Analysis_AnalysisFilters_interface_PVSelector_h
2 #define Analysis_AnalysisFilters_interface_PVSelector_h
3 
6 
9 
10 
11 // make a selector for this selection
12 class PVSelector : public Selector<edm::EventBase> {
13 public:
14 
16 
17  PVSelector( edm::ParameterSet const & params ) :
18  pvSrc_ (params.getParameter<edm::InputTag>("pvSrc") ),
19  pvSel_ (params)
20  {
21  push_back("NPV", params.getParameter<int>("NPV") );
22  set("NPV");
24  indexNPV_ = index_type(&bits_, "NPV");
25  }
26 
28  ret.set(false);
29  event.getByLabel(pvSrc_, h_primVtx);
30 
31  // check if there is a good primary vertex
32 
33  if ( h_primVtx->size() < 1 ) return false;
34 
35  // Loop over PV's and count those that pass
36  int npv = 0;
37  for ( std::vector<reco::Vertex>::const_iterator ibegin = h_primVtx->begin(),
38  iend = h_primVtx->end(), i = ibegin; i != iend; ++i ) {
39  reco::Vertex const & pv = *i;
40  bool ipass = pvSel_(pv);
41  if ( ipass ) {
42  ++npv;
43  }
44  }
45 
46  // Set the strbitset
47  if ( npv >= cut(indexNPV_, int() ) || ignoreCut(indexNPV_) ) {
48  passCut(ret, indexNPV_);
49  }
50 
51  // Check if there is anything to ignore
52  setIgnored(ret);
53 
54  // Return status
55  bool pass = (bool)ret;
56  return pass;
57  }
58 
60 
62 
63 private:
68 };
69 
70 #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:106
int i
Definition: DBlmapReader.cc:9
index_type indexNPV_
Definition: PVSelector.h:67
edm::Handle< std::vector< reco::Vertex > > const & vertices() const
Definition: PVSelector.h:61
pat::strbitset::index_type index_type
Definition: Selector.h:30
void setIgnored(pat::strbitset &ret)
set ignored bits
Definition: Selector.h:225
pat::strbitset retInternal_
internal ret if users don&#39;t care about return bits
Definition: Selector.h:288
pat::strbitset bits_
the bitset indexed by strings
Definition: Selector.h:287
void passCut(pat::strbitset &ret, std::string const &s)
Passing cuts.
Definition: Selector.h:177
bool ignoreCut(std::string const &s) const
ignore the cut at index &quot;s&quot;
Definition: Selector.h:160
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:47
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
Functor that operates on &lt;T&gt;
Definition: Selector.h:25
edm::InputTag pvSrc_
Definition: PVSelector.h:64
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
bool operator()(edm::EventBase const &event, pat::strbitset &ret)
This provides the interface for base classes to select objects.
Definition: PVSelector.h:27
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:213
PVObjectSelector pvSel_
Definition: PVSelector.h:65
edm::Handle< std::vector< reco::Vertex > > h_primVtx
Definition: PVSelector.h:66
PVSelector(edm::ParameterSet const &params)
Definition: PVSelector.h:17
int cut(index_type const &i, int val) const
Access the int cut values at index &quot;s&quot;.
Definition: Selector.h:195