CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
pf2pat::ElectronIDPFCandidateSelectorDefinition Class Reference

Selects PFCandidates basing on cuts provided with string cut parser. More...

#include "CommonTools/ParticleFlow/interface/ElectronIDPFCandidateSelectorDefinition.h"

Inheritance diagram for pf2pat::ElectronIDPFCandidateSelectorDefinition:
pf2pat::PFCandidateSelectorDefinition

Public Member Functions

 ElectronIDPFCandidateSelectorDefinition (const edm::ParameterSet &cfg)
 
void select (const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
 
- Public Member Functions inherited from pf2pat::PFCandidateSelectorDefinition
const_iterator begin () const
 
const_iterator end () const
 
 PFCandidateSelectorDefinition ()
 
const containerselected () const
 
size_t size () const
 

Private Attributes

edm::InputTag electronId_
 
edm::InputTag electrons_
 
bool isBitMap_
 
uint32_t mask_
 
double value_
 

Additional Inherited Members

- Public Types inherited from pf2pat::PFCandidateSelectorDefinition
typedef reco::PFCandidateCollection collection
 
typedef
boost::transform_iterator
< Pointer,
container::const_iterator > 
const_iterator
 
typedef std::vector
< reco::PFCandidate
container
 
typedef edm::Handle< collectionHandleToCollection
 
- Protected Attributes inherited from pf2pat::PFCandidateSelectorDefinition
container selected_
 

Detailed Description

Selects PFCandidates basing on cuts provided with string cut parser.

Author
Giovanni Petrucciani
Version
Id:
ElectronIDPFCandidateSelectorDefinition.h,v 1.2 2011/04/06 12:12:38 rwolf Exp

Definition at line 21 of file ElectronIDPFCandidateSelectorDefinition.h.

Constructor & Destructor Documentation

pf2pat::ElectronIDPFCandidateSelectorDefinition::ElectronIDPFCandidateSelectorDefinition ( const edm::ParameterSet cfg)
inline

Definition at line 23 of file ElectronIDPFCandidateSelectorDefinition.h.

References edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), isBitMap_, mask_, and value_.

23  :
24  electrons_( cfg.getParameter< edm::InputTag >( "recoGsfElectrons" ) ),
25  electronId_( cfg.getParameter< edm::InputTag >( "electronIdMap" ) )
26  {
27  if (cfg.exists("bitsToCheck")) {
28  isBitMap_ = true;
29  mask_ = 0;
30  if (cfg.existsAs<std::vector<std::string> >("bitsToCheck")) {
31  std::vector<std::string> strbits = cfg.getParameter<std::vector<std::string> >("bitsToCheck");
32  for (std::vector<std::string>::const_iterator istrbit = strbits.begin(), estrbit = strbits.end();
33  istrbit != estrbit; ++istrbit) {
34  if (*istrbit == "id" ) { mask_ |= 1; }
35  else if (*istrbit == "iso") { mask_ |= 2; }
36  else if (*istrbit == "conv") { mask_ |= 4; }
37  else if (*istrbit == "ip") { mask_ |= 8; }
38  else throw cms::Exception("Configuration") << "ElectronIDPFCandidateSelector: " <<
39  "bitsToCheck allowed string values are only id(0), iso(1), conv(2), ip(3).\n" <<
40  "Otherwise, use uint32_t bitmask).\n";
41  }
42  } else if (cfg.existsAs<uint32_t>("bitsToCheck")) {
43  mask_ = cfg.getParameter<uint32_t>("bitsToCheck");
44  } else {
45  throw cms::Exception("Configuration") << "ElectronIDPFCandidateSelector: " <<
46  "bitsToCheck must be either a vector of strings, or a uint32 bitmask.\n";
47  }
48  } else {
49  isBitMap_ = false;
50  value_ = cfg.getParameter<double>("electronIdCut");
51  }
52  }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
bool exists(std::string const &parameterName) const
checks if a parameter exists

Member Function Documentation

void pf2pat::ElectronIDPFCandidateSelectorDefinition::select ( const HandleToCollection hc,
const edm::Event e,
const edm::EventSetup s 
)
inline

Definition at line 54 of file ElectronIDPFCandidateSelectorDefinition.h.

References prof2calltree::count, electronId_, HI_PhotonSkim_cff::electrons, electrons_, edm::Event::getByLabel(), isBitMap_, edm::Ref< C, T, F >::isNull(), combine::key, mask_, match(), pf2pat::PFCandidateSelectorDefinition::selected_, and value_.

Referenced by Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Views.LineDecayView.LineDecayContainer::mousePressEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), and Vispa.Views.AbstractView.AbstractView::restoreSelection().

56  {
57  selected_.clear();
58 
60  e.getByLabel(electrons_, electrons);
61 
63  e.getByLabel(electronId_, electronId);
64 
65  unsigned key=0;
66  for( collection::const_iterator pfc = hc->begin();
67  pfc != hc->end(); ++pfc, ++key) {
68 
69  // Get GsfTrack for matching with reco::GsfElectron objects
70  reco::GsfTrackRef PfTk = pfc->gsfTrackRef();
71 
72  // skip ones without GsfTrack: they won't be matched anyway
73  if (PfTk.isNull()) continue;
74 
75  int match = -1;
76  // try first the non-ambiguous tracks
77  for (reco::GsfElectronCollection::const_iterator it = electrons->begin(), ed = electrons->end(); it != ed; ++it) {
78  if (it->gsfTrack() == PfTk) { match = it - electrons->begin(); break; }
79  }
80  // then the ambiguous ones
81  if (match == -1) {
82  for (reco::GsfElectronCollection::const_iterator it = electrons->begin(), ed = electrons->end(); it != ed; ++it) {
83  if (std::count(it->ambiguousGsfTracksBegin(), it->ambiguousGsfTracksEnd(), PfTk) > 0) {
84  match = it - electrons->begin(); break;
85  }
86  }
87  }
88  // if found, make a GsfElectronRef and read electron id
89  if (match != -1) {
90  reco::GsfElectronRef ref(electrons,match);
91  float eleId = (*electronId)[ref];
92  bool pass = false;
93  if (isBitMap_) {
94  uint32_t thisval = eleId;
95  pass = ((thisval & mask_) == mask_);
96  } else {
97  pass = (eleId > value_);
98  }
99  if (pass) {
100  selected_.push_back( reco::PFCandidate(*pfc) );
101  reco::PFCandidatePtr ptrToMother( hc, key );
102  selected_.back().setSourceCandidatePtr( ptrToMother );
103  }
104  }
105  }
106  }
bool isNull() const
Checks for null.
Definition: Ref.h:247
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
list key
Definition: combine.py:13
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6

Member Data Documentation

edm::InputTag pf2pat::ElectronIDPFCandidateSelectorDefinition::electronId_
private

Definition at line 110 of file ElectronIDPFCandidateSelectorDefinition.h.

Referenced by select().

edm::InputTag pf2pat::ElectronIDPFCandidateSelectorDefinition::electrons_
private

Definition at line 109 of file ElectronIDPFCandidateSelectorDefinition.h.

Referenced by select().

bool pf2pat::ElectronIDPFCandidateSelectorDefinition::isBitMap_
private
uint32_t pf2pat::ElectronIDPFCandidateSelectorDefinition::mask_
private
double pf2pat::ElectronIDPFCandidateSelectorDefinition::value_
private