CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::Candidate
CandLooper
 
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,
CandRefType
value_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 30 of file EventHypothesis.h.

Member Typedef Documentation

Definition at line 37 of file EventHypothesis.h.

Definition at line 32 of file EventHypothesis.h.

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

Definition at line 35 of file EventHypothesis.h.

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

Definition at line 36 of file EventHypothesis.h.

Definition at line 54 of file EventHypothesis.h.

Definition at line 55 of file EventHypothesis.h.

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

Definition at line 33 of file EventHypothesis.h.

Definition at line 34 of file EventHypothesis.h.

Member Function Documentation

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

Definition at line 11 of file EventHypothesis.cc.

Referenced by counter.Counter::register().

11  {
12  particles_.push_back(value_type(role,ref));
13 }
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 45 of file EventHypothesis.cc.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor::all().

46 {
47  return all(pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
48 }
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 51 of file EventHypothesis.cc.

References begin, end, alcazmumu_cfi::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)) ret.push_back(it->second);
56  }
57  return ret;
58 }
tuple 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

Definition at line 41 of file EventHypothesis.h.

References particles_.

Referenced by pat::eventhypothesis::Looper< T >::globalIndex().

41 { return particles_.begin(); }
std::vector< value_type > particles_
size_t pat::EventHypothesis::count ( void  ) const
inline

Definition at line 69 of file EventHypothesis.h.

References particles_.

69 { 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 KineDebug3::count().

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

Counts particles which satisfy some condition.

Definition at line 67 of file EventHypothesis.cc.

References begin, end, and gen::n.

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 }
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 147 of file EventHypothesis.h.

References getDemangledSymbol(), python.rootplot.argparse::message, and mergeVDriftHistosByStation::name.

147  {
148  std::stringstream message;
149  char *currentType = getDemangledSymbol(typeid(std::remove_reference<decltype(ref)>::type::value_type).name());
150  char *targetType = getDemangledSymbol(typeid(T).name());
151  if (currentType != nullptr && targetType != nullptr) {
152  message << "You can't convert a '" << currentType << "' to a '" << targetType << "'" << std::endl;
153  free(currentType);
154  free(targetType);
155  } else {
156  message << "You can't convert a '" << typeid(ref).name() << "' to a '" << typeid(T).name() << "'" << std::endl;
157  message << "Note: you can use 'c++filt -t' command to convert the above in human readable types." << std::endl;
158  }
159  return message.str();
160  }
char * getDemangledSymbol(const char *mangledSymbol) const
long double T
const_iterator pat::EventHypothesis::end ( void  ) const
inline

Definition at line 42 of file EventHypothesis.h.

References particles_.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

42 { return particles_.end(); }
std::vector< value_type > particles_
const pat::EventHypothesis::CandRefType & pat::EventHypothesis::get ( const std::string &  role,
int  index = 0 
) const

Definition at line 16 of file EventHypothesis.cc.

References begin, end, and Exception.

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().

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 }
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 30 of file EventHypothesis.cc.

References begin, end, and Exception.

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().

31 {
32  if (index >= 0) {
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 {
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 }
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 164 of file EventHypothesis.h.

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

165  {
166  CandRefType ref = get(role, index);
167  const T* ret = dynamic_cast<const T*>(ref.get());
168  if ((ret == 0) && (ref.get() != 0)) throw cms::Exception("Type Checking") << createExceptionMessage<T>(ref);
169  return ret;
170  }
tuple 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 173 of file EventHypothesis.h.

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

174  {
175  CandRefType ref = get(filter, index);
176  const T* ret = dynamic_cast<const T*>(ref.get());
177  if ((ret == 0) && (ref.get() != 0)) throw cms::Exception("Type Checking") << createExceptionMessage<T>(ref);
178  return ret;
179  }
tuple ret
prodAgent to be discontinued
eventhypothesis::CandRefType CandRefType
long double T
char * pat::EventHypothesis::getDemangledSymbol ( const char *  mangledSymbol) const
private

Definition at line 5 of file EventHypothesis.cc.

References mps_update::status.

Referenced by createExceptionMessage().

5  {
6  int status;
7  char *demangledSymbol = abi::__cxa_demangle(mangledSymbol, nullptr, nullptr, &status);
8  return (status == 0) ? demangledSymbol : nullptr;
9 }
tuple status
Definition: mps_update.py:57
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( ) const

Loops over all particles.

Definition at line 77 of file EventHypothesis.cc.

References pat::eventhypothesis::AcceptAllFilter::get(), and cmsHarvester::loop.

78 {
80 }
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 83 of file EventHypothesis.cc.

References cmsHarvester::loop.

84 {
85  return loop(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
86 }
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 89 of file EventHypothesis.cc.

90 {
91  return CandLooper(*this, role);
92 }
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 95 of file EventHypothesis.cc.

96 {
97  return CandLooper(*this, role);
98 }
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 101 of file EventHypothesis.cc.

102 {
103  return CandLooper(*this, role);
104 }
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 182 of file EventHypothesis.h.

183  {
184  return loopAs<T>(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
185  }
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 189 of file EventHypothesis.h.

190  {
191  return pat::eventhypothesis::Looper<T>(*this, role);
192  }
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 196 of file EventHypothesis.h.

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

Loops over particles which satisfy some condition.

Definition at line 203 of file EventHypothesis.h.

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

Definition at line 61 of file EventHypothesis.h.

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

Definition at line 62 of file EventHypothesis.h.

References alcazmumu_cfi::filter.

62 { return get(filter,0); }
const_reverse_iterator pat::EventHypothesis::rbegin ( ) const
inline

Definition at line 43 of file EventHypothesis.h.

References particles_.

43 { 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 132 of file EventHypothesis.h.

133  {
134  Iterator it = realBegin;
135  while (it != realEnd) {
136  if (pred(*it)) {
137  if (idx == 0) return it;
138  idx--;
139  }
140  ++it;
141  }
142  return it;
143  }
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const_reverse_iterator pat::EventHypothesis::rend ( ) const
inline

Definition at line 44 of file EventHypothesis.h.

References particles_.

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

Member Data Documentation

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

Definition at line 108 of file EventHypothesis.h.

Referenced by begin(), count(), end(), rbegin(), and rend().