CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
pat::EventHypothesis Class Reference

#include <EventHypothesis.h>

Classes

class  ByRole
 

Public Types

typedef eventhypothesis::Looper< reco::CandidateCandLooper
 
typedef eventhypothesis::CandRefType CandRefType
 
typedef vector_type::const_iterator const_iterator
 
typedef vector_type::const_reverse_iterator const_reverse_iterator
 
typedef eventhypothesis::ParticleFilter ParticleFilter
 
typedef eventhypothesis::ParticleFilterPtr ParticleFilterPtr
 
typedef std::pair< std::string, CandRefTypevalue_type
 
typedef std::vector< value_typevector_type
 

Public Member Functions

void add (const CandRefType &ref, const std::string &role)
 
std::vector< CandRefTypeall (const std::string &roleRegexp) const
 Return EDM references to all particles which have certaint roles. More...
 
std::vector< CandRefTypeall (const ParticleFilter &filter) const
 Return EDM references to all particles which satisfy some condition. More...
 
const_iterator begin () const
 
size_t count () const
 
size_t count (const std::string &roleRegexp) const
 Counts particles which have certaint roles. More...
 
size_t count (const ParticleFilter &role) const
 Counts particles which satisfy some condition. More...
 
const_iterator end () const
 
const CandRefTypeget (const std::string &role, int index=0) const
 
const CandRefTypeget (const ParticleFilter &filter, int index=0) const
 
template<typename T >
const TgetAs (const std::string &role, int index=0) const
 
template<typename T >
const TgetAs (const ParticleFilter &filter, int index=0) const
 
CandLooper loop () const
 Loops over all particles. More...
 
CandLooper loop (const std::string &roleRegexp) const
 Loops over particles which have certaint roles. More...
 
CandLooper loop (const ParticleFilter &filter) const
 
CandLooper loop (const ParticleFilter *filter) const
 
CandLooper loop (const ParticleFilterPtr &filter) const
 Loops over particles which satisfy some condition. More...
 
template<typename T >
eventhypothesis::Looper< TloopAs (const std::string &roleRegexp) const
 Loops over particles which have certaint roles. More...
 
template<typename T >
eventhypothesis::Looper< TloopAs (const ParticleFilter &filter) const
 
template<typename T >
eventhypothesis::Looper< TloopAs (const ParticleFilter *filter) const
 
template<typename T >
eventhypothesis::Looper< TloopAs (const ParticleFilterPtr &filter) const
 Loops over particles which satisfy some condition. More...
 
const CandRefTypeoperator[] (const std::string &role) const
 
const CandRefTypeoperator[] (const ParticleFilter &filter) const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 

Private Member Functions

template<typename T >
std::string createExceptionMessage (const CandRefType &ref) const
 
char * getDemangledSymbol (const char *mangledSymbol) const
 
template<typename Iterator , typename Predicate >
Iterator realGet (const Iterator &realBegin, const Iterator &realEnd, const Predicate &p, size_t idx) const
 

Private Attributes

std::vector< value_typeparticles_
 

Detailed Description

Definition at line 33 of file EventHypothesis.h.

Member Typedef Documentation

Definition at line 40 of file EventHypothesis.h.

Definition at line 35 of file EventHypothesis.h.

typedef vector_type::const_iterator pat::EventHypothesis::const_iterator

Definition at line 38 of file EventHypothesis.h.

typedef vector_type::const_reverse_iterator pat::EventHypothesis::const_reverse_iterator

Definition at line 39 of file EventHypothesis.h.

Definition at line 58 of file EventHypothesis.h.

Definition at line 59 of file EventHypothesis.h.

typedef std::pair<std::string, CandRefType> pat::EventHypothesis::value_type

Definition at line 36 of file EventHypothesis.h.

Definition at line 37 of file EventHypothesis.h.

Member Function Documentation

void pat::EventHypothesis::add ( const CandRefType ref,
const std::string &  role 
)

Definition at line 10 of file EventHypothesis.cc.

References particles_.

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

10  {
11  particles_.push_back(value_type(role, ref));
12 }
std::vector< value_type > particles_
std::pair< std::string, CandRefType > value_type
std::vector< pat::EventHypothesis::CandRefType > pat::EventHypothesis::all ( const std::string &  roleRegexp) const

Return EDM references to all particles which have certaint roles.

Definition at line 48 of file EventHypothesis.cc.

48  {
49  return all(pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
50 }
std::vector< CandRefType > all(const std::string &roleRegexp) const
Return EDM references to all particles which have certaint roles.
std::vector< pat::EventHypothesis::CandRefType > pat::EventHypothesis::all ( const ParticleFilter filter) const

Return EDM references to all particles which satisfy some condition.

Definition at line 52 of file EventHypothesis.cc.

References begin(), end(), ALCARECOTkAlBeamHalo_cff::filter, and runTheMatrix::ret.

52  {
53  std::vector<pat::EventHypothesis::CandRefType> ret;
54  for (const_iterator it = begin(); it != end(); ++it) {
55  if (filter(*it))
56  ret.push_back(it->second);
57  }
58  return ret;
59 }
ret
prodAgent to be discontinued
const_iterator end() const
vector_type::const_iterator const_iterator
const_iterator begin() const
const_iterator pat::EventHypothesis::begin ( void  ) const
inline
size_t pat::EventHypothesis::count ( void  ) const
inline

Definition at line 75 of file EventHypothesis.h.

References KineDebug3::count(), training_settings::idx, heppy_loop::loop, AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by count().

75 { return particles_.size(); }
std::vector< value_type > particles_
size_t pat::EventHypothesis::count ( const std::string &  roleRegexp) const

Counts particles which have certaint roles.

Definition at line 61 of file EventHypothesis.cc.

References count().

size_t pat::EventHypothesis::count ( const ParticleFilter role) const

Counts particles which satisfy some condition.

Definition at line 65 of file EventHypothesis.cc.

References begin(), end(), and dqmiodumpmetadata::n.

65  {
66  size_t n = 0;
67  for (const_iterator it = begin(); it != end(); ++it) {
68  if (role(*it))
69  ++n;
70  }
71  return n;
72 }
const_iterator end() const
vector_type::const_iterator const_iterator
const_iterator begin() const
template<typename T >
std::string pat::EventHypothesis::createExceptionMessage ( const CandRefType ref) const
private

Definition at line 160 of file EventHypothesis.h.

References Skims_PA_cff::name.

160  {
161  std::stringstream message;
162  char *currentType = getDemangledSymbol(typeid(std::remove_reference<decltype(ref)>::type::value_type).name());
163  char *targetType = getDemangledSymbol(typeid(T).name());
164  if (currentType != nullptr && targetType != nullptr) {
165  message << "You can't convert a '" << currentType << "' to a '" << targetType << "'" << std::endl;
166  free(currentType);
167  free(targetType);
168  } else {
169  message << "You can't convert a '" << typeid(ref).name() << "' to a '" << typeid(T).name() << "'" << std::endl;
170  message << "Note: you can use 'c++filt -t' command to convert the above in human readable types." << std::endl;
171  }
172  return message.str();
173  }
char * getDemangledSymbol(const char *mangledSymbol) const
long double T
const_iterator pat::EventHypothesis::end ( void  ) const
inline
const pat::EventHypothesis::CandRefType & pat::EventHypothesis::get ( const std::string &  role,
int  index = 0 
) const

Definition at line 14 of file EventHypothesis.cc.

References begin(), end(), Exception, rbegin(), realGet(), and rend().

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), util.rrapi.RRApi::count(), rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), util.rrapi.RRApi::report(), rrapi.RRApi::reports(), util.rrapi.RRApi::reports(), util.rrapi.RRApi::tables(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), util.rrapi.RRApi::tags(), rrapi.RRApi::templates(), util.rrapi.RRApi::templates(), util.rrapi.RRApi::workspaces(), and rrapi.RRApi::workspaces().

14  {
15  if (index >= 0) {
16  const_iterator it = realGet(begin(), end(), ByRole(role), index);
17  if (it == end()) {
18  throw cms::Exception("Index not found")
19  << "Can't find a particle with role " << role << " and index " << index << "\n";
20  }
21  return it->second;
22  } else {
23  const_reverse_iterator it = realGet(rbegin(), rend(), ByRole(role), -index);
24  if (it == rend()) {
25  throw cms::Exception("Index not found")
26  << "Can't find a particle with role " << role << " and index " << index << "\n";
27  }
28  return it->second;
29  }
30 }
Iterator realGet(const Iterator &realBegin, const Iterator &realEnd, const Predicate &p, size_t idx) const
const_iterator end() const
vector_type::const_iterator const_iterator
const_reverse_iterator rend() const
const_iterator begin() const
vector_type::const_reverse_iterator const_reverse_iterator
const_reverse_iterator rbegin() const
const pat::EventHypothesis::CandRefType & pat::EventHypothesis::get ( const ParticleFilter filter,
int  index = 0 
) const

Definition at line 32 of file EventHypothesis.cc.

References begin(), end(), Exception, rbegin(), realGet(), and rend().

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), util.rrapi.RRApi::count(), rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), util.rrapi.RRApi::report(), rrapi.RRApi::reports(), util.rrapi.RRApi::reports(), util.rrapi.RRApi::tables(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), util.rrapi.RRApi::tags(), rrapi.RRApi::templates(), util.rrapi.RRApi::templates(), util.rrapi.RRApi::workspaces(), and rrapi.RRApi::workspaces().

32  {
33  if (index >= 0) {
35  if (it == end()) {
36  throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n";
37  }
38  return it->second;
39  } else {
41  if (it == rend()) {
42  throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n";
43  }
44  return it->second;
45  }
46 }
Iterator realGet(const Iterator &realBegin, const Iterator &realEnd, const Predicate &p, size_t idx) const
const_iterator end() const
vector_type::const_iterator const_iterator
const_reverse_iterator rend() const
const_iterator begin() const
vector_type::const_reverse_iterator const_reverse_iterator
const_reverse_iterator rbegin() const
template<typename T >
const T * pat::EventHypothesis::getAs ( const std::string &  role,
int  index = 0 
) const

Definition at line 176 of file EventHypothesis.h.

References Exception, edm::Ptr< T >::get(), and runTheMatrix::ret.

176  {
177  CandRefType ref = get(role, index);
178  const T *ret = dynamic_cast<const T *>(ref.get());
179  if ((ret == 0) && (ref.get() != nullptr))
180  throw cms::Exception("Type Checking") << createExceptionMessage<T>(ref);
181  return ret;
182  }
ret
prodAgent to be discontinued
eventhypothesis::CandRefType CandRefType
long double T
template<typename T >
const T * pat::EventHypothesis::getAs ( const ParticleFilter filter,
int  index = 0 
) const

Definition at line 184 of file EventHypothesis.h.

References Exception, ALCARECOTkAlBeamHalo_cff::filter, edm::Ptr< T >::get(), and runTheMatrix::ret.

184  {
185  CandRefType ref = get(filter, index);
186  const T *ret = dynamic_cast<const T *>(ref.get());
187  if ((ret == 0) && (ref.get() != nullptr))
188  throw cms::Exception("Type Checking") << createExceptionMessage<T>(ref);
189  return ret;
190  }
ret
prodAgent to be discontinued
eventhypothesis::CandRefType CandRefType
long double T
char * pat::EventHypothesis::getDemangledSymbol ( const char *  mangledSymbol) const
private

Definition at line 4 of file EventHypothesis.cc.

References mps_update::status.

4  {
5  int status;
6  char *demangledSymbol = abi::__cxa_demangle(mangledSymbol, nullptr, nullptr, &status);
7  return (status == 0) ? demangledSymbol : nullptr;
8 }
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( ) const

Loops over all particles.

Definition at line 74 of file EventHypothesis.cc.

References pat::eventhypothesis::AcceptAllFilter::get().

Referenced by loop().

74  {
76 }
CandLooper loop() const
Loops over all particles.
static const AcceptAllFilter & get()
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( const std::string &  roleRegexp) const

Loops over particles which have certaint roles.

Definition at line 78 of file EventHypothesis.cc.

References loop().

78  {
79  return loop(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
80 }
CandLooper loop() const
Loops over all particles.
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( const ParticleFilter filter) const

Loops over particles which satisfy some condition. The caller code owns the filter, and must take care it is not deleted while the looper is still being used

Definition at line 82 of file EventHypothesis.cc.

82  {
83  return CandLooper(*this, role);
84 }
eventhypothesis::Looper< reco::Candidate > CandLooper
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( const ParticleFilter filter) const

Loops over particles which satisfy some condition. The looper owns the filter, which will be deleted when the looper is deleted. That is, you can call eventHypothesis.loop(new WhateverFilterYouLike(...))

Definition at line 86 of file EventHypothesis.cc.

86  {
87  return CandLooper(*this, role);
88 }
eventhypothesis::Looper< reco::Candidate > CandLooper
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( const ParticleFilterPtr filter) const

Loops over particles which satisfy some condition.

Definition at line 90 of file EventHypothesis.cc.

References pat::eventhypothesis::AcceptAllFilter::s_dummyFilter.

90  {
91  return CandLooper(*this, role);
92 }
eventhypothesis::Looper< reco::Candidate > CandLooper
template<typename T >
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs ( const std::string &  roleRegexp) const

Loops over particles which have certaint roles.

Definition at line 192 of file EventHypothesis.h.

192  {
193  return loopAs<T>(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
194  }
template<typename T >
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs ( const ParticleFilter filter) const

Loops over particles which satisfy some condition. The caller code owns the filter, and must take care it is not deleted while the looper is still being used

Definition at line 197 of file EventHypothesis.h.

197  {
198  return pat::eventhypothesis::Looper<T>(*this, role);
199  }
template<typename T >
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs ( const ParticleFilter filter) const

Loops over particles which satisfy some condition. The looper owns the filter, which will be deleted when the looper is deleted. That is, you can call eventHypothesis.loopAs<...>(new WhateverFilterYouLike(...))

Definition at line 202 of file EventHypothesis.h.

202  {
203  return pat::eventhypothesis::Looper<T>(*this, role);
204  }
template<typename T >
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs ( const ParticleFilterPtr filter) const

Loops over particles which satisfy some condition.

Definition at line 207 of file EventHypothesis.h.

207  {
208  return pat::eventhypothesis::Looper<T>(*this, role);
209  }
const CandRefType& pat::EventHypothesis::operator[] ( const std::string &  role) const
inline

Definition at line 67 of file EventHypothesis.h.

67 { return get(role, 0); }
const CandRefType& pat::EventHypothesis::operator[] ( const ParticleFilter filter) const
inline
const_reverse_iterator pat::EventHypothesis::rbegin ( ) const
inline

Definition at line 46 of file EventHypothesis.h.

Referenced by get().

46 { return particles_.rbegin(); }
std::vector< value_type > particles_
template<typename Iterator , typename Predicate >
Iterator pat::EventHypothesis::realGet ( const Iterator realBegin,
const Iterator realEnd,
const Predicate &  p,
size_t  idx 
) const
private

Definition at line 143 of file EventHypothesis.h.

Referenced by get().

146  {
147  Iterator it = realBegin;
148  while (it != realEnd) {
149  if (pred(*it)) {
150  if (idx == 0)
151  return it;
152  idx--;
153  }
154  ++it;
155  }
156  return it;
157  }
const_reverse_iterator pat::EventHypothesis::rend ( ) const
inline

Definition at line 47 of file EventHypothesis.h.

Referenced by get().

47 { return particles_.rend(); }
std::vector< value_type > particles_

Member Data Documentation

std::vector<value_type> pat::EventHypothesis::particles_
private

Definition at line 118 of file EventHypothesis.h.

Referenced by add().