CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EventHypothesis.cc
Go to the documentation of this file.
3 
4 char *
5 pat::EventHypothesis::getDemangledSymbol(const char* mangledSymbol) const {
6  int status;
7  char *demangledSymbol = abi::__cxa_demangle(mangledSymbol, nullptr, nullptr, &status);
8  return (status == 0) ? demangledSymbol : nullptr;
9 }
10 
11 void pat::EventHypothesis::add(const CandRefType &ref, const std::string &role) {
12  particles_.push_back(value_type(role,ref));
13 }
14 
17 {
18  if (index >= 0) {
19  const_iterator it = realGet(begin(), end(), ByRole(role), index);
20  if (it == end()) { throw cms::Exception("Index not found") << "Can't find a particle with role " << role << " and index " << index << "\n"; }
21  return it->second;
22  } else {
23  const_reverse_iterator it = realGet(rbegin(), rend(), ByRole(role), -index);
24  if (it == rend()) { throw cms::Exception("Index not found") << "Can't find a particle with role " << role << " and index " << index << "\n"; }
25  return it->second;
26  }
27 }
28 
31 {
32  if (index >= 0) {
33  const_iterator it = realGet(begin(), end(), filter, index);
34  if (it == end()) { throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n"; }
35  return it->second;
36  } else {
37  const_reverse_iterator it = realGet(rbegin(), rend(), filter, -index);
38  if (it == rend()) { throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n"; }
39  return it->second;
40  }
41 }
42 
43 
44 std::vector<pat::EventHypothesis::CandRefType>
45 pat::EventHypothesis::all(const std::string &roleRegexp) const
46 {
47  return all(pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
48 }
49 
50 std::vector<pat::EventHypothesis::CandRefType>
52 {
53  std::vector<pat::EventHypothesis::CandRefType> ret;
54  for (const_iterator it = begin(); it != end(); ++it) {
55  if (filter(*it)) ret.push_back(it->second);
56  }
57  return ret;
58 }
59 
60 size_t
61 pat::EventHypothesis::count(const std::string &roleRegexp) const
62 {
64 }
65 
66 size_t
68 {
69  size_t n = 0;
70  for (const_iterator it = begin(); it != end(); ++it) {
71  if (role(*it)) ++n;
72  }
73  return n;
74 }
75 
78 {
80 }
81 
83 pat::EventHypothesis::loop(const std::string &roleRegexp) const
84 {
85  return loop(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
86 }
87 
90 {
91  return CandLooper(*this, role);
92 }
93 
96 {
97  return CandLooper(*this, role);
98 }
99 
102 {
103  return CandLooper(*this, role);
104 }
105 
CandLooper loop() const
Loops over all particles.
static const AcceptAllFilter s_dummyFilter
size_t count() const
static const AcceptAllFilter & get()
void add(const CandRefType &ref, const std::string &role)
int loop
CMSSW
std::vector< CandRefType > all(const std::string &roleRegexp) const
Return EDM references to all particles which have certaint roles.
char * getDemangledSymbol(const char *mangledSymbol) const
#define end
Definition: vmac.h:37
Container::value_type value_type
eventhypothesis::ParticleFilterPtr ParticleFilterPtr
vector_type::const_iterator const_iterator
#define begin
Definition: vmac.h:30
Looper< reco::Candidate > CandLooper
tuple status
Definition: ntuplemaker.py:245
vector_type::const_reverse_iterator const_reverse_iterator
const CandRefType & get(const std::string &role, int index=0) const