CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenJetParticleSelector.cc
Go to the documentation of this file.
6 #include <algorithm>
7 using namespace std;
8 using namespace edm;
9 
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 }
42 
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 }
56 
58  for(vpdt::iterator i = pdtList_.begin(); i != pdtList_.end(); ++i )
59  i->setup(es);
60 }
61 
GenJetParticleSelector(const edm::ParameterSet &, edm::ConsumesCollector &iC)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
tuple cfg
Definition: looper.py:293
virtual int status() const =0
status word
std::vector< PdtEntry > vpdt
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:194
virtual size_type numberOfDaughters() const =0
number of daughters
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void init(const edm::EventSetup &)
virtual int pdgId() const =0
PDG identifier.
bool operator()(const reco::Candidate &)
volatile std::atomic< bool > shutdown_flag false
tuple status
Definition: ntuplemaker.py:245