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
 This provides the interface for base classes to select objects. More...
 
 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 (index_type const &i)
 
void clear (std::string const &s)
 Turn off a given selection cut. More...
 
bool considerCut (index_type const &i) const
 
bool considerCut (std::string const &s) const
 consider the cut at index "s" More...
 
double cut (index_type const &i, double val) const
 Access the double cut values at index "s". More...
 
int cut (index_type const &i, 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...
 
int cut (std::string s, int val) const
 Access the int cut values at index "s". More...
 
pat::strbitset getBitTemplate () const
 Get an empty bitset with the proper names. More...
 
double getPasses (index_type const &i) const
 
double getPasses (std::string const &s) const
 Return the number of passing cases. More...
 
bool ignoreCut (index_type const &i) const
 
bool ignoreCut (std::string const &s) const
 ignore the cut at index "s" 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)
 This provides an alternative signature that includes extra information. 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...
 
bool operator[] (index_type const &i) const
 
bool operator[] (std::string const &s) const
 
void passCut (pat::strbitset &ret, index_type const &i)
 
void passCut (pat::strbitset &ret, std::string const &s)
 Passing cuts. More...
 
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, double cut)
 This is the registration of an individual cut string, with a double cut value. 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...
 
 Selector ()
 Constructor clears the bits. More...
 
void set (index_type const &i, bool val=true)
 
void set (index_type const &i, double cut, bool val=true)
 
void set (index_type const &i, int cut, bool val=true)
 
void set (std::string const &s, bool val=true)
 Set a given selection cut, on or off. More...
 
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 (std::string const &s, int cut, bool val=true)
 Set a given selection cut, on or off, and reset int cut value. More...
 
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::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 14 of file PVSelector.h.

Constructor & Destructor Documentation

◆ PVSelector() [1/3]

PVSelector::PVSelector ( )
inline

Definition at line 16 of file PVSelector.h.

16 {}

◆ PVSelector() [2/3]

PVSelector::PVSelector ( edm::ParameterSet const &  params)
inline

◆ PVSelector() [3/3]

PVSelector::PVSelector ( edm::ParameterSet const &  params,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 26 of file PVSelector.h.

26  : PVSelector(params) {
27  pvSrcToken_ = iC.consumes<std::vector<reco::Vertex> >(pvSrc_);
28  }

References pvSrc_, and pvSrcToken_.

Member Function Documentation

◆ GetNpv()

int PVSelector::GetNpv ( void  )
inline

Definition at line 77 of file PVSelector.h.

77 { return mNpv; }

References mNpv.

◆ GetSelectedPvs()

std::vector<edm::Ptr<reco::Vertex> > const& PVSelector::GetSelectedPvs ( ) const
inline

Definition at line 79 of file PVSelector.h.

79 { return mvSelPvs; }

References mvSelPvs.

◆ operator()()

bool PVSelector::operator() ( edm::EventBase const &  t,
pat::strbitset ret 
)
inlineoverridevirtual

This provides the interface for base classes to select objects.

Implements Selector< edm::EventBase >.

Definition at line 31 of file PVSelector.h.

31  {
32  ret.set(false);
33  event.getByLabel(pvSrc_, h_primVtx);
34 
35  // check if there is a good primary vertex
36 
37  if (h_primVtx->empty())
38  return false;
39 
40  // Loop over PV's and count those that pass
41  int npv = 0;
42  int _ntotal = 0;
43  mvSelPvs.clear();
44  for (std::vector<reco::Vertex>::const_iterator ibegin = h_primVtx->begin(), iend = h_primVtx->end(), i = ibegin;
45  i != iend;
46  ++i) {
47  reco::Vertex const& pv = *i;
48  bool ipass = pvSel_(pv);
49  if (ipass) {
50  ++npv;
51  mvSelPvs.push_back(edm::Ptr<reco::Vertex>(h_primVtx, _ntotal));
52  }
53  ++_ntotal;
54  }
55 
56  // cache npv
57  mNpv = npv;
58 
59  // Set the strbitset
60  if (npv >= cut(indexNPV_, int()) || ignoreCut(indexNPV_)) {
62  }
63 
64  // Check if there is anything to ignore
65  setIgnored(ret);
66 
67  // Return status
68  bool pass = (bool)ret;
69  return pass;
70  }

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

◆ vertices()

edm::Handle<std::vector<reco::Vertex> > const& PVSelector::vertices ( ) const
inline

Definition at line 74 of file PVSelector.h.

74 { return h_primVtx; }

References h_primVtx.

Member Data Documentation

◆ h_primVtx

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

Definition at line 87 of file PVSelector.h.

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

◆ indexNPV_

index_type PVSelector::indexNPV_
private

Definition at line 89 of file PVSelector.h.

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

◆ mNpv

int PVSelector::mNpv
private

Definition at line 90 of file PVSelector.h.

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

◆ mvSelPvs

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

Definition at line 88 of file PVSelector.h.

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

◆ pvSel_

PVObjectSelector PVSelector::pvSel_
private

Definition at line 86 of file PVSelector.h.

Referenced by operator()().

◆ pvSrc_

edm::InputTag PVSelector::pvSrc_
private

Definition at line 82 of file PVSelector.h.

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

◆ pvSrcToken_

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

Definition at line 84 of file PVSelector.h.

Referenced by PVSelector().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:367
Selector< edm::EventBase >::setIgnored
void setIgnored(pat::strbitset &ret)
set ignored bits
Definition: Selector.h:181
electrons_cff.bool
bool
Definition: electrons_cff.py:393
Selector< edm::EventBase >::bits_
pat::strbitset bits_
the bitset indexed by strings
Definition: Selector.h:241
mps_fire.i
i
Definition: mps_fire.py:428
Selector< edm::EventBase >::index_type
pat::strbitset::index_type index_type
Definition: Selector.h:25
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
PVSelector::pvSrc_
edm::InputTag pvSrc_
Definition: PVSelector.h:82
Selector< edm::EventBase >::retInternal_
pat::strbitset retInternal_
internal ret if users don't care about return bits
Definition: Selector.h:242
Selector< edm::EventBase >::ignoreCut
bool ignoreCut(std::string const &s) const
ignore the cut at index "s"
Definition: Selector.h:127
PVSelector::pvSrcToken_
edm::EDGetTokenT< std::vector< reco::Vertex > > pvSrcToken_
Definition: PVSelector.h:84
PVSelector::h_primVtx
edm::Handle< std::vector< reco::Vertex > > h_primVtx
Definition: PVSelector.h:87
PVSelector::pvSel_
PVObjectSelector pvSel_
Definition: PVSelector.h:86
Selector< edm::EventBase >::push_back
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:42
PVSelector::PVSelector
PVSelector()
Definition: PVSelector.h:16
PVSelector::mNpv
int mNpv
Definition: PVSelector.h:90
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
Selector< edm::EventBase >::getBitTemplate
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:168
PVSelector::mvSelPvs
std::vector< edm::Ptr< reco::Vertex > > mvSelPvs
Definition: PVSelector.h:88
Selector< edm::EventBase >::passCut
void passCut(pat::strbitset &ret, std::string const &s)
Passing cuts.
Definition: Selector.h:142
PVSelector::indexNPV_
index_type indexNPV_
Definition: PVSelector.h:89
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
edm::Ptr
Definition: AssociationVector.h:31
Selector< edm::EventBase >::cut
int cut(index_type const &i, int val) const
Access the int cut values at index "s".
Definition: Selector.h:158
Selector< edm::EventBase >::set
void set(std::string const &s, bool val=true)
Set a given selection cut, on or off.
Definition: Selector.h:93
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35