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

Member Typedef Documentation

Definition at line 33 of file EventHypothesis.h.

Definition at line 28 of file EventHypothesis.h.

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

Definition at line 31 of file EventHypothesis.h.

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

Definition at line 32 of file EventHypothesis.h.

Definition at line 50 of file EventHypothesis.h.

Definition at line 51 of file EventHypothesis.h.

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

Definition at line 29 of file EventHypothesis.h.

Definition at line 30 of file EventHypothesis.h.

Member Function Documentation

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

Definition at line 4 of file EventHypothesis.cc.

References particles_.

4  {
5  particles_.push_back(value_type(role,ref));
6 }
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 38 of file EventHypothesis.cc.

References cond::ecalcond::all.

39 {
40  return all(pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
41 }
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 44 of file EventHypothesis.cc.

References begin, end, alcazmumu_cfi::filter, and run_regression::ret.

45 {
46  std::vector<pat::EventHypothesis::CandRefType> ret;
47  for (const_iterator it = begin(); it != end(); ++it) {
48  if (filter(*it)) ret.push_back(it->second);
49  }
50  return ret;
51 }
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 37 of file EventHypothesis.h.

References particles_.

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

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

Definition at line 65 of file EventHypothesis.h.

References particles_.

65 { 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 54 of file EventHypothesis.cc.

References prof2calltree::count.

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

Counts particles which satisfy some condition.

Definition at line 60 of file EventHypothesis.cc.

References begin, end, and n.

61 {
62  size_t n = 0;
63  for (const_iterator it = begin(); it != end(); ++it) {
64  if (role(*it)) ++n;
65  }
66  return n;
67 }
const_iterator end() const
vector_type::const_iterator const_iterator
const_iterator begin() const
const_iterator pat::EventHypothesis::end ( void  ) const
inline

Definition at line 38 of file EventHypothesis.h.

References particles_.

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

38 { 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 9 of file EventHypothesis.cc.

References begin, end, and edm::hlt::Exception.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), and betterConfigParser.BetterConfigParser::getResultingSection().

10 {
11  if (index >= 0) {
12  const_iterator it = realGet(begin(), end(), ByRole(role), index);
13  if (it == end()) { throw cms::Exception("Index not found") << "Can't find a particle with role " << role << " and index " << index << "\n"; }
14  return it->second;
15  } else {
16  const_reverse_iterator it = realGet(rbegin(), rend(), ByRole(role), -index);
17  if (it == rend()) { throw cms::Exception("Index not found") << "Can't find a particle with role " << role << " and index " << index << "\n"; }
18  return it->second;
19  }
20 }
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 23 of file EventHypothesis.cc.

References begin, end, and edm::hlt::Exception.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), and betterConfigParser.BetterConfigParser::getResultingSection().

24 {
25  if (index >= 0) {
27  if (it == end()) { throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n"; }
28  return it->second;
29  } else {
31  if (it == rend()) { throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n"; }
32  return it->second;
33  }
34 }
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 138 of file EventHypothesis.h.

References edm::hlt::Exception, edm::Ptr< T >::get(), getHLTprescales::index, mergeVDriftHistosByStation::name, and run_regression::ret.

139  {
140  CandRefType ref = get(role, index);
141  const T* ret = dynamic_cast<const T*>(ref.get());
142  if ((ret == 0) && (ref.get() != 0)) throw cms::Exception("Type Checking") <<
143  "You can't convert a " << typeid(*ref).name() << " to a " << typeid(T).name() << "\n" <<
144  "note: you can use c++filt command to convert the above in human readable types.\n";
145  return ret;
146  }
eventhypothesis::CandRefType CandRefType
long double T
template<typename T >
const T * pat::EventHypothesis::getAs ( const ParticleFilter filter,
int  index = 0 
) const

Definition at line 149 of file EventHypothesis.h.

References edm::hlt::Exception, alcazmumu_cfi::filter, edm::Ptr< T >::get(), getHLTprescales::index, mergeVDriftHistosByStation::name, and run_regression::ret.

150  {
151  CandRefType ref = get(filter, index);
152  const T* ret = dynamic_cast<const T*>(ref.get());
153  if ((ret == 0) && (ref.get() != 0)) throw cms::Exception("Type Checking") <<
154  "You can't convert a " << typeid(*ref).name() << " to a " << typeid(T).name() << "\n" <<
155  "note: you can use c++filt command to convert the above in human readable types.\n";
156  return ret;
157  }
eventhypothesis::CandRefType CandRefType
long double T
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( ) const

Loops over all particles.

Definition at line 70 of file EventHypothesis.cc.

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

Referenced by loop().

71 {
73 }
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 76 of file EventHypothesis.cc.

References python.cmstools::loop().

77 {
78  return loop(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
79 }
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.

83 {
84  return CandLooper(*this, role);
85 }
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 88 of file EventHypothesis.cc.

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

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

161  {
162  return loopAs<T>(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
163  }
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 167 of file EventHypothesis.h.

168  {
169  return pat::eventhypothesis::Looper<T>(*this, role);
170  }
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 174 of file EventHypothesis.h.

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

Loops over particles which satisfy some condition.

Definition at line 181 of file EventHypothesis.h.

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

Definition at line 57 of file EventHypothesis.h.

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

Definition at line 58 of file EventHypothesis.h.

References alcazmumu_cfi::filter.

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

Definition at line 39 of file EventHypothesis.h.

References particles_.

39 { 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 123 of file EventHypothesis.h.

124  {
125  Iterator it = realBegin;
126  while (it != realEnd) {
127  if (pred(*it)) {
128  if (idx == 0) return it;
129  idx--;
130  }
131  ++it;
132  }
133  return it;
134  }
const_reverse_iterator pat::EventHypothesis::rend ( ) const
inline

Definition at line 40 of file EventHypothesis.h.

References particles_.

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

Member Data Documentation

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

Definition at line 102 of file EventHypothesis.h.

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