CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PVSelector Class Reference

#include <PVSelector.h>

Inheritance diagram for PVSelector:
Selector< edm::EventBase >

Public Member Functions

int GetNpv (void)
 
std::vector< edm::Ptr< reco::Vertex > > const & GetSelectedPvs () const
 
bool operator() (edm::EventBase const &event, pat::strbitset &ret) override
 
 PVSelector ()
 
 PVSelector (edm::ParameterSet const &params)
 
 PVSelector (edm::ParameterSet const &params, edm::ConsumesCollector &&iC)
 
edm::Handle< std::vector< reco::Vertex > > const & vertices () const
 
- Public Member Functions inherited from Selector< edm::EventBase >
void clear (std::string const &s)
 Turn off a given selection cut. More...
 
void clear (index_type const &i)
 
bool considerCut (std::string const &s) const
 consider the cut at index "s" More...
 
bool considerCut (index_type const &i) const
 
int cut (index_type const &i, int val) const
 Access the int cut values at index "s". More...
 
double cut (index_type const &i, double val) const
 Access the double cut values at index "s". More...
 
int cut (std::string s, int val) const
 Access the int cut values at index "s". More...
 
double cut (std::string s, double val) const
 Access the double cut values at index "s". More...
 
pat::strbitset getBitTemplate () const
 Get an empty bitset with the proper names. More...
 
double getPasses (std::string const &s) const
 Return the number of passing cases. More...
 
double getPasses (index_type const &i) const
 
bool ignoreCut (std::string const &s) const
 ignore the cut at index "s" More...
 
bool ignoreCut (index_type const &i) const
 
virtual bool operator() (edm::EventBase const &t, pat::strbitset &ret)=0
 This provides the interface for base classes to select objects. More...
 
virtual bool operator() (edm::EventBase const &t)
 This provides an alternative signature without the second ret. More...
 
virtual bool operator() (edm::EventBase const &t, edm::EventBase const &e, pat::strbitset &ret)
 This provides an alternative signature that includes extra information. More...
 
virtual bool operator() (edm::EventBase const &t, edm::EventBase const &e)
 This provides an alternative signature that includes extra information. More...
 
bool operator[] (std::string const &s) const
 
bool operator[] (index_type const &i) const
 
void passCut (pat::strbitset &ret, std::string const &s)
 Passing cuts. More...
 
void passCut (pat::strbitset &ret, index_type const &i)
 
void print (std::ostream &out) const
 Print the cut flow. More...
 
void printActiveCuts (std::ostream &out) const
 Print the cuts being considered. More...
 
virtual void push_back (std::string const &s)
 This is the registration of an individual cut string. More...
 
virtual void push_back (std::string const &s, int cut)
 This is the registration of an individual cut string, with an int cut value. More...
 
virtual void push_back (std::string const &s, double cut)
 This is the registration of an individual cut string, with a double cut value. More...
 
 Selector ()
 Constructor clears the bits. More...
 
void set (std::string const &s, bool val=true)
 Set a given selection cut, on or off. More...
 
void set (index_type const &i, bool val=true)
 
void set (std::string const &s, int cut, bool val=true)
 Set a given selection cut, on or off, and reset int cut value. More...
 
void set (index_type const &i, int cut, bool val=true)
 
void set (std::string const &s, double cut, bool val=true)
 Set a given selection cut, on or off, and reset int cut value. More...
 
void set (index_type const &i, double cut, bool val=true)
 
void setIgnored (pat::strbitset &ret)
 set ignored bits More...
 
void setIgnoredCuts (std::vector< std::string > const &bitsToIgnore)
 set the bits to ignore from a vector More...
 
virtual ~Selector ()
 

Private Attributes

edm::Handle< std::vector< reco::Vertex > > h_primVtx
 
index_type indexNPV_
 
int mNpv
 
std::vector< edm::Ptr< reco::Vertex > > mvSelPvs
 
PVObjectSelector pvSel_
 
edm::InputTag pvSrc_
 
edm::EDGetTokenT< std::vector< reco::Vertex > > pvSrcToken_
 

Additional Inherited Members

- Public Types inherited from Selector< edm::EventBase >
typedef std::binary_function< edm::EventBase, pat::strbitset, bool > base_type
 
typedef std::pair< index_type, size_t > cut_flow_item
 
typedef std::vector< cut_flow_itemcut_flow_map
 
typedef edm::EventBase data_type
 
typedef std::map< index_type, double > double_map
 
typedef pat::strbitset::index_type index_type
 
typedef std::map< index_type, int > int_map
 
- Protected Attributes inherited from Selector< edm::EventBase >
pat::strbitset bits_
 the bitset indexed by strings More...
 
cut_flow_map cutFlow_
 map of cut flows in "human" order More...
 
double_map doubleCuts_
 the double-value cut map More...
 
int_map intCuts_
 the int-value cut map More...
 
pat::strbitset retInternal_
 internal ret if users don't care about return bits More...
 

Detailed Description

Definition at line 15 of file PVSelector.h.

Constructor & Destructor Documentation

PVSelector::PVSelector ( )
inline

Definition at line 18 of file PVSelector.h.

18 {}
PVSelector::PVSelector ( edm::ParameterSet const &  params)
inline

Definition at line 20 of file PVSelector.h.

References Selector< edm::EventBase >::bits_, Selector< edm::EventBase >::getBitTemplate(), edm::ParameterSet::getParameter(), indexNPV_, Selector< edm::EventBase >::push_back(), and Selector< edm::EventBase >::retInternal_.

20  :
21  pvSrc_ (params.getParameter<edm::InputTag>("pvSrc") ),
22  pvSel_ (params)
23  {
24  push_back("NPV", params.getParameter<int>("NPV") );
25  set("NPV");
27  indexNPV_ = index_type(&bits_, "NPV");
28  }
index_type indexNPV_
Definition: PVSelector.h:101
pat::strbitset::index_type index_type
Definition: Selector.h:29
pat::strbitset retInternal_
internal ret if users don&#39;t care about return bits
Definition: Selector.h:287
pat::strbitset bits_
the bitset indexed by strings
Definition: Selector.h:286
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:46
edm::InputTag pvSrc_
Definition: PVSelector.h:94
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:212
PVObjectSelector pvSel_
Definition: PVSelector.h:98
PVSelector::PVSelector ( edm::ParameterSet const &  params,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 31 of file PVSelector.h.

References pvSrc_, and pvSrcToken_.

31  :
32  PVSelector(params)
33  {
34  pvSrcToken_ = iC.consumes<std::vector<reco::Vertex> >(pvSrc_);
35  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::InputTag pvSrc_
Definition: PVSelector.h:94
edm::EDGetTokenT< std::vector< reco::Vertex > > pvSrcToken_
Definition: PVSelector.h:96

Member Function Documentation

int PVSelector::GetNpv ( void  )
inline

Definition at line 84 of file PVSelector.h.

References mNpv.

84 {return mNpv;}
std::vector<edm::Ptr<reco::Vertex> > const& PVSelector::GetSelectedPvs ( ) const
inline

Definition at line 89 of file PVSelector.h.

References mvSelPvs.

89 { return mvSelPvs; }
std::vector< edm::Ptr< reco::Vertex > > mvSelPvs
Definition: PVSelector.h:100
bool PVSelector::operator() ( edm::EventBase const &  event,
pat::strbitset ret 
)
inlineoverride

Definition at line 38 of file PVSelector.h.

References electrons_cff::bool, Selector< edm::EventBase >::cut(), h_primVtx, mps_fire::i, Selector< edm::EventBase >::ignoreCut(), indexNPV_, mNpv, mvSelPvs, Utilities::operator, Selector< edm::EventBase >::passCut(), MetAnalyzer::pv(), pvSel_, pvSrc_, pat::strbitset::set(), and Selector< edm::EventBase >::setIgnored().

38  {
39  ret.set(false);
40  event.getByLabel(pvSrc_, h_primVtx);
41 
42  // check if there is a good primary vertex
43 
44  if ( h_primVtx->empty() ) return false;
45 
46  // Loop over PV's and count those that pass
47  int npv = 0;
48  int _ntotal = 0;
49  mvSelPvs.clear();
50  for ( std::vector<reco::Vertex>::const_iterator ibegin = h_primVtx->begin(),
51  iend = h_primVtx->end(), i = ibegin; i != iend; ++i ) {
52  reco::Vertex const & pv = *i;
53  bool ipass = pvSel_(pv);
54  if ( ipass ) {
55  ++npv;
56  mvSelPvs.push_back(edm::Ptr<reco::Vertex>(h_primVtx,_ntotal));
57  }
58  ++_ntotal;
59  }
60 
61  // cache npv
62  mNpv = npv;
63 
64  // Set the strbitset
65  if ( npv >= cut(indexNPV_, int() ) || ignoreCut(indexNPV_) ) {
66  passCut(ret, indexNPV_);
67  }
68 
69  // Check if there is anything to ignore
70  setIgnored(ret);
71 
72  // Return status
73  bool pass = (bool)ret;
74  return pass;
75  }
std::vector< edm::Ptr< reco::Vertex > > mvSelPvs
Definition: PVSelector.h:100
index_type indexNPV_
Definition: PVSelector.h:101
void setIgnored(pat::strbitset &ret)
set ignored bits
Definition: Selector.h:224
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 "s"
Definition: Selector.h:159
def pv(vc)
Definition: MetAnalyzer.py:6
edm::InputTag pvSrc_
Definition: PVSelector.h:94
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
PVObjectSelector pvSel_
Definition: PVSelector.h:98
edm::Handle< std::vector< reco::Vertex > > h_primVtx
Definition: PVSelector.h:99
int cut(index_type const &i, int val) const
Access the int cut values at index "s".
Definition: Selector.h:194
edm::Handle<std::vector<reco::Vertex> > const& PVSelector::vertices ( ) const
inline

Definition at line 79 of file PVSelector.h.

References h_primVtx.

79 { return h_primVtx; }
edm::Handle< std::vector< reco::Vertex > > h_primVtx
Definition: PVSelector.h:99

Member Data Documentation

edm::Handle<std::vector<reco::Vertex> > PVSelector::h_primVtx
private

Definition at line 99 of file PVSelector.h.

Referenced by operator()(), and vertices().

index_type PVSelector::indexNPV_
private

Definition at line 101 of file PVSelector.h.

Referenced by operator()(), and PVSelector().

int PVSelector::mNpv
private

Definition at line 102 of file PVSelector.h.

Referenced by GetNpv(), and operator()().

std::vector<edm::Ptr<reco::Vertex> > PVSelector::mvSelPvs
private

Definition at line 100 of file PVSelector.h.

Referenced by GetSelectedPvs(), and operator()().

PVObjectSelector PVSelector::pvSel_
private

Definition at line 98 of file PVSelector.h.

Referenced by operator()().

edm::InputTag PVSelector::pvSrc_
private

Definition at line 94 of file PVSelector.h.

Referenced by operator()(), and PVSelector().

edm::EDGetTokenT<std::vector<reco::Vertex> > PVSelector::pvSrcToken_
private

Definition at line 96 of file PVSelector.h.

Referenced by PVSelector().