CMS 3D CMS Logo

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

#include <GenJetParticleSelector.h>

Public Member Functions

 GenJetParticleSelector (const edm::ParameterSet &, edm::ConsumesCollector &iC)
 
void init (const edm::EventSetup &)
 
bool operator() (const reco::Candidate &)
 

Private Types

typedef std::vector< PdtEntryvpdt
 

Private Attributes

bool bInclude_
 
bool partons_
 
vpdt pdtList_
 
std::set< int > pIds_
 
bool stableOnly_
 

Detailed Description

Definition at line 16 of file GenJetParticleSelector.h.

Member Typedef Documentation

typedef std::vector<PdtEntry> GenJetParticleSelector::vpdt
private

Definition at line 22 of file GenJetParticleSelector.h.

Constructor & Destructor Documentation

GenJetParticleSelector::GenJetParticleSelector ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC 
)

Definition at line 10 of file GenJetParticleSelector.cc.

References bInclude_, Exception, spr::find(), runEdmFileComparison::found, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), partons_, pdtList_, and stableOnly_.

10  :
11  stableOnly_(cfg.getParameter<bool>("stableOnly")),
12  partons_(false), bInclude_(false) {
13  const string excludeString("excludeList");
14  const string includeString("includeList");
15  vpdt includeList, excludeList;
16  vector<string> vPdtParams = cfg.getParameterNamesForType<vpdt>();
17  bool found = std::find(vPdtParams.begin(), vPdtParams.end(), includeString) != vPdtParams.end();
18  if(found) includeList = cfg.getParameter<vpdt>(includeString);
19  found = find(vPdtParams.begin(), vPdtParams.end(), excludeString) != vPdtParams.end();
20  if(found) excludeList = cfg.getParameter<vpdt>(excludeString);
21  const string partonsString("partons");
22  vector<string> vBoolParams = cfg.getParameterNamesForType<bool>();
23  found = find(vBoolParams.begin(), vBoolParams.end(), partonsString) != vBoolParams.end();
24  if(found) partons_ = cfg.getParameter<bool>(partonsString);
25  bool bExclude = false;
26  if (includeList.size() > 0) bInclude_ = true;
27  if (excludeList.size() > 0) bExclude = true;
28 
29  if (bInclude_ && bExclude) {
30  throw cms::Exception("ConfigError", "not allowed to use both includeList and excludeList at the same time\n");
31  }
32  else if (bInclude_) {
33  pdtList_ = includeList;
34  }
35  else {
36  pdtList_ = excludeList;
37  }
38  if(stableOnly_ && partons_) {
39  throw cms::Exception("ConfigError", "not allowed to have both stableOnly and partons true at the same time\n");
40  }
41 }
T getParameter(std::string const &) const
std::vector< PdtEntry > vpdt
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:194

Member Function Documentation

void GenJetParticleSelector::init ( const edm::EventSetup es)

Definition at line 57 of file GenJetParticleSelector.cc.

References mps_fire::i, and pdtList_.

Referenced by reco::modules::GenJetParticleSelectorEventSetupInit::init().

57  {
58  for(vpdt::iterator i = pdtList_.begin(); i != pdtList_.end(); ++i )
59  i->setup(es);
60 }
bool GenJetParticleSelector::operator() ( const reco::Candidate p)

Definition at line 43 of file GenJetParticleSelector.cc.

References funct::abs(), bInclude_, reco::Candidate::daughter(), reco::Candidate::numberOfDaughters(), partons_, reco::Candidate::pdgId(), pIds_, stableOnly_, mps_update::status, and reco::Candidate::status().

43  {
44  int status = p.status();
45  int id = abs(p.pdgId());
46  if((!stableOnly_ || status == 1) && !partons_ &&
47  ( (pIds_.find(id) == pIds_.end()) ^ bInclude_))
48  return true;
49  else if(partons_ &&
50  (p.numberOfDaughters() > 0 && (p.daughter(0)->pdgId() == 91 || p.daughter(0)->pdgId() == 92)) &&
51  ( ((pIds_.find(id) == pIds_.end()) ^ bInclude_)))
52  return true;
53  else
54  return false;
55 }
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual int status() const =0
status word
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual size_type numberOfDaughters() const =0
number of daughters

Member Data Documentation

bool GenJetParticleSelector::bInclude_
private

Definition at line 26 of file GenJetParticleSelector.h.

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

bool GenJetParticleSelector::partons_
private

Definition at line 24 of file GenJetParticleSelector.h.

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

vpdt GenJetParticleSelector::pdtList_
private

Definition at line 25 of file GenJetParticleSelector.h.

Referenced by GenJetParticleSelector(), and init().

std::set<int> GenJetParticleSelector::pIds_
private

Definition at line 27 of file GenJetParticleSelector.h.

Referenced by operator()().

bool GenJetParticleSelector::stableOnly_
private

Definition at line 23 of file GenJetParticleSelector.h.

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